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
53,327,240
I have been trying to find a way to get python to ready my `csv`. Take the values that are in the date columns (`3months | 6months | 12months`) and plot it onto a graph however I have been struggling to find resources and have no previous experience with python. If anyone could point me in the right direction it woul...
2018/11/15
[ "https://Stackoverflow.com/questions/53327240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10471828/" ]
The pattern `(?!\S)` uses a negative lookahead to check what follows is not a non whitespace character. What you could so is replace the `(?!\S)` with a word boundary `\b` to let it not be part of a larger match: `(?i)(?<!\S)lending\s?qb\b` [Regex demo](https://regex101.com/r/nyHoT5/1) Another way could be to use a...
This `(?!\S)` is a forward whitespace boundary. It is really this `(?![^\s])` a negative of a negative with the added benefit of it matching at the EOS (end of string). What that means is you can use the negative class form to add characters that qualify as a boundary. So, just put the period and comma in w...
53,327,240
I have been trying to find a way to get python to ready my `csv`. Take the values that are in the date columns (`3months | 6months | 12months`) and plot it onto a graph however I have been struggling to find resources and have no previous experience with python. If anyone could point me in the right direction it woul...
2018/11/15
[ "https://Stackoverflow.com/questions/53327240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10471828/" ]
The pattern `(?!\S)` uses a negative lookahead to check what follows is not a non whitespace character. What you could so is replace the `(?!\S)` with a word boundary `\b` to let it not be part of a larger match: `(?i)(?<!\S)lending\s?qb\b` [Regex demo](https://regex101.com/r/nyHoT5/1) Another way could be to use a...
You have correctly identified one issue in the regex (punctuation immediately after QB), but there is a second edge case to consider given that the input is messy -- what if there are multiple spaces in `Lending QB`?. I believe the most robust solution to your problem is: ``` (?i)(?<!\S)lending\s*qb\b ``` * `\b` en...
53,327,240
I have been trying to find a way to get python to ready my `csv`. Take the values that are in the date columns (`3months | 6months | 12months`) and plot it onto a graph however I have been struggling to find resources and have no previous experience with python. If anyone could point me in the right direction it woul...
2018/11/15
[ "https://Stackoverflow.com/questions/53327240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10471828/" ]
The pattern `(?!\S)` uses a negative lookahead to check what follows is not a non whitespace character. What you could so is replace the `(?!\S)` with a word boundary `\b` to let it not be part of a larger match: `(?i)(?<!\S)lending\s?qb\b` [Regex demo](https://regex101.com/r/nyHoT5/1) Another way could be to use a...
Thank you "The fourth bird", "sln", and "Mark\_Anderson". Your answers provided solutions and also were very educational. I went with Mark's answer since it seemed to be the most robust, which is where I'm trying to get to. Ideally, I do want to capture all cases when the product name is mentioned, no matter how messy ...
53,327,240
I have been trying to find a way to get python to ready my `csv`. Take the values that are in the date columns (`3months | 6months | 12months`) and plot it onto a graph however I have been struggling to find resources and have no previous experience with python. If anyone could point me in the right direction it woul...
2018/11/15
[ "https://Stackoverflow.com/questions/53327240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10471828/" ]
You have correctly identified one issue in the regex (punctuation immediately after QB), but there is a second edge case to consider given that the input is messy -- what if there are multiple spaces in `Lending QB`?. I believe the most robust solution to your problem is: ``` (?i)(?<!\S)lending\s*qb\b ``` * `\b` en...
This `(?!\S)` is a forward whitespace boundary. It is really this `(?![^\s])` a negative of a negative with the added benefit of it matching at the EOS (end of string). What that means is you can use the negative class form to add characters that qualify as a boundary. So, just put the period and comma in w...
53,327,240
I have been trying to find a way to get python to ready my `csv`. Take the values that are in the date columns (`3months | 6months | 12months`) and plot it onto a graph however I have been struggling to find resources and have no previous experience with python. If anyone could point me in the right direction it woul...
2018/11/15
[ "https://Stackoverflow.com/questions/53327240", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10471828/" ]
You have correctly identified one issue in the regex (punctuation immediately after QB), but there is a second edge case to consider given that the input is messy -- what if there are multiple spaces in `Lending QB`?. I believe the most robust solution to your problem is: ``` (?i)(?<!\S)lending\s*qb\b ``` * `\b` en...
Thank you "The fourth bird", "sln", and "Mark\_Anderson". Your answers provided solutions and also were very educational. I went with Mark's answer since it seemed to be the most robust, which is where I'm trying to get to. Ideally, I do want to capture all cases when the product name is mentioned, no matter how messy ...
42,358,433
I have a simple Python test code as under: **tmp.py** ``` import time while True: print "New val" time.sleep(1) ``` If I run it as below, I see the logs on terminal normally: ``` python tmp.py ``` But if I redirect the logs to a log file, it takes quite a while before the logs appear in the file: ``` ...
2017/02/21
[ "https://Stackoverflow.com/questions/42358433", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2091948/" ]
The best option for your case is to set the environment variable `PYTHONUNBUFFERED`. This is a little more robust than calling `#/usr/bin/python -u`, as this may not work in some virtual envs. In your terminal: ``` export PYTHONUNBUFFERED=1 python tmp.py >/tmp/logs.log 2>&1 #or however else you want to call your sc...
The issue is that the output is buffered, that means python saves the output in a buffer and flushes it every now and then, but not necessarily after each print. You could fix by forcing a flush after each print by explicitly calling `sys.stdout.flush()`. ``` import time import sys while True: print "New val" ...
65,700,886
My experience in python is close to 0, bear with me. I want to install <https://pypi.org/project/locuplot/> on an EC2 machine to create some plots after running Locust in headless mode. However, I do not manage to install it: ``` yum update -y yum install python3 -y yum install python3-devel -y yum install python3-p...
2021/01/13
[ "https://Stackoverflow.com/questions/65700886", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11868615/" ]
You have ``` pip install locuplot ``` in your last line, but `locuplot` does only work with python3 and, depending on your setup, `pip` might default to the python2 installation, so you should do ``` pip3 install locuplot ``` instead
Thanks to FlyingTeller found the issue. The reason is that it requires python>=3.8 ``` amazon-linux-extras install python3 python3.8 -m pip install locuplot pip install locuplot ```
29,166,538
From what I read about variable scopes and importing resource files in [robotframework doc](http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#id487) i would expect this to work (python 2.7, RF 2.8.7): Test file: ``` *** Settings *** Resource VarRes.txt Suite Setup Precondit...
2015/03/20
[ "https://Stackoverflow.com/questions/29166538", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4629534/" ]
The following works for me: JavaScript: ``` // Traian Băsescu encodes to VHJhaWFuIELEg3Nlc2N1 var base64 = btoa(unescape(encodeURIComponent( $("#Contact_description").val() ))); ``` PHP: ``` $utf8 = base64_decode($base64); ```
The problem is that Javascript strings are encoded in UTF-16, and browsers do not offer very many good tools to deal with encodings. A great resource specifically for dealing with Base64 encodings and Unicode can be found at MDN: <https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/Base64_encoding_and_decodin...
26,013,487
I need to change the path of the python's core dump file, or completely disable it. I'm aware that it's possible to change the pattern and location of the core dumps in linux using: ``` /proc/sys/kernel/core_pattern ``` But this is not a suitable solution on a shared server and/or on a grid engine. So, how can I c...
2014/09/24
[ "https://Stackoverflow.com/questions/26013487", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2536294/" ]
You can use shell command `ulimit` to control it: ``` ulimit -c 0 # Disable core file creation ``` Without the value, it will print current limit (the maximum size of core file will be created): ``` ulimit -c ```
I think, this page gives you what you are looking for: <http://sigquit.wordpress.com/2009/03/13/the-core-pattern/> Quoting from the page: > > "...the kernel configuration includes a file named “core\_pattern”: > > > > ``` /proc/sys/kernel/core_pattern ``` > > In my system, that file contains just this sin...
56,863,556
I want to convert Binary Tree into Array using Python and i don't know how to give index to tree-node? I have done this using the formula left\_son=(2\*p)+1; and right\_son=(2\*p)+2; in java But i'm stuck in python. Is there any Function to give index to tree-node in python ?
2019/07/03
[ "https://Stackoverflow.com/questions/56863556", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8627333/" ]
You can represent a binary tree in python as a one-dimensional list the exact same way. For example if you have at tree represented as: ``` [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15] ``` `0` is the root `1` & `2` are the next level the children of `1` & `2` are `[3, 4]` and `[5, 6]` This corresponds...
Incase of a binary tree, you'll have to perform a level order traversal. And as you keep traversing, you'll have to store the values in the array in the order they appear during the traversal. This will help you in restoring the properties of a binary tree and will also maintain the order of elements. Here is the code ...
45,804,534
I'm trying to load Parquet data into `PySpark`, where a column has a space in the name: ``` df = spark.read.parquet('my_parquet_dump') df.select(df['Foo Bar'].alias('foobar')) ``` Even though I have aliased the column, I'm still getting this error and error propagating from the `JVM` side of `PySpark`. I've attached...
2017/08/21
[ "https://Stackoverflow.com/questions/45804534", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1922392/" ]
Have you tried, ```py df = df.withColumnRenamed("Foo Bar", "foobar") ``` When you select the column with an alias you're still passing the wrong column name through a select clause.
I tried @ktang 's method and it worked for me as well. I'm working with SQL and Python, so it may be different for you, but it worked nonetheless. Ensure there are no spaces in your column names/headers. Despite the list of characters provided in the error message, space ( ) doesn't seem to be acceptable by Pyspark. ...
20,862,510
How do you determine if an incoming url Request to an Openshift app is 'http' or 'https'? I wrote an Openshift python 3.3 app back in June '13. I was able to tell if the incoming url to my Openshift app was 'http' or 'https' by the following code: ``` if request['HTTP_X_FORWARDED_PROTO'] == 'https': #do something ...
2013/12/31
[ "https://Stackoverflow.com/questions/20862510", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1924325/" ]
This is a bug and will be fixed. EDIT: Opened <https://bugzilla.redhat.com/show_bug.cgi?id=1048331> to track
In the meantime I found that this works. if request.environ['HTTP\_X\_FORWARDED\_PROTO'] == 'http': # or https
32,111,279
I want to read a pdf file in python. Tried some of the ways- PdfReader and pdfquery but not getting the result in string format. Want to have some of the content from that pdf file. is there any way to do that?
2015/08/20
[ "https://Stackoverflow.com/questions/32111279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4075219/" ]
[PDFminer](http://www.unixuser.org/%7Eeuske/python/pdfminer/index.html) is a tool for extracting information from PDF documents.
Does it matter in your case if file is pdf or not. If you just want to read your file as string, just open it as you would open a normal file. E.g.- ``` with open('my_file.pdf') as file: content = file.read() ```
56,914,592
I have a lot of PNG images that I want to classify, using a trained CNN model. To speed up the process, I would like to use multiple-processing with CPUs (I have 72 available, here I'm just using 4). I don't have a GPU available at the moment, but if necessary, I could get one. **My workflow:** 1. read a figure with...
2019/07/06
[ "https://Stackoverflow.com/questions/56914592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11124934/" ]
Does a processing-speed or a size-of-RAMor a number-of-CPU-coresor an introduced add-on processing latency matter most?[ALL OF THESE DO:](https://stackoverflow.com/revisions/18374629/3) --------------------------------------------------------------------------------------------------------------------------------------...
One python package I know that may help you is `joblib`. Hope it can solve your problem. ``` from joblib import Parallel, delayed ``` ``` # load model mymodel = load_model('190704_1_fcs_plotclassifier.h5') # Define callback function to collect the output in 'outcomes' outcomes = [] def collect_result(result): ...
56,914,592
I have a lot of PNG images that I want to classify, using a trained CNN model. To speed up the process, I would like to use multiple-processing with CPUs (I have 72 available, here I'm just using 4). I don't have a GPU available at the moment, but if necessary, I could get one. **My workflow:** 1. read a figure with...
2019/07/06
[ "https://Stackoverflow.com/questions/56914592", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11124934/" ]
Does a processing-speed or a size-of-RAMor a number-of-CPU-coresor an introduced add-on processing latency matter most?[ALL OF THESE DO:](https://stackoverflow.com/revisions/18374629/3) --------------------------------------------------------------------------------------------------------------------------------------...
img\_height = 512 # Height of the input images img\_width =512 # Width of the input images img\_channels = 3 # Number of color channels of the input images orig\_images = [] # Store the images here. batch\_holder = np.zeros((20, img\_height, img\_width, 3)) img\_dir = "path/to/image/" for i,img, in enumerate(os.l...
12,167,192
I want to create a dict which can be accessed as: ``` d[id_1][id_2][id_3] = amount ``` As of now I have a huge ugly function: ``` def parse_dict(id1,id2,id3,principal, data_dict): if data_dict.has_key(id1): values = data_dict[id1] if values.has_key[id2] .. else: ...
2012/08/28
[ "https://Stackoverflow.com/questions/12167192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902885/" ]
You may want to consider using [`defaultdict`](http://docs.python.org/library/collections.html): For example: ``` json_dict = defaultdict(lambda: defaultdict(dict)) ``` will create a `defaultdict` of `defaultdict`s of `dict`s (I know..but it is right), to access it, you can simply do: ``` json_dict['context']['nam...
Maybe you need to have a look at multi-dimensional arrays - for example in numpy: <http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html>
12,167,192
I want to create a dict which can be accessed as: ``` d[id_1][id_2][id_3] = amount ``` As of now I have a huge ugly function: ``` def parse_dict(id1,id2,id3,principal, data_dict): if data_dict.has_key(id1): values = data_dict[id1] if values.has_key[id2] .. else: ...
2012/08/28
[ "https://Stackoverflow.com/questions/12167192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902885/" ]
You may want to consider using [`defaultdict`](http://docs.python.org/library/collections.html): For example: ``` json_dict = defaultdict(lambda: defaultdict(dict)) ``` will create a `defaultdict` of `defaultdict`s of `dict`s (I know..but it is right), to access it, you can simply do: ``` json_dict['context']['nam...
``` from collections import defaultdict d = defaultdict(lambda : defaultdict(dict)) d[id_1][id_2][id_3] = amount ```
12,167,192
I want to create a dict which can be accessed as: ``` d[id_1][id_2][id_3] = amount ``` As of now I have a huge ugly function: ``` def parse_dict(id1,id2,id3,principal, data_dict): if data_dict.has_key(id1): values = data_dict[id1] if values.has_key[id2] .. else: ...
2012/08/28
[ "https://Stackoverflow.com/questions/12167192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902885/" ]
You may want to consider using [`defaultdict`](http://docs.python.org/library/collections.html): For example: ``` json_dict = defaultdict(lambda: defaultdict(dict)) ``` will create a `defaultdict` of `defaultdict`s of `dict`s (I know..but it is right), to access it, you can simply do: ``` json_dict['context']['nam...
You can make a simple dictionary that creates new ones (using [Autovivification](http://en.wikipedia.org/wiki/Autovivification)): ``` >>> class AutoDict(dict): def __missing__(self, key): x = AutoDict() self[key] = x return x >>> d = AutoDict() >>> d[1][2][3] = 4 >>> d {1: {2: {3: 4}}} ``...
12,167,192
I want to create a dict which can be accessed as: ``` d[id_1][id_2][id_3] = amount ``` As of now I have a huge ugly function: ``` def parse_dict(id1,id2,id3,principal, data_dict): if data_dict.has_key(id1): values = data_dict[id1] if values.has_key[id2] .. else: ...
2012/08/28
[ "https://Stackoverflow.com/questions/12167192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902885/" ]
You may want to consider using [`defaultdict`](http://docs.python.org/library/collections.html): For example: ``` json_dict = defaultdict(lambda: defaultdict(dict)) ``` will create a `defaultdict` of `defaultdict`s of `dict`s (I know..but it is right), to access it, you can simply do: ``` json_dict['context']['nam...
``` >>> from collections import defaultdict >>> import json >>> def tree(): return defaultdict(tree) >>> t = tree() >>> t['a']['b']['c'] = 'foo' >>> t['a']['b']['d'] = 'bar' >>> json.dumps(t) '{"a": {"b": {"c": "foo", "d": "bar"}}}' ```
12,167,192
I want to create a dict which can be accessed as: ``` d[id_1][id_2][id_3] = amount ``` As of now I have a huge ugly function: ``` def parse_dict(id1,id2,id3,principal, data_dict): if data_dict.has_key(id1): values = data_dict[id1] if values.has_key[id2] .. else: ...
2012/08/28
[ "https://Stackoverflow.com/questions/12167192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902885/" ]
``` from collections import defaultdict d = defaultdict(lambda : defaultdict(dict)) d[id_1][id_2][id_3] = amount ```
Maybe you need to have a look at multi-dimensional arrays - for example in numpy: <http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html>
12,167,192
I want to create a dict which can be accessed as: ``` d[id_1][id_2][id_3] = amount ``` As of now I have a huge ugly function: ``` def parse_dict(id1,id2,id3,principal, data_dict): if data_dict.has_key(id1): values = data_dict[id1] if values.has_key[id2] .. else: ...
2012/08/28
[ "https://Stackoverflow.com/questions/12167192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902885/" ]
You can make a simple dictionary that creates new ones (using [Autovivification](http://en.wikipedia.org/wiki/Autovivification)): ``` >>> class AutoDict(dict): def __missing__(self, key): x = AutoDict() self[key] = x return x >>> d = AutoDict() >>> d[1][2][3] = 4 >>> d {1: {2: {3: 4}}} ``...
Maybe you need to have a look at multi-dimensional arrays - for example in numpy: <http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html>
12,167,192
I want to create a dict which can be accessed as: ``` d[id_1][id_2][id_3] = amount ``` As of now I have a huge ugly function: ``` def parse_dict(id1,id2,id3,principal, data_dict): if data_dict.has_key(id1): values = data_dict[id1] if values.has_key[id2] .. else: ...
2012/08/28
[ "https://Stackoverflow.com/questions/12167192", "https://Stackoverflow.com", "https://Stackoverflow.com/users/902885/" ]
``` >>> from collections import defaultdict >>> import json >>> def tree(): return defaultdict(tree) >>> t = tree() >>> t['a']['b']['c'] = 'foo' >>> t['a']['b']['d'] = 'bar' >>> json.dumps(t) '{"a": {"b": {"c": "foo", "d": "bar"}}}' ```
Maybe you need to have a look at multi-dimensional arrays - for example in numpy: <http://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html>
50,552,153
I have used the following code to find the last digit of sum of fibonacci numbers ``` #using python3 def fibonacci_sum(n): if n < 2: print(n) else: a, b = 0, 1 sum=1 for i in range(1,n): a, b = b, (a+b) sum=sum+b lastdigit=(sum)%10 print(lastdigit) n = ...
2018/05/27
[ "https://Stackoverflow.com/questions/50552153", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5405806/" ]
Keeping track of the last digit only ==================================== Note that whenever you add integers, the last digit of the sum depends only on the last digits of the addents. This means we only have to keep the last digit on every iteration. The same applies to the sum, at all time we only need to keep its l...
You're asking for code that returns the last digit of the sum of the first n Fibonacci numbers. First thing to note is that fib(1) + fib(2) + ... + fib(n) = fib(n+2)-1. That's easily proved: Let S(n) be the sum of the first n Fibonacci numbers. Then S(1) = 1, S(2) = 2, and S(n) - S(n-1) = fib(n). The result follows b...
63,559,190
I am trying to loop through the files in a folder with python. I have found different ways to do that such as using os package or glob. But for some reason, they don't maintain the order the files appear in the folder. For example, my folder has `img_10`, `img_20`, `img_30`... But when i loop through them, my code read...
2020/08/24
[ "https://Stackoverflow.com/questions/63559190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11446390/" ]
You need to pass the data in an `array`(`->with()` method) or you can use `compact` method too. ```php return view('admin.faq.index', compact('faqs')); ``` Or ```php return view('admin.faq.index')->with(array('faqs'=>$faqs)); ```
try to use the `compact` method as below: ``` public function index(Request $request) { $faqs = Faq::all(); return view('admin.faq.index',compact('faqs')); } ```
63,559,190
I am trying to loop through the files in a folder with python. I have found different ways to do that such as using os package or glob. But for some reason, they don't maintain the order the files appear in the folder. For example, my folder has `img_10`, `img_20`, `img_30`... But when i loop through them, my code read...
2020/08/24
[ "https://Stackoverflow.com/questions/63559190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11446390/" ]
try to use the `compact` method as below: ``` public function index(Request $request) { $faqs = Faq::all(); return view('admin.faq.index',compact('faqs')); } ```
Looks like $faqs is empty. You can check that with @isset(). <https://laravel.com/docs/7.x/blade#if-statements>
63,559,190
I am trying to loop through the files in a folder with python. I have found different ways to do that such as using os package or glob. But for some reason, they don't maintain the order the files appear in the folder. For example, my folder has `img_10`, `img_20`, `img_30`... But when i loop through them, my code read...
2020/08/24
[ "https://Stackoverflow.com/questions/63559190", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11446390/" ]
You need to pass the data in an `array`(`->with()` method) or you can use `compact` method too. ```php return view('admin.faq.index', compact('faqs')); ``` Or ```php return view('admin.faq.index')->with(array('faqs'=>$faqs)); ```
Looks like $faqs is empty. You can check that with @isset(). <https://laravel.com/docs/7.x/blade#if-statements>
36,177,019
Okays so I'm new to python and I just really need some help with this. This is my code so far. I keep getting a syntax error and I have no idea what im doing wrong ``` count = int(input("What number do you want the timer to start: ")) count == ">" -1: print("count") print("") count = count - 1 time.sleep(1) ```
2016/03/23
[ "https://Stackoverflow.com/questions/36177019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5970976/" ]
You need to ensure you import the time library before you can access the time.sleep method. Also it may be more effective to a for use a loop to repeat code. The structure of your if statement is also incorrect and is not a correct expression. ``` IF <Expression> is TRUE: DO THIS. ``` Also consider using a ran...
In the 2nd line, you can't deduct 1 from ">" which is a string. What you need here is apparently a for loop. EDIT: You forgot the import too! ``` import time count = int(input("What number do you want the timer to start: ")) for i in range(count): print("count") print(i) count = count - 1 time.sleep(1)...
36,177,019
Okays so I'm new to python and I just really need some help with this. This is my code so far. I keep getting a syntax error and I have no idea what im doing wrong ``` count = int(input("What number do you want the timer to start: ")) count == ">" -1: print("count") print("") count = count - 1 time.sleep(1) ```
2016/03/23
[ "https://Stackoverflow.com/questions/36177019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5970976/" ]
You need to ensure you import the time library before you can access the time.sleep method. Also it may be more effective to a for use a loop to repeat code. The structure of your if statement is also incorrect and is not a correct expression. ``` IF <Expression> is TRUE: DO THIS. ``` Also consider using a ran...
The syntax error presumably comes from the line that reads ``` count == ">" -1: ``` I'm not sure where you got that from! What you need is a *loop* that stops when the counter runs out, and otherwise repeats the same code. ``` count = int(input("What number do you want the timer to start: ")) while count > 0: p...
36,177,019
Okays so I'm new to python and I just really need some help with this. This is my code so far. I keep getting a syntax error and I have no idea what im doing wrong ``` count = int(input("What number do you want the timer to start: ")) count == ">" -1: print("count") print("") count = count - 1 time.sleep(1) ```
2016/03/23
[ "https://Stackoverflow.com/questions/36177019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5970976/" ]
You need to ensure you import the time library before you can access the time.sleep method. Also it may be more effective to a for use a loop to repeat code. The structure of your if statement is also incorrect and is not a correct expression. ``` IF <Expression> is TRUE: DO THIS. ``` Also consider using a ran...
First, you must `import time` in order to use the `time.sleep()` function Next, I'm not too sure what you mean by: > > `count == ">" -1:` > > > If you're creating a "stopwatch", then it would be logical to use some sort of a loop: ``` while count > 0: print(count,"seconds left") count -= 1 time.slee...
36,177,019
Okays so I'm new to python and I just really need some help with this. This is my code so far. I keep getting a syntax error and I have no idea what im doing wrong ``` count = int(input("What number do you want the timer to start: ")) count == ">" -1: print("count") print("") count = count - 1 time.sleep(1) ```
2016/03/23
[ "https://Stackoverflow.com/questions/36177019", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5970976/" ]
You need to ensure you import the time library before you can access the time.sleep method. Also it may be more effective to a for use a loop to repeat code. The structure of your if statement is also incorrect and is not a correct expression. ``` IF <Expression> is TRUE: DO THIS. ``` Also consider using a ran...
There is a syntax error in your second line. I am not sure what you are trying to achieve there. Probably you want to check if count>-1. do this: ``` import time count = int(input("What number do you want the timer to start: ")) if count>0: while(count): print(count) time.sleep(1) count = count -1 ```
52,008,168
I have this python code that should make a video: ``` import cv2 import numpy as np out = cv2.VideoWriter("/tmp/test.mp4", cv2.VideoWriter_fourcc(*'MP4V'), 25, (500, 500), True) data = np.zeros((500,500,3)) for i in xrange(500): ...
2018/08/24
[ "https://Stackoverflow.com/questions/52008168", "https://Stackoverflow.com", "https://Stackoverflow.com/users/325809/" ]
So it looks like you did a DBinspect on an existing database to generate this model. I'm guessing this is failing because Django ORM expects your table to have a primary key. "id" is the default name for a Django generated model primary key field. I suspect when you are trying to call `Characterweapons.objects.all()` i...
The best solution that I found, in this case, was to perform my own query, for example: ``` fact = MyModelWithoutPK.objects.raw("SELECT * FROM my_model_without_pk WHERE my_search=some_search") ``` This way you don't have to implement or add another middleware. see more at [Django docs](https://docs.djangoproject.com...
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
You just don't have `swig` installed. **Try:** ``` sudo yum install swig ``` **And then:** ``` sudo easy_install M2crypto ```
``` sudo yum install m2crypto ``` worked for me to get around this problem.
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
You just don't have `swig` installed. **Try:** ``` sudo yum install swig ``` **And then:** ``` sudo easy_install M2crypto ```
It seems like not having swig is the problem, as @LeoC said. For those on MacOS, I'd recommend downloading swig via a package manager like homebrew because it's cleaner. I.e. you'd run ```html brew install swig ```
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
There's a repository where "pip install" works: <https://github.com/martinpaljak/M2Crypto>
It seems like not having swig is the problem, as @LeoC said. For those on MacOS, I'd recommend downloading swig via a package manager like homebrew because it's cleaner. I.e. you'd run ```html brew install swig ```
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
I had a similar issue where `/usr/include/openssl` was missing `opensslconf.h` (source <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733644#10>) ```bash sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl ```
I found a new way to fix this problem in centos5.8, try it. `vim setup.py` ``` def finalize_options(self): ... self.swig_opts.append('-includeall') # after this line self.swig_opts.append('-I/usr/include/openssl') # add here ``` then `python setup.py install` will work.
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
You just don't have `swig` installed. **Try:** ``` sudo yum install swig ``` **And then:** ``` sudo easy_install M2crypto ```
I had a similar issue where `/usr/include/openssl` was missing `opensslconf.h` (source <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733644#10>) ```bash sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl ```
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
M2Crypto supplies a fedora\_setup.sh script to handle the problems with Fedora/RL/CentOs releases, but pip, of course, doesn't know anything about it. After the pip install fails, it leaves the downloaded stuff in the venv/build/M2Crypto directory. do this: ``` cd <path-to-your-venv>/venv/build/M2Crypto chmod u+x fed...
I had a similar issue where `/usr/include/openssl` was missing `opensslconf.h` (source <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733644#10>) ```bash sudo ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl ```
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
I did this and it works very well : ``` env SWIG_FEATURES="-cpperraswarn -includeall -I/usr/include/openssl" pip install M2Crypto ``` Of course you have to install swigg with `sudo yum install swig` before
``` sudo yum install m2crypto ``` worked for me to get around this problem.
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
M2Crypto supplies a fedora\_setup.sh script to handle the problems with Fedora/RL/CentOs releases, but pip, of course, doesn't know anything about it. After the pip install fails, it leaves the downloaded stuff in the venv/build/M2Crypto directory. do this: ``` cd <path-to-your-venv>/venv/build/M2Crypto chmod u+x fed...
It seems like not having swig is the problem, as @LeoC said. For those on MacOS, I'd recommend downloading swig via a package manager like homebrew because it's cleaner. I.e. you'd run ```html brew install swig ```
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
I did this and it works very well : ``` env SWIG_FEATURES="-cpperraswarn -includeall -I/usr/include/openssl" pip install M2Crypto ``` Of course you have to install swigg with `sudo yum install swig` before
It seems like not having swig is the problem, as @LeoC said. For those on MacOS, I'd recommend downloading swig via a package manager like homebrew because it's cleaner. I.e. you'd run ```html brew install swig ```
7,772,965
I'm trying to install the Python M2Crypto package into a virtualenv on an x86\_64 RHEL 6.1 machine. This process invokes swig, which fails with the following error: ``` $ virtualenv -q --no-site-packages venv $ pip install -E venv M2Crypto==0.20.2 Downloading/unpacking M2Crypto==0.20.2 Downloading M2Crypto-0.20.2.t...
2011/10/14
[ "https://Stackoverflow.com/questions/7772965", "https://Stackoverflow.com", "https://Stackoverflow.com/users/742/" ]
If you are seeing this and are on Ubuntu, use apt-get instead of pip to avoid this issue. `apt-get install python-m2crypto`
On FreeBSD I had to install Swig (the obvious part) as well (by `sudo pkg install swig`), but Swig 2.0 executable was named `swig2.0` and handle `swig` resulted in `command not found`. Solution: symlink Swig 2.0 to handle `swig`: ``` ln -s /usr/local/bin/swig2.0 /usr/local/bin/swig ```
52,733,094
I am using Ubuntu 16.04 lts. My default python binary is python2.7. When I am trying to install ipykernel for hydrogen in atom editor, with the following command ``` python -m pip install ipykernel ``` It is giving the following errors ``` ERROR: ipykernel requires Python version 3.4 or above. ``` I am trying to ...
2018/10/10
[ "https://Stackoverflow.com/questions/52733094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8881054/" ]
Starting with version 5.0 of the [kernel](https://ipykernel.readthedocs.io/en/latest/changelog.html#id3), and version 6.0 of [IPython](https://ipython.readthedocs.io/en/stable/whatsnew/version6.html#ipython-6-0), compatibility with Python 2 was dropped. As far as I know, the only solution is to install an earlier relea...
Try using `Anaconda` You can learn how to install Anaconda from [here](https://conda.io/docs/user-guide/install/linux.html) After that, try creating a virtual environment via: ``` conda create -n yourenvname python=2.7 anaconda ``` And activate it via: ``` source activate yourenvname ``` After that, try insta...
56,789,173
I have a simple class in which I want to generate methods based on inherited class fields: ``` class Parent: def __init__(self, *args, **kwargs): self.fields = getattr(self, 'TOGGLEABLE') self.generate_methods() def _toggle(self, instance): print(self, instance) # Prints correctly ...
2019/06/27
[ "https://Stackoverflow.com/questions/56789173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5729960/" ]
maybe this is too hackish, and maybe there's a more elegant (i.e. dedicated) way to achieve this, but: you can create a wrapper function that passes the func\_name to the inner `_toggle` func: ```py class Parent: def __init__(self, *args, **kwargs): self.fields = getattr(self, 'TOGGLEABLE') self.g...
Another approach to solve the same problem would be to use `__getattr__` in the following way: ``` class Parent: def _toggle(self, instance, func_name): print(self, instance) # Prints correctly print(func_name) def __getattr__(self, attr): if not attr.startswith("toggle_"): ...
39,400,319
My opinion of the Azure-Python SDK is not high for Azure RM. What takes 1 line in PowerShell takes 10 in Python. That is the opposite of what python is supposed to do. So, my idea is to create python package which comes with a directory containing a few template .ps1 scripts. You would define a few variables like vmna...
2016/09/08
[ "https://Stackoverflow.com/questions/39400319", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6293857/" ]
@RobTruxal, the new CLI for Azure will be in Python and will be released as a preview soon. You can already try it from the github account: <https://github.com/Azure/azure-cli> The Azure SDK for Python is not supposed to mimic the Powershell cmdlets, but to be a language SDK (like C#, Java, Ruby, etc.). If you have a...
@RobTruxal, It seems that a feasible way to call PowerShell in Python is using the module `subprocess`, such as the code below as reference. ``` import subprocess subprocess.call(["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", "your-script.ps1", "arguments"]) ``` You need to write your powershell ...
62,295,329
I'm trying to play an mp3 file using python VLC but it seems like nothing is happening and there is no error message. Below is the code: ``` import vlc p = vlc.MediaPlayer(r"C:\Users\user\Desktop\python\projects\etc\lady_maria.mp3") p.play() ``` I tried below code as I've read from another post: ``` import vlc mp3 ...
2020/06/10
[ "https://Stackoverflow.com/questions/62295329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11639529/" ]
If audio files are playing fine on the system:- for pygame library adjust volume using: ``` mixer.music.set_volume(1.0) # float value from 0.0 to 1.0 for volume setting ```
I can't work out what the actual issue is given the code in the OP. Please try this test code. ``` import pygame WINDOW_WIDTH = 200 WINDOW_HEIGHT = 200 ### initialisation pygame.init() pygame.font.init() pygame.mixer.init() window = pygame.display.set_mode( ( WINDOW_WIDTH, WINDOW_HEIGHT ) ) # Rain sound from: http...
62,295,329
I'm trying to play an mp3 file using python VLC but it seems like nothing is happening and there is no error message. Below is the code: ``` import vlc p = vlc.MediaPlayer(r"C:\Users\user\Desktop\python\projects\etc\lady_maria.mp3") p.play() ``` I tried below code as I've read from another post: ``` import vlc mp3 ...
2020/06/10
[ "https://Stackoverflow.com/questions/62295329", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11639529/" ]
So the problem was solved as: ``` from pygame import mixer mixer.init() mixer.music.load(r'C:\Users\user\Desktop\python\projects\etc\lady_maria.mp3') mixer.music.play() time.sleep(5) ``` adding `time.sleep(5)` fixed the problem! [Pygame, sounds don't play](https://stackoverflow.com/questions/2936914/pygame-sounds-...
I can't work out what the actual issue is given the code in the OP. Please try this test code. ``` import pygame WINDOW_WIDTH = 200 WINDOW_HEIGHT = 200 ### initialisation pygame.init() pygame.font.init() pygame.mixer.init() window = pygame.display.set_mode( ( WINDOW_WIDTH, WINDOW_HEIGHT ) ) # Rain sound from: http...
67,109,676
example1.py: ``` from tkinter import * root = Tk() filename = 'james' Lbl = Label(root,text="ciao") Lbl.pack() root.mainloop() ``` example2.py: ``` from example1 import filename print(filename) ``` Why python open tkinter window if I run only example2.py? It is necessary for me that filename is in the example1...
2021/04/15
[ "https://Stackoverflow.com/questions/67109676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9811405/" ]
**This is because the standard rules of Python** yup! Python automatically excecutes the Python file which you imported.In Your Case its example1 file. **To prevent This Use this instance:** ``` if __name__ == '__main__': root.mainloop() ``` in your file [see](https://www.geeksforgeeks.org/what-does-the-...
First, I don't know how to solve your problem. but I know what you want to know. I understand you have two python file ('example 1' and 'example 2'). And you want to import 'filename' from 'example 1'. But Tkinter is worked and you want to know why. right? The import function is not pick-up tool. \*\*\* That's mean ...
5,249,353
I'm learning python. I have a list of simple entries and I want to convert it in a dictionary where the first element of list is the key of the second element, the third is the key of the fourth, and so on. How can I do it? ``` list = ['first_key', 'first_value', 'second_key', 'second_value'] ``` Thanks in advance!
2011/03/09
[ "https://Stackoverflow.com/questions/5249353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619378/" ]
``` myDict = dict(zip(myList[::2], myList[1::2])) ``` Please do not use 'list' as a variable name, as it prevents you from accessing the list() function. If there is much data involved, we can do it more efficiently using iterator functions: ``` from itertools import izip, islice myList = ['first_key', 'first_value...
The most concise way is ``` some_list = ['first_key', 'first_value', 'second_key', 'second_value'] d = dict(zip(*[iter(some_list)] * 2)) ```
5,249,353
I'm learning python. I have a list of simple entries and I want to convert it in a dictionary where the first element of list is the key of the second element, the third is the key of the fourth, and so on. How can I do it? ``` list = ['first_key', 'first_value', 'second_key', 'second_value'] ``` Thanks in advance!
2011/03/09
[ "https://Stackoverflow.com/questions/5249353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619378/" ]
The most concise way is ``` some_list = ['first_key', 'first_value', 'second_key', 'second_value'] d = dict(zip(*[iter(some_list)] * 2)) ```
If the list is large, you end up wasting memory by building slices or eager zips. One way to convert the list more lazily is to (ab)use the list iterator and `izip`. ``` from itertools import izip lst = ['first_key', 'first_value', 'second_key', 'second_value'] i = iter(lst) d = dict(izip(i,i)) ```
5,249,353
I'm learning python. I have a list of simple entries and I want to convert it in a dictionary where the first element of list is the key of the second element, the third is the key of the fourth, and so on. How can I do it? ``` list = ['first_key', 'first_value', 'second_key', 'second_value'] ``` Thanks in advance!
2011/03/09
[ "https://Stackoverflow.com/questions/5249353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619378/" ]
The most concise way is ``` some_list = ['first_key', 'first_value', 'second_key', 'second_value'] d = dict(zip(*[iter(some_list)] * 2)) ```
The KISS way: Use exception and iterators ``` myDict = {} it = iter(list) for x in list: try: myDict[it.next()] = it.next() except: pass myDict ```
5,249,353
I'm learning python. I have a list of simple entries and I want to convert it in a dictionary where the first element of list is the key of the second element, the third is the key of the fourth, and so on. How can I do it? ``` list = ['first_key', 'first_value', 'second_key', 'second_value'] ``` Thanks in advance!
2011/03/09
[ "https://Stackoverflow.com/questions/5249353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619378/" ]
``` myDict = dict(zip(myList[::2], myList[1::2])) ``` Please do not use 'list' as a variable name, as it prevents you from accessing the list() function. If there is much data involved, we can do it more efficiently using iterator functions: ``` from itertools import izip, islice myList = ['first_key', 'first_value...
If the list is large, you end up wasting memory by building slices or eager zips. One way to convert the list more lazily is to (ab)use the list iterator and `izip`. ``` from itertools import izip lst = ['first_key', 'first_value', 'second_key', 'second_value'] i = iter(lst) d = dict(izip(i,i)) ```
5,249,353
I'm learning python. I have a list of simple entries and I want to convert it in a dictionary where the first element of list is the key of the second element, the third is the key of the fourth, and so on. How can I do it? ``` list = ['first_key', 'first_value', 'second_key', 'second_value'] ``` Thanks in advance!
2011/03/09
[ "https://Stackoverflow.com/questions/5249353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619378/" ]
``` myDict = dict(zip(myList[::2], myList[1::2])) ``` Please do not use 'list' as a variable name, as it prevents you from accessing the list() function. If there is much data involved, we can do it more efficiently using iterator functions: ``` from itertools import izip, islice myList = ['first_key', 'first_value...
The KISS way: Use exception and iterators ``` myDict = {} it = iter(list) for x in list: try: myDict[it.next()] = it.next() except: pass myDict ```
5,249,353
I'm learning python. I have a list of simple entries and I want to convert it in a dictionary where the first element of list is the key of the second element, the third is the key of the fourth, and so on. How can I do it? ``` list = ['first_key', 'first_value', 'second_key', 'second_value'] ``` Thanks in advance!
2011/03/09
[ "https://Stackoverflow.com/questions/5249353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/619378/" ]
If the list is large, you end up wasting memory by building slices or eager zips. One way to convert the list more lazily is to (ab)use the list iterator and `izip`. ``` from itertools import izip lst = ['first_key', 'first_value', 'second_key', 'second_value'] i = iter(lst) d = dict(izip(i,i)) ```
The KISS way: Use exception and iterators ``` myDict = {} it = iter(list) for x in list: try: myDict[it.next()] = it.next() except: pass myDict ```
45,636,955
I've got the following python method, it gets a string and returns an integer. I'm looking for the correct `input` that will print "Great Success!" ``` input = "XXX" def enc(pwd): inc = 0 for i in range(1, len(pwd) + 1): _1337 = pwd[i - 1] _move = ord(_1337) - 47 if i == 1: ...
2017/08/11
[ "https://Stackoverflow.com/questions/45636955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8451227/" ]
It's encoding the input in base 42 (starting from `chr(47)` which is `'/'`), and easy to decode: ``` def dec(x): while x: yield chr(47 + x % 42) x //= 42 print ''.join(dec(0xEA9D1ED352B8)) ``` The output is: `?O95PIVII`
You can try to bruteforce it. Just make a while loop where the input is encrypted by the function until you have the same hash. But with no informations about the length of the input and so on it could take a while.
45,636,955
I've got the following python method, it gets a string and returns an integer. I'm looking for the correct `input` that will print "Great Success!" ``` input = "XXX" def enc(pwd): inc = 0 for i in range(1, len(pwd) + 1): _1337 = pwd[i - 1] _move = ord(_1337) - 47 if i == 1: ...
2017/08/11
[ "https://Stackoverflow.com/questions/45636955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8451227/" ]
It's encoding the input in base 42 (starting from `chr(47)` which is `'/'`), and easy to decode: ``` def dec(x): while x: yield chr(47 + x % 42) x //= 42 print ''.join(dec(0xEA9D1ED352B8)) ``` The output is: `?O95PIVII`
Yes it is easy to crack. The answer is "?O95PIVII". ``` >>> enc("?O95PIVII")==0xEA9D1ED352B8 True ``` The check in your example is invalid by the way, you need to drop the `hex` from it because the literal 0xEA9D1ED352B8 is parsed as an int. *edit* See Rawing's comment for a hint of how I got the answer. A bit mor...
38,697,820
I'm trying to run sqoop command inside Python script. I had no problem to do that trough shell command, but when I'm trying to execute python stript: ``` #!/usr/bin/python sqoopcom="sqoop import --direct --connect abcd --username abc --P --query "queryname" " exec (sqoopcom) ``` I got an error, Invalid syntax, how...
2016/08/01
[ "https://Stackoverflow.com/questions/38697820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5312431/" ]
The build in `exec` statement that you're using is for interpreting python code inside a python program. What you want is to execute an external (shell) command. For that you could use `call` from the **subprocess module** ``` import subprocess subprocess.call(["echo", "Hello", "World"]) ``` <https://docs.python.or...
You need to skip " on --query param ``` sqoopcom="sqoop import --direct --connect abcd --username abc --P --query \"queryname\" --target-dir /pwd/dir --m 1 --fetch-size 1000 --verbose --fields-terminated-by , --escaped-by \\ --enclosed-by '\"'/dir/part-m-00000" ```
38,697,820
I'm trying to run sqoop command inside Python script. I had no problem to do that trough shell command, but when I'm trying to execute python stript: ``` #!/usr/bin/python sqoopcom="sqoop import --direct --connect abcd --username abc --P --query "queryname" " exec (sqoopcom) ``` I got an error, Invalid syntax, how...
2016/08/01
[ "https://Stackoverflow.com/questions/38697820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5312431/" ]
You need to skip " on --query param ``` sqoopcom="sqoop import --direct --connect abcd --username abc --P --query \"queryname\" --target-dir /pwd/dir --m 1 --fetch-size 1000 --verbose --fields-terminated-by , --escaped-by \\ --enclosed-by '\"'/dir/part-m-00000" ```
You can use: Invalid syntax error noted that you haven't backslashed \"queryname\" ``` #!/usr/bin/env python import os sqoopcom="sqoop import --direct --connect abcd --username abc --P --query \"queryname\" " os.system(sqoopcom) ```
38,697,820
I'm trying to run sqoop command inside Python script. I had no problem to do that trough shell command, but when I'm trying to execute python stript: ``` #!/usr/bin/python sqoopcom="sqoop import --direct --connect abcd --username abc --P --query "queryname" " exec (sqoopcom) ``` I got an error, Invalid syntax, how...
2016/08/01
[ "https://Stackoverflow.com/questions/38697820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5312431/" ]
The build in `exec` statement that you're using is for interpreting python code inside a python program. What you want is to execute an external (shell) command. For that you could use `call` from the **subprocess module** ``` import subprocess subprocess.call(["echo", "Hello", "World"]) ``` <https://docs.python.or...
You can use: Invalid syntax error noted that you haven't backslashed \"queryname\" ``` #!/usr/bin/env python import os sqoopcom="sqoop import --direct --connect abcd --username abc --P --query \"queryname\" " os.system(sqoopcom) ```
46,225,871
``` x = open("file.txt",'w') s = chr(931) # 'Σ' x.write(s) ``` Error ``` Traceback (most recent call last): File "C:\Python34\lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\u03a3' in position ...
2017/09/14
[ "https://Stackoverflow.com/questions/46225871", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4772772/" ]
Your default encoding seems to be cp1252, not utf-8. You need to specify the encoding, to be sure it's utf-8. ### this works fine: ``` with open('outfile.txt', 'w', encoding='utf-8') as f: f.write('Σ') ``` ### this raises your error: ``` with open('outfile.txt', 'w', encoding='cp1252') as f: f.write('Σ') ...
I solve the problem by saving as bytes instead of string ``` def save_byte(): x = open("file.txt",'wb') s = chr(931) # 'Σ' s = s.encode() x.write(s) x.close() ``` outout: Σ
7,139,293
I'm currently building my android project from the project folder with ant like the following: ``` MyProject/ build.xml ``` The ant command that I use to build is: ``` $ MyProject/ant install ``` In my java code, I have some unused imports and variables, for instance: ``` import java.io.IOException; String ...
2011/08/21
[ "https://Stackoverflow.com/questions/7139293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/117642/" ]
You can use [PMD](http://pmd.sourceforge.net/) to do this and much more. It includes checks for both unused local variables and unused imports. It can be [integrated with ant](https://pmd.github.io/pmd-6.17.0/pmd_userdocs_tools_ant.html) and you can configure it to fail the build if any errors are detected. If you are ...
You do not have to do this if you have proguard enabled. <http://developer.android.com/guide/developing/tools/proguard.html>
3,032,519
When I was using the built-in simple server, everything is OK, the admin interface is beautiful: `python manage.py runserver` However, when I try to serve my application using a wsgi server with `django.core.handlers.wsgi.WSGIHandler`, Django seems to forget where the admin media files is, and the admin page is not s...
2010/06/13
[ "https://Stackoverflow.com/questions/3032519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225262/" ]
When I look into the source code of Django, I find out the reason. Somewhere in the `django.core.management.commands.runserver` module, a `WSGIHandler` object is wrapped inside an `AdminMediaHandler`. According to the document, `AdminMediaHandler` is a > > WSGI middleware that intercepts calls > to the admin med...
Django by default doesn't serve the media files since it usually is better to serve these static files on another server (for performance etc.). So, when deploying your application you have to make sure you setup another server (or virtual server) which serves the media (including the admin media). You can find the adm...
3,032,519
When I was using the built-in simple server, everything is OK, the admin interface is beautiful: `python manage.py runserver` However, when I try to serve my application using a wsgi server with `django.core.handlers.wsgi.WSGIHandler`, Django seems to forget where the admin media files is, and the admin page is not s...
2010/06/13
[ "https://Stackoverflow.com/questions/3032519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225262/" ]
Django by default doesn't serve the media files since it usually is better to serve these static files on another server (for performance etc.). So, when deploying your application you have to make sure you setup another server (or virtual server) which serves the media (including the admin media). You can find the adm...
I've run into this problem too (because I do some development against gunicorn), and here's how to remove the admin-media magic and serve admin media like any other media through urls.py: ``` import os import django ... admin_media_url = settings.ADMIN_MEDIA_PREFIX.lstrip('/') + '(?P<path>.*)$' admin_media_path = o...
3,032,519
When I was using the built-in simple server, everything is OK, the admin interface is beautiful: `python manage.py runserver` However, when I try to serve my application using a wsgi server with `django.core.handlers.wsgi.WSGIHandler`, Django seems to forget where the admin media files is, and the admin page is not s...
2010/06/13
[ "https://Stackoverflow.com/questions/3032519", "https://Stackoverflow.com", "https://Stackoverflow.com/users/225262/" ]
When I look into the source code of Django, I find out the reason. Somewhere in the `django.core.management.commands.runserver` module, a `WSGIHandler` object is wrapped inside an `AdminMediaHandler`. According to the document, `AdminMediaHandler` is a > > WSGI middleware that intercepts calls > to the admin med...
I've run into this problem too (because I do some development against gunicorn), and here's how to remove the admin-media magic and serve admin media like any other media through urls.py: ``` import os import django ... admin_media_url = settings.ADMIN_MEDIA_PREFIX.lstrip('/') + '(?P<path>.*)$' admin_media_path = o...
72,991,013
How can I get an input like this in python3 The first input is = 2 and based on this first input I want to get 2 get new inputs For example: ``` 2 # how many inputs? 1 2 # 2 numbers inputs ``` or ``` 3 # how many inputs? 3 5 8 # in one line getting 3 inputs ``` Here is another example: ``` 4 6 8 7 9 ``` How ...
2022/07/15
[ "https://Stackoverflow.com/questions/72991013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19312041/" ]
This might be an approach: ``` <?php $input = "1234-ABC 2345 rBC 9998DDD 9657 lJi"; preg_match_all('/(\d{4}[-\s]*[a-z]{3})/i', $input, $matches); $output = array_shift($matches); array_walk($output, function(&$value) { $value = strtoupper(str_replace(" ", "", $value)); }); print_r($output); ``` The output obvi...
You regular expression `(\d{4})( *)(-*)( *)([a-zA-Z]{3})` was correct but you needed to use `preg_match_all` to return multiple matches. This is a demo: <https://onlinephp.io/c/e5acb> ``` <?php function parsePlates($subject){ $plates = []; preg_match_all('/(\d{4})( *)(-*)( *)([a-zA-Z]{3})/sim', $subject, $r...
38,442,107
I tried the following: ``` #!/usr/bin/env python import keras from keras.models import model_from_yaml model_file_path = 'model-301.yaml' weights_file_path = 'model-301.hdf5' # Load network with open(model_file_path) as f: yaml_string = f.read() model = model_from_yaml(yaml_string) model.load_weights(weights_fi...
2016/07/18
[ "https://Stackoverflow.com/questions/38442107", "https://Stackoverflow.com", "https://Stackoverflow.com/users/562769/" ]
The problem is also referenced on the [issues page](https://github.com/fchollet/keras/issues/3210) of the keras project. You need to install a version of `pydot` <= 1.1.0 because the function `find_graphviz` was [removed](https://github.com/erocarrera/pydot/commit/bc639e76b214b1795ebd6263680ee55d9d4fca9f#diff-44fda7721...
If you have not already installed `pydot` python package - try to install it. If you have `pydot` reinstallation should help with your problem.
10,782,285
> > **Possible Duplicate:** > > [How to generate all permutations of a list in Python](https://stackoverflow.com/questions/104420/how-to-generate-all-permutations-of-a-list-in-python) > > > I am given a list `[1,2,3]` and the task is to create all the possible permutations of this list. Expected output: ``` ...
2012/05/28
[ "https://Stackoverflow.com/questions/10782285", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1407910/" ]
[itertools.permutations](http://docs.python.org/library/itertools.html#itertools.permutations) does this for you. Otherwise, a simple method consist in finding the permutations recursively: you successively select the first element of the output, then ask your function to find all the permutations of the remaining ele...
this is a rudimentary solution... the idea is to use recursion to go through all permutation and reject the non valid permutations. ``` def perm(list_to_perm,perm_l,items,out): if len(perm_l) == items: out +=[perm_l] else: for i in list_to_perm: if i not in ...
35,042,340
I am using [Backbone.LocalStorage](https://github.com/jeromegn/Backbone.localStorage) plugin with backbone app. It is working fine in chrome and safari however, it is giving me below error in firefox. > > DOMException [SecurityError: "The operation is insecure." > code: 18 > nsresult: 0x80530012 > location: <http:...
2016/01/27
[ "https://Stackoverflow.com/questions/35042340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136062/" ]
Make sure Firefox has cookies enabled. The setting can be found under Menu/Options/Privacy/History In the dropdown, select either 'Remember History' or if You prefer use custom settings for history, but select option Accept cookies from sites Hope it helps.
Make sure your domains are same. verify [Same Origin Policy](http://en.wikipedia.org/wiki/Same_origin_policy) which means same domain, subdomain, protocol (http vs https) and same port. [What is Same Origin Policy?](http://en.wikipedia.org/wiki/Same_origin_policy) [How does pushState protect against potential conte...
35,042,340
I am using [Backbone.LocalStorage](https://github.com/jeromegn/Backbone.localStorage) plugin with backbone app. It is working fine in chrome and safari however, it is giving me below error in firefox. > > DOMException [SecurityError: "The operation is insecure." > code: 18 > nsresult: 0x80530012 > location: <http:...
2016/01/27
[ "https://Stackoverflow.com/questions/35042340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136062/" ]
This happens when we try to access a resource (CSS...) that is located on a different domain. To deal with this error we can use this: ``` try { //your critical access to ressources ! //rules = document.styleSheets[i].cssRules; } catc...
Make sure your domains are same. verify [Same Origin Policy](http://en.wikipedia.org/wiki/Same_origin_policy) which means same domain, subdomain, protocol (http vs https) and same port. [What is Same Origin Policy?](http://en.wikipedia.org/wiki/Same_origin_policy) [How does pushState protect against potential conte...
35,042,340
I am using [Backbone.LocalStorage](https://github.com/jeromegn/Backbone.localStorage) plugin with backbone app. It is working fine in chrome and safari however, it is giving me below error in firefox. > > DOMException [SecurityError: "The operation is insecure." > code: 18 > nsresult: 0x80530012 > location: <http:...
2016/01/27
[ "https://Stackoverflow.com/questions/35042340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136062/" ]
Make sure your domains are same. verify [Same Origin Policy](http://en.wikipedia.org/wiki/Same_origin_policy) which means same domain, subdomain, protocol (http vs https) and same port. [What is Same Origin Policy?](http://en.wikipedia.org/wiki/Same_origin_policy) [How does pushState protect against potential conte...
I had similar issue with one script, I dig into error and found it required SSL websockets, so I started SSL and again checked, and It worked. Try enabling HTTPS and access website as <https://127.0.0.1/> It may solve error.
35,042,340
I am using [Backbone.LocalStorage](https://github.com/jeromegn/Backbone.localStorage) plugin with backbone app. It is working fine in chrome and safari however, it is giving me below error in firefox. > > DOMException [SecurityError: "The operation is insecure." > code: 18 > nsresult: 0x80530012 > location: <http:...
2016/01/27
[ "https://Stackoverflow.com/questions/35042340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136062/" ]
Make sure Firefox has cookies enabled. The setting can be found under Menu/Options/Privacy/History In the dropdown, select either 'Remember History' or if You prefer use custom settings for history, but select option Accept cookies from sites Hope it helps.
This happens when we try to access a resource (CSS...) that is located on a different domain. To deal with this error we can use this: ``` try { //your critical access to ressources ! //rules = document.styleSheets[i].cssRules; } catc...
35,042,340
I am using [Backbone.LocalStorage](https://github.com/jeromegn/Backbone.localStorage) plugin with backbone app. It is working fine in chrome and safari however, it is giving me below error in firefox. > > DOMException [SecurityError: "The operation is insecure." > code: 18 > nsresult: 0x80530012 > location: <http:...
2016/01/27
[ "https://Stackoverflow.com/questions/35042340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136062/" ]
Make sure Firefox has cookies enabled. The setting can be found under Menu/Options/Privacy/History In the dropdown, select either 'Remember History' or if You prefer use custom settings for history, but select option Accept cookies from sites Hope it helps.
I had similar issue with one script, I dig into error and found it required SSL websockets, so I started SSL and again checked, and It worked. Try enabling HTTPS and access website as <https://127.0.0.1/> It may solve error.
35,042,340
I am using [Backbone.LocalStorage](https://github.com/jeromegn/Backbone.localStorage) plugin with backbone app. It is working fine in chrome and safari however, it is giving me below error in firefox. > > DOMException [SecurityError: "The operation is insecure." > code: 18 > nsresult: 0x80530012 > location: <http:...
2016/01/27
[ "https://Stackoverflow.com/questions/35042340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1136062/" ]
This happens when we try to access a resource (CSS...) that is located on a different domain. To deal with this error we can use this: ``` try { //your critical access to ressources ! //rules = document.styleSheets[i].cssRules; } catc...
I had similar issue with one script, I dig into error and found it required SSL websockets, so I started SSL and again checked, and It worked. Try enabling HTTPS and access website as <https://127.0.0.1/> It may solve error.
54,204,181
I am trying to set the return value of a `get` request in python in order to do a unit test, which tests if the `post` request is called with the correct arguments. Assume I have the following code to test ``` # main.py import requests from django.contrib.auth.models import User def function_with_get(): client =...
2019/01/15
[ "https://Stackoverflow.com/questions/54204181", "https://Stackoverflow.com", "https://Stackoverflow.com/users/7226268/" ]
I think you almost have it, except you're missing the return value for `session()` - because `session` is instantiated to create the `client` instance. I think you can drop the `[0]` too. Try: ``` mock_sess**.return\_value.**get.return_value.content = 'User1' ```
Try with .text because this should work for strings. ``` s = requests.Session() s.get('https://httpbin.org/cookies/ set/sessioncookie/123456789') r = s.get('https://httpbin.org/ cookies') print(r.text) ``` <http://docs.python-requests.org/en/master/user/advanced/>
37,932,363
So I need to make this plot in python. I wish to remove my legend's border. However, when I tried the different solutions other posters made, they were unable to work with mine. Please help. **This doesn't work:** ``` plt.legend({'z$\sim$0.35', 'z$\sim$0.1','z$\sim$1.55'}) plt.legend(frameon=False) ``` --- ``` plt...
2016/06/20
[ "https://Stackoverflow.com/questions/37932363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6491230/" ]
It's very strange because the command : ``` plt.legend(frameon=False) ``` Should work very well. You can also try this command, to compare : ``` plt.legend(frameon=None) ``` You can also read the documentation on this page about [plt.legend](http://matplotlib.org/api/legend_api.html) I scripted something as exam...
Try this if you want to draw only one plot (without subplot) ``` plt.legend({'z$\sim$0.35', 'z$\sim$0.1','z$\sim$1.55'}, frameon=False) ``` It is enough one plt.legend. The second one rewrites the first one.
37,932,363
So I need to make this plot in python. I wish to remove my legend's border. However, when I tried the different solutions other posters made, they were unable to work with mine. Please help. **This doesn't work:** ``` plt.legend({'z$\sim$0.35', 'z$\sim$0.1','z$\sim$1.55'}) plt.legend(frameon=False) ``` --- ``` plt...
2016/06/20
[ "https://Stackoverflow.com/questions/37932363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6491230/" ]
It's very strange because the command : ``` plt.legend(frameon=False) ``` Should work very well. You can also try this command, to compare : ``` plt.legend(frameon=None) ``` You can also read the documentation on this page about [plt.legend](http://matplotlib.org/api/legend_api.html) I scripted something as exam...
Make sure frameon = False is together with the positional argument in plt.legend(...) if you want to specify the position as well as remove the border. If these arguments are written separately or in sequential, there's an issue of overwriting and the desired effect may not be achieved. Correct! `plt.legend(loc="lower...
69,364,940
The text is like "1-2years. 3years. 10years." I want get result `[(1,2),(3),(10)]`. I use python. I first tried `r"([0-9]?)[-]?([0-9])years"`. It works well except for the case of 10. I also tried `r"([0-9]?)[-]?([0-9]|10)years"` but the result is still `[(1,2),(3),(1,0)]`.
2021/09/28
[ "https://Stackoverflow.com/questions/69364940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10490005/" ]
You need to listen for click event on newly added element. hence added a click listener on **newSpan** element after adding it into DOM. You are listening for event for removeLists element only but when you add a new element in the DOM, the newly doesn't have the click event. Hence, we have to listen for the event exp...
Please change some code. Please add remove event function to listItemMake() function. ```js const toDoInput = document.querySelector("input"); const addButton = document.querySelector("button"); const listParent = document.querySelector("ul"); const listItemMake = () => { if (toDoInput.value !== "") { const new...
69,364,940
The text is like "1-2years. 3years. 10years." I want get result `[(1,2),(3),(10)]`. I use python. I first tried `r"([0-9]?)[-]?([0-9])years"`. It works well except for the case of 10. I also tried `r"([0-9]?)[-]?([0-9]|10)years"` but the result is still `[(1,2),(3),(1,0)]`.
2021/09/28
[ "https://Stackoverflow.com/questions/69364940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10490005/" ]
You need to listen for click event on newly added element. hence added a click listener on **newSpan** element after adding it into DOM. You are listening for event for removeLists element only but when you add a new element in the DOM, the newly doesn't have the click event. Hence, we have to listen for the event exp...
Try to move const removeLists and removeList.addEventListener to listItemMake function, so when you add new item const removeLists can include new list item. ```js const listItemMake = () => { if (toDoInput.value !== "") { const newDiv = document.createElement("div"); newDiv.classList.add("list-item"); c...
69,364,940
The text is like "1-2years. 3years. 10years." I want get result `[(1,2),(3),(10)]`. I use python. I first tried `r"([0-9]?)[-]?([0-9])years"`. It works well except for the case of 10. I also tried `r"([0-9]?)[-]?([0-9]|10)years"` but the result is still `[(1,2),(3),(1,0)]`.
2021/09/28
[ "https://Stackoverflow.com/questions/69364940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10490005/" ]
You need to listen for click event on newly added element. hence added a click listener on **newSpan** element after adding it into DOM. You are listening for event for removeLists element only but when you add a new element in the DOM, the newly doesn't have the click event. Hence, we have to listen for the event exp...
```js const toDoInput = document.querySelector("input"); const addButton = document.querySelector("button"); const listParent = document.querySelector("ul"); const listItemMake = () => { if (toDoInput.value !== "") { const newDiv = document.createElement("div"); newDiv.classList.add("list-item"); const n...
69,364,940
The text is like "1-2years. 3years. 10years." I want get result `[(1,2),(3),(10)]`. I use python. I first tried `r"([0-9]?)[-]?([0-9])years"`. It works well except for the case of 10. I also tried `r"([0-9]?)[-]?([0-9]|10)years"` but the result is still `[(1,2),(3),(1,0)]`.
2021/09/28
[ "https://Stackoverflow.com/questions/69364940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10490005/" ]
You need to listen for click event on newly added element. hence added a click listener on **newSpan** element after adding it into DOM. You are listening for event for removeLists element only but when you add a new element in the DOM, the newly doesn't have the click event. Hence, we have to listen for the event exp...
You don't need the `removeLists` variable at all (just add event listeners to the static elements). The event listener to the `removeList` button/span should be added in the `listItemMake` function. The first three lines (`document.querySelector()`) return an [`Element DOM object`](https://developer.mozilla.org/en-US/...
69,364,940
The text is like "1-2years. 3years. 10years." I want get result `[(1,2),(3),(10)]`. I use python. I first tried `r"([0-9]?)[-]?([0-9])years"`. It works well except for the case of 10. I also tried `r"([0-9]?)[-]?([0-9]|10)years"` but the result is still `[(1,2),(3),(1,0)]`.
2021/09/28
[ "https://Stackoverflow.com/questions/69364940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10490005/" ]
Please change some code. Please add remove event function to listItemMake() function. ```js const toDoInput = document.querySelector("input"); const addButton = document.querySelector("button"); const listParent = document.querySelector("ul"); const listItemMake = () => { if (toDoInput.value !== "") { const new...
```js const toDoInput = document.querySelector("input"); const addButton = document.querySelector("button"); const listParent = document.querySelector("ul"); const listItemMake = () => { if (toDoInput.value !== "") { const newDiv = document.createElement("div"); newDiv.classList.add("list-item"); const n...
69,364,940
The text is like "1-2years. 3years. 10years." I want get result `[(1,2),(3),(10)]`. I use python. I first tried `r"([0-9]?)[-]?([0-9])years"`. It works well except for the case of 10. I also tried `r"([0-9]?)[-]?([0-9]|10)years"` but the result is still `[(1,2),(3),(1,0)]`.
2021/09/28
[ "https://Stackoverflow.com/questions/69364940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10490005/" ]
Please change some code. Please add remove event function to listItemMake() function. ```js const toDoInput = document.querySelector("input"); const addButton = document.querySelector("button"); const listParent = document.querySelector("ul"); const listItemMake = () => { if (toDoInput.value !== "") { const new...
You don't need the `removeLists` variable at all (just add event listeners to the static elements). The event listener to the `removeList` button/span should be added in the `listItemMake` function. The first three lines (`document.querySelector()`) return an [`Element DOM object`](https://developer.mozilla.org/en-US/...
69,364,940
The text is like "1-2years. 3years. 10years." I want get result `[(1,2),(3),(10)]`. I use python. I first tried `r"([0-9]?)[-]?([0-9])years"`. It works well except for the case of 10. I also tried `r"([0-9]?)[-]?([0-9]|10)years"` but the result is still `[(1,2),(3),(1,0)]`.
2021/09/28
[ "https://Stackoverflow.com/questions/69364940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10490005/" ]
Try to move const removeLists and removeList.addEventListener to listItemMake function, so when you add new item const removeLists can include new list item. ```js const listItemMake = () => { if (toDoInput.value !== "") { const newDiv = document.createElement("div"); newDiv.classList.add("list-item"); c...
```js const toDoInput = document.querySelector("input"); const addButton = document.querySelector("button"); const listParent = document.querySelector("ul"); const listItemMake = () => { if (toDoInput.value !== "") { const newDiv = document.createElement("div"); newDiv.classList.add("list-item"); const n...
69,364,940
The text is like "1-2years. 3years. 10years." I want get result `[(1,2),(3),(10)]`. I use python. I first tried `r"([0-9]?)[-]?([0-9])years"`. It works well except for the case of 10. I also tried `r"([0-9]?)[-]?([0-9]|10)years"` but the result is still `[(1,2),(3),(1,0)]`.
2021/09/28
[ "https://Stackoverflow.com/questions/69364940", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10490005/" ]
Try to move const removeLists and removeList.addEventListener to listItemMake function, so when you add new item const removeLists can include new list item. ```js const listItemMake = () => { if (toDoInput.value !== "") { const newDiv = document.createElement("div"); newDiv.classList.add("list-item"); c...
You don't need the `removeLists` variable at all (just add event listeners to the static elements). The event listener to the `removeList` button/span should be added in the `listItemMake` function. The first three lines (`document.querySelector()`) return an [`Element DOM object`](https://developer.mozilla.org/en-US/...
8,948,034
I want to retrieve and work with basic Vimeo data in python 3.2, given a video's URL. I'm a newcomer to JSON (and python), but it looked like the right fit for doing this. 1. Request Vimeo video data (via an API-formatted .json URL) 2. Convert returned JSON data into python dict 3. Display dict keys & data ("id", "tit...
2012/01/20
[ "https://Stackoverflow.com/questions/8948034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73807/" ]
This works for me: ``` import urllib.request, json response = urllib.request.urlopen('http://vimeo.com/api/v2/video/31161781.json') content = response.read() data = json.loads(content.decode('utf8')) ``` Or with Requests: ``` import requests data = requests.get('http://vimeo.com/api/v2/video/31161781.json').json(...
Check out: <http://www.voidspace.org.uk/python/articles/urllib2.shtml> ``` >>> import urllib2 >>> import json >>> req = urllib2.Request("http://vimeo.com/api/v2/video/31161781.json") >>> response = urllib2.urlopen(req) >>> content_string = response.read() >>> content_string '[{"id":31161781,"title":"Kevin Fanning talk...
8,948,034
I want to retrieve and work with basic Vimeo data in python 3.2, given a video's URL. I'm a newcomer to JSON (and python), but it looked like the right fit for doing this. 1. Request Vimeo video data (via an API-formatted .json URL) 2. Convert returned JSON data into python dict 3. Display dict keys & data ("id", "tit...
2012/01/20
[ "https://Stackoverflow.com/questions/8948034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73807/" ]
Check out: <http://www.voidspace.org.uk/python/articles/urllib2.shtml> ``` >>> import urllib2 >>> import json >>> req = urllib2.Request("http://vimeo.com/api/v2/video/31161781.json") >>> response = urllib2.urlopen(req) >>> content_string = response.read() >>> content_string '[{"id":31161781,"title":"Kevin Fanning talk...
**you can try to like so:** ``` import requests url1 = 'http://vimeo.com/api/v2/video/31161781.json' html = requests.get(url1) html.encoding = html.apparent_encoding print(html.text) ```
8,948,034
I want to retrieve and work with basic Vimeo data in python 3.2, given a video's URL. I'm a newcomer to JSON (and python), but it looked like the right fit for doing this. 1. Request Vimeo video data (via an API-formatted .json URL) 2. Convert returned JSON data into python dict 3. Display dict keys & data ("id", "tit...
2012/01/20
[ "https://Stackoverflow.com/questions/8948034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73807/" ]
This works for me: ``` import urllib.request, json response = urllib.request.urlopen('http://vimeo.com/api/v2/video/31161781.json') content = response.read() data = json.loads(content.decode('utf8')) ``` Or with Requests: ``` import requests data = requests.get('http://vimeo.com/api/v2/video/31161781.json').json(...
Can you try to just request the url like so ``` response = urllib.urlopen('http://www.weather.com/weather/today/Ellicott+City+MD+21042') response_dict = json.loads(response.read()) ``` As you see python has a lot of libraries that share functionality, you shouldn't need to build an opener or anything to get this da...
8,948,034
I want to retrieve and work with basic Vimeo data in python 3.2, given a video's URL. I'm a newcomer to JSON (and python), but it looked like the right fit for doing this. 1. Request Vimeo video data (via an API-formatted .json URL) 2. Convert returned JSON data into python dict 3. Display dict keys & data ("id", "tit...
2012/01/20
[ "https://Stackoverflow.com/questions/8948034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73807/" ]
Can you try to just request the url like so ``` response = urllib.urlopen('http://www.weather.com/weather/today/Ellicott+City+MD+21042') response_dict = json.loads(response.read()) ``` As you see python has a lot of libraries that share functionality, you shouldn't need to build an opener or anything to get this da...
**you can try to like so:** ``` import requests url1 = 'http://vimeo.com/api/v2/video/31161781.json' html = requests.get(url1) html.encoding = html.apparent_encoding print(html.text) ```
8,948,034
I want to retrieve and work with basic Vimeo data in python 3.2, given a video's URL. I'm a newcomer to JSON (and python), but it looked like the right fit for doing this. 1. Request Vimeo video data (via an API-formatted .json URL) 2. Convert returned JSON data into python dict 3. Display dict keys & data ("id", "tit...
2012/01/20
[ "https://Stackoverflow.com/questions/8948034", "https://Stackoverflow.com", "https://Stackoverflow.com/users/73807/" ]
This works for me: ``` import urllib.request, json response = urllib.request.urlopen('http://vimeo.com/api/v2/video/31161781.json') content = response.read() data = json.loads(content.decode('utf8')) ``` Or with Requests: ``` import requests data = requests.get('http://vimeo.com/api/v2/video/31161781.json').json(...
**you can try to like so:** ``` import requests url1 = 'http://vimeo.com/api/v2/video/31161781.json' html = requests.get(url1) html.encoding = html.apparent_encoding print(html.text) ```
48,117,638
I would like to know how to have setup.py install c modules locally. Locally as in not in `/usr/local/python..` and not in `~/local/python...`, but in `[where_all_my_code_is]/bin` and I can import it from scripts within the [where\_all\_my\_code\_is] folder. I have some c code. src/foo/foo.c ``` #include <Python.h> s...
2018/01/05
[ "https://Stackoverflow.com/questions/48117638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2886575/" ]
Here is one option: setup using ``` $ python3 setup.py install --root . --install-lib lib ``` add local `lib` path to the python path ``` $ export PYTHONPATH:$PYTHONPATH:./lib ``` Now python scripts in `.` can import the `c` modules we just compiled. Something fancier would need to be used for the exact scenari...
you would have to create custom package for the type of os you are using, deb or rpm or ebuild these system level tools install files into /usr/bin and /usr/lib instead of your local builds which go to /usr/local or user builds ~/local.
37,955,984
I don't have a clue what's causing this error. It appears to be a bug that there isn't a fix for. Could anyone tell give me a hint as to how I might get around this? It's frustrating me to no end. Thanks. ``` Operations to perform: Apply all migrations: admin, contenttypes, optilab, auth, sessions Running migrations...
2016/06/21
[ "https://Stackoverflow.com/questions/37955984", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2075859/" ]
This appears to be the line that's causing the errror: ``` INSERT INTO "optilab_lasersubstrate" () SELECT FROM "optilab_lasersubstrate__old"; ``` You are usually expected to have a list of columns in those parenthesis. Eg `INSERT INTO "optilab_lasersubstrate" (col1,col2,etc)` however the migration has produced a b...
Edit base.py in the lines that breaks and update it to: ``` def execute(self, query, params=None): if params is None: if '()' not in str(query): return Database.Cursor.execute(self, query) query = self.convert_query(query) if '()' not in str(query): return Database.Cursor.execut...
33,281,217
I'm crawling through a simple, but long HTML chunk, which is similar to this: ```html <table> <tbody> <tr> <td> Some text </td> <td> Some text </td> </tr> <tr> <td> Some text <br/> Some more text </td> </tr> </tbody> </table> ``` I'm collect...
2015/10/22
[ "https://Stackoverflow.com/questions/33281217", "https://Stackoverflow.com", "https://Stackoverflow.com/users/256965/" ]
Because `<br/>` is a self-closing tag, it does not have any `text` content. Instead, you need to access it's `tail` content. The `tail` content is the content after the element's closing tag, but before the next opening tag. To access this content in your for loop you will need to use the following: ``` for element in...
To me below is working to extract all the text after `br`- ``` normalize-space(//table//br/following::text()[1]) ``` **Working example is** [**at**](http://www.xpathtester.com/xpath/283dca20a024adbb5ece93de6c914531).
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
The `u` means a [`unicode`](https://docs.python.org/2/howto/unicode.html) string which should be perfectly fine to use. But if you want to convert `unicode` to `str` (which just represents plain bytes in Python 2) then you may `encode` it using a character encoding such as `utf-8`. ``` >>> items = [u'[190215]'] >>> [i...
You can convert your unicode to normal string with `str` : ``` >>> list(str(l[0])) ['[', '1', '9', '0', '2', '1', '5', ']'] ```
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
The `u` means a [`unicode`](https://docs.python.org/2/howto/unicode.html) string which should be perfectly fine to use. But if you want to convert `unicode` to `str` (which just represents plain bytes in Python 2) then you may `encode` it using a character encoding such as `utf-8`. ``` >>> items = [u'[190215]'] >>> [i...
In your current code, you are iterating on a string, which represents a list, hence you get the individual characters. ``` >>> from ast import literal_eval >>> l = [u'[190215]'] >>> l = [item for value in l for item in value] >>> l [u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']'] ``` Seems to me, you want to convert...
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
The `u` means a [`unicode`](https://docs.python.org/2/howto/unicode.html) string which should be perfectly fine to use. But if you want to convert `unicode` to `str` (which just represents plain bytes in Python 2) then you may `encode` it using a character encoding such as `utf-8`. ``` >>> items = [u'[190215]'] >>> [i...
use `[str(item) for item in list]` example ``` >>> li = [u'a', u'b', u'c', u'd'] >>> print li [u'a', u'b', u'c', u'd'] >>> li_u_removed = [str(i) for i in li] >>> print li_u_removed ['a', 'b', 'c', 'd'] ```
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
The `u` means a [`unicode`](https://docs.python.org/2/howto/unicode.html) string which should be perfectly fine to use. But if you want to convert `unicode` to `str` (which just represents plain bytes in Python 2) then you may `encode` it using a character encoding such as `utf-8`. ``` >>> items = [u'[190215]'] >>> [i...
I think this issue occurred in `python 2.7` but in latest python version **u** did not displayed when it run ``` l = [u'[190215]'] l = [item for value in l for item in value] print(l) ``` **output -:** `['[', '1', '9', '0', '2', '1', '5', ']']` If you want to **concatenate** string items in a list into a single str...
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
In your current code, you are iterating on a string, which represents a list, hence you get the individual characters. ``` >>> from ast import literal_eval >>> l = [u'[190215]'] >>> l = [item for value in l for item in value] >>> l [u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']'] ``` Seems to me, you want to convert...
You can convert your unicode to normal string with `str` : ``` >>> list(str(l[0])) ['[', '1', '9', '0', '2', '1', '5', ']'] ```
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
use `[str(item) for item in list]` example ``` >>> li = [u'a', u'b', u'c', u'd'] >>> print li [u'a', u'b', u'c', u'd'] >>> li_u_removed = [str(i) for i in li] >>> print li_u_removed ['a', 'b', 'c', 'd'] ```
You can convert your unicode to normal string with `str` : ``` >>> list(str(l[0])) ['[', '1', '9', '0', '2', '1', '5', ']'] ```
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
You can convert your unicode to normal string with `str` : ``` >>> list(str(l[0])) ['[', '1', '9', '0', '2', '1', '5', ']'] ```
I think this issue occurred in `python 2.7` but in latest python version **u** did not displayed when it run ``` l = [u'[190215]'] l = [item for value in l for item in value] print(l) ``` **output -:** `['[', '1', '9', '0', '2', '1', '5', ']']` If you want to **concatenate** string items in a list into a single str...
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
In your current code, you are iterating on a string, which represents a list, hence you get the individual characters. ``` >>> from ast import literal_eval >>> l = [u'[190215]'] >>> l = [item for value in l for item in value] >>> l [u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']'] ``` Seems to me, you want to convert...
I think this issue occurred in `python 2.7` but in latest python version **u** did not displayed when it run ``` l = [u'[190215]'] l = [item for value in l for item in value] print(l) ``` **output -:** `['[', '1', '9', '0', '2', '1', '5', ']']` If you want to **concatenate** string items in a list into a single str...
30,975,911
I have a python list of list as follows. I want to flatten it to a single list. ``` l = [u'[190215]'] ``` I am trying. ``` l = [item for value in l for item in value] ``` It turns the list to `[u'[', u'1', u'9', u'0', u'2', u'1', u'5', u']']` How to remove the `u` from the list.
2015/06/22
[ "https://Stackoverflow.com/questions/30975911", "https://Stackoverflow.com", "https://Stackoverflow.com/users/567797/" ]
use `[str(item) for item in list]` example ``` >>> li = [u'a', u'b', u'c', u'd'] >>> print li [u'a', u'b', u'c', u'd'] >>> li_u_removed = [str(i) for i in li] >>> print li_u_removed ['a', 'b', 'c', 'd'] ```
I think this issue occurred in `python 2.7` but in latest python version **u** did not displayed when it run ``` l = [u'[190215]'] l = [item for value in l for item in value] print(l) ``` **output -:** `['[', '1', '9', '0', '2', '1', '5', ']']` If you want to **concatenate** string items in a list into a single str...