qid
int64
46k
74.7M
question
stringlengths
54
37.8k
date
stringlengths
10
10
metadata
listlengths
3
3
response_j
stringlengths
17
26k
response_k
stringlengths
26
26k
17,128,878
I was trying to install `autoclose.vim` to Vim. I noticed I didn't have a `~/.vim/plugin` folder, so I accidentally made a `~/.vim/plugins` folder (notice the extra 's' in plugins). I then added `au FileType python set rtp += ~/.vim/plugins` to my .vimrc, because from what I've read, that will allow me to automatically...
2013/06/15
[ "https://Stackoverflow.com/questions/17128878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2467761/" ]
[:help load-plugins](http://vimdoc.sourceforge.net/htmldoc/starting.html#load-plugins) outlines how plugins are loaded. Adding a folder to your `rtp` alone does not suffice; it must have a `plugin` subdirectory. For example, given `:set rtp+=/tmp/foo`, a file `/tmp/foo/plugin/bar.vim` would be detected and loaded, but...
All folders in the `rtp` (runtimepath) option need to have the same folder structure as your `$VIMRUNTIME` (`$VIMRUNTIME` is usually `/usr/share/vim/vim{version}`). So it should have the same subdirectory names e.g. `autoload`, `doc`, `plugin` (whichever you need, but having the same names is key). The plugins should b...
17,128,878
I was trying to install `autoclose.vim` to Vim. I noticed I didn't have a `~/.vim/plugin` folder, so I accidentally made a `~/.vim/plugins` folder (notice the extra 's' in plugins). I then added `au FileType python set rtp += ~/.vim/plugins` to my .vimrc, because from what I've read, that will allow me to automatically...
2013/06/15
[ "https://Stackoverflow.com/questions/17128878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2467761/" ]
[:help load-plugins](http://vimdoc.sourceforge.net/htmldoc/starting.html#load-plugins) outlines how plugins are loaded. Adding a folder to your `rtp` alone does not suffice; it must have a `plugin` subdirectory. For example, given `:set rtp+=/tmp/foo`, a file `/tmp/foo/plugin/bar.vim` would be detected and loaded, but...
In addition to @Nikita Kouevda answer: modifying `rtp` on `FileType` event may be too late for vim to load any plugins from the modified runtimepath: if this event was launched after vimrc was sourced it is not guaranteed plugins from new addition will be loaded; if this event was launched after `VimEnter` event it is ...
17,128,878
I was trying to install `autoclose.vim` to Vim. I noticed I didn't have a `~/.vim/plugin` folder, so I accidentally made a `~/.vim/plugins` folder (notice the extra 's' in plugins). I then added `au FileType python set rtp += ~/.vim/plugins` to my .vimrc, because from what I've read, that will allow me to automatically...
2013/06/15
[ "https://Stackoverflow.com/questions/17128878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2467761/" ]
You are on the right track with `set rtp+=...` but there's a bit more to it (`rtp` is non-recursive, help indexing, many corner cases) than what meets the eye so it is not a very good idea to do it by yourself. Unless you are ready for a months-long drop in productivity. If you want to store all your plugins in a spec...
All folders in the `rtp` (runtimepath) option need to have the same folder structure as your `$VIMRUNTIME` (`$VIMRUNTIME` is usually `/usr/share/vim/vim{version}`). So it should have the same subdirectory names e.g. `autoload`, `doc`, `plugin` (whichever you need, but having the same names is key). The plugins should b...
17,128,878
I was trying to install `autoclose.vim` to Vim. I noticed I didn't have a `~/.vim/plugin` folder, so I accidentally made a `~/.vim/plugins` folder (notice the extra 's' in plugins). I then added `au FileType python set rtp += ~/.vim/plugins` to my .vimrc, because from what I've read, that will allow me to automatically...
2013/06/15
[ "https://Stackoverflow.com/questions/17128878", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2467761/" ]
In addition to @Nikita Kouevda answer: modifying `rtp` on `FileType` event may be too late for vim to load any plugins from the modified runtimepath: if this event was launched after vimrc was sourced it is not guaranteed plugins from new addition will be loaded; if this event was launched after `VimEnter` event it is ...
All folders in the `rtp` (runtimepath) option need to have the same folder structure as your `$VIMRUNTIME` (`$VIMRUNTIME` is usually `/usr/share/vim/vim{version}`). So it should have the same subdirectory names e.g. `autoload`, `doc`, `plugin` (whichever you need, but having the same names is key). The plugins should b...
53,494,097
I am trying to get hands on with selenium and webdriver with python. ``` from selenium import webdriver PROXY = "119.82.253.95:61853" url = 'http://google.co.in/search?q=book+flights' chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--proxy-server=%s' % PROXY) driver = webdriver.Chrome(options...
2018/11/27
[ "https://Stackoverflow.com/questions/53494097", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2954789/" ]
`fscanf` is a non-starter. The only way to read empty fields would be to use `"%c"` to read delimiters (and that would require you to know which fields were empty beforehand -- not very useful) Otherwise, depending on the *format specifier* used, `fscanf` would simply consume the `tabs` as leading whitespace or experie...
> > I wanna use fscanf to read consecutive tabs as empty fields and store them in a structure. > > > Ideally, code should read a *line*, as with `fgets()` and then parse the *string*. Yet staying with `fscanf()`, this can be done in a loop. --- The main idea is to use `"%[^/t/n]"` to read one token. If the next...
63,322,884
I have a python script that is responsible for verifying the existence of a process with its respective name, I am using the pip module `pgrep`, the problem is that it does not allow me to kill the processes with the kill module of pip or with the of `os.kill` because there are several processes that I want to kill and...
2020/08/09
[ "https://Stackoverflow.com/questions/63322884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14063362/" ]
You would loop over processes using a `for` loop. Ideally you should send a `SIGTERM` before resorting to `SIGKILL`, because it can allow processes to exit more gracefully. ``` import time import os import signal # send all the processes a SIGTERM for p in pid: os.kill(p, signal.SIGTERM) # give them a short time...
Try this it may work ``` processes = {'pro1', 'pro2', 'pro3'} for proc in psutil.process_iter(): if proc.name() in processes: proc.kill() ``` For more information you can refer [here](https://psutil.readthedocs.io/en/latest/)
53,546,396
How to reduce numbers in python after comma without rounding Example : I have x = 2.97656 I want it to be 2.9 not 3.0 Thank you
2018/11/29
[ "https://Stackoverflow.com/questions/53546396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9705031/" ]
If you don't want to use `math.round()` you can use `math.floor()`: ``` import math x = 2.97656 print(math.floor(x * 10) / 10) #Output = 2.9 ```
you can use round(var , number precision ) see this link please to more info **<https://www.geeksforgeeks.org/precision-handling-python/>**
64,575,636
I'm trying to convert json data into a dict by using load() but I'm unable to do so if I have more than one object. For example, the code below works perfectly, I can dump 'dog' into a json file and then I can load 'dog' and print it out as a dict. ``` import json dog = { "name":"Sally", "color": "yel...
2020/10/28
[ "https://Stackoverflow.com/questions/64575636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14209856/" ]
You should only have one json thing you dump to a file. `json.load` will try to load the whole file, it doesn't find the first instance of a valid json object You could combine them into an array ``` j_obj = [dog, cat] ``` Or create a new dict ``` j_obj = {'dog': dog, 'cat': cat} ``` Then `j_obj` can be dumped t...
The JSON module doesn't append it automatically. If you want your JSON to contain a number of objects use an array as insert your dictionaries into it. the dump the array
64,575,636
I'm trying to convert json data into a dict by using load() but I'm unable to do so if I have more than one object. For example, the code below works perfectly, I can dump 'dog' into a json file and then I can load 'dog' and print it out as a dict. ``` import json dog = { "name":"Sally", "color": "yel...
2020/10/28
[ "https://Stackoverflow.com/questions/64575636", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14209856/" ]
Before dumping, include your objects in a list, then dump them: ``` dog = { "name":"Sally", "color": "yellow", "breed": "lab", "age": 2, }, cat = { "name":"Daniel", "color": "black", "breed": "unknown", "age": 8, } all_objects = [dog, cat] w...
The JSON module doesn't append it automatically. If you want your JSON to contain a number of objects use an array as insert your dictionaries into it. the dump the array
63,074,629
I am a newbie to a python dictionary. Excume me for my mistakes. I want to create a list of **all** the keys which have a Maximum and Minimum values from Python Dictionary. I searched it about on Google but didn't get any answer. I have written the following code: ``` a = {1:1, 2:3, 4:3, 3:2, 5:1, 6:3} maxi = [keys ...
2020/07/24
[ "https://Stackoverflow.com/questions/63074629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13285566/" ]
The `ngModel` binding might have precedence here. You could ignore the `value` attribute and set `updatedStockValue` in it's definition. Try the following ```js @Component({ selector: 'app-stock-status', template:` <input type="number" min="0" required [(ngModel)]="updatedStockValue"/> <button class="btn btn-...
You can initialize a variable in the template with ng-init if you don't want to do it in the controller. ``` <input type="number" min='0' required [(ngModel)]='updatedStockValue' ng-init="updatedStockValue=0"/> ```
68,500,403
I am using Pandas to analyze a dataset which includes a column named "Age on Intake" (floating numbers). I had been trying to further categorize the data into a few small age buckets using the function I wrote. However, I keep getting the error **"*'<=' not supported between instances of 'str' and 'int'*"**. How could ...
2021/07/23
[ "https://Stackoverflow.com/questions/68500403", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16494766/" ]
`for` loops in Rust act on iterators, so if you want succinct semantics, change your code to use them. There's not really that much other choice - what's ergonomic in C isn't necessarily ergonomic in Rust, and vice versa. If your `next` functions follow a common pattern, you can create a structure that implements `Ite...
It would be most idiomatic to convert the code to use an `Iterator`, but that is "non-trivial" in this case due to how next works. The simplest version I could create was to create that was similar to the C code yet IMO reasonably idiomatic was to create an `on_each` style function that accepts a closure. ``` #[derive...
55,639,746
I am new to python and Jupyter Notebook The objective of the code I am writing is to request the user to introduce 10 different integers. The program is supposed to return the highest odd number introduced previously by the user. My code is as followws: ``` i=1 c=1 y=1 while i<=10: c=int(input('Enter an i...
2019/04/11
[ "https://Stackoverflow.com/questions/55639746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10023598/" ]
You have `elif c > y`, you should just need to add a colon there so it's `elif c > y:`
Yup. ``` i=1 c=1 y=1 while i<=10: c=int(input('Enter an integer number: ')) # This line was off if c%2==0: print('The number is even') elif c> y: # Need also ':' y=c print('y') i=i+1 ```
55,639,746
I am new to python and Jupyter Notebook The objective of the code I am writing is to request the user to introduce 10 different integers. The program is supposed to return the highest odd number introduced previously by the user. My code is as followws: ``` i=1 c=1 y=1 while i<=10: c=int(input('Enter an i...
2019/04/11
[ "https://Stackoverflow.com/questions/55639746", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10023598/" ]
You have `elif c > y`, you should just need to add a colon there so it's `elif c > y:`
You can right this in a much compact fashion like so. Start by asking for 10 numbers in a single line, separated by a space. Then split the string by `,` into a list of numbers and exit the code if exactly 10 numbers are not provided. ``` numbers_str = input("Input 10 integers separated by a comma(,) >>> ") numbers =...
32,893,568
I'm trying to parse json string with an escape character (Of some sort I guess) ``` { "publisher": "\"O'Reilly Media, Inc.\"" } ``` Parser parses well if I remove the character `\"` from the string, the exceptions raised by different parsers are, **json** ``` File "/usr/lib/python2.7/json/__init__.py", line...
2015/10/01
[ "https://Stackoverflow.com/questions/32893568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4597501/" ]
You almost certainly did not define properly escaped backslashes. If you define the string properly the JSON parses *just fine*: ``` >>> import json >>> json_str = r''' ... { ... "publisher": "\"O'Reilly Media, Inc.\"" ... } ... ''' # raw string to prevent the \" from being interpreted by Python >>> json.loads(js...
Your JSON is invalid. If you have questions about your JSON objects, you can always validate them with [JSONlint](http://jsonlint.com). In your case you have an object ``` { "publisher": "\"O'Reilly Media, Inc.\"", } ``` and you have an extra comma indicating that something else should be coming. So JSONlint yields ...
35,901,517
I get the following error when I run my code which has been annotated with @profile: ``` Wrote profile results to monthly_spi_gamma.py.prof Traceback (most recent call last): File "/home/james.adams/anaconda2/lib/python2.7/site-packages/kernprof.py", line 233, in <module> sys.exit(main(sys.argv)) File "/home/j...
2016/03/09
[ "https://Stackoverflow.com/questions/35901517", "https://Stackoverflow.com", "https://Stackoverflow.com/users/85248/" ]
I worked this out by using the -l option, i.e. ``` $ kernprof.py -l my_code.py ```
``` kernprof -l -b web_app.py ``` This worked for me, if we see ``` kernprof --help ``` we see an option to include in builtin namespace ``` usage: kernprof [-h] [-V] [-l] [-b] [-o OUTFILE] [-s SETUP] [-v] [-u UNIT] [-z] script ... Run and profile a python script. positional argu...
32,838,802
Say that I have a color image, and naturally this will be represented by a 3-dimensional array in python, say of shape (n x m x 3) and call it img. I want a new 2-d array, call it "narray" to have a shape (3,nxm), such that each row of this array contains the "flattened" version of R,G,and B channel respectively. More...
2015/09/29
[ "https://Stackoverflow.com/questions/32838802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929035/" ]
You need to use [`np.transpose`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.transpose.html) to rearrange dimensions. Now, `n x m x 3` is to be converted to `3 x (n*m)`, so send the last axis to the front and shift right the order of the remaining axes `(0,1)`. Finally , reshape to have `3` rows. Thus, th...
[ORIGINAL ANSWER] Let's say we have an array `img` of size `m x n x 3` to transform into an array `new_img` of size `3 x (m*n)` Initial Solution: ``` new_img = img.reshape((img.shape[0]*img.shape[1]), img.shape[2]) new_img = new_img.transpose() ``` [EDITED ANSWER] **Flaw**: The reshape starts from the first dimen...
32,838,802
Say that I have a color image, and naturally this will be represented by a 3-dimensional array in python, say of shape (n x m x 3) and call it img. I want a new 2-d array, call it "narray" to have a shape (3,nxm), such that each row of this array contains the "flattened" version of R,G,and B channel respectively. More...
2015/09/29
[ "https://Stackoverflow.com/questions/32838802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929035/" ]
You need to use [`np.transpose`](http://docs.scipy.org/doc/numpy/reference/generated/numpy.transpose.html) to rearrange dimensions. Now, `n x m x 3` is to be converted to `3 x (n*m)`, so send the last axis to the front and shift right the order of the remaining axes `(0,1)`. Finally , reshape to have `3` rows. Thus, th...
If you have the scikit module installed, then you can use the rgb2grey (or rgb2gray) to make a photo from color to gray (from 3D to 2D) ``` from skimage import io, color lina_color = io.imread(path+img) lina_gray = color.rgb2gray(lina_color) In [33]: lina_color.shape Out[33]: (1920, 1280, 3) In [34]: lina_gray.sha...
32,838,802
Say that I have a color image, and naturally this will be represented by a 3-dimensional array in python, say of shape (n x m x 3) and call it img. I want a new 2-d array, call it "narray" to have a shape (3,nxm), such that each row of this array contains the "flattened" version of R,G,and B channel respectively. More...
2015/09/29
[ "https://Stackoverflow.com/questions/32838802", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4929035/" ]
[ORIGINAL ANSWER] Let's say we have an array `img` of size `m x n x 3` to transform into an array `new_img` of size `3 x (m*n)` Initial Solution: ``` new_img = img.reshape((img.shape[0]*img.shape[1]), img.shape[2]) new_img = new_img.transpose() ``` [EDITED ANSWER] **Flaw**: The reshape starts from the first dimen...
If you have the scikit module installed, then you can use the rgb2grey (or rgb2gray) to make a photo from color to gray (from 3D to 2D) ``` from skimage import io, color lina_color = io.imread(path+img) lina_gray = color.rgb2gray(lina_color) In [33]: lina_color.shape Out[33]: (1920, 1280, 3) In [34]: lina_gray.sha...
71,140,438
I am a beginner in Python and would really appreciate if someone could help me with the following: I would like to run this script 10 times and for that change for every run the sub-batch (from 0-9): E.g. the first run would be: ``` python $GWAS_TOOLS/gwas_summary_imputation.py \ -by_region_file $DATA/eur_ld.bed.gz \...
2022/02/16
[ "https://Stackoverflow.com/questions/71140438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18222525/" ]
While we can't show you how to retrofit a loop to the python code without actually seeing the python code, you could just use a shell loop to accomplish what you want without touching the python code. For bash shell, it would look like this: ``` for sub_batch in {0..9}; do \ python $GWAS_TOOLS/gwas_summary_imputatio...
a loop in python from 0 to 10 is very easy. ```py for i in range(0, 10): do stuff ```
71,140,438
I am a beginner in Python and would really appreciate if someone could help me with the following: I would like to run this script 10 times and for that change for every run the sub-batch (from 0-9): E.g. the first run would be: ``` python $GWAS_TOOLS/gwas_summary_imputation.py \ -by_region_file $DATA/eur_ld.bed.gz \...
2022/02/16
[ "https://Stackoverflow.com/questions/71140438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18222525/" ]
What you're looking for seems to be a way to run the same command on the command line a set number of times. If you're on Linux using the bash shell, this can be done using a shell loop: ``` for i in {0..9}; do python $GWAS_TOOLS/gwas_summary_imputation.py \ -by_region_file $DATA/eur_ld.bed.gz \ -gwas_file $OUTPUT/ha...
a loop in python from 0 to 10 is very easy. ```py for i in range(0, 10): do stuff ```
36,680,407
I on RHEL6 with Python 2.6 and need to install rrdtool with python. I have to upload and install packages manually as network admin blocks yum and pip outgoing traffic for security reason. During installation I encounter missing error missing rrdtoolmodule.c, where can I locate the file? or I missing something? ``` [u...
2016/04/17
[ "https://Stackoverflow.com/questions/36680407", "https://Stackoverflow.com", "https://Stackoverflow.com/users/79311/" ]
The one-hour difference is due to Daylight Savings Time, which by definition is not reflected in Unix timestamps. You may want to consider [moment-timezone.js](http://momentjs.com/timezone/docs/) to cope with DST in time conversions.
You can use [Date.parse()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse) in javascript. ```js const isoDate = new Date(); const convertToUnix = Date.parse(isoDate.toISOString()); ```
8,198,162
I have a script for deleting images older than a date. Can I pass this date as an argument when I call to run the script? Example: This script `delete_images.py` deletes images older than a date (YYYY-MM-DD) ``` python delete_images.py 2010-12-31 ``` Script (works with a fixed date (xDate variable)) ``` import os...
2011/11/19
[ "https://Stackoverflow.com/questions/8198162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/871976/" ]
The quick but crude way is to use `sys.argv`. ``` import sys xDate = sys.argv[1] ``` A more robust, extendable way is to use the [argparse](http://docs.python.org/library/argparse.html#module-argparse) module: ``` import argparse parser=argparse.ArgumentParser() parser.add_argument('xDate') args=parser.parse_args(...
The command line options can be accessed via the list `sys.argv`. So you can simply use ``` xDate = sys.argv[1] ``` (`sys.argv[0]` is the name of the current script.)
8,198,162
I have a script for deleting images older than a date. Can I pass this date as an argument when I call to run the script? Example: This script `delete_images.py` deletes images older than a date (YYYY-MM-DD) ``` python delete_images.py 2010-12-31 ``` Script (works with a fixed date (xDate variable)) ``` import os...
2011/11/19
[ "https://Stackoverflow.com/questions/8198162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/871976/" ]
The quick but crude way is to use `sys.argv`. ``` import sys xDate = sys.argv[1] ``` A more robust, extendable way is to use the [argparse](http://docs.python.org/library/argparse.html#module-argparse) module: ``` import argparse parser=argparse.ArgumentParser() parser.add_argument('xDate') args=parser.parse_args(...
you can use runtime arguments for this approach. Please see following link: <http://www.faqs.org/docs/diveintopython/kgp_commandline.html>
8,198,162
I have a script for deleting images older than a date. Can I pass this date as an argument when I call to run the script? Example: This script `delete_images.py` deletes images older than a date (YYYY-MM-DD) ``` python delete_images.py 2010-12-31 ``` Script (works with a fixed date (xDate variable)) ``` import os...
2011/11/19
[ "https://Stackoverflow.com/questions/8198162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/871976/" ]
The quick but crude way is to use `sys.argv`. ``` import sys xDate = sys.argv[1] ``` A more robust, extendable way is to use the [argparse](http://docs.python.org/library/argparse.html#module-argparse) module: ``` import argparse parser=argparse.ArgumentParser() parser.add_argument('xDate') args=parser.parse_args(...
Little bit more polish to unutbu's answer: ``` import argparse import time def mkdate(datestr): try: return time.strptime(datestr, '%Y-%m-%d') except ValueError: raise argparse.ArgumentTypeError(datestr + ' is not a proper date string') parser=argparse.ArgumentParser() parser.add_argument('xDate',type=mk...
8,198,162
I have a script for deleting images older than a date. Can I pass this date as an argument when I call to run the script? Example: This script `delete_images.py` deletes images older than a date (YYYY-MM-DD) ``` python delete_images.py 2010-12-31 ``` Script (works with a fixed date (xDate variable)) ``` import os...
2011/11/19
[ "https://Stackoverflow.com/questions/8198162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/871976/" ]
The command line options can be accessed via the list `sys.argv`. So you can simply use ``` xDate = sys.argv[1] ``` (`sys.argv[0]` is the name of the current script.)
you can use runtime arguments for this approach. Please see following link: <http://www.faqs.org/docs/diveintopython/kgp_commandline.html>
8,198,162
I have a script for deleting images older than a date. Can I pass this date as an argument when I call to run the script? Example: This script `delete_images.py` deletes images older than a date (YYYY-MM-DD) ``` python delete_images.py 2010-12-31 ``` Script (works with a fixed date (xDate variable)) ``` import os...
2011/11/19
[ "https://Stackoverflow.com/questions/8198162", "https://Stackoverflow.com", "https://Stackoverflow.com/users/871976/" ]
Little bit more polish to unutbu's answer: ``` import argparse import time def mkdate(datestr): try: return time.strptime(datestr, '%Y-%m-%d') except ValueError: raise argparse.ArgumentTypeError(datestr + ' is not a proper date string') parser=argparse.ArgumentParser() parser.add_argument('xDate',type=mk...
you can use runtime arguments for this approach. Please see following link: <http://www.faqs.org/docs/diveintopython/kgp_commandline.html>
47,555,613
It appears, based on a [urwid example](http://urwid.org/tutorial/#horizontal-menu) that `u'\N{HYPHEN BULLET}` will create a unicode character that is a hyphen intended for a bullet. The names for unicode characters seem to be defined at [fileformat.info](http://www.fileformat.info/info/unicode/char/b.htm) and some el...
2017/11/29
[ "https://Stackoverflow.com/questions/47555613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4360746/" ]
Not every gory detail can be found in a how-to. The [table of escape sequences](https://docs.python.org/2/reference/lexical_analysis.html#string-literals) in the reference manual includes: Escape Sequence: `\N{name}` Meaning: Character named `name` in the Unicode database (Unicode only)
The `\N{}` syntax is documented in the [Unicode HOWTO](https://docs.python.org/3/howto/unicode.html?highlight=unicode%20howto#the-string-type), at least. The names are documented in the Unicode standard, such as: ``` http://www.unicode.org/Public/UCD/latest/ucd/NamesList.txt ``` The `unicodedata` module can look up...
47,555,613
It appears, based on a [urwid example](http://urwid.org/tutorial/#horizontal-menu) that `u'\N{HYPHEN BULLET}` will create a unicode character that is a hyphen intended for a bullet. The names for unicode characters seem to be defined at [fileformat.info](http://www.fileformat.info/info/unicode/char/b.htm) and some el...
2017/11/29
[ "https://Stackoverflow.com/questions/47555613", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4360746/" ]
You are correct that `u"\N{CHARACTER NAME}` produces a valid unicode character in Python. It is not documented much in the Python docs, but after some searching I found a reference to it on effbot.org [http://effbot.org/librarybook/ucnhash.htm](https://web.archive.org/web/20200719141800/http://effbot.org/librarybook/...
The `\N{}` syntax is documented in the [Unicode HOWTO](https://docs.python.org/3/howto/unicode.html?highlight=unicode%20howto#the-string-type), at least. The names are documented in the Unicode standard, such as: ``` http://www.unicode.org/Public/UCD/latest/ucd/NamesList.txt ``` The `unicodedata` module can look up...
55,837,477
convert all txt files delimiter '|' from dir path and convert to csv and save in a location using python? i have tried this code which is hardcoded. ``` import csv txt_file = r"SentiWS_v1.8c_Positive.txt" csv_file = r"NewProcessedDoc.csv" with open(txt_file, "r") as in_text: in_reader = csv.reader(in_text, deli...
2019/04/24
[ "https://Stackoverflow.com/questions/55837477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11186737/" ]
You are trying to instantiate a typealias and are getting `interface doesn't have a constructor` error. To my understanding, typealias with function types work with three steps: 1. Define the typealias itself ``` typealias MyHandler = (Int, String) -> Unit ``` 2. declare an action of that type ``` val myHandler: My...
`typealias` are just an alias for the type :) in other words, it's just another name for the type. Imagine having to write all the time `(Int, String) -> Unit`. With `typealias` you can define something like you did to help out and write less,i.e. instead of: ``` fun Foo(handler: (Int, String) -> Unit) ``` You can...
55,837,477
convert all txt files delimiter '|' from dir path and convert to csv and save in a location using python? i have tried this code which is hardcoded. ``` import csv txt_file = r"SentiWS_v1.8c_Positive.txt" csv_file = r"NewProcessedDoc.csv" with open(txt_file, "r") as in_text: in_reader = csv.reader(in_text, deli...
2019/04/24
[ "https://Stackoverflow.com/questions/55837477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11186737/" ]
You are trying to instantiate a typealias and are getting `interface doesn't have a constructor` error. To my understanding, typealias with function types work with three steps: 1. Define the typealias itself ``` typealias MyHandler = (Int, String) -> Unit ``` 2. declare an action of that type ``` val myHandler: My...
Adding to [theThapa](https://stackoverflow.com/a/55838293/14619383) and [Fred](https://stackoverflow.com/a/55842709/14619383), function typealiases are a way to declare the type of a function. It can be later used. For example, the following shows a good example of how to declare it and use it: ``` import kotlin.test...
55,837,477
convert all txt files delimiter '|' from dir path and convert to csv and save in a location using python? i have tried this code which is hardcoded. ``` import csv txt_file = r"SentiWS_v1.8c_Positive.txt" csv_file = r"NewProcessedDoc.csv" with open(txt_file, "r") as in_text: in_reader = csv.reader(in_text, deli...
2019/04/24
[ "https://Stackoverflow.com/questions/55837477", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11186737/" ]
`typealias` are just an alias for the type :) in other words, it's just another name for the type. Imagine having to write all the time `(Int, String) -> Unit`. With `typealias` you can define something like you did to help out and write less,i.e. instead of: ``` fun Foo(handler: (Int, String) -> Unit) ``` You can...
Adding to [theThapa](https://stackoverflow.com/a/55838293/14619383) and [Fred](https://stackoverflow.com/a/55842709/14619383), function typealiases are a way to declare the type of a function. It can be later used. For example, the following shows a good example of how to declare it and use it: ``` import kotlin.test...
50,279,728
I have a code like this: ``` x = [] for fitur in self.fiturs: x.append(fitur[0]) a = [x , rpxy_list] join = zip(*a) print join ``` and in the self.fiturs is: ``` F1,1,1,1,1,0,1,1,0,0,1 F2,1,0,0,0,0,0,1,0,1,1 F3,1,0,0,0,0,0,1,1,1,1 F4,1,0,0,0,0,0,1,1,1,0 F5,14,24,22,22,22,16,18,19,26,22 F6,8.0625,6.2,6.2609,6.68...
2018/05/10
[ "https://Stackoverflow.com/questions/50279728", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9665999/" ]
It look okay for the most part, With Spark 2 you can try something like this by eliminating extra values there, ``` case class Rating(name:Int, product:Int, rating:Int) val spark:SparkSession = ??? val df = spark.read.csv("/path/to/file") .map({ case Row(u: Int, p: Int, r:Int) => Rating(u, p, r) }) ``` Hope this ...
my problem was related with NaN values down the road. I got it fixed using this: predictions.select([to\_null(c).alias(c) for c in predictions.columns]).na.drop() also I had to import "from pyspark.sql.functions import col, isnan, when, trim"
45,690,043
I have a str like `rjg[]u[ur"fur[ufrng[]"gree`, and i want to replace "[" and "]" between "" with #,the result is `rjg[]u[ur"fur[ufrng[]"gree` => `rjg[]u[ur"fur#ufrng##"gree`, how can i get this in python?
2017/08/15
[ "https://Stackoverflow.com/questions/45690043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6298732/" ]
One liner solution: ``` import re text = 'rjg[]u[ur"fur[ufrng[]"gree' text = re.sub(r'(")([^"]+)(")', lambda pat: pat.group(1)+pat.group(2).replace(']', '#').replace('[', '#')+pat.group(3), text) print text ``` Output: ``` rjg[]u[ur"fur#ufrng##"gree ```
I would try ``` L = data.split('"') for i in range(1, len(L), 2): L[i] = re.sub(r'[\[\]]', '#', L[i]) result = '"'.join(L) ```
45,690,043
I have a str like `rjg[]u[ur"fur[ufrng[]"gree`, and i want to replace "[" and "]" between "" with #,the result is `rjg[]u[ur"fur[ufrng[]"gree` => `rjg[]u[ur"fur#ufrng##"gree`, how can i get this in python?
2017/08/15
[ "https://Stackoverflow.com/questions/45690043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6298732/" ]
I would try ``` L = data.split('"') for i in range(1, len(L), 2): L[i] = re.sub(r'[\[\]]', '#', L[i]) result = '"'.join(L) ```
An option would be using [`str`](https://docs.python.org/3/library/stdtypes.html#str) built-in functions [`split()`](https://docs.python.org/3/library/stdtypes.html#str.split) and [`replace()`](https://docs.python.org/3/library/stdtypes.html#str.replace) like below (**without regex**): ``` s = 'rjg[]u[ur"fur[ufrng[]"g...
45,690,043
I have a str like `rjg[]u[ur"fur[ufrng[]"gree`, and i want to replace "[" and "]" between "" with #,the result is `rjg[]u[ur"fur[ufrng[]"gree` => `rjg[]u[ur"fur#ufrng##"gree`, how can i get this in python?
2017/08/15
[ "https://Stackoverflow.com/questions/45690043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6298732/" ]
I would try ``` L = data.split('"') for i in range(1, len(L), 2): L[i] = re.sub(r'[\[\]]', '#', L[i]) result = '"'.join(L) ```
A one liner without regular expression. Though your solution is very wonderful @jpnkls. ``` >>> text = 'rjg[]u[ur"fur[ufrng[]"gre[e]"abc[d"ef]"' >>> '\"'.join([substr.replace('[', '#').replace(']', '#') if n % 2 == 1 else substr for n, substr in enumerate(text.split('\"')[:-1])]+[text.split('\"')[-1]]) rjg[]u[ur"fur#u...
45,690,043
I have a str like `rjg[]u[ur"fur[ufrng[]"gree`, and i want to replace "[" and "]" between "" with #,the result is `rjg[]u[ur"fur[ufrng[]"gree` => `rjg[]u[ur"fur#ufrng##"gree`, how can i get this in python?
2017/08/15
[ "https://Stackoverflow.com/questions/45690043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6298732/" ]
One liner solution: ``` import re text = 'rjg[]u[ur"fur[ufrng[]"gree' text = re.sub(r'(")([^"]+)(")', lambda pat: pat.group(1)+pat.group(2).replace(']', '#').replace('[', '#')+pat.group(3), text) print text ``` Output: ``` rjg[]u[ur"fur#ufrng##"gree ```
An option would be using [`str`](https://docs.python.org/3/library/stdtypes.html#str) built-in functions [`split()`](https://docs.python.org/3/library/stdtypes.html#str.split) and [`replace()`](https://docs.python.org/3/library/stdtypes.html#str.replace) like below (**without regex**): ``` s = 'rjg[]u[ur"fur[ufrng[]"g...
45,690,043
I have a str like `rjg[]u[ur"fur[ufrng[]"gree`, and i want to replace "[" and "]" between "" with #,the result is `rjg[]u[ur"fur[ufrng[]"gree` => `rjg[]u[ur"fur#ufrng##"gree`, how can i get this in python?
2017/08/15
[ "https://Stackoverflow.com/questions/45690043", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6298732/" ]
One liner solution: ``` import re text = 'rjg[]u[ur"fur[ufrng[]"gree' text = re.sub(r'(")([^"]+)(")', lambda pat: pat.group(1)+pat.group(2).replace(']', '#').replace('[', '#')+pat.group(3), text) print text ``` Output: ``` rjg[]u[ur"fur#ufrng##"gree ```
A one liner without regular expression. Though your solution is very wonderful @jpnkls. ``` >>> text = 'rjg[]u[ur"fur[ufrng[]"gre[e]"abc[d"ef]"' >>> '\"'.join([substr.replace('[', '#').replace(']', '#') if n % 2 == 1 else substr for n, substr in enumerate(text.split('\"')[:-1])]+[text.split('\"')[-1]]) rjg[]u[ur"fur#u...
49,638,674
I have a string `s`, and I want to remove `'.mainlog'` from it. I tried: ``` >>> s = 'ntm_MonMar26_16_59_41_2018.mainlog' >>> s.strip('.mainlog') 'tm_MonMar26_16_59_41_2018' ``` Why did the `n` get removed from `'ntm...'`? Similarly, I had another issue: ``` >>> s = 'MonMar26_16_59_41_2018_rerun.mainlog' >>> s.str...
2018/04/03
[ "https://Stackoverflow.com/questions/49638674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868546/" ]
From Python documentation: <https://docs.python.org/2/library/string.html#string.strip> Currently, it tries to strip all the characters which you mentioned ('.', 'm', 'a', 'i'...) You can use string.replace instead. ``` s.replace('.mainlog', '') ```
You are using the wrong function. `strip` removes characters from the beginning and end of the string. By default spaces, but you can give a list of characters to remove. You should use instead: ``` s.replace('.mainlog', '') ``` Or: ``` import os.path os.path.splitext(s)[0] ```
49,638,674
I have a string `s`, and I want to remove `'.mainlog'` from it. I tried: ``` >>> s = 'ntm_MonMar26_16_59_41_2018.mainlog' >>> s.strip('.mainlog') 'tm_MonMar26_16_59_41_2018' ``` Why did the `n` get removed from `'ntm...'`? Similarly, I had another issue: ``` >>> s = 'MonMar26_16_59_41_2018_rerun.mainlog' >>> s.str...
2018/04/03
[ "https://Stackoverflow.com/questions/49638674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868546/" ]
If you read the docs for [`str.strip`](https://docs.python.org/3/library/stdtypes.html#str.strip) you will see that: > > The chars argument is a string specifying the **set of characters** to be removed. > > > So all the characters in `'.mainlog'` (`['.', 'm', 'a', 'i', 'n', 'l', 'o', 'g']`) are stripped just fro...
You are using the wrong function. `strip` removes characters from the beginning and end of the string. By default spaces, but you can give a list of characters to remove. You should use instead: ``` s.replace('.mainlog', '') ``` Or: ``` import os.path os.path.splitext(s)[0] ```
49,638,674
I have a string `s`, and I want to remove `'.mainlog'` from it. I tried: ``` >>> s = 'ntm_MonMar26_16_59_41_2018.mainlog' >>> s.strip('.mainlog') 'tm_MonMar26_16_59_41_2018' ``` Why did the `n` get removed from `'ntm...'`? Similarly, I had another issue: ``` >>> s = 'MonMar26_16_59_41_2018_rerun.mainlog' >>> s.str...
2018/04/03
[ "https://Stackoverflow.com/questions/49638674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868546/" ]
If you read the docs for [`str.strip`](https://docs.python.org/3/library/stdtypes.html#str.strip) you will see that: > > The chars argument is a string specifying the **set of characters** to be removed. > > > So all the characters in `'.mainlog'` (`['.', 'm', 'a', 'i', 'n', 'l', 'o', 'g']`) are stripped just fro...
From Python documentation: <https://docs.python.org/2/library/string.html#string.strip> Currently, it tries to strip all the characters which you mentioned ('.', 'm', 'a', 'i'...) You can use string.replace instead. ``` s.replace('.mainlog', '') ```
49,638,674
I have a string `s`, and I want to remove `'.mainlog'` from it. I tried: ``` >>> s = 'ntm_MonMar26_16_59_41_2018.mainlog' >>> s.strip('.mainlog') 'tm_MonMar26_16_59_41_2018' ``` Why did the `n` get removed from `'ntm...'`? Similarly, I had another issue: ``` >>> s = 'MonMar26_16_59_41_2018_rerun.mainlog' >>> s.str...
2018/04/03
[ "https://Stackoverflow.com/questions/49638674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868546/" ]
From Python documentation: <https://docs.python.org/2/library/string.html#string.strip> Currently, it tries to strip all the characters which you mentioned ('.', 'm', 'a', 'i'...) You can use string.replace instead. ``` s.replace('.mainlog', '') ```
The argument to the strip function, in this case, `.mainlog` is not a string, it's a set of individual characters. That's removing all leading and trailing characters that are in that list. We'd get the same result if we passed in the argument `aiglmno.`.
49,638,674
I have a string `s`, and I want to remove `'.mainlog'` from it. I tried: ``` >>> s = 'ntm_MonMar26_16_59_41_2018.mainlog' >>> s.strip('.mainlog') 'tm_MonMar26_16_59_41_2018' ``` Why did the `n` get removed from `'ntm...'`? Similarly, I had another issue: ``` >>> s = 'MonMar26_16_59_41_2018_rerun.mainlog' >>> s.str...
2018/04/03
[ "https://Stackoverflow.com/questions/49638674", "https://Stackoverflow.com", "https://Stackoverflow.com/users/868546/" ]
If you read the docs for [`str.strip`](https://docs.python.org/3/library/stdtypes.html#str.strip) you will see that: > > The chars argument is a string specifying the **set of characters** to be removed. > > > So all the characters in `'.mainlog'` (`['.', 'm', 'a', 'i', 'n', 'l', 'o', 'g']`) are stripped just fro...
The argument to the strip function, in this case, `.mainlog` is not a string, it's a set of individual characters. That's removing all leading and trailing characters that are in that list. We'd get the same result if we passed in the argument `aiglmno.`.
44,218,387
This is what I encountered when trying to import thread package: `>>> import thread Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packag es/thread.py", line 3 print('This is ultran00b's package - thread')` I tried u...
2017/05/27
[ "https://Stackoverflow.com/questions/44218387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7074612/" ]
thread module was deprecated in python 3. Try threading instead: ``` import threading ```
You are trying to import the thread class ? Use : ``` from threading import Thread ```
2,990,819
I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists? Update: The target is to have same templates files for different languages. ``` <html> {{head}} {{ var|escape }} {{body}} </html> ``` can be rendered from python (Django) code as well as from PHP, using...
2010/06/07
[ "https://Stackoverflow.com/questions/2990819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108826/" ]
* <http://www.jangod.org/> (There is now also <https://github.com/HubSpot/jinjava>) * run django via jython on jvm * use <http://mustache.github.com/>
Sure, there are all sorts of template engines for Java. I've used FreeMarker, Velocity and StringTemplate. I'm not sure what you mean by Django-like syntax; each engine has it's own variations on a templating approach. For a comparison of some different engines check out [here](http://java-source.net/open-source/templ...
2,990,819
I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists? Update: The target is to have same templates files for different languages. ``` <html> {{head}} {{ var|escape }} {{body}} </html> ``` can be rendered from python (Django) code as well as from PHP, using...
2010/06/07
[ "https://Stackoverflow.com/questions/2990819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108826/" ]
If you want the same templates for different languages, you might take a look at Clearsilver. Clearsilver is a language-neutral template engine which helps separate presentation from code by inserting a language-neutral hierarchial data format (HDF) between your code and templates. Think of HDF like XML, but much sim...
Sure, there are all sorts of template engines for Java. I've used FreeMarker, Velocity and StringTemplate. I'm not sure what you mean by Django-like syntax; each engine has it's own variations on a templating approach. For a comparison of some different engines check out [here](http://java-source.net/open-source/templ...
2,990,819
I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists? Update: The target is to have same templates files for different languages. ``` <html> {{head}} {{ var|escape }} {{body}} </html> ``` can be rendered from python (Django) code as well as from PHP, using...
2010/06/07
[ "https://Stackoverflow.com/questions/2990819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108826/" ]
I've developed [Jtwig](http://jtwig.org). You could give a try. It's being used in some projects with success. It's easy to setup with a nice integration with spring webmvc. Just include the dependency using maven or a similar system. ``` <dependency> <groupId>com.lyncode</groupId> <artifactId>jtwig-spring</artif...
Sure, there are all sorts of template engines for Java. I've used FreeMarker, Velocity and StringTemplate. I'm not sure what you mean by Django-like syntax; each engine has it's own variations on a templating approach. For a comparison of some different engines check out [here](http://java-source.net/open-source/templ...
2,990,819
I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists? Update: The target is to have same templates files for different languages. ``` <html> {{head}} {{ var|escape }} {{body}} </html> ``` can be rendered from python (Django) code as well as from PHP, using...
2010/06/07
[ "https://Stackoverflow.com/questions/2990819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108826/" ]
* <http://www.jangod.org/> (There is now also <https://github.com/HubSpot/jinjava>) * run django via jython on jvm * use <http://mustache.github.com/>
If you want the same templates for different languages, you might take a look at Clearsilver. Clearsilver is a language-neutral template engine which helps separate presentation from code by inserting a language-neutral hierarchial data format (HDF) between your code and templates. Think of HDF like XML, but much sim...
2,990,819
I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists? Update: The target is to have same templates files for different languages. ``` <html> {{head}} {{ var|escape }} {{body}} </html> ``` can be rendered from python (Django) code as well as from PHP, using...
2010/06/07
[ "https://Stackoverflow.com/questions/2990819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108826/" ]
* <http://www.jangod.org/> (There is now also <https://github.com/HubSpot/jinjava>) * run django via jython on jvm * use <http://mustache.github.com/>
You can use [Mustache.java](https://github.com/spullara/mustache.java) and [Handlebars.java](https://github.com/jknack/handlebars.java). Mustache is very minimalistic. Handlebars is similar and compatible with Mustache, but you can **very easily** write your own extensions.
2,990,819
I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists? Update: The target is to have same templates files for different languages. ``` <html> {{head}} {{ var|escape }} {{body}} </html> ``` can be rendered from python (Django) code as well as from PHP, using...
2010/06/07
[ "https://Stackoverflow.com/questions/2990819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108826/" ]
I've developed [Jtwig](http://jtwig.org). You could give a try. It's being used in some projects with success. It's easy to setup with a nice integration with spring webmvc. Just include the dependency using maven or a similar system. ``` <dependency> <groupId>com.lyncode</groupId> <artifactId>jtwig-spring</artif...
If you want the same templates for different languages, you might take a look at Clearsilver. Clearsilver is a language-neutral template engine which helps separate presentation from code by inserting a language-neutral hierarchial data format (HDF) between your code and templates. Think of HDF like XML, but much sim...
2,990,819
I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists? Update: The target is to have same templates files for different languages. ``` <html> {{head}} {{ var|escape }} {{body}} </html> ``` can be rendered from python (Django) code as well as from PHP, using...
2010/06/07
[ "https://Stackoverflow.com/questions/2990819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108826/" ]
If you want the same templates for different languages, you might take a look at Clearsilver. Clearsilver is a language-neutral template engine which helps separate presentation from code by inserting a language-neutral hierarchial data format (HDF) between your code and templates. Think of HDF like XML, but much sim...
You can use [Mustache.java](https://github.com/spullara/mustache.java) and [Handlebars.java](https://github.com/jknack/handlebars.java). Mustache is very minimalistic. Handlebars is similar and compatible with Mustache, but you can **very easily** write your own extensions.
2,990,819
I'm looking for the templates engine for Java with syntax like in Django templates or Twig (PHP). Does it exists? Update: The target is to have same templates files for different languages. ``` <html> {{head}} {{ var|escape }} {{body}} </html> ``` can be rendered from python (Django) code as well as from PHP, using...
2010/06/07
[ "https://Stackoverflow.com/questions/2990819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/108826/" ]
I've developed [Jtwig](http://jtwig.org). You could give a try. It's being used in some projects with success. It's easy to setup with a nice integration with spring webmvc. Just include the dependency using maven or a similar system. ``` <dependency> <groupId>com.lyncode</groupId> <artifactId>jtwig-spring</artif...
You can use [Mustache.java](https://github.com/spullara/mustache.java) and [Handlebars.java](https://github.com/jknack/handlebars.java). Mustache is very minimalistic. Handlebars is similar and compatible with Mustache, but you can **very easily** write your own extensions.
55,656,522
I installed Python 3.7.3 on windows 10, but I can't install Python packages via PIP in Gitbash (Git SCM), due to my company's internet proxy. I tryed to create environment variables for the proxy via the following, but it didn't work: * export http\_proxy='proxy.com:8080' * export https\_proxy='proxy.com:8080' I fou...
2019/04/12
[ "https://Stackoverflow.com/questions/55656522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8691122/" ]
One approach here would be to use lookarounds to ensure that you match *only* islands of exactly two sixes: ``` String regex = "(?<!6)66(?!6)"; String text = "6678793346666786784966"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(text); ``` This finds a count of two, for the input stri...
You need to use ``` String regex = "(?<!6)66(?!6)"; ``` See the [regex demo](https://regex101.com/r/3QHER6/2). [![enter image description here](https://i.stack.imgur.com/6b4St.png)](https://i.stack.imgur.com/6b4St.png) **Details** * `(?<!6)` - no `6` right before the current location * `66` - `66` substring * `(?...
55,656,522
I installed Python 3.7.3 on windows 10, but I can't install Python packages via PIP in Gitbash (Git SCM), due to my company's internet proxy. I tryed to create environment variables for the proxy via the following, but it didn't work: * export http\_proxy='proxy.com:8080' * export https\_proxy='proxy.com:8080' I fou...
2019/04/12
[ "https://Stackoverflow.com/questions/55656522", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8691122/" ]
One approach here would be to use lookarounds to ensure that you match *only* islands of exactly two sixes: ``` String regex = "(?<!6)66(?!6)"; String text = "6678793346666786784966"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(text); ``` This finds a count of two, for the input stri...
This didn't take long to come up with. I like regular expressions but I don't use them unless really necessary. Here is one loop method that appears to work. ``` char TARGET = '6'; int GROUPSIZE = 2; // String with random termination character that's not a TARGET String s = "6678793346666786784966" + "z"; i...
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
The fix based on the comment led to this fun way. It assumes no commas occur in the string entries of the list to be joined (which would be problematic anyway, so is a reasonable assumption.) ``` def special_join(my_list): return ", ".join(my_list)[::-1].replace(",", "dna ", 1)[::-1] In [50]: def special_join(my_...
In case you need a solution where negative indexing isn't supported (i.e. Django QuerySet) ``` def oxford_join(string_list): if len(string_list) < 1: text = '' elif len(string_list) == 1: text = string_list[0] elif len(string_list) == 2: text = ' and '.join(string_list) else: ...
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
The fix based on the comment led to this fun way. It assumes no commas occur in the string entries of the list to be joined (which would be problematic anyway, so is a reasonable assumption.) ``` def special_join(my_list): return ", ".join(my_list)[::-1].replace(",", "dna ", 1)[::-1] In [50]: def special_join(my_...
just special-case the last one. something like this: ``` '%s and %s'%(', '.join(mylist[:-1]),mylist[-1]) ``` there's probably not going to be any more concise method. this will fail in the zero case too.
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
This expression does it: ``` print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ``` As seen here: ``` >>> data ['foo', 'bar', 'baaz', 'bah'] >>> while data: ... print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ... data.pop() ... foo, bar, baaz and bah foo, bar and baaz foo and bar foo ```
The fix based on the comment led to this fun way. It assumes no commas occur in the string entries of the list to be joined (which would be problematic anyway, so is a reasonable assumption.) ``` def special_join(my_list): return ", ".join(my_list)[::-1].replace(",", "dna ", 1)[::-1] In [50]: def special_join(my_...
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
This expression does it: ``` print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ``` As seen here: ``` >>> data ['foo', 'bar', 'baaz', 'bah'] >>> while data: ... print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ... data.pop() ... foo, bar, baaz and bah foo, bar and baaz foo and bar foo ```
Already good answers available. This one works in all test cases and is slightly different than some others. ``` def grammar_join(words): return reduce(lambda x, y: x and x + ' and ' + y or y, (', '.join(words[:-1]), words[-1])) if words else '' tests = ([], ['a'], ['a', 'b'], ['a', 'b', 'c']) f...
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
Try this, it takes into consideration the edge cases and uses `format()`, to show another possible solution: ``` def my_join(lst): if not lst: return "" elif len(lst) == 1: return str(lst[0]) return "{} and {}".format(", ".join(lst[:-1]), lst[-1]) ``` Works as expected: ``` my_join([]) ...
just special-case the last one. something like this: ``` '%s and %s'%(', '.join(mylist[:-1]),mylist[-1]) ``` there's probably not going to be any more concise method. this will fail in the zero case too.
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
This expression does it: ``` print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ``` As seen here: ``` >>> data ['foo', 'bar', 'baaz', 'bah'] >>> while data: ... print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ... data.pop() ... foo, bar, baaz and bah foo, bar and baaz foo and bar foo ```
Try this, it takes into consideration the edge cases and uses `format()`, to show another possible solution: ``` def my_join(lst): if not lst: return "" elif len(lst) == 1: return str(lst[0]) return "{} and {}".format(", ".join(lst[:-1]), lst[-1]) ``` Works as expected: ``` my_join([]) ...
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
Already good answers available. This one works in all test cases and is slightly different than some others. ``` def grammar_join(words): return reduce(lambda x, y: x and x + ' and ' + y or y, (', '.join(words[:-1]), words[-1])) if words else '' tests = ([], ['a'], ['a', 'b'], ['a', 'b', 'c']) f...
In case you need a solution where negative indexing isn't supported (i.e. Django QuerySet) ``` def oxford_join(string_list): if len(string_list) < 1: text = '' elif len(string_list) == 1: text = string_list[0] elif len(string_list) == 2: text = ' and '.join(string_list) else: ...
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
This expression does it: ``` print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ``` As seen here: ``` >>> data ['foo', 'bar', 'baaz', 'bah'] >>> while data: ... print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ... data.pop() ... foo, bar, baaz and bah foo, bar and baaz foo and bar foo ```
just special-case the last one. something like this: ``` '%s and %s'%(', '.join(mylist[:-1]),mylist[-1]) ``` there's probably not going to be any more concise method. this will fail in the zero case too.
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
This expression does it: ``` print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ``` As seen here: ``` >>> data ['foo', 'bar', 'baaz', 'bah'] >>> while data: ... print ", ".join(data[:-2] + [" and ".join(data[-2:])]) ... data.pop() ... foo, bar, baaz and bah foo, bar and baaz foo and bar foo ```
In case you need a solution where negative indexing isn't supported (i.e. Django QuerySet) ``` def oxford_join(string_list): if len(string_list) < 1: text = '' elif len(string_list) == 1: text = string_list[0] elif len(string_list) == 2: text = ' and '.join(string_list) else: ...
19,838,976
What's the most pythonic way of joining a list so that there are commas between each item, except for the last which uses "and"? ``` ["foo"] --> "foo" ["foo","bar"] --> "foo and bar" ["foo","bar","baz"] --> "foo, bar and baz" ["foo","bar","baz","bah"] --> "foo, bar, baz and bah" ```
2013/11/07
[ "https://Stackoverflow.com/questions/19838976", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1277170/" ]
Try this, it takes into consideration the edge cases and uses `format()`, to show another possible solution: ``` def my_join(lst): if not lst: return "" elif len(lst) == 1: return str(lst[0]) return "{} and {}".format(", ".join(lst[:-1]), lst[-1]) ``` Works as expected: ``` my_join([]) ...
Already good answers available. This one works in all test cases and is slightly different than some others. ``` def grammar_join(words): return reduce(lambda x, y: x and x + ' and ' + y or y, (', '.join(words[:-1]), words[-1])) if words else '' tests = ([], ['a'], ['a', 'b'], ['a', 'b', 'c']) f...
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
I forgot to create a celery object in tasks.py: ``` from celery import Celery from celery import task celery = Celery('tasks', broker='amqp://guest@localhost//') #! import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" @task() def add_photos_task( lad_id ): ... ``` After that we could normally sta...
When you run `celery -A tasks worker --loglevel=info`, your celery app should be exposed in the module `tasks`. It shouldn't be wrapped in a function or an `if` statements that. If you `make_celery` in another file, you should import the celery app in to your the file you are passing to celery.
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
Celery uses `celery` file for storing configuration of your app, you can't just give a python file with tasks and start celery. You should define `celery` file ( for Celery>3.0; previously it was `celeryconfig.py`).. > > celeryd --app app.celery -l info > > > This example how to start celery with config file at `...
My problem was that I put the `celery` variable inside a main function: ``` if __name__ == '__main__': # Remove this row app = Flask(__name__) celery = make_celery(app) ``` when it should be put outside.
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
I forgot to create a celery object in tasks.py: ``` from celery import Celery from celery import task celery = Celery('tasks', broker='amqp://guest@localhost//') #! import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" @task() def add_photos_task( lad_id ): ... ``` After that we could normally sta...
My problem was that I put the `celery` variable inside a main function: ``` if __name__ == '__main__': # Remove this row app = Flask(__name__) celery = make_celery(app) ``` when it should be put outside.
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
I forgot to create a celery object in tasks.py: ``` from celery import Celery from celery import task celery = Celery('tasks', broker='amqp://guest@localhost//') #! import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" @task() def add_photos_task( lad_id ): ... ``` After that we could normally sta...
Celery uses `celery` file for storing configuration of your app, you can't just give a python file with tasks and start celery. You should define `celery` file ( for Celery>3.0; previously it was `celeryconfig.py`).. > > celeryd --app app.celery -l info > > > This example how to start celery with config file at `...
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
For anyone who is getting the same error message for an apparently different reason, note that if any of the imports in your initialization file fail, your app will raise this totally ambiguous `AttributeError` rather than the exception that initially caused it.
My problem was that I put the `celery` variable inside a main function: ``` if __name__ == '__main__': # Remove this row app = Flask(__name__) celery = make_celery(app) ``` when it should be put outside.
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
My problem was that I put the `celery` variable inside a main function: ``` if __name__ == '__main__': # Remove this row app = Flask(__name__) celery = make_celery(app) ``` when it should be put outside.
Try start celery: `celeryd --config=my_app.my_config --loglevel=INFO --purge -Q my_queue` There is next script in my `tasks.py`: ``` @task(name="my_queue", routing_key="my_queue") def add_photos_task( lad_id ): ``` There is next script in `my_config.py`: ``` CELERY_IMPORTS = \ ( "my_app.tasks", ) CELERY_ROUTE...
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
I forgot to create a celery object in tasks.py: ``` from celery import Celery from celery import task celery = Celery('tasks', broker='amqp://guest@localhost//') #! import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" @task() def add_photos_task( lad_id ): ... ``` After that we could normally sta...
For anyone who is getting the same error message for an apparently different reason, note that if any of the imports in your initialization file fail, your app will raise this totally ambiguous `AttributeError` rather than the exception that initially caused it.
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
When you run `celery -A tasks worker --loglevel=info`, your celery app should be exposed in the module `tasks`. It shouldn't be wrapped in a function or an `if` statements that. If you `make_celery` in another file, you should import the celery app in to your the file you are passing to celery.
Try start celery: `celeryd --config=my_app.my_config --loglevel=INFO --purge -Q my_queue` There is next script in my `tasks.py`: ``` @task(name="my_queue", routing_key="my_queue") def add_photos_task( lad_id ): ``` There is next script in `my_config.py`: ``` CELERY_IMPORTS = \ ( "my_app.tasks", ) CELERY_ROUTE...
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
For anyone who is getting the same error message for an apparently different reason, note that if any of the imports in your initialization file fail, your app will raise this totally ambiguous `AttributeError` rather than the exception that initially caused it.
Try start celery: `celeryd --config=my_app.my_config --loglevel=INFO --purge -Q my_queue` There is next script in my `tasks.py`: ``` @task(name="my_queue", routing_key="my_queue") def add_photos_task( lad_id ): ``` There is next script in `my_config.py`: ``` CELERY_IMPORTS = \ ( "my_app.tasks", ) CELERY_ROUTE...
13,555,386
I try to start a Celery worker server from a command line: ``` celery -A tasks worker --loglevel=info ``` The code in tasks.py: ``` import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" from celery import task @task() def add_photos_task( lad_id ): ... ``` I get the next error: ``` Traceback (most...
2012/11/25
[ "https://Stackoverflow.com/questions/13555386", "https://Stackoverflow.com", "https://Stackoverflow.com/users/749288/" ]
I forgot to create a celery object in tasks.py: ``` from celery import Celery from celery import task celery = Celery('tasks', broker='amqp://guest@localhost//') #! import os os.environ[ 'DJANGO_SETTINGS_MODULE' ] = "proj.settings" @task() def add_photos_task( lad_id ): ... ``` After that we could normally sta...
Try start celery: `celeryd --config=my_app.my_config --loglevel=INFO --purge -Q my_queue` There is next script in my `tasks.py`: ``` @task(name="my_queue", routing_key="my_queue") def add_photos_task( lad_id ): ``` There is next script in `my_config.py`: ``` CELERY_IMPORTS = \ ( "my_app.tasks", ) CELERY_ROUTE...
31,800,998
Issue: Remove the hyperlinks, numbers and signs like `^&*$ etc` from twitter text. The tweet file is in CSV tabulated format as shown below: ``` s.No. username tweetText 1. @abc This is a test #abc example.com 2. @bcd This is another test #bcd example.com ``` Being a novice at python, I search and ...
2015/08/04
[ "https://Stackoverflow.com/questions/31800998", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4195053/" ]
To remove `&amp` from string you can use [html\_entity\_decode](http://php.net/manual/en/function.html-entity-decode.php) ``` while ($row = mysql_fetch_array($result)) { $row['value'] = html_entity_decode($row['value']); $row['id'] = (int) $row['client_id']; $row_set[] = $row; } ```
Change this `htmlentities` to this `html_entity_decode()` So **final Code will** be ``` $term = trim(strip_tags($_GET['term'])); $term = str_replace(' ', '%', $term); $qstring = "SELECT name as value, client_id FROM goa WHERE name LIKE '" . $term . "%' limit 0,5000"; $result = mysql_query($qstring); $qcount = 0; if (...
58,926,146
I trained a model with RBF kernel-based support vector machine regression. I want to know the features that are very important or major contributing features for the RBF kernel-based support vector machine. I know there is a method to know the most contributing features for linear support vector regression based on wei...
2019/11/19
[ "https://Stackoverflow.com/questions/58926146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8739662/" ]
Let me sort the comments as an answer: As you can read [here](https://stackoverflow.com/questions/52640386/how-do-i-solve-the-future-warning-min-groups-self-n-splits-warning-in): > > Weights asigned to the features (coefficients in the primal > problem). This is only available in the case of linear kernel. > > > ...
In relation with the inspection of non linear SVM models (e.g. using RBF kernel), here I share an answer posted in another thread which might be useful for this purpose. The method is based on "[sklearn.inspection.permutation\_importance](https://stackoverflow.com/a/67910281/13670156)". And here, a compressive discus...
42,149,079
I've managed to install pymol on windows following the instructions [here](https://stackoverflow.com/questions/27885397/how-do-i-install-a-python-package-with-a-whl-file) and using the file Pmw‑2.0.1‑py2‑none‑any.whl from [here](http://www.lfd.uci.edu/~gohlke/pythonlibs/#pymol) Various folders have appeared in `C:\Use...
2017/02/09
[ "https://Stackoverflow.com/questions/42149079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2923519/" ]
Try changing ``` lastRow44 = Cells(Rows.Count, "A").End(xlUp).Row LastRow3 = Worksheets("Temp").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).Row ``` to ``` lastRow44 = Sheets("Temp").Cells(Rows.Count, 1).End(xlUp).Row LastRow3 = Worksheets("Temp").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row ``` Also, I am n...
How about something like that: ``` lastRow44 = Cells(Rows.Count, "A").End(xlUp).Row For x = 50 To LastRow3 Range("A" & x).Formula = "=Sum(""M""" & x & "": M "" & lastRow44 & ")" Next x ```
40,687,397
I am trying to update my chromedriver.exe file as outlined here. [Python selenium webdriver "Session not created" exception when opening Chrome](https://stackoverflow.com/questions/40373801/python-selenium-webdriver-session-not-created-exception-when-opening-chrome) The problem is, I do not know the location of the o...
2016/11/18
[ "https://Stackoverflow.com/questions/40687397", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5960274/" ]
If you don't want to expose your constructors for some reasons, you can easily hide them behind a factory method based on templates and perfect forwarding: ``` class Foo { // defined somewhere Foo( Param1, Param2 ); Foo( Param1, Param3, Param4 ); Foo( Param1, Param4 ); Foo( Param1, Param2, Param4 )...
As an user, I prefer ``` Foo* CreateFoo(Param1* P1, Param2* P2, Param3* P3, Param4* P4); ``` Why should I construc a `struct` just to pass some (maybe NULL) parameters?
72,173,142
I need to create a fórmula that when it is dragged down it jumps a certain pre defined number of cells. For example, I have this column: [![enter image description here](https://i.stack.imgur.com/y7c78.png)](https://i.stack.imgur.com/y7c78.png) However I want a formula that when I drag down it jumps 6 rows, something...
2022/05/09
[ "https://Stackoverflow.com/questions/72173142", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5606352/" ]
Try in B2 ``` =offset($A$1;5*row(A2)-10;) ```
try instead: ``` =QUERY(A1:A; "skipping 5"; 0) ``` [![enter image description here](https://i.stack.imgur.com/09MiK.png)](https://i.stack.imgur.com/09MiK.png)
41,131,038
Given an interactive python script ``` #!/usr/bin/python import sys name = raw_input("Please enter your name: ") age = raw_input("Please enter your age: ") print("Happy %s.th birthday %s!" % (age, name)) while 1: r = raw_input("q for quit: ") if r == "q": sys.exit() ``` I want to interact with it f...
2016/12/13
[ "https://Stackoverflow.com/questions/41131038", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1922202/" ]
Storing an unsigned integer straight *in* a pointer portably isn't allowed, but you can: * do the reverse: you can store your pointer in an unsigned integer; specifically, `uintptr_t` is explicitly guaranteed by the standard to be big enough to let pointers survive the roundtrip; * use a `union`: ``` union NodePtr { ...
Well, you can store int as a pointer with casts: ``` uint32_t i = 123; Octree* ptr = reinterpret_cast<Octree*>(i); uint32_t ii = reinterpret_cast<uint32_t>(ptr); std::cout << ii << std::endl; //Prints 123 ``` But if you do it this way I can't see how you detect that a given Octree\* actually stores data and is not a...
12,569,356
I'm a very beginner with Python classes and JSON and I'm not sure I'm going in the right direction. Basically, I have a web service that accepts a JSON request in a POST body like this: ``` { "item" : { "thing" : "foo", "flag" : true, "language" : "en_us" }, "numresults" : 3 } ``` I st...
2012/09/24
[ "https://Stackoverflow.com/questions/12569356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/476638/" ]
just add one method to your class that returns a dictionary ``` def jsonify(self): return { 'Class Whatever':{ 'data1':self.data1, 'data2':self.data2, ... } } ``` and call your tojson function on the result ... or call it before you...
Take a look at the [`colander` project](http://docs.pylonsproject.org/projects/colander/en/latest/); it let's you define an object-oriented 'schema' that is easily serializable to and from JSON. ``` import colander class Item(colander.MappingSchema): thing = colander.SchemaNode(colander.String(), ...
12,569,356
I'm a very beginner with Python classes and JSON and I'm not sure I'm going in the right direction. Basically, I have a web service that accepts a JSON request in a POST body like this: ``` { "item" : { "thing" : "foo", "flag" : true, "language" : "en_us" }, "numresults" : 3 } ``` I st...
2012/09/24
[ "https://Stackoverflow.com/questions/12569356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/476638/" ]
Take a look at the [`colander` project](http://docs.pylonsproject.org/projects/colander/en/latest/); it let's you define an object-oriented 'schema' that is easily serializable to and from JSON. ``` import colander class Item(colander.MappingSchema): thing = colander.SchemaNode(colander.String(), ...
The colander and dict suggestions are both great. I'd just add that you should step back for a moment and decide how you'll use these objects. A potential problem with this general approach is that you'll need a list or function or some other mapping to decide which attributes are exported. ( you see this in the co...
12,569,356
I'm a very beginner with Python classes and JSON and I'm not sure I'm going in the right direction. Basically, I have a web service that accepts a JSON request in a POST body like this: ``` { "item" : { "thing" : "foo", "flag" : true, "language" : "en_us" }, "numresults" : 3 } ``` I st...
2012/09/24
[ "https://Stackoverflow.com/questions/12569356", "https://Stackoverflow.com", "https://Stackoverflow.com/users/476638/" ]
just add one method to your class that returns a dictionary ``` def jsonify(self): return { 'Class Whatever':{ 'data1':self.data1, 'data2':self.data2, ... } } ``` and call your tojson function on the result ... or call it before you...
The colander and dict suggestions are both great. I'd just add that you should step back for a moment and decide how you'll use these objects. A potential problem with this general approach is that you'll need a list or function or some other mapping to decide which attributes are exported. ( you see this in the co...
6,800,280
This is a follow-up to this previous question: [Complicated COUNT query in MySQL](https://stackoverflow.com/questions/6580684/complicated-count-query-in-mysql). None of the answers worked under all conditions, and I have had trouble figuring out a solution as well. I will be awarding a 75 point bounty to the first pers...
2011/07/23
[ "https://Stackoverflow.com/questions/6800280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/651174/" ]
Couldn't there be problem with `<Files .*>`? I think this is a wildcard pattern so you should use just `<Files *>`.
The order of your htaccess, should be... ``` RewriteEngine On <Files .*> Order allow,deny Allow from all </Files> Options FollowSymLinks RewriteRule ^photos.+$ thumbs.php [L,QSA] RewriteRule ^[a-zA-Z0-9\-_]*$ index.php [L,QSA] RewriteRule ^[a-zA-Z0-9\-_]+\.html$ index.php [L,QSA] ```
6,800,280
This is a follow-up to this previous question: [Complicated COUNT query in MySQL](https://stackoverflow.com/questions/6580684/complicated-count-query-in-mysql). None of the answers worked under all conditions, and I have had trouble figuring out a solution as well. I will be awarding a 75 point bounty to the first pers...
2011/07/23
[ "https://Stackoverflow.com/questions/6800280", "https://Stackoverflow.com", "https://Stackoverflow.com/users/651174/" ]
I managed to find the solution, the issue was really simple, i was missing a + before FollowSymLinks. Simple issue, few wasted hours to find the solution. The weirdest part is that the on the same hosting, different domain/folder it is working the same without the +... Anyway thank you for your help. this is my final ...
The order of your htaccess, should be... ``` RewriteEngine On <Files .*> Order allow,deny Allow from all </Files> Options FollowSymLinks RewriteRule ^photos.+$ thumbs.php [L,QSA] RewriteRule ^[a-zA-Z0-9\-_]*$ index.php [L,QSA] RewriteRule ^[a-zA-Z0-9\-_]+\.html$ index.php [L,QSA] ```
44,732,839
I am trying to process txt file using pandas. However, I get following error at read\_csv > > CParserError Traceback (most recent call > last) in () > 22 Col.append(elm) > 23 > ---> 24 revised=pd.read\_csv(Path+file,skiprows=Header+1,header=None,delim\_whitespace=True) > 25 > 26 TimeSeries.append(revised)...
2017/06/24
[ "https://Stackoverflow.com/questions/44732839", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7124344/" ]
It fails because the part of the file you're reading looks like this: ``` Timestamp Trend Flags Status Value (ºC) ------------------------- ----------- ------ ---------- 20-Oct-12 8:00:00 PM HKT {start} {ok} 15.310 ºC 21-Oct-12 12:00:00 AM HKT { } {ok} 15.130 ºC ``` But...
Include This line before ======================== ``` file_name = Path+file #change below line to given ``` > > revised=pd.read\_csv(Path+file,skiprows=Header+1,header=None,delim\_whitespace=True) > revised=pd.read\_csv(file\_name,skiprows=Header+1,header=None,sep=" ") > > >
27,647,922
I'm working on my python script as I'm created a list to stored the elements in the arrays. I have got a problem with the if statement. I'm trying to find the elements if I have the values `375` but it won't let me to get pass on the if statement. Here is the code: ``` program_X = list() #create the rows to count f...
2014/12/25
[ "https://Stackoverflow.com/questions/27647922", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4275381/" ]
As the `program_x` contains string elements : ``` program_X = map(str, program_X) ^ ``` you need to change the following : ``` if pos_X == 375 ``` to ``` if pos_X == '375' ```
If you are storing strings in list that way, ``` program_X = ['14:08:55 T:1260 NOTICE: 8081.35', ...] ``` Then use `in` keyword to check the word ``` for pos_X in programs_X: #find the position with 375 if '375' in pos_X: print pos_X ```
45,692,894
Problem ------- Some reoccurring events, that don't really end at some point (like club meetings?), depend on other conditions (like holiday season). However, manually adding these exceptions would be necessary every year, as the dates might differ. **Research** * I have found out about `exdate` (see the image of...
2017/08/15
[ "https://Stackoverflow.com/questions/45692894", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4550784/" ]
[RFC2445 defines an `EXRULE`](https://www.rfc-editor.org/rfc/rfc2445#section-4.8.5.2) (exception rule) property. You can use that in addition to the `RRULE` to define recurring exceptions. However, RFC2445 was superseded by [RFC5545, which unfortunately deprecates the `EXRULE`](https://www.rfc-editor.org/rfc/rfc5545#a...
`BYMONTH` would be another possibility, e.g. here's a rule for a club meeting that occurs the first Wednesday of every month except December (which is their Christmas party, so no business meeting) ``` RRULE:FREQ=MONTHLY;BYDAY=1WE;BYMONTH=1,2,3,4,5,6,7,8,9,10,11 ```
42,519,094
I am trying to start a Python 3.6 project by creating a virtualenv to keep the dependencies. I currently have both Python 2.7 and 3.6 installed on my machine, as I have been coding in 2.7 up until now and I wish to try out 3.6. I am running into a problem with the different versions of Python not detecting modules I am...
2017/02/28
[ "https://Stackoverflow.com/questions/42519094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4588188/" ]
You have to select the interpreter when you create the virtualenv. ``` virtualenv --python=PYTHON36_EXE my_venv ``` Substitute the path to your Python 3.6 installation in place of `PYTHON36_EXE`. Then after you've activated, `python` executable will be bound to 3.6 and you can just `pip install Django` as usual.
The key is that `pip` installs things for a specific version of Python, and to a very specific location. Basically, the `pip` command in your virtual environment is set up specifically for the interpreter that your virtual environment is using. So even if you explicitly call another interpreter with that environment ac...
42,519,094
I am trying to start a Python 3.6 project by creating a virtualenv to keep the dependencies. I currently have both Python 2.7 and 3.6 installed on my machine, as I have been coding in 2.7 up until now and I wish to try out 3.6. I am running into a problem with the different versions of Python not detecting modules I am...
2017/02/28
[ "https://Stackoverflow.com/questions/42519094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4588188/" ]
Create virtual environment based on python3.6 ``` virtualenv -p python3.6 env36 ``` Activate it: ``` source env36/bin/activate ``` Then the venv36 has been activated, `venv36`'s pip is available now , you can install `Django` as usual, and the package would be stored under `env36/lib/python3.6/site-packages`: ...
The key is that `pip` installs things for a specific version of Python, and to a very specific location. Basically, the `pip` command in your virtual environment is set up specifically for the interpreter that your virtual environment is using. So even if you explicitly call another interpreter with that environment ac...
21,426,329
I followed mbrochh's instruction <https://github.com/mbrochh/vim-as-a-python-ide> to build my vim as a python IDE. But things go wrong when openning the vim after I put `jedi-vim` into `~/.vim/bundle`. The following is the warnings ``` Error detected while processing CursorMovedI Auto commands for "buffer=1": Tracebac...
2014/01/29
[ "https://Stackoverflow.com/questions/21426329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1263069/" ]
If you’re trying to use Vundle to install the jedi-vim plugin, I don’t think you should have to place it under `~/.vim/bundle`. Instead, make sure you have Vundle set up correctly, as [described in its “Quick start”](https://github.com/gmarik/vundle#quick-start), and then try adding this line to your `~/.vimrc` after t...
make sure that you have install jedi, I solved my problem with below command.. ``` cd ~/.vim/bundle/jedi-vim git submodule update --init ```
21,426,329
I followed mbrochh's instruction <https://github.com/mbrochh/vim-as-a-python-ide> to build my vim as a python IDE. But things go wrong when openning the vim after I put `jedi-vim` into `~/.vim/bundle`. The following is the warnings ``` Error detected while processing CursorMovedI Auto commands for "buffer=1": Tracebac...
2014/01/29
[ "https://Stackoverflow.com/questions/21426329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1263069/" ]
If you’re trying to use Vundle to install the jedi-vim plugin, I don’t think you should have to place it under `~/.vim/bundle`. Instead, make sure you have Vundle set up correctly, as [described in its “Quick start”](https://github.com/gmarik/vundle#quick-start), and then try adding this line to your `~/.vimrc` after t...
Dependencies exists in the Jedi git repo. *I expect you are using pathogen as extension manager.* Use `git clone` with `--recursive` option. > > cd ~/.vim/bundle/ && git clone --recursive <https://github.com/davidhalter/jedi-vim.git> > > > Dave Halter has this instruction in the [docs on github](https://github.c...
21,426,329
I followed mbrochh's instruction <https://github.com/mbrochh/vim-as-a-python-ide> to build my vim as a python IDE. But things go wrong when openning the vim after I put `jedi-vim` into `~/.vim/bundle`. The following is the warnings ``` Error detected while processing CursorMovedI Auto commands for "buffer=1": Tracebac...
2014/01/29
[ "https://Stackoverflow.com/questions/21426329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1263069/" ]
If you’re trying to use Vundle to install the jedi-vim plugin, I don’t think you should have to place it under `~/.vim/bundle`. Instead, make sure you have Vundle set up correctly, as [described in its “Quick start”](https://github.com/gmarik/vundle#quick-start), and then try adding this line to your `~/.vimrc` after t...
(Using ubuntu 14.04LTS with Python 2.7) I had a very similar issue and I found that I needed to integrate Jedi into my Python installation. I did the following... ``` sudo apt-get install python-pip sudo pip install jedi ``` Then if you haven't done so already, you can then add Jedi to VIM via Pathogen as follows...
21,426,329
I followed mbrochh's instruction <https://github.com/mbrochh/vim-as-a-python-ide> to build my vim as a python IDE. But things go wrong when openning the vim after I put `jedi-vim` into `~/.vim/bundle`. The following is the warnings ``` Error detected while processing CursorMovedI Auto commands for "buffer=1": Tracebac...
2014/01/29
[ "https://Stackoverflow.com/questions/21426329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1263069/" ]
make sure that you have install jedi, I solved my problem with below command.. ``` cd ~/.vim/bundle/jedi-vim git submodule update --init ```
Dependencies exists in the Jedi git repo. *I expect you are using pathogen as extension manager.* Use `git clone` with `--recursive` option. > > cd ~/.vim/bundle/ && git clone --recursive <https://github.com/davidhalter/jedi-vim.git> > > > Dave Halter has this instruction in the [docs on github](https://github.c...
21,426,329
I followed mbrochh's instruction <https://github.com/mbrochh/vim-as-a-python-ide> to build my vim as a python IDE. But things go wrong when openning the vim after I put `jedi-vim` into `~/.vim/bundle`. The following is the warnings ``` Error detected while processing CursorMovedI Auto commands for "buffer=1": Tracebac...
2014/01/29
[ "https://Stackoverflow.com/questions/21426329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1263069/" ]
(Using ubuntu 14.04LTS with Python 2.7) I had a very similar issue and I found that I needed to integrate Jedi into my Python installation. I did the following... ``` sudo apt-get install python-pip sudo pip install jedi ``` Then if you haven't done so already, you can then add Jedi to VIM via Pathogen as follows...
Dependencies exists in the Jedi git repo. *I expect you are using pathogen as extension manager.* Use `git clone` with `--recursive` option. > > cd ~/.vim/bundle/ && git clone --recursive <https://github.com/davidhalter/jedi-vim.git> > > > Dave Halter has this instruction in the [docs on github](https://github.c...
47,972,811
I am on CentOs7. I installed tk, tk-devel, tkinter through yum. I can import tkinter in Python 3, but not in Python 2.7. Any ideas? Success in Python 3 (Anaconda): ``` Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for mo...
2017/12/25
[ "https://Stackoverflow.com/questions/47972811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9139945/" ]
For python 3 use: ``` import tkinter ``` For python 2 use: ``` import Tkinter ``` If these do not work install with, for python 3: ``` sudo apt-get install python3-tk ``` or, for python 2: ``` sudo apt-get install python-tk ``` you can find more details [here](https://www.techinfected.net/2015/09/how-to-in...
For python2.7 try ``` import Tkinter ``` With a capital T. It should already be pre-installed in default centos 7 python setup, if not do `yum install tkinter`
17,273,393
In my python code I have global `requests.session` instance: ``` import requests session = requests.session() ``` How can I mock it with `Mock`? Is there any decorator for this kind of operations? I tried following: ``` session.get = mock.Mock(side_effect=self.side_effects) ``` but (as expected) this code doesn't...
2013/06/24
[ "https://Stackoverflow.com/questions/17273393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1325846/" ]
Use `mock.patch` to patch session in your module. Here you go, a complete working example <https://gist.github.com/k-bx/5861641>
With some inspiration from the previous answer and : [mock-attributes-in-python-mock](https://stackoverflow.com/questions/16867509/mock-attributes-in-python-mock) I was able to mock a session defined like this: ``` class MyClient(object): """ """ def __init__(self): self.session = requests.sessio...
17,273,393
In my python code I have global `requests.session` instance: ``` import requests session = requests.session() ``` How can I mock it with `Mock`? Is there any decorator for this kind of operations? I tried following: ``` session.get = mock.Mock(side_effect=self.side_effects) ``` but (as expected) this code doesn't...
2013/06/24
[ "https://Stackoverflow.com/questions/17273393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1325846/" ]
Since requests.session() returns an instance of the Session class, it is also possible to use patch.object() ``` from requests import Session from unittest.mock import patch @patch.object(Session, 'get') def test_foo(mock_get): mock_get.return_value = 'bar' ```
Use `mock.patch` to patch session in your module. Here you go, a complete working example <https://gist.github.com/k-bx/5861641>
17,273,393
In my python code I have global `requests.session` instance: ``` import requests session = requests.session() ``` How can I mock it with `Mock`? Is there any decorator for this kind of operations? I tried following: ``` session.get = mock.Mock(side_effect=self.side_effects) ``` but (as expected) this code doesn't...
2013/06/24
[ "https://Stackoverflow.com/questions/17273393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1325846/" ]
Use `mock.patch` to patch session in your module. Here you go, a complete working example <https://gist.github.com/k-bx/5861641>
I discovered [the requests\_mock library](https://pypi.org/project/requests-mock/). It saved me a lot of bother. With pytest... ``` def test_success(self, requests_mock): """They give us a token. """ requests_mock.get("https://example.com/api/v1/login", text=( '{"result":1001, "errMsg":n...
17,273,393
In my python code I have global `requests.session` instance: ``` import requests session = requests.session() ``` How can I mock it with `Mock`? Is there any decorator for this kind of operations? I tried following: ``` session.get = mock.Mock(side_effect=self.side_effects) ``` but (as expected) this code doesn't...
2013/06/24
[ "https://Stackoverflow.com/questions/17273393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1325846/" ]
Since requests.session() returns an instance of the Session class, it is also possible to use patch.object() ``` from requests import Session from unittest.mock import patch @patch.object(Session, 'get') def test_foo(mock_get): mock_get.return_value = 'bar' ```
With some inspiration from the previous answer and : [mock-attributes-in-python-mock](https://stackoverflow.com/questions/16867509/mock-attributes-in-python-mock) I was able to mock a session defined like this: ``` class MyClient(object): """ """ def __init__(self): self.session = requests.sessio...
17,273,393
In my python code I have global `requests.session` instance: ``` import requests session = requests.session() ``` How can I mock it with `Mock`? Is there any decorator for this kind of operations? I tried following: ``` session.get = mock.Mock(side_effect=self.side_effects) ``` but (as expected) this code doesn't...
2013/06/24
[ "https://Stackoverflow.com/questions/17273393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1325846/" ]
Since requests.session() returns an instance of the Session class, it is also possible to use patch.object() ``` from requests import Session from unittest.mock import patch @patch.object(Session, 'get') def test_foo(mock_get): mock_get.return_value = 'bar' ```
I discovered [the requests\_mock library](https://pypi.org/project/requests-mock/). It saved me a lot of bother. With pytest... ``` def test_success(self, requests_mock): """They give us a token. """ requests_mock.get("https://example.com/api/v1/login", text=( '{"result":1001, "errMsg":n...