title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
Calling methods from C/C++ DLL with Python
38,997,898
<p>I do have a tutorial here about calling functions from a c/c++ dll, the example is written here from the <a href="https://docs.python.org/3.3/library/ctypes.html#function-prototypes" rel="nofollow">official tutorial</a>.</p> <pre><code>WINUSERAPI int WINAPI MessageBoxA( HWND hWnd, LPCSTR lpText, LPCSTR ...
0
2016-08-17T13:20:57Z
38,998,526
<p>Unfortunately, you can not do that easily and in portable way with <code>ctypes</code>.</p> <p><code>ctypes</code> is designed to call <strong>functions</strong> in DLLs with <strong>C compatible data</strong> types. </p> <p>Since there is no <a href="https://en.wikipedia.org/wiki/Application_binary_interface" rel...
0
2016-08-17T13:48:15Z
[ "python", "c++", "c", "dll" ]
Python bitwise logic to operate LEDs
38,997,913
<p>So i'm currently playing with my Raspberry Pi and 7 segment(actually 8 because there is dot) display and i need help. I know how to operate it using single LEDs(so for example i know which LEDs i need to light up to create "1" so i can basically operate it) but there was code in manual that's using some bitwise logi...
2
2016-08-17T13:22:03Z
39,001,354
<h2>SETUP</h2> <p>I'm going to refer to this image I found on a <a href="https://www.reddit.com/r/EngineeringStudents/comments/3pl9jv/designed_my_first_pcb_hope_i_made_you_all_proud/" rel="nofollow">thread on reddit</a>:</p> <p><a href="http://i.stack.imgur.com/a3zfz.png" rel="nofollow"><img src="http://i.stack.imgur...
1
2016-08-17T16:00:24Z
[ "python", "raspberry-pi", "bit-manipulation" ]
Why does my nested loop throw an exception in Python?
38,998,035
<p>This is a simple code,</p> <pre><code>def door_traversal(): arr = [] for i in range(1, 101, 1): arr.append(0) for i in range(1, 101, 1): for j in range(i, 101, i): arr[j] = not arr[j] count = 0 for i in range(1, 101, 1): if arr[i] == 1: count += 1...
0
2016-08-17T13:27:21Z
38,998,179
<p>you're accessing the indices from 1 to 101 but the first index of a list is 0, you should iterate with for i in range(100)</p> <pre><code>def door_traversal(): arr = [0 for i in range(100)] for i in range(100): for j in range(100): arr[j] = not arr[j] count = 0 for i in range(1...
3
2016-08-17T13:34:14Z
[ "python" ]
Why does my nested loop throw an exception in Python?
38,998,035
<p>This is a simple code,</p> <pre><code>def door_traversal(): arr = [] for i in range(1, 101, 1): arr.append(0) for i in range(1, 101, 1): for j in range(i, 101, i): arr[j] = not arr[j] count = 0 for i in range(1, 101, 1): if arr[i] == 1: count += 1...
0
2016-08-17T13:27:21Z
38,998,215
<p>Python list indices always start from zero. Thus, the following creates a list containing 100 elements, with indices from 0 to 99 (<em>not</em> from 1 to 100 as you might be expecting):</p> <pre><code>for i in range(1, 101, 1): arr.append(0) </code></pre> <p>Now, the following can try to access the element at ...
3
2016-08-17T13:35:26Z
[ "python" ]
Why does my nested loop throw an exception in Python?
38,998,035
<p>This is a simple code,</p> <pre><code>def door_traversal(): arr = [] for i in range(1, 101, 1): arr.append(0) for i in range(1, 101, 1): for j in range(i, 101, i): arr[j] = not arr[j] count = 0 for i in range(1, 101, 1): if arr[i] == 1: count += 1...
0
2016-08-17T13:27:21Z
38,998,284
<p>In this line you add 100 items to <code>arr</code></p> <pre><code> for i in range(1, 101, 1): arr.append(0) </code></pre> <p>So your <code>arr</code> array is 100 items long. Then in this loop:</p> <pre><code> for i in range(1, 101, 1): for j in range(i, 101, i): arr[j] = not arr...
1
2016-08-17T13:38:42Z
[ "python" ]
Why does my nested loop throw an exception in Python?
38,998,035
<p>This is a simple code,</p> <pre><code>def door_traversal(): arr = [] for i in range(1, 101, 1): arr.append(0) for i in range(1, 101, 1): for j in range(i, 101, i): arr[j] = not arr[j] count = 0 for i in range(1, 101, 1): if arr[i] == 1: count += 1...
0
2016-08-17T13:27:21Z
38,998,704
<p>You have some pretty fundamental errors in your understanding.</p> <p>First, lists in python <em>always</em> start with an index of 0. A list of size 3 looks like this:</p> <pre><code>three = [0, 1, 2] </code></pre> <p>The indexes are the values themselves. And yes, you could ignore the first element, and create ...
2
2016-08-17T13:54:10Z
[ "python" ]
Why does my nested loop throw an exception in Python?
38,998,035
<p>This is a simple code,</p> <pre><code>def door_traversal(): arr = [] for i in range(1, 101, 1): arr.append(0) for i in range(1, 101, 1): for j in range(i, 101, i): arr[j] = not arr[j] count = 0 for i in range(1, 101, 1): if arr[i] == 1: count += 1...
0
2016-08-17T13:27:21Z
39,000,022
<p>Index problems aside, please consider the following python idioms (with comments which are for pedagogical purposes only):</p> <pre><code>def door_traversal(): """got doc?""" # why does this func. exist? arr = [0] * 100 # list concatenation for i in range(1, 101, 1): for j in range(i, 101, i...
0
2016-08-17T14:54:42Z
[ "python" ]
Flask permissions for file writing
38,998,060
<p>I'm running a Flask webserver on an EC2 Ubuntu instance. The purpose is to capture the body of an incoming POST, write it to a file locally, then upload that file to S3.</p> <p>The code is, basically:</p> <pre><code>@app.route('/', methods=['GET','POST']) @app.route('/index.html', methods=['GET','POST']) def inde...
0
2016-08-17T13:28:34Z
38,998,429
<p>You should make sure the program is actually trying to write in the directory you want it to write to. It could be that it tries to write into the directory of the Python binary (or anything else), that depends on your command and the current working directory. For testing purposes you might try to change the path l...
2
2016-08-17T13:44:15Z
[ "python", "ubuntu", "amazon-ec2", "flask" ]
How to replace " ' " in python?
38,998,200
<p>So I just got a quick question. I need to replace (') in python but obviously it is not working.</p> <p>This is the code I use for replaceing things in python:</p> <pre><code>with open('ID.txt','r') as f: newlines = [] for line in f.readlines(): newlines.append(line.replace('Machine',)) with ope...
-5
2016-08-17T13:35:00Z
38,998,351
<p>Using <code>replace(''','')</code> will run into errors. Try this instead:</p> <p><code>line.replace("'","")</code></p>
0
2016-08-17T13:41:05Z
[ "python" ]
How to replace " ' " in python?
38,998,200
<p>So I just got a quick question. I need to replace (') in python but obviously it is not working.</p> <p>This is the code I use for replaceing things in python:</p> <pre><code>with open('ID.txt','r') as f: newlines = [] for line in f.readlines(): newlines.append(line.replace('Machine',)) with ope...
-5
2016-08-17T13:35:00Z
38,998,383
<p>You can write string literals in python in several ways like</p> <p><code>"bla'bla\"bla"</code>, <code>'bla\'bla"bla'</code>, <code>"""bla'bla"bla"""</code>, <code>'''bla'bla"bla'''</code></p> <p>See <a href="https://docs.python.org/3/tutorial/introduction.html#strings" rel="nofollow">https://docs.python.org/3/tut...
0
2016-08-17T13:42:27Z
[ "python" ]
How to replace " ' " in python?
38,998,200
<p>So I just got a quick question. I need to replace (') in python but obviously it is not working.</p> <p>This is the code I use for replaceing things in python:</p> <pre><code>with open('ID.txt','r') as f: newlines = [] for line in f.readlines(): newlines.append(line.replace('Machine',)) with ope...
-5
2016-08-17T13:35:00Z
38,998,561
<pre><code>for a in '', "'", '"': print(''' 1'2'3"4"5 '''.replace(a, '*')) </code></pre>
0
2016-08-17T13:49:44Z
[ "python" ]
How to replace " ' " in python?
38,998,200
<p>So I just got a quick question. I need to replace (') in python but obviously it is not working.</p> <p>This is the code I use for replaceing things in python:</p> <pre><code>with open('ID.txt','r') as f: newlines = [] for line in f.readlines(): newlines.append(line.replace('Machine',)) with ope...
-5
2016-08-17T13:35:00Z
38,998,743
<p>This is very straightforward as it can be handled with replace. There is no "obvious" reason this would not work. There is an "obvious" reason you'd have an error and that is trying to call out a single quot with additional single quotes</p> <pre><code>text = "dog's toy" text.replace("'","-") ==&gt;"dog-s toy" </co...
0
2016-08-17T13:55:52Z
[ "python" ]
How to replace " ' " in python?
38,998,200
<p>So I just got a quick question. I need to replace (') in python but obviously it is not working.</p> <p>This is the code I use for replaceing things in python:</p> <pre><code>with open('ID.txt','r') as f: newlines = [] for line in f.readlines(): newlines.append(line.replace('Machine',)) with ope...
-5
2016-08-17T13:35:00Z
38,998,762
<p>Here's a possible solution:</p> <pre><code>with open('ID.txt', 'r') as f: contents = f.read().replace("'", "") with open('ID.txt', 'w') as f2: f2.write(contents) </code></pre>
0
2016-08-17T13:56:48Z
[ "python" ]
How to give beta and gamma in tf.contrib.layers.batch_norm
38,998,238
<p>I'm trying to use normalization layer given by tensorflow. In that <a href="https://www.tensorflow.org/versions/r0.10/api_docs/python/contrib.layers.html#batch_norm" rel="nofollow">function</a>, there is a field to specify whether we are using beta or gamma values.</p> <blockquote> <p><strong>center:</strong> If ...
1
2016-08-17T13:36:25Z
38,998,456
<p>The link you provided has specified the function as <code>tf.contrib.layers.batch_norm(*args, **kwargs)</code>.</p> <p>Looks like you should be able to pass <code>beta</code> and <code>gamma</code> as <code>keyword arguments</code> or <code>**kwargs</code> like this:</p> <pre><code>tf.contrib.layers.batch_norm(bet...
2
2016-08-17T13:45:40Z
[ "python", "python-2.7", "tensorflow" ]
How to give beta and gamma in tf.contrib.layers.batch_norm
38,998,238
<p>I'm trying to use normalization layer given by tensorflow. In that <a href="https://www.tensorflow.org/versions/r0.10/api_docs/python/contrib.layers.html#batch_norm" rel="nofollow">function</a>, there is a field to specify whether we are using beta or gamma values.</p> <blockquote> <p><strong>center:</strong> If ...
1
2016-08-17T13:36:25Z
38,998,510
<p>Beta and gamma are the learnable parameters of the batch normalization layer.</p> <p>As you can see from the image below, these parameters are used to scale and shift the normalized values. The value you can pass to the <code>batch_norm</code> method, are the init value of these parameters.</p> <p><a href="http://...
0
2016-08-17T13:47:40Z
[ "python", "python-2.7", "tensorflow" ]
Python / Django app: a wine list with filter menu. Where should the filter logic go? Frontend or Backend?
38,998,263
<p>I have created a wine list app and I am starting to question my design. First off if you look at the views.py snippet below, you see a simple solution to send all active Wine objects. But the real question is, how do I create a filter side menu? I like using views for all of the logic, but to me it seems that having...
0
2016-08-17T13:37:38Z
38,999,056
<p>one solution to your problem is using django forms, so your filter box will be a normal django form, user will select items from those forms then click on submit button</p> <p>in your view method you use submitted data to generate a queryset and render template for user. (check out <a href="http://django-filter.rea...
0
2016-08-17T14:10:02Z
[ "python", "django", "rest", "filter", "views" ]
Odoo Onchange method not working on many2one field
38,998,333
<p>I have written a onchange method on the many2one field using new api for v9. my code is</p> <pre><code>branch_id = fields.Many2one('branch.branch', 'Branch') @api.onchange('branch_id') def onchange_branch(self): if self.branch_id: self.shop_ids = self.branch_id.shop_ids </code></pre> <p>I have not add...
1
2016-08-17T13:40:22Z
38,999,837
<p>I faced this kind of issue while migrating code from v7 to v9. where I was changing the methods from old api to odoo new api. that time i forgot to comment the old api method. </p> <p>May be this can be your issue.</p> <p>kindly check your for the method <code>onchange_branch</code>, if you have two method with sa...
1
2016-08-17T14:46:09Z
[ "python", "openerp", "odoo-9" ]
Odoo: How to process winmail.dat attached in conversations?
38,998,486
<p>We have some customers who uses Microsoft Outlook to send attachments. However in odoo we see only <code>winmail.dat</code> files (while everything looks ok in mail client).</p> <p>Is there any way to force odoo to expose <code>winmail.dat</code> content?</p>
2
2016-08-17T13:46:48Z
38,998,706
<p>The problem is that Microsoft Outlook uses <a href="https://en.wikipedia.org/wiki/Transport_Neutral_Encapsulation_Format" rel="nofollow">Transport Neutral Encapsulation Format</a> and packs all attachments in one file.</p> <p>There is a good python parser for tnef format - <a href="https://pypi.python.org/pypi/tnef...
1
2016-08-17T13:54:14Z
[ "python", "openerp", "winmail.dat" ]
Differences between scipy and matlab spectogram
38,998,522
<p>I'm attempting to convert a MATLAB script to Python and running into slight differences between the results of the <code>spectrogram</code> function between MATLAB 2012a and Python using scipy v. 0.17.0. In MATLAB I have the code:</p> <pre class="lang-matlab prettyprint-override"><code>WINDOW = 240; NOVERLAP = 180...
0
2016-08-17T13:48:04Z
39,004,643
<p>Scipy and MATLAB use different FFT libraries. Scipy uses lapack, while MATLAB uses FFTW. These libraries use different algorithms and produce slightly different results. </p> <p>You can use FFTW with Python using the <a href="https://pypi.python.org/pypi/pyFFTW" rel="nofollow">pyFFTW</a> package, and you can eve...
1
2016-08-17T19:20:01Z
[ "python", "matlab", "scipy" ]
How to read/pass a js var to python script?
38,998,541
<p>I have a .js file (test.js) with a bunch of calculations and variables. Let's just say 1 number (var1) and 1 array (var2).</p> <p>I also have a .py file (test2.py) with a bunch of stuff. Is there any way to pass (var1) and (var2) so test2.py can read it and do some more work on it?</p> <p>Is this possible? If so, ...
-1
2016-08-17T13:48:59Z
38,998,951
<p>You can't do this . How Python will know javascript variables ?. No language will understand the other languages memory structures . There should be some interface(agreement) to make it understand. For example , Java and C can be using JNI (Java Native Interface) .</p>
0
2016-08-17T14:05:12Z
[ "javascript", "python", "python-2.7" ]
How to read/pass a js var to python script?
38,998,541
<p>I have a .js file (test.js) with a bunch of calculations and variables. Let's just say 1 number (var1) and 1 array (var2).</p> <p>I also have a .py file (test2.py) with a bunch of stuff. Is there any way to pass (var1) and (var2) so test2.py can read it and do some more work on it?</p> <p>Is this possible? If so, ...
-1
2016-08-17T13:48:59Z
38,998,978
<p>You can export the variables as JSON from Javascript - how depends on which environment you run the script in (nodejs, browser, ...) - and import them in Python <a href="https://docs.python.org/2/library/json.html" rel="nofollow">docs</a>. This works the other way, too.</p>
0
2016-08-17T14:06:28Z
[ "javascript", "python", "python-2.7" ]
Insert space between characters regex
38,998,547
<p>I'm very new to regex, and i'm trying to find instances in a string where there exists a word consisting of either the letter <code>w</code> or <code>e</code> followed by 2 digits, such as <code>e77</code> <code>w10</code> etc.</p> <p>Here's the regex that I currently have, which I think finds that (correct me if i...
-2
2016-08-17T13:49:15Z
38,998,838
<p>Your regex needs to just look like this:</p> <pre><code>([ew])(\d{2}) </code></pre> <p>if you want to only match specifically 2 digits, or</p> <pre><code>([ew])(\d{1,2}) </code></pre> <p>if you also want to match single digits like <code>e4</code></p> <p>The brackets are called capturing groups and could be <a ...
4
2016-08-17T13:59:45Z
[ "python", "regex" ]
Insert space between characters regex
38,998,547
<p>I'm very new to regex, and i'm trying to find instances in a string where there exists a word consisting of either the letter <code>w</code> or <code>e</code> followed by 2 digits, such as <code>e77</code> <code>w10</code> etc.</p> <p>Here's the regex that I currently have, which I think finds that (correct me if i...
-2
2016-08-17T13:49:15Z
38,998,839
<p>This is what you're after:</p> <pre><code>import re print(re.sub(r'([ew])(\d{1,2})', r'\g&lt;1&gt; \g&lt;2&gt;', 'hello e77 world')) </code></pre>
1
2016-08-17T13:59:54Z
[ "python", "regex" ]
Pandas or Numpy, searching, editing and extracting data
38,998,836
<p>Few weeks ago I started to study python in order to write a programme,<br> at the moment I try to extract some information from a file, it looks like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html ...
1
2016-08-17T13:59:39Z
39,000,690
<p>Try using this line for reading lines C1 to H11 with options to skip first 11 rows, read 12 lines and specify the extents of fixed-width fields of each line.</p> <pre><code>dt =pandas.read_fwf ("ga1.01.in", header =None, skiprows=11, nrows=12, colspecs=[(0,5), (12,35), (36,61),(62,91)]) </code></pre>
0
2016-08-17T15:26:37Z
[ "python", "pandas", "numpy", "scipy", "full-text-search" ]
How can I record a sound and play it back after a user-defined delay in Python?
38,998,920
<p>I'm looking for a Python's code that would record a sound and play it back after a certain delay (for example 10 seconds). In other words, I would like to constantly hear (on my headphones) what's going on outside, but with a certain delay.</p> <p>I found a Python script on GitHub (<a href="https://gist.github.com/...
-2
2016-08-17T14:03:43Z
39,231,229
<p>Here is an example using <code>sounddevice</code> , although you can do it using other <code>audio/sound</code> modules as well.</p> <p>Below example records audio from microphone for <code>#seconds</code> as per variable <code>duration</code> which you can modify as per your requirements. Same contents are played ...
1
2016-08-30T15:12:56Z
[ "python", "audio", "wav", "wave", "pyaudio" ]
Send value of variable that is in a loop from one script to another script
38,998,988
<p>I've been fiddling with sending a variable from one script to another and have done some basic things pretty easily, but I have gotten stuck and was hoping to get some input.</p> <p>This is my script1.py</p> <pre><code>import time x = 0 while x &lt; 100: x = x+1 time.sleep(1) </code></pre> <p>This is my ...
0
2016-08-17T14:06:45Z
38,999,199
<p>main.py</p> <pre><code>from subprocess import Popen, PIPE import sys p = Popen(['py', 'client.py'], stdout=PIPE) while True: o = p.stdout.read(1) if o: sys.stdout.write(o.decode('utf-8')) sys.stdout.flush() print '*' else: break </code></pre> <p>client.py</p> <pre><code>import...
0
2016-08-17T14:15:54Z
[ "python" ]
Send value of variable that is in a loop from one script to another script
38,998,988
<p>I've been fiddling with sending a variable from one script to another and have done some basic things pretty easily, but I have gotten stuck and was hoping to get some input.</p> <p>This is my script1.py</p> <pre><code>import time x = 0 while x &lt; 100: x = x+1 time.sleep(1) </code></pre> <p>This is my ...
0
2016-08-17T14:06:45Z
39,005,070
<p>I finally got it to work. Thanks to going back and forth with Vadim, I was able to learn how some of this stuff works. Below is what my code is.</p> <p>script1.py:</p> <pre><code>import sys, time x=0 while x&lt;10: print(x) sys.stdout.flush() x = x+1 time.sleep(1) </code></pre> <p>script2.py:</p> ...
0
2016-08-17T19:45:49Z
[ "python" ]
Doing combination of row entries in python
38,998,997
<p>I have a csv with data similar to </p> <pre><code>a,b b,c c,d </code></pre> <p>I am working on a script which does combination (math) operation on this list taking input from each row and printing it to stdout. like below</p> <pre><code>a,b;b,c a,b;c,d b,c;c,d </code></pre> <p>Here is what I am trying:</p> <pre...
0
2016-08-17T14:07:14Z
38,999,425
<p>Try below. Why are you doing this result thing ? </p> <pre><code>import csv import sys import sys from itertools import combinations f = open("d.csv", 'rt') reader = csv.reader(f) for row in reader: combine = combinations(row, 2) for i in list(combine): print i </code></pre>
0
2016-08-17T14:26:58Z
[ "python", "csv" ]
Doing combination of row entries in python
38,998,997
<p>I have a csv with data similar to </p> <pre><code>a,b b,c c,d </code></pre> <p>I am working on a script which does combination (math) operation on this list taking input from each row and printing it to stdout. like below</p> <pre><code>a,b;b,c a,b;c,d b,c;c,d </code></pre> <p>Here is what I am trying:</p> <pre...
0
2016-08-17T14:07:14Z
39,001,108
<p>You are trying to do three different things all at once. Because you have having trouble, it follows that you should split them up into separate tasks, and figure out each part.</p> <p>First, you want to read the csv file in an unusual way. Second, you want to take combinations. Third, you want to print each combin...
0
2016-08-17T15:48:11Z
[ "python", "csv" ]
Incremental Door Pass Riddle - Only Square Positions Open
38,999,011
<p>There are hundred doors, all closed to start with, a robot makes 100 passes, such that on every pass it increments by the next starting token. Thus,</p> <pre><code>1, 2, 3,..... 2, 4, 6, 8,.... 3, 6, 9, 11,.... 4, 8, 12, 16,.... ....... 100 </code></pre> <p>Every time it visits a door it switches from its current ...
0
2016-08-17T14:07:38Z
38,999,044
<p>Factorize the numbers - each factor indicates the 'pass' through which the door is open/closed. Square numbers have odd numbers of factors (9 = 1,3 [twice],9). Everything else has an even number of factors</p>
4
2016-08-17T14:09:28Z
[ "python", "math" ]
execute a python script in django webpage
38,999,015
<p>I have a python script which process text, i want to create webpages with django and then django call the python script to execute it.</p> <p>Here an Example for my case:</p> <p>There is an input text in the web page, when we click in the button, the script take the input text, process it and return the result in...
-2
2016-08-17T14:07:49Z
38,999,236
<ol> <li><p>Create a form with a text input, like this:</p> <pre><code>&lt;form action="{% url "hello" %}" method="post"&gt; {% csrf_token %} &lt;input name="hiya"&gt; &lt;input type="submit"&gt; &lt;/form&gt; </code></pre></li> <li><p>Route the <code>hello</code> URL in <code>urls.py</code>:</p> <pre><code>fro...
4
2016-08-17T14:17:43Z
[ "python", "django", "django-views" ]
Second matplotlib x-axis related to the first one : wrong tick position
38,999,021
<p>I would like to add a second x-axis to a matplotlib plot, not to add a second plot, but to add labels linked to the first axis. The answers in this <a href="http://stackoverflow.com/questions/10514315/how-to-add-a-second-x-axis-in-matplotlib">question</a> somehow fail to adress a problem in the bounds of the second ...
0
2016-08-17T14:08:08Z
39,002,068
<p>I believe your are getting unexpected results because you are forcing the x-ticks and the x-tick-labels on the second axis to be something predefined. No matter what you put as x-ticks on the second axis they will always be labeled by: <code>ax2.set_xticklabels(np.log10(second_ticks))</code>. Instead, update the x...
1
2016-08-17T16:41:02Z
[ "python", "matplotlib" ]
How to save certain but also multiple words from a string into a variable?
38,999,037
<p>If I have a string that is like this "Hello everyone Thank you for helping me"</p> <p>Is there any python command that is easy to use that can generate a variable (lets say var) that contains the string "Hello Thank you for helping" based on the numbered order of the words? For example, I want to generate this stri...
-1
2016-08-17T14:09:07Z
38,999,204
<p>You can use a <code>split</code>, followed by a <code>list comprehension</code>, and finally a <code>join</code> like so:</p> <pre><code>&gt;&gt;&gt; s = "Hello everyone Thank you for helping me" &gt;&gt;&gt; " ".join([x for i,x in enumerate(s.split()) if i not in (1,6)]) 'Hello Thank you for helping' </code></pre>...
0
2016-08-17T14:16:13Z
[ "python" ]
How to save certain but also multiple words from a string into a variable?
38,999,037
<p>If I have a string that is like this "Hello everyone Thank you for helping me"</p> <p>Is there any python command that is easy to use that can generate a variable (lets say var) that contains the string "Hello Thank you for helping" based on the numbered order of the words? For example, I want to generate this stri...
-1
2016-08-17T14:09:07Z
38,999,209
<p>Based just on what you've provided, to get the, if existing, 1st/3rd/4th/5th/6th words all saved to one var and not a list, you would use</p> <pre><code>string1 = 'Hello everyone Thank you for helping me' var = ' '.join([string1.split(' ')[i] for i in range(len(string1.split())) if i != 1 and i &lt; 6]) </code></pr...
0
2016-08-17T14:16:22Z
[ "python" ]
How to save certain but also multiple words from a string into a variable?
38,999,037
<p>If I have a string that is like this "Hello everyone Thank you for helping me"</p> <p>Is there any python command that is easy to use that can generate a variable (lets say var) that contains the string "Hello Thank you for helping" based on the numbered order of the words? For example, I want to generate this stri...
-1
2016-08-17T14:09:07Z
38,999,240
<p>Why not </p> <pre><code>x="Hello everyone Thank you for helping me".split() del x[6] #throw away seventh word del x[1] #throw away second word s=" ".join(x) </code></pre> <p>?</p>
1
2016-08-17T14:18:11Z
[ "python" ]
Django Test -- Unable to drop and recreate test database
38,999,203
<p>I am running Django 1.9, Postgres 9.5.1 on Mac OS X</p> <p>When I run <code>/manage.py test --settings=myproj.settings.local</code></p> <p>I get :</p> <pre><code>Creating test database for alias 'default'... Creating test database for alias 'userlocation'... Got an error creating the test database: database "test...
2
2016-08-17T14:16:10Z
39,000,107
<p><code>sudo /etc/init.d/postgresql restart</code> may be a restart will solve this issue</p>
1
2016-08-17T14:58:38Z
[ "python", "django", "postgresql", "postgis" ]
How to simulate saturations and thresholds with Scipy?
38,999,317
<p>how to simulate saturations and thresholds with scipy?</p> <p>I precise my question I want to simulate with scipy a system like the one described by the block diagram below. If the system had only linear transfer functions, there would be no problem, but here I have a non-linear block, a saturation (it could there ...
-7
2016-08-17T14:22:05Z
39,187,861
<p>You could try <a href="http://pythonhosted.org/bms/getting_started.html" rel="nofollow">Steven Masfaraud's block module simulator (BMS)</a>. As of August 2016 it has nonlinear block elements for Saturation, Coulomb, Dead Zone, and Hysteresis. Here's <a href="https://github.com/masfaraud/BMSpy/blob/master/examples/se...
1
2016-08-28T03:54:14Z
[ "python", "scipy" ]
Extract string within parentheses - PYTHON
38,999,344
<p>I have a string "Name(something)" and I am trying to extract the portion of the string within the parentheses! </p> <p>Iv'e tried the following solutions but don't seem to be getting the results I'm looking for. </p> <pre><code>n.split('()') name, something = n.split('()') </code></pre>
0
2016-08-17T14:23:25Z
38,999,572
<p>You can use a simple regex to catch everything between the parenthesis:</p> <pre><code>&gt;&gt;&gt; s = 'Name(something)' &gt;&gt;&gt; re.search('\(([^)]+)', s).group(1) 'something' </code></pre> <p>The regex matches the first "(", then it matches everything that's <em>not</em> a ")":</p> <ul> <li><code>\(</code>...
3
2016-08-17T14:33:41Z
[ "python", "string", "split", "extract" ]
Extract string within parentheses - PYTHON
38,999,344
<p>I have a string "Name(something)" and I am trying to extract the portion of the string within the parentheses! </p> <p>Iv'e tried the following solutions but don't seem to be getting the results I'm looking for. </p> <pre><code>n.split('()') name, something = n.split('()') </code></pre>
0
2016-08-17T14:23:25Z
38,999,578
<p>You can use split as in your example but this way</p> <pre><code>val = s.split('(', 1)[1].split(')')[0] </code></pre> <p>or using regex</p>
0
2016-08-17T14:34:03Z
[ "python", "string", "split", "extract" ]
Extract string within parentheses - PYTHON
38,999,344
<p>I have a string "Name(something)" and I am trying to extract the portion of the string within the parentheses! </p> <p>Iv'e tried the following solutions but don't seem to be getting the results I'm looking for. </p> <pre><code>n.split('()') name, something = n.split('()') </code></pre>
0
2016-08-17T14:23:25Z
38,999,682
<p>You can use <code>re.match</code>:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; s = "name(something)" &gt;&gt;&gt; na, so = re.match(r"(.*)\((.*)\)" ,s).groups() &gt;&gt;&gt; na, so ('name', 'something') </code></pre> <p>that matches two <code>(.*)</code> which means anything, where the second is between par...
0
2016-08-17T14:38:54Z
[ "python", "string", "split", "extract" ]
Using a python webserver
38,999,349
<p>I am looking for a web server, where I can upload files and download files from Ubuntu to Windows and the vice versa. I've builded a web server with Python and I share my folder in Ubuntu and download the files in this folder at Windows. Now I want to look up every millisecond if there is a new file and download thi...
-2
2016-08-17T14:23:36Z
38,999,734
<p>There are many ways to synchronise folders, even remote. If you need to stick with the python server approach for some reason, look for file system events libraries to trigger your upload code (for example <a href="https://pypi.python.org/pypi/watchdog" rel="nofollow" title="watchdog">watchdog</a>). But if not, it m...
0
2016-08-17T14:41:00Z
[ "python", "http", "webserver" ]
Execute flask-SQLAlchemy subquery
38,999,534
<p>I want to execute the following subquery in flask-SQLAlchemy but don't know how:</p> <pre><code>SELECT * FROM ( SELECT * FROM `articles` WHERE publisher_id = "bild" ORDER BY date_time DESC LIMIT 10 ) AS t ORDER BY RAND( ) LIMIT 2 </code></pre> <p>I know I can build the query as:</p> ...
1
2016-08-17T14:32:08Z
39,001,648
<p>You can use <a href="http://docs.sqlalchemy.org/en/rel_1_0/orm/query.html#sqlalchemy.orm.query.Query.select_entity_from" rel="nofollow">select_entity_from</a></p> <pre><code>qry = db.session.query(Article).select_entity_from(subq).order_by(func.rand()).limit(2) </code></pre> <p>or <a href="http://docs.sqlalchemy.o...
0
2016-08-17T16:16:13Z
[ "python", "mysql", "sqlalchemy", "flask-sqlalchemy" ]
Change pagination based on user type with django rest framework
38,999,535
<p>I try to set the pagination of my WebAPI based on the status of a User. If the user <code>is_anonymous</code> he should not be able to set the page size with a query parameter. I try to do this with one view class. I could do it with two different view classes and limit the access to one of them, but I think this is...
0
2016-08-17T14:32:08Z
38,999,960
<p>The problem is: <code>self._paginator</code> needs a paginator class instance, not a class itself</p> <p>It should be <code>AnonymousPaginator()</code>and <code>RegisteredPaginator()</code>, not <code>AnonymousPaginator</code>, <code>RegisteredPaginator</code>.</p> <pre><code> if self.request.user.is_anony...
2
2016-08-17T14:52:12Z
[ "python", "django", "pagination", "django-rest-framework" ]
Update webpage after receiving POST request
38,999,552
<p>I've to tried to find out similar issue in stack overflow, but I couldn't. I am using python requests library to send POST request to my personal domain name www.****.com. </p> <pre><code>r = requests.post('http://www.****.com', data = {'temp1':"Anum"}) print r.text </code></pre> <p>When I run the script, the r.t...
0
2016-08-17T14:32:52Z
38,999,640
<p>I understand you want the python script to send a variable, which will be visible to other visitors of the website? You need to store the value which you recieve from python somewhere, like in a database. Then you can read that value and show it to the visitor.</p>
1
2016-08-17T14:37:15Z
[ "php", "python", "http-post" ]
Loading cookies in JSON format into requests
38,999,554
<p>I've got some cookies sent over from a client to allow me to log into his server programatically without needing the credentials.</p> <p>I'm using the requests package to make HTTP requests to his server. The problem is the cookies he has sent are all in JSON format and I can't seem to find any way to load these co...
1
2016-08-17T14:32:54Z
38,999,760
<p>Use <a href="http://docs.python-requests.org/en/master/api/#requests.utils.cookiejar_from_dict" rel="nofollow">requests.utils.cookiejar_from_dict(cookie_dict)</a> to create a cookie jar from a dict:</p> <pre><code>jar = requests.utils.cookiejar_from_dict(cookie_dict) session = request.Session() session.cookies = ja...
0
2016-08-17T14:42:14Z
[ "python" ]
Crontab - run command random time
38,999,597
<p>I have created a cron job in which it runs a command within random value (Example 10 mins) at 11pm everyday. I found this example online but I can not find reference. </p> <p>What I have that doesn't work</p> <pre><code>SHELL=/bin/bash PATH=/usr/bin:$PATH LOCAL_CONFIG_DIR=/user/folder 0 11 * * * sleep $(...
1
2016-08-17T14:34:51Z
38,999,776
<p>I'm not really good with bash, but You surely can implement sleep inside your python scipt.</p> <pre><code>import random import time time.sleep(random.randint(1, 10)*60) #Your actual script goes here </code></pre>
2
2016-08-17T14:43:11Z
[ "python", "random", "cron", "crontab" ]
Format the index in connection with to_html in a Pandas DataFrame
38,999,600
<p>I was hoping that it was possible to format the index (column) directly in connection with output to HTML with the to_html() in the Pandas DataFrame?</p> <p>Something like:</p> <pre><code>df = DataFrame([[1, 2]], index=['a'], columns=['A', 'B']) print(df.to_html(formatters={ 'index': lambda elem: '&lt;a href="...
1
2016-08-17T14:35:01Z
38,999,706
<p>you should use <code>__index__</code> instead of <code>index</code>:</p> <pre><code>print(df.to_html(formatters={ '__index__': lambda elem: '&lt;a href="example.com/{}"&gt;{}&lt;/a&gt;'.format(elem, elem)}, escape=False)) </code></pre> <p>Source: <a href="https://github.com/pydata/pandas/pull/2409" rel="nofoll...
1
2016-08-17T14:39:54Z
[ "python", "pandas" ]
Python3 Tracking movement with opencv2
38,999,617
<p>So, I've downloaded this source code from <a href="http://www.pyimagesearch.com/2015/05/25/basic-motion-detection-and-tracking-with-python-and-opencv/" rel="nofollow">http://www.pyimagesearch.com/2015/05/25/basic-motion-detection-and-tracking-with-python-and-opencv/</a> :</p> <pre><code> # import the necessary p...
0
2016-08-17T14:35:50Z
39,009,340
<p>try adding [-2:] behind </p> <p>(cnts, _) = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[-2:]</p>
0
2016-08-18T03:03:14Z
[ "python", "opencv" ]
how to use config in flask extensions when use factory pattern in flask?
38,999,702
<p>I use factory pattern and flask extensions such as flask-admin during the development of web application. I want to load some configurations in flask-admin when the app haven't created. So i use the <code>current_app.config["SOME_CONFIG"]</code> to get the config value.But i got the <code>Working outside of applicat...
0
2016-08-17T14:39:40Z
39,000,316
<p>Your application is still in the setup state during the create_app function (see <a href="http://flask.pocoo.org/docs/0.11/appcontext/" rel="nofollow">http://flask.pocoo.org/docs/0.11/appcontext/</a>). During the setup state you need to have a reference to the application object to access it, you can't use current_a...
2
2016-08-17T15:07:34Z
[ "python", "flask" ]
how to use config in flask extensions when use factory pattern in flask?
38,999,702
<p>I use factory pattern and flask extensions such as flask-admin during the development of web application. I want to load some configurations in flask-admin when the app haven't created. So i use the <code>current_app.config["SOME_CONFIG"]</code> to get the config value.But i got the <code>Working outside of applicat...
0
2016-08-17T14:39:40Z
39,006,238
<p>All you need to do is set it up like the following.</p> <pre><code># config.py class Config(object): ADMIN_NAME = 'admin' # __init__.py from flask import Flask from flask_admin import Admin # initiate all extensions here admin = Admin(template='bootstrap2') def create_app(config): app = Flask(__name__) ...
0
2016-08-17T21:02:37Z
[ "python", "flask" ]
Python - RPG name maker using lists
39,000,032
<p>I am trying to make a 3 part name generator in python for an RPG game. I have a 2 dimensional array in order to combine 3 parts of a name:</p> <pre><code>name = [["Raan","Feim","Od","Yol","Dur"]["Mir","Zii","Ah","Toor","Neh"][ "Tah","Gron","Viing","Shul","Viir"]] </code></pre> <p>However, when I run it, I get th...
1
2016-08-17T14:55:04Z
39,000,197
<p>You need commas between your lists:</p> <pre><code>name = [["Raan","Feim","Od","Yol","Dur"], ["Mir","Zii","Ah","Toor","Neh"], [ "Tah","Gron","Viing","Shul","Viir"]] </code></pre>
1
2016-08-17T15:02:18Z
[ "python" ]
Python - RPG name maker using lists
39,000,032
<p>I am trying to make a 3 part name generator in python for an RPG game. I have a 2 dimensional array in order to combine 3 parts of a name:</p> <pre><code>name = [["Raan","Feim","Od","Yol","Dur"]["Mir","Zii","Ah","Toor","Neh"][ "Tah","Gron","Viing","Shul","Viir"]] </code></pre> <p>However, when I run it, I get th...
1
2016-08-17T14:55:04Z
39,000,218
<p>wrong list syntax. This works:</p> <pre><code>import random name = [["Raan","Feim","Od","Yol","Dur"],["Mir","Zii","Ah","Toor","Neh"],["Tah","Gron","Viing","Shul","Viir"]] print (" ".join([random.choice(nl) for nl in name])) </code></pre>
2
2016-08-17T15:03:07Z
[ "python" ]
Python - RPG name maker using lists
39,000,032
<p>I am trying to make a 3 part name generator in python for an RPG game. I have a 2 dimensional array in order to combine 3 parts of a name:</p> <pre><code>name = [["Raan","Feim","Od","Yol","Dur"]["Mir","Zii","Ah","Toor","Neh"][ "Tah","Gron","Viing","Shul","Viir"]] </code></pre> <p>However, when I run it, I get th...
1
2016-08-17T14:55:04Z
39,000,283
<p>You need commas inbetween each list.</p> <pre><code>name = [["Raan","Feim","Od","Yol","Dur"],["Mir","Zii","Ah","Toor","Neh"],[ "Tah","Gron","Viing","Shul","Viir"]] </code></pre> <p>then to get a random name use:</p> <pre><code>from random import randint print (name[randint(0,2)][randint(0,4)]) </code></pre> <p>a...
2
2016-08-17T15:06:08Z
[ "python" ]
How can I set the colors per value when coloring plots by a DataFrame column?
39,000,115
<p>In matplotlib (in particular, pandas), how can I map specific colors to values of a column that I use for differentiating colors?</p> <p>Let's say I have a column ...</p> <pre><code>&gt;&gt; df["country"] DE EN US DE </code></pre> <p>... and now I'd like to plot values from the DataFrame where each country is col...
-1
2016-08-17T14:58:53Z
39,003,608
<p>You can do so by specifying the dictionary mapping of hue levels to corresponding <code>matplotlib</code> colors in the <a href="https://stanford.edu/~mwaskom/software/seaborn/tutorial/color_palettes.html" rel="nofollow"><code>palette</code></a> argument of a <a href="https://stanford.edu/~mwaskom/software/seaborn/t...
2
2016-08-17T18:11:23Z
[ "python", "pandas", "matplotlib", "colors", "seaborn" ]
How to display two different outputs in python console
39,000,250
<p>Is there a way to split the output console? I would like to display one section on top (the main program) and the bottom part will display a progress bar for example.</p> <p>(excuse my horrible design skills)</p> <p><a href="http://i.stack.imgur.com/pXcbD.png" rel="nofollow"><img src="http://i.stack.imgur.com/pXcb...
1
2016-08-17T15:04:56Z
39,002,750
<p>If there is one python app that outputs - using curses library as @Rawing suggested: <a href="https://docs.python.org/3.5/howto/curses.html" rel="nofollow">https://docs.python.org/3.5/howto/curses.html</a> . It's prebuilt and at hand.</p> <p>If there are more apps that output data there are several ways to do so. F...
0
2016-08-17T17:19:06Z
[ "python", "split", "terminal" ]
Two y axes for a single plot
39,000,269
<p>I'm trying to create a plot with two Y axes (left and right) for the same data, that is, one is a scaled version of the other. I would like also to preserve the tick positions and grid positions, so the grid will match the ticks at both sides.</p> <p>I'm trying to do this by plotting twice the same data, one as-is ...
0
2016-08-17T15:05:37Z
39,000,482
<p>Not sure if you can achieve this without getting ugly-looking numbers on your normalized axis. But if that doesn't bother you, try adding this to your code:</p> <pre><code>ax2.set_ylim([ax1.get_ylim()[0]/max(y1),ax1.get_ylim()[1]/max(y1)]) ax2.set_yticks(ax1.get_yticks()/max(y1)) </code></pre> <p>Probably not the ...
0
2016-08-17T15:16:10Z
[ "python", "matplotlib" ]
Emit new style PyQt signals with arbitrary signature
39,000,286
<p>I am creating a PyQt GUI for an experimental setup. This will involve computationally heavy operations so I am aiming for an architecture based on the multiprocessing module and inspired from <a href="http://stackoverflow.com/a/30048847/1291711">this answer</a>. </p> <p>The QMainWindow creates</p> <ol> <li>child P...
1
2016-08-17T15:06:27Z
39,044,391
<p>The <a href="http://pyqt.sourceforge.net/Docs/PyQt4/new_style_signals_slots.html" rel="nofollow">new-style signal and slot syntax</a> requires that signals are pre-defined as class attributes on a class that inherits from <code>QObject</code>. When the class is instantiated, a bound-signal object is automatically cr...
1
2016-08-19T17:05:07Z
[ "python", "python-3.x", "pyqt4", "python-multiprocessing", "qt-signals" ]
How to send the encrypted data to the client?
39,000,296
<p>Here is my client code.</p> <pre><code>import socket, pickle,time from encryption import * def Main(): host = '127.0.0.1' port = 5006 s = socket.socket() s.connect((host, port)) m= encryption() pri_key,pub_key,n=m.generating_keys(1) filename = input("Filename? -&gt; ") if filenam...
-1
2016-08-17T15:06:55Z
39,014,705
<p>On the server side, change the code to:</p> <pre><code>while bytesToSend != s: bytesToSend = f.read(1024) length = len(bytesTosend) leng = length.to_bytes(4, 'little') sock.sendall(leng) msg = m.encrypt(bytesToSend, dat[1], dat[2]) k = msg.bit_length() if k % 8 &gt;= 1 : k = k /...
0
2016-08-18T09:34:32Z
[ "python", "sockets", "python-3.x", "encryption" ]
How to send the encrypted data to the client?
39,000,296
<p>Here is my client code.</p> <pre><code>import socket, pickle,time from encryption import * def Main(): host = '127.0.0.1' port = 5006 s = socket.socket() s.connect((host, port)) m= encryption() pri_key,pub_key,n=m.generating_keys(1) filename = input("Filename? -&gt; ") if filenam...
-1
2016-08-17T15:06:55Z
39,023,618
<p>It is rather difficult to check your code without seeing the <code>encryption</code> module referenced in your code. With such functionality absent, testing to find out where the problem is becomes impossible. As such, the following programs are provided along with the implementation of another encryption module.</p...
0
2016-08-18T16:50:48Z
[ "python", "sockets", "python-3.x", "encryption" ]
Openerp - how to update filed with write()
39,000,306
<p>I have this function and up to last update query it works fine. What I tried to do is update the current value of 'number_of_days_temp' field by adding 0.5 to it. But <code>cr.execute</code> doesn't update the field and just return the same old value. Please help me with this with fixing the <code>cr.execute</code> ...
0
2016-08-17T15:07:15Z
39,002,357
<p>Here is the little optimized version of your method</p> <pre><code>def allocate_on_probations(self, cr, uid, ids, tl=False, context=None): result = {} emp_obj = self.pool.get('hr.employee') emp_ids = emp_obj.search(cr, uid, [('current_status','=','active')], context=context) if emps: for em...
1
2016-08-17T16:56:16Z
[ "python", "python-2.7", "openerp", "openerp-7" ]
Fit t distribution using scipy with predetermined mean and std(loc & scale)?
39,000,357
<p>How can I fit t distribution using <code>scipy.stats.t.fit()</code> with predetermined mean and std?</p> <p>The question is, I have a standardized dataset, with <code>mean=0</code> and <code>std=1</code>, I only want to get <code>df</code> of t distribution. But when I do <code>scipy.stats.t.fit(data)</code>, it ou...
2
2016-08-17T15:09:36Z
39,001,308
<p>In the call to <code>.fit()</code>, use the arguments <code>floc=0</code> and <code>fscale=1</code> to fix these parameters.</p> <p>Here's an example. First, import <code>t</code> and generate a sample to work with:</p> <pre><code>In [24]: from scipy.stats import t In [25]: np.random.seed(123) In [26]: sample =...
1
2016-08-17T15:57:45Z
[ "python", "scipy" ]
Handling web-log files as a CSV with Python
39,000,374
<p>I'm using the Python 3 CSV Reader to read some web-log files into a namedtuple. I have no control over the log file structures, and there are varying types.</p> <p>The delimiter is a space ( ), the problem is that some log file formats place a space in the timestamp, as Logfile 2 below. The CSV reader then reads th...
2
2016-08-17T15:10:33Z
39,000,418
<p>This will do, you need to use a regex in place of sep.<br> This for example will parse NGinx log files into a <code>pandas.Dataframe</code>:</p> <pre><code>import pandas as pd df = pd.read_csv(log_file, sep=r'\s(?=(?:[^"]*"[^"]*")*[^"]*$)(?![^\[]*\])', engine='python', use...
1
2016-08-17T15:12:58Z
[ "python", "python-3.x", "csv" ]
converting time into seconds+mili seconds
39,000,429
<p>I have a .csv file which contains a column "Time" which comprises of data in the format "01/02/2016 08:01:29;12", So now I want to separate this into two columns. Can anyone suggest me how to do that in python. </p> <p>I am successfull in splitting the columns, but now i want to convert the time part(08:01:29;12) i...
0
2016-08-17T15:13:26Z
39,000,717
<p>Assuming that ";12" in your date are microseconds, and that you want to separate date and time into two columns (if I understood correctly) it would be the best to convert str to datetime:</p> <pre><code>data = "01/02/2016 08:01:29;12" actual_date = datetime.datetime.strptime(data, "%d/%m/%Y %H:%M:%S;%f") </code></...
1
2016-08-17T15:28:02Z
[ "python", "pandas" ]
Let printed lines disapear in python
39,000,491
<p>How can I tell my program to delete the previous text if <kbd>Enter</kbd> was pressed?</p> <pre><code>print('Information: \n ' ) input('Press Enter to continue.') </code></pre> <p>So if the user read the Info and presses <kbd>Enter</kbd> the text above still remains. </p> <p>How can I remove it?</p>
0
2016-08-17T15:16:37Z
39,000,621
<p>Following script can clear your screen</p> <pre><code>import subprocess as sp sp.call('cls',shell=True) </code></pre>
0
2016-08-17T15:22:49Z
[ "python" ]
Custome delimiter file upload using pyspark function not working
39,000,674
<p>I am using below function to upload custom delimiter file.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>from pyspark.sql.types import * from pyspark.sql import * ...
1
2016-08-17T15:25:55Z
39,089,894
<p>Would recommend trying with a smaller dataset or couple of rows. 2 GB data-file may have some data anomalies which may be causing this issue.</p>
0
2016-08-22T22:52:09Z
[ "python", "apache-spark", "pyspark", "windows-azure-storage", "spark-dataframe" ]
Find the sum of values within the values of a nested Dictionary
39,000,681
<p>This is a question based on <em>nested</em> dictionaries.</p> <p>We are given a nested dictionary wherein in the outer dictionary, the name of the match is mentioned and the value for the matches is another dictionary with it's key and values respectively and the name of the function is <code>orangecap(d)</code> w...
2
2016-08-17T15:26:12Z
39,000,852
<p>Something like this should work:</p> <pre><code>def orangecap(d): players = {} for match, scores in d.iteritems(): for player, score in scores.iteritems(): if player not in players: players[player] = score else: players[player] += score ret...
1
2016-08-17T15:35:24Z
[ "python", "dictionary" ]
Find the sum of values within the values of a nested Dictionary
39,000,681
<p>This is a question based on <em>nested</em> dictionaries.</p> <p>We are given a nested dictionary wherein in the outer dictionary, the name of the match is mentioned and the value for the matches is another dictionary with it's key and values respectively and the name of the function is <code>orangecap(d)</code> w...
2
2016-08-17T15:26:12Z
39,000,892
<p>Here's a possible solution:</p> <pre><code>from collections import defaultdict data = { 'match1': {'player1': 57, 'player2': 38}, 'match2': {'player3': 9, 'player1': 42}, 'match3': {'player2': 41, 'player4': 63, 'player3': 91} } def orangecap(d): result = defaultdict(int) for k, v in data.ite...
0
2016-08-17T15:37:36Z
[ "python", "dictionary" ]
Find the sum of values within the values of a nested Dictionary
39,000,681
<p>This is a question based on <em>nested</em> dictionaries.</p> <p>We are given a nested dictionary wherein in the outer dictionary, the name of the match is mentioned and the value for the matches is another dictionary with it's key and values respectively and the name of the function is <code>orangecap(d)</code> w...
2
2016-08-17T15:26:12Z
39,001,012
<p>This is a slightly modified answer taken from a <em>previous</em> answer of <strong><a href="http://stackoverflow.com/a/38959235/6320655">mine</a></strong>.</p> <pre><code>def find_totals(d): total = {} for match, results in d.items(): for player, score in results.items(): total[player] ...
4
2016-08-17T15:43:37Z
[ "python", "dictionary" ]
Find the sum of values within the values of a nested Dictionary
39,000,681
<p>This is a question based on <em>nested</em> dictionaries.</p> <p>We are given a nested dictionary wherein in the outer dictionary, the name of the match is mentioned and the value for the matches is another dictionary with it's key and values respectively and the name of the function is <code>orangecap(d)</code> w...
2
2016-08-17T15:26:12Z
39,002,265
<p>Because someone had to do it... Here's a one-liner. </p> <p>EDIT: no longer a one liner because I realised the player was also meant to be returned. So it's now a one-liner in a function.</p> <pre><code>def total_score(*, match_results: dict, player_name: str): return player_name, sum(score for player_scores i...
0
2016-08-17T16:51:07Z
[ "python", "dictionary" ]
Python Simple Class not Recognized
39,000,686
<pre><code>class Example: values=None s1=Example s1.values.append(1) s1.values.append(2) for x in s1.values: print x </code></pre> <p>Using Python 2.7</p> <p>Output:</p> <pre><code>line 8, in Example s1=Example NameError: name 'Example' is not defined enter code here </code></pre> <p>New to python and...
-3
2016-08-17T15:26:26Z
39,001,148
<p>Here's a working example for you:</p> <pre><code>class Example: def __init__(self): self.values = [] s1 = Example() s1.values.append(1) s1.values.append(2) for x in s1.values: print x </code></pre> <p>Also, I'd recommend you to follow some available <a href="https://docs.python.org/2/tutorial/" ...
2
2016-08-17T15:50:03Z
[ "python" ]
split list by delimited in python
39,000,718
<p>From a dict/list, how to split the list by \n. Eg:</p> <pre><code>In [1]: d = {'key1': 'value1\n value2 \n value3\n'} In [2]: d.values() Out[2]: ['value1\n value2 \n value3\n'] </code></pre> <p>Desired output:</p> <pre><code>['value1', 'value2 ', 'value3'] </code></pre> <p>I looked at existing examples b...
-4
2016-08-17T15:28:07Z
39,000,781
<p>Here you go:</p> <pre><code>d['key1'].split('\n') </code></pre>
0
2016-08-17T15:31:20Z
[ "python", "list", "split" ]
split list by delimited in python
39,000,718
<p>From a dict/list, how to split the list by \n. Eg:</p> <pre><code>In [1]: d = {'key1': 'value1\n value2 \n value3\n'} In [2]: d.values() Out[2]: ['value1\n value2 \n value3\n'] </code></pre> <p>Desired output:</p> <pre><code>['value1', 'value2 ', 'value3'] </code></pre> <p>I looked at existing examples b...
-4
2016-08-17T15:28:07Z
39,000,881
<p>You mean you want the values as a flat list? Something like this?</p> <pre><code>&gt;&gt;&gt; {k: [x.strip() for x in v.splitlines()] for k, v in d.iteritems()} {'key1': ['value1', 'value2', 'value3']} </code></pre>
0
2016-08-17T15:36:56Z
[ "python", "list", "split" ]
split list by delimited in python
39,000,718
<p>From a dict/list, how to split the list by \n. Eg:</p> <pre><code>In [1]: d = {'key1': 'value1\n value2 \n value3\n'} In [2]: d.values() Out[2]: ['value1\n value2 \n value3\n'] </code></pre> <p>Desired output:</p> <pre><code>['value1', 'value2 ', 'value3'] </code></pre> <p>I looked at existing examples b...
-4
2016-08-17T15:28:07Z
39,001,086
<p><strong>Python 2.x</strong></p> <pre><code>d = {'key1': 'value1\n value2 \n value3\n'} print {k: [x.strip() for x in v.splitlines()] for k, v in d.iteritems()} </code></pre> <p><strong>Python 3.x</strong></p> <pre><code>d = {'key1': 'value1\n value2 \n value3\n'} print({k: [x.strip() for x in v.splitlines()...
0
2016-08-17T15:47:01Z
[ "python", "list", "split" ]
Why Django generate new migrations file each time I use `makemigrations` command. For ImageFIeld with changed upload_path attribute
39,000,797
<p>I need to get ImageField name in <code>upload_path</code> function.<br> I tried use <code>partial</code> in ImageField definition: </p> <pre><code>class MyModel(models.Model): image = models.ImageField( upload_to=partial(image_upload_path, 'image') ) </code></pre> <p>Now I can get that string by...
0
2016-08-17T15:31:50Z
39,002,452
<p>It seems like you don't need to provide a partial in this case, but just a callable with two parameters like in <a href="https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.FileField.upload_to" rel="nofollow">this example</a> in the Django documentation.</p> <p>Django will invoke the callable ...
1
2016-08-17T17:02:21Z
[ "python", "django", "django-models" ]
Why Django generate new migrations file each time I use `makemigrations` command. For ImageFIeld with changed upload_path attribute
39,000,797
<p>I need to get ImageField name in <code>upload_path</code> function.<br> I tried use <code>partial</code> in ImageField definition: </p> <pre><code>class MyModel(models.Model): image = models.ImageField( upload_to=partial(image_upload_path, 'image') ) </code></pre> <p>Now I can get that string by...
0
2016-08-17T15:31:50Z
39,078,879
<p>I decide to build my own field: </p> <pre><code>class SorlImageField(ImageField): def __init__(self, verbose_name=None, name=None, width_field=None, height_field=None, lookup_name=None, **kwargs): self.lookup_name = lookup_name kwargs['upload_to'] = partial(image_upload_path, look...
0
2016-08-22T11:53:42Z
[ "python", "django", "django-models" ]
Modify a DBF file
39,000,886
<p>I want to modify one column in a .dpf file using Python with this library <a href="http://pythonhosted.org/dbf/" rel="nofollow">http://pythonhosted.org/dbf/</a>. <br>When I want to print out some column, it works just fine. But when I am trying to modify a column, I get error </p> <blockquote> <p>unable to modify...
1
2016-08-17T15:37:20Z
39,021,399
<p>My apologies for the state of the docs. Here are a couple options that should work:</p> <pre><code>table = dbf.Table('./path/to/file.dbf') # Process will open and close a table if not already opened for record in dbf.Process(table): record.izo = sys.argv[2] </code></pre> <p>or</p> <pre><code>with dbf.Table('...
1
2016-08-18T14:54:15Z
[ "python" ]
pandas column selection: non commutative bitwise OR when selecting on str and NaN
39,000,907
<h3>Introduction:</h3> <p>Given a dataframe, I though that the following were True:</p> <pre><code>df[(condition_1) | (condition_2)] &lt;=&gt; df[(condition_2) | (condition_1)] </code></pre> <p>as in </p> <pre><code>df[(df.col1==1) | (df.col1==2)] &lt;=&gt; df[(df.col1==2) | (df.col1==1)] </code></pre> <h3>Problem...
3
2016-08-17T15:38:26Z
39,038,706
<p>After some research, I am rather sure that this is a bug in <code>pandas</code>. I was not able to find the specific reason in their code but my conclusion is that either you should be forbidden to do the comparison at all or there is a bug in evaluating the <code>|</code> expression. You can reproduce the problem w...
1
2016-08-19T12:07:05Z
[ "python", "pandas" ]
Extracting information using XPaths
39,000,988
<p>Good afternoon dear community,</p> <p>I have finally compiled a list of working XPaths required to scrape all of the information from URL's that i need.</p> <p>I would like to ask for your suggestion, for a newbie in coding what is the best way to scrape around 50k links using only XPaths (around 100 xpaths for ea...
-2
2016-08-17T15:42:37Z
39,001,165
<p>That strongly depends on what you mean by "scraping information". What exactly do you want to mine from the websites? All major languages (certainly Java and Python that you mentioned) have good solutions for connecting to websites, reading content, parsing HTML using a DOM and using XPath to extract certain fragmen...
1
2016-08-17T15:50:59Z
[ "java", "python", "xml", "xpath", "import.io" ]
Extracting information using XPaths
39,000,988
<p>Good afternoon dear community,</p> <p>I have finally compiled a list of working XPaths required to scrape all of the information from URL's that i need.</p> <p>I would like to ask for your suggestion, for a newbie in coding what is the best way to scrape around 50k links using only XPaths (around 100 xpaths for ea...
-2
2016-08-17T15:42:37Z
39,001,191
<p>I would encourage you to use Python (I use 2.7.x) w/ Selenium. I routinely automate scraping and testing of websites with this combo (in both a headed and headless manner), and Selenium unlocks the opportunity to interact with scripted sites that do not have explicit webcalls for each and every page. </p> <p>Here...
1
2016-08-17T15:52:01Z
[ "java", "python", "xml", "xpath", "import.io" ]
match changes by words, not by characters
39,001,097
<p>I'm using <code>difflib</code>'s <code>SequenceMatcher</code> to <code>get_opcodes()</code> and than highlight the changes with <code>css</code> to create some kind of web <code>diff</code>.</p> <p>First, I set a <code>min_delta</code> so that I consider two strings different if only 3 or more characters in the who...
1
2016-08-17T15:47:36Z
39,075,165
<p><code>SequenceMatcher</code> can accept lists of <code>str</code> as input.</p> <p>You can first split the input into words, and then use <code>SequenceMatcher</code> to help you diff words. Then your colored diff would be <em>by words</em> instead of <em>by characters</em>.</p> <pre><code>&gt;&gt;&gt; def my_get_...
2
2016-08-22T08:57:08Z
[ "python", "string", "python-3.x", "diff", "difflib" ]
In Keras, If samples_per_epoch is less than the 'end' of the generator when it (loops back on itself) will this negatively affect result?
39,001,104
<p>I'm using Keras with Theano to train a basic logistic regression model.</p> <p>Say I've got a training set of 1 million entries, it's too large for my system to use the standard <code>model.fit()</code> without blowing away memory.</p> <ul> <li>I decide to use a python generator function and fit my model using <co...
0
2016-08-17T15:48:03Z
39,093,328
<p>I'm dealing some something similar right now. I want to make my epochs shorter so I can record more information about the loss or adjust my learning rate more often. </p> <p>Without diving into the code, I think the fact that <code>.fit_generator</code> works with the randomly augmented/shuffled data produced by th...
0
2016-08-23T05:53:41Z
[ "python", "machine-learning", "deep-learning", "theano", "keras" ]
Where can I find a python source file by the import?
39,001,135
<p>There is this line in a python class file, and I am trying to find the python file that defines the PeieApi</p> <pre><code>from peieapi.peieapi import PeieApi </code></pre> <p>I've recursively searched in the project folder for "class PeieApi", didn't find it.</p> <p>I've check the directory where this file is lo...
0
2016-08-17T15:49:25Z
39,009,498
<p>It was actually installed into this directory by pip when running the project installation script. I saw it showed up from the list returned by this command.</p> <pre><code>pip list </code></pre> <p>Seems if it's not in the project directory, it will be in the global python library directory, in my case on a Mac, ...
0
2016-08-18T03:22:25Z
[ "python", "import" ]
Matplotlib secondary axis with equal aspect ratio
39,001,152
<p>I'm trying to create a secondary axis to an axis with equal aspect ratio using <code>twinx()</code>, however, as can be seen in the example below, the secondary axis does not match the aspect ratio of the original.</p> <p>Is there something additional that needs to be done, or is this a bug in matplotlib?</p> <hr>...
2
2016-08-17T15:50:13Z
39,078,948
<p>Creating the host axis with <code>host_subplot</code> like in the <a href="http://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#parasiteaxes" rel="nofollow">matplotlib example</a> on parasitic axes instead of <code>fig.add_subplot</code> appears to resolve the issue. The plots now occupy the same space a...
0
2016-08-22T11:56:43Z
[ "python", "matplotlib" ]
Web Scraping Data to File with Results Separated by Commas
39,001,195
<p>I took a python class last semester and we went over web scraping for about a week. I realized that it can be very helpful in some data entry I'm doing for my job right now but am having troubles figuring it out. I am trying to get all of the model numbers for a part number on <a href="http://servicenet.dewalt.com/P...
2
2016-08-17T15:52:11Z
39,001,428
<p>In your <code>get_data</code> function, instead of focusing the on the specific data you're after, you grab <em>all</em> <code>td</code> tags that don't have a class. Instead of doing such a wide search, why not target your data specifically?</p> <p>The list of parts you're after is contained in a <code>table</cod...
0
2016-08-17T16:05:07Z
[ "python", "web-scraping", "beautifulsoup", "comma", "nonetype" ]
Web Scraping Data to File with Results Separated by Commas
39,001,195
<p>I took a python class last semester and we went over web scraping for about a week. I realized that it can be very helpful in some data entry I'm doing for my job right now but am having troubles figuring it out. I am trying to get all of the model numbers for a part number on <a href="http://servicenet.dewalt.com/P...
2
2016-08-17T15:52:11Z
39,001,527
<p>It fails because in some cells there is no link - item1.find('a') is None and so you can't get "text" property of it.</p> <p>Also you don't need to use JSON at all as you want output file to be just model numbers separated by comma).</p> <p>Here is my code:</p> <pre><code>from bs4 import BeautifulSoup import requ...
1
2016-08-17T16:10:03Z
[ "python", "web-scraping", "beautifulsoup", "comma", "nonetype" ]
Web Scraping Data to File with Results Separated by Commas
39,001,195
<p>I took a python class last semester and we went over web scraping for about a week. I realized that it can be very helpful in some data entry I'm doing for my job right now but am having troubles figuring it out. I am trying to get all of the model numbers for a part number on <a href="http://servicenet.dewalt.com/P...
2
2016-08-17T15:52:11Z
39,001,567
<p>The text you want is inside anchor inside the first td in the rows of the tbody of the <em>table</em> with the <em>id</em> <em>customerList</em>, don't grab every td available on the page, even if there was an anchor inside that has text it by no way means is it anyways related to the table or content you want.:</p>...
1
2016-08-17T16:12:15Z
[ "python", "web-scraping", "beautifulsoup", "comma", "nonetype" ]
self.env for manually defined model raise an error
39,001,201
<p>I'm trying to create country guess application for Odoo 9, based on barcode value, for this I've created following models:</p> <pre class="lang-py prettyprint-override"><code>class InstantProductTemplate(models.Model): _name = 'product.template' _inherit = 'product.template' country_of_origin = fields....
2
2016-08-17T15:52:29Z
39,001,682
<p>You cannot make a dependency from another model filed in <a href="https://www.odoo.com/documentation/8.0/reference/orm.html#openerp.api.depends" rel="nofollow"><code>@api.depends</code></a>. Decorator expects that you supply a list of <em>current</em> model fields:</p> <blockquote> <p>Each argument must be a stri...
2
2016-08-17T16:18:05Z
[ "python", "openerp", "odoo-9" ]
How to put a JSON file's content in a response
39,001,230
<p>I have a file on my computer that I'm trying to serve up as JSON from a django view.</p> <pre><code>def serve(request): file = os.path.join(BASE_DIR, 'static', 'files', 'apple-app-site-association') response = HttpResponse(content=file) response['Content-Type'] = 'application/json' </code></pre> <p>Wha...
2
2016-08-17T15:53:47Z
39,001,468
<p><code>os.path.join</code> returns a string, it's why you get a path in the content of the response. You need to read the file at that path first.</p> <h1>For a static file</h1> <p>If the file is static and on disk, you could just return it using the webserver and avoid using python and django at all. If the file n...
2
2016-08-17T16:06:48Z
[ "python", "json", "django", "file" ]
How to put a JSON file's content in a response
39,001,230
<p>I have a file on my computer that I'm trying to serve up as JSON from a django view.</p> <pre><code>def serve(request): file = os.path.join(BASE_DIR, 'static', 'files', 'apple-app-site-association') response = HttpResponse(content=file) response['Content-Type'] = 'application/json' </code></pre> <p>Wha...
2
2016-08-17T15:53:47Z
39,001,489
<p>If you feed <code>HttpResponse</code> a string a <code>content</code> you tell it to <a href="https://docs.djangoproject.com/en/1.10/ref/request-response/#id3" rel="nofollow">serve that string</a> as HTTP body:</p> <blockquote> <p><code>content</code> should be an iterator or a string. If it’s an iterator, it s...
2
2016-08-17T16:07:50Z
[ "python", "json", "django", "file" ]
How can I extract data from a file?
39,001,249
<p>I have a file data like below, I want to calculate the time difference between two line for each station (here PAR and PAY), I mean for example for PAR we are going to calculate '7 48 42.64 - 7 48 42.24' (7=hour, 48=minute, and 42.64 is second).</p> <pre><code>2006 03 20 07 47 46.7 32.314 55.843 15.5 4.5 PAR GZ I...
-1
2016-08-17T15:54:32Z
39,002,931
<p>If your lines are consistently separated by whitespace, then you can just iterate through the file to get all of the lines in a usable format and subtract whatever two lines that you want.</p> <pre><code>all_lines = open('your_file.txt', 'r').readlines() all_lines = [l.split() for l in all_lines] # Hour is index 3...
0
2016-08-17T17:30:31Z
[ "python", "python-2.7" ]
Defining external path variable for python package on installation
39,001,278
<p>If I have a Python package, <code>foo</code>, and I want a path variable that is user-defined during package installation (<code>foo.ext_path = '/Home/User_name/Data_files/foo_data'</code> or something), what is the best/recommended/most pythonic manner to accomplish this? I do not want to include the data within t...
0
2016-08-17T15:55:55Z
39,002,244
<p>Required configuration usually falls into the category of things belonging in an external configuration file. </p> <p>The package can define a configuration file path, in posix this is usually something under <code>/etc</code>, and ask that the user populate it with appropriate entries for their configuration.</p> ...
1
2016-08-17T16:50:11Z
[ "python", "packages" ]
Opencv webcam and Kivy GUI actionbar simultaneously
39,001,299
<p>Hey so I am trying to work with opencv and kivy. My code returns a class called KivyCamera which unables me to add an actionbar on the top of the screen. Is there any way that I can simultaneously add an action bar and an opencv webcam in Kivy GUI framework? Thanks. Also if you do </p> <p>def build: pass in the ...
0
2016-08-17T15:57:09Z
39,182,766
<p>(Note: I haven't worked with opencv yet and I can't find it on pypi)</p> <p>I see that your class <code>KivyCamera</code> is just a casual widget used in Kivy. What happens when you do <code>def build(self): pass</code> is, that it opens the <code>kv</code> file and finds something that can be used as a root widget...
0
2016-08-27T15:28:47Z
[ "python", "opencv", "kivy", "webcam", "kivy-language" ]
Can't finish the loop when asking for valid answers
39,001,305
<p>I have a problem with my code that I can't find the solution as well. I ask for questions that has to be valid but the loops just continues, and let me input. </p> <pre><code>print('Do you want to go to the store or woods?') lists = ('woods', 'store') while True: answers = input() if answers == 'store...
-2
2016-08-17T15:57:39Z
39,001,408
<p>You want to check if the user's answer is not in your list of valid answers. What you're doing is the other way around. Try this:</p> <pre><code>if answers not in lists: print('That is not a valid answer') </code></pre> <p>You'll also want to either <code>break</code> at that point, or print your prompt messag...
2
2016-08-17T16:03:49Z
[ "python", "adventure" ]
Can't finish the loop when asking for valid answers
39,001,305
<p>I have a problem with my code that I can't find the solution as well. I ask for questions that has to be valid but the loops just continues, and let me input. </p> <pre><code>print('Do you want to go to the store or woods?') lists = ('woods', 'store') while True: answers = input() if answers == 'store...
-2
2016-08-17T15:57:39Z
39,001,412
<p>Try this:</p> <pre><code>print('Do you want to go to the store or woods?') places = ('woods', 'store') while True: answer = input() if answer in places: print ("Going to the {0}...".format(answer)) break else: print('That is not a valid answer') </code></pre>
1
2016-08-17T16:03:57Z
[ "python", "adventure" ]
Can't finish the loop when asking for valid answers
39,001,305
<p>I have a problem with my code that I can't find the solution as well. I ask for questions that has to be valid but the loops just continues, and let me input. </p> <pre><code>print('Do you want to go to the store or woods?') lists = ('woods', 'store') while True: answers = input() if answers == 'store...
-2
2016-08-17T15:57:39Z
39,001,636
<p>First of all, your <code>print</code> statements are unreachable. You can find more information <a href="https://docs.python.org/3/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops" rel="nofollow">here</a>.</p> <pre class="lang-py prettyprint-override"><code>#... if answers == 'store...
1
2016-08-17T16:15:45Z
[ "python", "adventure" ]
Convert MySQL Query to Django query
39,001,317
<p>I'm converting a FlaskApp to Django. In my Flask App I was doing straight DB queries w/o an ORM like MySQLAlchemy.</p> <p>I'm having trouble converting my count queries for use in Django. Seems simple enought, but I'm missing something.</p> <p><strong>OLD FUNCTION W/ QUERY</strong></p> <pre><code>def countClien...
0
2016-08-17T15:58:06Z
39,001,403
<p>Your <code>.count()</code> is in the wrong place. It needs to be after the second close parenthesis, not the third.</p> <p>As it is, you are calling it on the result of <code>append</code>, which is always None.</p>
1
2016-08-17T16:03:41Z
[ "python", "mysql", "django" ]
Pymongo check user permissions on connection
39,001,450
<p>I enabled authentication on my MongoDB database, and I'm connecting to it through pymongo. Everything works well when the user connecting to the DB has all the relevant permissions, but when a user with limited permissions connects, an exception is raised only when executing the first command. Is there a way I can c...
1
2016-08-17T16:06:08Z
39,009,930
<p>If you are using a recent version of pymongo you may want to check this <a href="https://api.mongodb.com/python/current/migrate-to-pymongo3.html#mongoclient-connects-asynchronously" rel="nofollow">page of the docs</a> </p> <blockquote> <p>In PyMongo 3, the MongoClient constructor no longer blocks while connect...
0
2016-08-18T04:18:49Z
[ "python", "mongodb", "pymongo" ]
Change working directory of a imported module
39,001,455
<p>i am having trouble with some modules i want to import, so let's me put a sample to explain better.</p> <pre><code>proyect/ helpers/ config.py locations/ loc1.py pages/ page1.py Tools/ myTool.py </code></pre> <p>So whats happening is that in <code>myTool.py</code> i'm importing <code>page1....
0
2016-08-17T16:06:20Z
39,001,840
<p>Modules don't have working dirs, only the program as a whole does.</p> <p>You should add the proyect dir to sys.path at the start of the script, then import loc1 from locations.</p>
1
2016-08-17T16:27:00Z
[ "python", "python-2.7" ]
hdf5 not supported (please install/reinstall h5py) Scipy not supported! when importing TFLearn?
39,001,457
<p>I'm getting this error:</p> <pre><code>hdf5 not supported (please install/reinstall h5py) Scipy not supported! </code></pre> <p>when I try to import <code>tflearn</code>. And I think due to this problem my TFLearn code is not working properly?</p>
1
2016-08-17T16:06:25Z
39,005,705
<p>I ran into the same issue a few minutes ago, pretty much you just need to reinstall h5py using the package manager of your current environment. </p> <p><a href="http://docs.h5py.org/en/latest/build.html" rel="nofollow">http://docs.h5py.org/en/latest/build.html</a></p>
0
2016-08-17T20:27:53Z
[ "python", "scipy", "tensorflow" ]
Manage secret key in django settings
39,001,568
<p>Following <a href="http://fearofcode.github.io/blog/2013/01/15/how-to-scrub-sensitive-information-from-django-settings-dot-py-files/" rel="nofollow">this post</a> and <a href="http://stackoverflow.com/a/31883650/5530234">this answer</a> I have set up a separate file for storing <code>SECRETY_KEY</code> and importing...
0
2016-08-17T16:12:18Z
39,001,640
<p>Just try, <code>from .settings_secret import *</code> . [dot] ensures that you are importing from the current module.</p>
0
2016-08-17T16:15:51Z
[ "python", "django" ]