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
How to remove floats of a list of lists?
37,519,626
<p>For example:</p> <pre><code> [['D', 'D', '-', '1', '.', '0'],['+', '2', '.', '0', 'D', 'D'],['D', 'D', 'D']] </code></pre> <p>This is:</p> <pre><code>D D -1.0 +2.0 D D D D D </code></pre> <p>I want to extract the values, put in differents variables and know the line and column where the signal was (so i can put ...
1
2016-05-30T07:10:23Z
37,519,935
<p>Don't create a list of list. Take directly the lines from your file and split them with the help of regular expressions:</p> <pre><code>maze = [] for line in arq: maze.append(re.findall('[-+][0-9.]+|\S', line) </code></pre>
1
2016-05-30T07:27:52Z
[ "python", "list" ]
How to remove floats of a list of lists?
37,519,626
<p>For example:</p> <pre><code> [['D', 'D', '-', '1', '.', '0'],['+', '2', '.', '0', 'D', 'D'],['D', 'D', 'D']] </code></pre> <p>This is:</p> <pre><code>D D -1.0 +2.0 D D D D D </code></pre> <p>I want to extract the values, put in differents variables and know the line and column where the signal was (so i can put ...
1
2016-05-30T07:10:23Z
37,520,136
<p>I'm not sure if this is what you want, could add more information in your description. </p> <pre><code> import csv csv_file = open("maze.txt") csv_reader = csv.reader(csv_file) maze = [] for line in csv_reader: for char in line: maze.append(char.split()) print(maze) ...
0
2016-05-30T07:39:52Z
[ "python", "list" ]
How to remove floats of a list of lists?
37,519,626
<p>For example:</p> <pre><code> [['D', 'D', '-', '1', '.', '0'],['+', '2', '.', '0', 'D', 'D'],['D', 'D', 'D']] </code></pre> <p>This is:</p> <pre><code>D D -1.0 +2.0 D D D D D </code></pre> <p>I want to extract the values, put in differents variables and know the line and column where the signal was (so i can put ...
1
2016-05-30T07:10:23Z
37,520,495
<p>Use <a href="https://docs.python.org/2/library/re.html#re.findall" rel="nofollow"><code>re.findall</code></a>. The pattern <code>[-+]?\d*\.\d+|\d+</code> is used to extract float values from a string.</p> <pre><code>import re list2d = [['D', 'D', '-', '1', '.', '0'],['+', '2', '.', '0', 'D', 'D'],['D', 'D', 'D']] ...
0
2016-05-30T07:59:53Z
[ "python", "list" ]
Django move table to other app using db_table and don't delete original table
37,519,709
<p>I have moved my table from <code>app_a</code> to other <code>app_b</code> using <a href="https://docs.djangoproject.com/en/dev/ref/models/options/#db-table" rel="nofollow"><code>db_table</code></a>. I initially added meta information as,</p> <pre><code># app_b.models.ppy class Table(models.Model) # all fields class...
1
2016-05-30T07:15:48Z
37,608,321
<p>After I moved my table from <code>app_a</code> to other <code>app_b</code> using <code>db_table</code> and <code>app_label</code>. Migrations are working if I run them only for <code>app_a</code>. </p> <pre><code>python manage.py makemigrations app_a </code></pre> <p>This command run migration for <code>app_b</cod...
1
2016-06-03T07:22:19Z
[ "python", "django", "models", "schema-migration" ]
Yammer API requests return 401
37,519,711
<p>I am trying to retrieve user like information using Yammer and requests. I am getting 401 status codes repeatedly.</p> <p>Below is my code:</p> <pre><code>import json import requests import requests.auth access_token = "mytoken" headers = {"Authorization": "bearer " + access_token} response = requests.post("htt...
0
2016-05-30T07:15:58Z
37,519,728
<p>401 means you are not authorized, for more on status codes - <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" rel="nofollow">https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html</a></p> <p>Your credentials are either incorrect or you are simply not authorized.</p> <blockquote> <p>The request ...
1
2016-05-30T07:16:50Z
[ "python", "json", "yammer" ]
Yammer API requests return 401
37,519,711
<p>I am trying to retrieve user like information using Yammer and requests. I am getting 401 status codes repeatedly.</p> <p>Below is my code:</p> <pre><code>import json import requests import requests.auth access_token = "mytoken" headers = {"Authorization": "bearer " + access_token} response = requests.post("htt...
0
2016-05-30T07:15:58Z
37,581,862
<p>"The docs say Bearer with capital B" Right on the money mate. Thanks heaps as I spent a few hours on this .</p>
0
2016-06-02T02:53:40Z
[ "python", "json", "yammer" ]
package a pyqt desktop application its resource file with pyinstaller
37,519,769
<p>I have created a desktop gui application which i want to package. I was directed to use pyinstaller to package it so i did. I have a mainwindow.py file where i import a resource file (converted to python code) as well as other imports going on in there. However when i run the output file,it gives me an error. I susp...
0
2016-05-30T07:19:06Z
37,521,528
<p>I have managed to solve the problem. After reading this <a href="http://stackoverflow.com/questions/1619574/problems-using-pyqts-resource-system">answer</a>, I tried pyrcc4 with the '-py3' flag and it worked. I think without the py3 flag,the resource file is converted into a python 2.x code. And I was trying to inte...
0
2016-05-30T08:54:58Z
[ "python", "pyqt", "pyinstaller" ]
Wiriting a multidimensional numpy array into a CSV file
37,519,830
<p>I have a 2D array which I want to write into a csv file. I am using the following code to do it. My array is already a <em>float32 dtype</em> array. Then I'm converting the array into a numpy using <code>.asarray()</code> function. Now i want to write it to a csv file and using the following code:</p> <pre><code>ac...
1
2016-05-30T07:22:11Z
37,520,221
<p>Try:</p> <pre><code>np.savetxt("/home/workstation/activation_data_file_1.csv",activaiton_array.flatten()) </code></pre>
-1
2016-05-30T07:44:05Z
[ "python", "arrays", "csv", "numpy" ]
Wiriting a multidimensional numpy array into a CSV file
37,519,830
<p>I have a 2D array which I want to write into a csv file. I am using the following code to do it. My array is already a <em>float32 dtype</em> array. Then I'm converting the array into a numpy using <code>.asarray()</code> function. Now i want to write it to a csv file and using the following code:</p> <pre><code>ac...
1
2016-05-30T07:22:11Z
37,530,221
<p>If <code>activaiton_array</code> is a 2d array of floats then <code>savetxt</code> iterates over rows (the first dimension) and performs</p> <pre><code>fh.write(asbytes(format % tuple(row) + newline)) </code></pre> <p>This expects <code>row</code> to be a 1d array of floats; <code>format</code> is derived from you...
0
2016-05-30T16:31:51Z
[ "python", "arrays", "csv", "numpy" ]
How to scrape data from html which does not belong to any tag
37,519,920
<p>I want to scrape country name and date from the below website html example. Here the name of the country and date are not inside any tag but just free data. How to scrape it?</p> <pre><code>&lt;div class="infos"&gt; &lt;p&gt; &lt;span class="hidden-xs hidden-sm"&gt;Item offered for sale by:&lt;br/&gt;&lt;/span&gt; ...
0
2016-05-30T07:27:11Z
37,520,188
<p>You can try specifically filtering out the elements that are not tags:</p> <pre><code>import bs4 html = """&lt;div class="infos"&gt; &lt;p&gt; &lt;span class="hidden-xs hidden-sm"&gt;Item offered for sale by:&lt;br/&gt;&lt;/span&gt; &lt;span class="slk" id="product_seller_firstname" title="#sl#members#sl#profile-...
-1
2016-05-30T07:42:50Z
[ "python", "html", "python-3.x", "web-scraping", "beautifulsoup" ]
Cant get the tag 'rel' via beautifulsoup webscrapping python
37,519,993
<p>I am trying to test a beautifulsoup4 webscrap code on a website. Have done most of it but one attribute information due to its location is little tricky for me to accomplish.</p> <p>Code goes like this:</p> <pre><code>span class="callseller-description-icon"&gt; &lt;a id="phone-lead" class="callseller-description-...
1
2016-05-30T07:31:04Z
37,520,225
<p><a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find" rel="nofollow"><code>find</code></a> returns the element not a list, if you want all <code>a</code> tags, use the <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find-all" rel="nofollow"><code>find_all</code></a> method. Also to g...
1
2016-05-30T07:44:14Z
[ "python", "web-scraping", "beautifulsoup", "bs4" ]
Bing API not giving outputs of subdomains in Burp Suite (Following through Blackhat Python)
37,520,146
<p>I have linked bhp_bing.py as an extension in Burp Suite. But My Burp Suite is not giving outputs of the target site's subdomains. <a href="http://i.stack.imgur.com/w79ZR.png" rel="nofollow">supposed result</a></p> <p>But mine stops at "performing bing search*****" and I checked the error log and it shows this:</p>...
0
2016-05-30T07:40:47Z
37,524,066
<p>Burp is blocking the self._callbacks.makeHttpRequest() call because it's executing in the Swing (user-interface) thread. If Burp allowed this, the entire UI would lock up briefly while the HTTP request was sent. To fix it, you need to spawn a new thread in which to execute the bing_query function. </p>
0
2016-05-30T11:03:14Z
[ "java", "python", "multithreading", "bing-api", "burp" ]
How to send authentication credentials in app.post for Flask unit testing of API views
37,520,163
<p>I have written a Flask application. In that, I am using basic auth to restrict certain POST API views. From Python requests, I can access those views as - </p> <pre><code>print post(url, json=data, auth=('username', 'password')) </code></pre> <p>And from curl,</p> <pre><code>curl -a username:password -d "data" u...
0
2016-05-30T07:41:47Z
37,622,104
<p>I find the above method right for sending the post request in unit testing. But for doing so you should have to keep in mind that you should have to disable the CSRF protection in the testing configuration.</p> <p>class TestingConfig(Config): </p> <p>WTF_CSRF_ENABLED = False</p> <p>and best of luck for GSOC 16....
0
2016-06-03T19:32:35Z
[ "python", "flask", "flask-restful", "flask-restplus" ]
How to send authentication credentials in app.post for Flask unit testing of API views
37,520,163
<p>I have written a Flask application. In that, I am using basic auth to restrict certain POST API views. From Python requests, I can access those views as - </p> <pre><code>print post(url, json=data, auth=('username', 'password')) </code></pre> <p>And from curl,</p> <pre><code>curl -a username:password -d "data" u...
0
2016-05-30T07:41:47Z
37,655,405
<p>Basic authorization credentials are stored in header as follows - </p> <pre><code>"Authorization": "Basic username:password" </code></pre> <p>However the <code>username:password</code> part is base64 encoded. So one can use the base64 module to do the same.</p> <pre><code>import base64 headers={ 'content-type...
0
2016-06-06T10:45:44Z
[ "python", "flask", "flask-restful", "flask-restplus" ]
How can I get a terminal output, seperate it into lines and enter it into a list of lists in python?
37,520,210
<p>How can I get the output of "service --status-all" from the terminal and enter it into a list of list? (each list contains a line)</p> <p>I have tried this code:</p> <pre><code>a = os.popen('service --status-all').readlines() print a string=str(a) str=string.split('\n') </code></pre> <p>but it does n...
-2
2016-05-30T07:43:42Z
37,520,349
<p>You need to use <code>splitlines</code> method to split output by lines</p> <blockquote> <p>str.splitlines([keepends]) Return a list of the lines in the string, breaking at line boundaries. This method uses the universal newlines approach to splitting lines. Line breaks are not included in the resulting lis...
0
2016-05-30T07:50:55Z
[ "python", "list" ]
How can I get a terminal output, seperate it into lines and enter it into a list of lists in python?
37,520,210
<p>How can I get the output of "service --status-all" from the terminal and enter it into a list of list? (each list contains a line)</p> <p>I have tried this code:</p> <pre><code>a = os.popen('service --status-all').readlines() print a string=str(a) str=string.split('\n') </code></pre> <p>but it does n...
-2
2016-05-30T07:43:42Z
37,520,358
<p>Using <code>.readlines()</code> <strong>already</strong> breaks your output into lines.</p> <p>If you want to get rid of the additional <code>\n</code>, you can also use <code>.strip()</code>.</p> <pre><code>import os a = os.popen('service --status-all').readlines() output = [el.strip() for el in a] print(output...
-1
2016-05-30T07:51:39Z
[ "python", "list" ]
Opening files in python using a mac
37,520,218
<p>How can I python to open a file on my mac? I am currently working on a project to proof read for curse words but I can't seem to be able to open the word document in which I want python to check. I have all the code done and dusted but I am having trouble opening the file for python to read. I am also a beginner ...
1
2016-05-30T07:44:00Z
37,520,324
<p>Maybe you are currently open a <strong>folder</strong> with</p> <pre><code>quotes = open("/Users/AquaAurelius/Documents/Home/Programming/Houston") </code></pre> <p>You should open the <strong>file</strong>:</p> <pre><code>quotes = open("/Users/AquaAurelius/Documents/Home/Programming/Houston/YOUR_FILENAME.txt") </...
3
2016-05-30T07:49:10Z
[ "python", "osx" ]
Opening files in python using a mac
37,520,218
<p>How can I python to open a file on my mac? I am currently working on a project to proof read for curse words but I can't seem to be able to open the word document in which I want python to check. I have all the code done and dusted but I am having trouble opening the file for python to read. I am also a beginner ...
1
2016-05-30T07:44:00Z
37,541,374
<p>Beginner noted. Understand that I am new to Python also. </p> <p>First I think in the above solutions the assumption is that your Word doc file is in a folder Houston. From my reading I understand your file name is Houston, and the folder it is in is called Programming. </p> <p>Secondly if the file you are seeking...
1
2016-05-31T09:06:47Z
[ "python", "osx" ]
Using Python to create SPSS custom dialog
37,520,307
<p>I am trying to use Python in SPSS custom dialog. My question is how to capture the input value(s) from the UI of the SPSS custom dialog into a variable in Python? I've tried something like <code>var_python=%%thisvalue%%</code> but this returns an error.</p> <p>Thanks a lot for your help.</p> <p>Cheers,</p>
1
2016-05-30T07:48:26Z
37,524,601
<p>You have to add quotation marks. Also don't forget to add BEGIN PROGRAM and END PROGRAM command.</p> <p>e.g.:</p> <pre><code>BEGIN PROGRAM PYTHON. this="%%item_294%%" print this END PROGRAM. </code></pre>
2
2016-05-30T11:30:34Z
[ "python", "spss", "customdialog" ]
substitutes of time.sleep for while loop in django views
37,520,338
<p>Below is what I want to do in django views.</p> <pre><code>import requests, time def SOME_VIEW_FOR_AJAX(request): if request.is_ajax(): response = requests.get('API_URL_START_TASK') # response is like {'ready':false, 'status':'PENDING'} while not response['ready']: response =...
0
2016-05-30T07:50:14Z
37,521,015
<p>This is the wrong approach. The whole point of Celery is to offload long-running tasks so that they don't delay the response.</p> <p>Instead you should immediately return a holding response, then get your front end - maybe via Ajax - to periodically request a status, probably from another view.</p>
1
2016-05-30T08:29:08Z
[ "python", "django", "celery" ]
substitutes of time.sleep for while loop in django views
37,520,338
<p>Below is what I want to do in django views.</p> <pre><code>import requests, time def SOME_VIEW_FOR_AJAX(request): if request.is_ajax(): response = requests.get('API_URL_START_TASK') # response is like {'ready':false, 'status':'PENDING'} while not response['ready']: response =...
0
2016-05-30T07:50:14Z
37,538,172
<p>After the answer and the comment, thankfully, I leave a record for some later use.</p> <p>As Daniel's answer says, the use of celery is not to wait during some computing by a server. Therefore it is natural for the front end to throw and check a celery task.</p> <p>And the exposure of url in the javascript is not ...
-1
2016-05-31T06:18:23Z
[ "python", "django", "celery" ]
Can I extract schema information from empty Access tables with Python?
37,520,428
<p>I'm trying to extract the schema from Microsoft Access databases as part of a larger project to merge ~300 databases. Using my current code, I can only get table names, not field names.</p> <p>I've been using this win32com code snippet, but I'm open to other suggestions (<a href="http://code.activestate.com/recipes...
1
2016-05-30T07:56:31Z
37,529,830
<p>Using the <code>cursor.tables()</code> and <code>cursor.columns()</code> methods in pyodbc will reveal the information you seek, even for empty tables. For example</p> <pre class="lang-python prettyprint-override"><code># -*- coding: utf-8 -*- import pyodbc connStr = ( r"Driver={Microsoft Access Driver (*.mdb, ...
1
2016-05-30T16:04:16Z
[ "python", "python-2.7", "ms-access" ]
tweepy error with requests.exceptions.SSLError: bad handshake
37,520,670
<p>I used the following code </p> <pre><code>auth = tweepy.OAuthHandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret) api = tweepy.API(auth) screen_name =[] class CustomStreamListener(tweepy.StreamListener): def on_status(self, status): if '#selffile' in status.te...
0
2016-05-30T08:09:50Z
39,275,755
<p>Twitter no longer supports SSLv3, you'll need to use TLS instead. You may need to update your version of Tweepy.</p>
0
2016-09-01T15:38:38Z
[ "python", "tweepy" ]
How to get intersection of each element of two nested lists in python?
37,520,686
<p>I'm working in pyspark environment and if I have <strong>two nested lists</strong> a and b,</p> <pre><code>a=[[1,2,3],[8,9,45,0,65],[3,7,23,88],[44,77,99,100,654]] b=[[1,3,7],[0,9,67,22,45,8,11],[23,3],[100]] </code></pre> <p>and I want the intersection of these two in python</p> <pre><code>intersection_list=[[1,...
0
2016-05-30T08:10:50Z
37,520,767
<pre><code>[[n for n in x if n in y] for x, y in zip(a, b)] </code></pre> <p>However if the sublists are big this would be better:</p> <pre><code>[set(x).intersection(y) for x, y in zip(a, b)] </code></pre> <p>(although the order of elements is lost)</p>
1
2016-05-30T08:15:41Z
[ "python", "list", "apache-spark", "pyspark", "nested-lists" ]
How to get intersection of each element of two nested lists in python?
37,520,686
<p>I'm working in pyspark environment and if I have <strong>two nested lists</strong> a and b,</p> <pre><code>a=[[1,2,3],[8,9,45,0,65],[3,7,23,88],[44,77,99,100,654]] b=[[1,3,7],[0,9,67,22,45,8,11],[23,3],[100]] </code></pre> <p>and I want the intersection of these two in python</p> <pre><code>intersection_list=[[1,...
0
2016-05-30T08:10:50Z
37,520,801
<pre><code>a=[[1,2,3],[8,9,45,0,65],[3,7,23,88],[44,77,99,100,654]] b=[[1,3,7],[0,9,67,22,45,8,11],[23,3],[100]] intersection_list = [list(set(x) &amp; set(y)) for x, y in zip(a,b)] &gt;&gt; [[1, 3], [8, 9, 45, 0], [3, 23], [100]] list_count = [ len(x) for x in intersection_list ] &gt;&gt; [2, 4, 2, 1] </code></pre...
1
2016-05-30T08:17:13Z
[ "python", "list", "apache-spark", "pyspark", "nested-lists" ]
PyMC DiscreteMetropolis in Discrete Float Grid
37,520,690
<p>Currently, I am trying to solve a problem from astrophysics which can be simplified as following :</p> <p>I wanted to fit a linear model (say <code>y = a + b*x</code>) to observed data, and I wish to use <code>PyMC</code> to characterize posterior of a and b in discrete grid parameter space like in this figure:</p>...
1
2016-05-30T08:10:58Z
37,692,080
<p>I managed to solve my problem a few days ago. And to my surprise, some of my astronomy friends in Facebook group are also interested in this question, so I think it might be useful to post my solution just in case other people are having the same issue. Please note, this solution may not be the best way to tackle th...
1
2016-06-08T01:55:34Z
[ "python", "pymc" ]
Python: Do I have to use else statements (unless mandated by code)?
37,520,751
<p>I understand <code>if</code>, <code>else</code>, and <code>elif</code> statements. However, I am unsure of the best practice for their use with <code>return</code> in function blocks. What is the most Pythonic way to write if/else constructs with return blocks?</p> <pre><code># Other's code: def my_function(): ...
0
2016-05-30T08:14:29Z
37,520,994
<p>Maybe you need an example with real code. Let's use the one with <code>elif</code> and <code>else</code> first.</p> <pre><code>x = 0 if x == 0: print('x == 0') x = 1 elif x == 1: print('x == 1') x = 2 else: print('x is not 0 or 1') </code></pre> <p>This will print <code>x == 0</code>.</p> <p>N...
1
2016-05-30T08:27:47Z
[ "python", "python-3.x", "if-statement" ]
Python: Do I have to use else statements (unless mandated by code)?
37,520,751
<p>I understand <code>if</code>, <code>else</code>, and <code>elif</code> statements. However, I am unsure of the best practice for their use with <code>return</code> in function blocks. What is the most Pythonic way to write if/else constructs with return blocks?</p> <pre><code># Other's code: def my_function(): ...
0
2016-05-30T08:14:29Z
37,521,128
<p>The two blocks of code are not equivalent:</p> <p>In the first one, <code>select</code> only gets tested once if it is "a" (more efficient), and the <code>print</code> will <strong>only</strong> be executed if <code>select</code> is something other than a, s, or x.</p> <pre><code>select = input("Enter 'a' to add, ...
0
2016-05-30T08:35:24Z
[ "python", "python-3.x", "if-statement" ]
Python: Do I have to use else statements (unless mandated by code)?
37,520,751
<p>I understand <code>if</code>, <code>else</code>, and <code>elif</code> statements. However, I am unsure of the best practice for their use with <code>return</code> in function blocks. What is the most Pythonic way to write if/else constructs with return blocks?</p> <pre><code># Other's code: def my_function(): ...
0
2016-05-30T08:14:29Z
37,521,342
<p>You codes aren't a good example for <code>elif</code> and <code>else</code>. But i will analyze your example firstly. </p> <ol> <li>The first condition:</li> </ol> <pre><code>select = input("Enter 'a' to add, 's' to subtract, 'x' to exit: ") if select == "a": # code elif select == "s": # code elif selec...
1
2016-05-30T08:46:52Z
[ "python", "python-3.x", "if-statement" ]
Run python tests in parallel
37,520,759
<p>I tried to run my tests using pytest with <a href="https://pytest.org/latest/xdist.html" rel="nofollow">xdist</a> in order to speed up my tests (that are very slow since most of them involve database transactions with SQLAlchemy). I launched them with:</p> <p><code>py.test -n 4</code></p> <p>(since my macbook pro ...
0
2016-05-30T08:14:59Z
37,530,774
<p>When creating unittest that can run in parallel you need to be careful how you use your <code>tearUp()</code> and <code>tearDown()</code> so you do isolate the unittests.</p>
0
2016-05-30T17:11:11Z
[ "python", "multithreading", "unit-testing", "concurrency" ]
Draw points connected by spiral on a sphere with Matplotlib
37,520,781
<p>I would like to draw a sphere with points on its surface using Matplotlib. These points shall be connected by a spiral that spirals from one side of the sphere to the other. To clarify this a little bit the plot should more or less look like this: <a href="http://i.stack.imgur.com/ldrdN.png" rel="nofollow"><img src...
1
2016-05-30T08:15:57Z
37,524,427
<p>Need to know parameters of spiral, formula or set of points.</p> <p>However I post a code to plot a line with markers on a sphere for your start:</p> <pre><code>import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ...
1
2016-05-30T11:21:49Z
[ "python", "matplotlib" ]
The python command-line file handling doesn't work? am i working correctly?
37,520,862
<p>I am a new python learner and now i have entered into file handling.</p> <p>I tried solution for my problem but failed, so posting my question. before duplication please consider my question.</p> <p>I tried to create a file, it worked. writing in the file also worked. </p> <p>But when i tried to read the text or ...
-1
2016-05-30T08:20:36Z
37,520,937
<p>First of all if you <code>open</code> with <code>wb</code> flag then the file will be only in writeable mode. If you want to both read and write then you need <code>wb+</code> flag. If you don't want the file to be truncated each time then you need <code>rb+</code>.</p> <p>Now files are streams with pointers pointi...
0
2016-05-30T08:24:45Z
[ "python", "command-line", "ubuntu-12.04" ]
How to get a node in a tree by its label in nltk python?
37,521,009
<p>I have a tree: </p> <pre><code>(S (WH-QUERY Which) (FLIGHT-NP (FLIGHT-CNP (FLIGHT-CNP (FLIGHT-N flight)) (FLIGHT-DEST to (CITY-NP (CITY-NAME Hue) (CITY-N city))))) (FLIGHT-VP (FLIGHT-V arrives) (FLIGHT-TIME (P-TIME at) (TIME-MOD 20:00HR))...
1
2016-05-30T08:28:48Z
37,627,519
<p>Look at the _get_node method in the function.</p> <p><a href="http://www.nltk.org/_modules/nltk/tree.html" rel="nofollow">http://www.nltk.org/_modules/nltk/tree.html</a></p>
0
2016-06-04T07:15:46Z
[ "python", "nlp", "nltk", "nltk-trainer" ]
How to get a node in a tree by its label in nltk python?
37,521,009
<p>I have a tree: </p> <pre><code>(S (WH-QUERY Which) (FLIGHT-NP (FLIGHT-CNP (FLIGHT-CNP (FLIGHT-N flight)) (FLIGHT-DEST to (CITY-NP (CITY-NAME Hue) (CITY-N city))))) (FLIGHT-VP (FLIGHT-V arrives) (FLIGHT-TIME (P-TIME at) (TIME-MOD 20:00HR))...
1
2016-05-30T08:28:48Z
37,819,697
<p>One way to do it is to walk the tree searching for nodes that match:</p> <pre><code>for subtree in tree.subtrees(): if subtree.label() == 'CITY-NAME': print subtree.leaves() </code></pre>
1
2016-06-14T18:37:35Z
[ "python", "nlp", "nltk", "nltk-trainer" ]
Distributing the random data records across the day using Python
37,521,095
<p>I'm designing the data simulator, which generates some records based on the limit, limit can be anything from 100 to 10000 </p> <pre><code>limit = 100 </code></pre> <p>the records should be distributed across whole day ex: 15% of the records in 0th hour, 20% in 1st hour, 5% in 2nd hour and so on...</p> <p>How to ...
0
2016-05-30T08:33:37Z
37,530,736
<p>I you look at the documentation of <a href="https://docs.python.org/2/library/random.html" rel="nofollow"><code>random</code></a> package which is part of the standard library, you will find that it does support generating numbers with a normal (Gaussian) distribution.</p>
0
2016-05-30T17:08:13Z
[ "python", "timestamp", "normal-distribution" ]
Distributing the random data records across the day using Python
37,521,095
<p>I'm designing the data simulator, which generates some records based on the limit, limit can be anything from 100 to 10000 </p> <pre><code>limit = 100 </code></pre> <p>the records should be distributed across whole day ex: 15% of the records in 0th hour, 20% in 1st hour, 5% in 2nd hour and so on...</p> <p>How to ...
0
2016-05-30T08:33:37Z
37,531,290
<p>Here's one way to generate something along the lines of what you describe. Note that <code>limit</code> can be made random, as can be the weights per hour. </p> <pre><code>In [78]: df.tail() Out[78]: gateway t_amount t_id transaction_date 2016-11-05 03:00:00 Amex 68 195 2016-11-05 ...
0
2016-05-30T17:51:44Z
[ "python", "timestamp", "normal-distribution" ]
Finding all paths in graph, Python
37,521,097
<p>I have a graph, represented in a way of a dictionary with pairs <code>key|value - A node|Edges to other nodes</code>. Example:</p> <pre><code>{'5': '1 2 3 W', '0': '1 2 3 W', '2': '0 4 5 L', '1': '0 4 5 L', '4': '1 2 3 W', '3': '0 4 5 L'} </code></pre> <p>(<code>W</code> and <code>L</code> are the marks of the nod...
0
2016-05-30T08:33:42Z
37,521,308
<p>A "breadth first search" algorithm may be what you are looking for. You can find a good explanation and a Python implementation <a href="http://interactivepython.org/runestone/static/pythonds/Graphs/ImplementingBreadthFirstSearch.html" rel="nofollow">here</a>.</p>
-1
2016-05-30T08:44:55Z
[ "python", "graph" ]
Python - filtering lines from data frame
37,521,129
<p>I have a simple data frame: </p> <pre><code>ID Stime Etime 1 13:00:00 13:15:00 1 14:00:00 14:15:00 2 15:00:00 15:42:00 3 13:00:00 13:25:00 4 15:00:00 15:15:00 4 15:05:00 15:15:00 </code></pre> <p>What I would like to do is to unit the 2 last lines, because they belong to the sa...
0
2016-05-30T08:35:27Z
37,521,997
<h3>Solution</h3> <pre><code>def setup(df): td = df.Stime - df.Etime.shift() td = td.apply(lambda x: x.total_seconds() &gt; 1) td.iloc[0] = True return td.cumsum() def collapse(df): df_ = df.iloc[0, :] df_.loc['Stime'] = df.Stime.min() df_.loc['Etime'] = df.Etime.max() return df_ df['...
1
2016-05-30T09:20:02Z
[ "python", "pandas", "dataframe" ]
How solve ImportError: No module named 'dbus'?
37,521,162
<p>I have installed <code>anaconda4</code> on my ubuntu and I have these modules on my Python:</p> <pre><code>dbus-python (1.2.4) gi (1.2) pydbus (0.2) QtAwesome (0.3.2) qtconsole (4.2.0) QtPy (1.0) sip (4.18) </code></pre> <p>I tried installing <code>dbus-python (1.2.4)</code> and <code>pydbus (0.2)</code>, howe...
2
2016-05-30T08:38:03Z
37,521,527
<p>I'm not sure how you installed the modules but this error most likely occurs because the module is not installed or not installed correctly. I would recommend the following for installing a module.</p> <p><code>pip install dbus</code></p> <p>or since you have anaconda this will also work</p> <p><code>conda instal...
5
2016-05-30T08:54:58Z
[ "python", "python-2.7", "python-3.x", "dbus", "qtdbus" ]
How solve ImportError: No module named 'dbus'?
37,521,162
<p>I have installed <code>anaconda4</code> on my ubuntu and I have these modules on my Python:</p> <pre><code>dbus-python (1.2.4) gi (1.2) pydbus (0.2) QtAwesome (0.3.2) qtconsole (4.2.0) QtPy (1.0) sip (4.18) </code></pre> <p>I tried installing <code>dbus-python (1.2.4)</code> and <code>pydbus (0.2)</code>, howe...
2
2016-05-30T08:38:03Z
37,554,371
<p>finally, I find another solution for dbus on python, pyQt4 &amp; pyQT5 dbus library works perfectly on Linux ubuntu. a handful of examples is presented on <a href="https://github.com/Werkov/PyQt4/tree/master/examples/dbus" rel="nofollow">https://github.com/Werkov/PyQt4/tree/master/examples/dbus</a></p> <p>and i co...
0
2016-05-31T19:44:17Z
[ "python", "python-2.7", "python-3.x", "dbus", "qtdbus" ]
How solve ImportError: No module named 'dbus'?
37,521,162
<p>I have installed <code>anaconda4</code> on my ubuntu and I have these modules on my Python:</p> <pre><code>dbus-python (1.2.4) gi (1.2) pydbus (0.2) QtAwesome (0.3.2) qtconsole (4.2.0) QtPy (1.0) sip (4.18) </code></pre> <p>I tried installing <code>dbus-python (1.2.4)</code> and <code>pydbus (0.2)</code>, howe...
2
2016-05-30T08:38:03Z
37,562,374
<p>pydbus requires python-gi (or python3-gi in the case of Python 3). And pydbus 0.2 is really outdated, 0.5.1 is the current version.</p>
0
2016-06-01T07:41:51Z
[ "python", "python-2.7", "python-3.x", "dbus", "qtdbus" ]
How solve ImportError: No module named 'dbus'?
37,521,162
<p>I have installed <code>anaconda4</code> on my ubuntu and I have these modules on my Python:</p> <pre><code>dbus-python (1.2.4) gi (1.2) pydbus (0.2) QtAwesome (0.3.2) qtconsole (4.2.0) QtPy (1.0) sip (4.18) </code></pre> <p>I tried installing <code>dbus-python (1.2.4)</code> and <code>pydbus (0.2)</code>, howe...
2
2016-05-30T08:38:03Z
37,927,053
<p>I don't know about installing dbus in anaconda but you can install it using apt-get in ubuntu .</p> <pre><code>sudo apt-get install python-dbus </code></pre> <p>I tried with pip earlier but that didn't work for me.</p>
4
2016-06-20T16:04:34Z
[ "python", "python-2.7", "python-3.x", "dbus", "qtdbus" ]
How solve ImportError: No module named 'dbus'?
37,521,162
<p>I have installed <code>anaconda4</code> on my ubuntu and I have these modules on my Python:</p> <pre><code>dbus-python (1.2.4) gi (1.2) pydbus (0.2) QtAwesome (0.3.2) qtconsole (4.2.0) QtPy (1.0) sip (4.18) </code></pre> <p>I tried installing <code>dbus-python (1.2.4)</code> and <code>pydbus (0.2)</code>, howe...
2
2016-05-30T08:38:03Z
38,411,445
<p>I had the same problem when running an application called zeitgeist-explorer, but solved it by installing python2-dbus because the system was using version 3.5 and the application needed the 2 something version. check this post if you are getting an error like this one <a href="http://hongouru.blogspot.com/2016/07/s...
0
2016-07-16T12:55:59Z
[ "python", "python-2.7", "python-3.x", "dbus", "qtdbus" ]
How do I set up Tkinter in python to display and update a variable?
37,521,173
<p>I am trying to update a variable every 2.5 seconds, but somehow it will not display on Tkinter.</p> <p>I wrote all of the code except Tkinter related things as I have very little knowledge in that area. I manipulated code I got from a website giving an example for using Tkinter.</p> <p>Here is the code:</p> <pre>...
0
2016-05-30T08:38:34Z
37,521,875
<p>To solve your problem of getting your <code>balance</code> variable to update on tkinter here is my solution: </p> <pre><code> from Tkinter import * root = Tk() moneyShown = Label(root, font=('times', 20, 'bold')) #use a Label widget, not Text moneyShown.pack(fill=BOTH, expand=1) def onclick(): pass ...
1
2016-05-30T09:14:35Z
[ "python", "variables", "tkinter", "display" ]
How to format '0000-00-00 00:00:00' using strftime() in python?
37,521,247
<p>formatting date as:</p> <pre><code>dob = datetime(0000, 00, 00) dob = dob.strftime("%Y-%m-%d") </code></pre> <p>but it gives error: <code>ValueError: year is out of range</code></p> <p>how can i format <code>datetime(0000,00,00)</code> using <code>strftime()</code> in python?</p>
-1
2016-05-30T08:41:52Z
37,521,362
<p>You cannot use a year/month/day of value 0.</p> <pre><code>edob = datetime(1989, 1, 1) dob = dob.strftime("%Y-%m-%d") </code></pre> <blockquote> <p>'1989-01-01'</p> </blockquote>
0
2016-05-30T08:47:44Z
[ "python", "datetime", "strftime" ]
How to format '0000-00-00 00:00:00' using strftime() in python?
37,521,247
<p>formatting date as:</p> <pre><code>dob = datetime(0000, 00, 00) dob = dob.strftime("%Y-%m-%d") </code></pre> <p>but it gives error: <code>ValueError: year is out of range</code></p> <p>how can i format <code>datetime(0000,00,00)</code> using <code>strftime()</code> in python?</p>
-1
2016-05-30T08:41:52Z
37,521,396
<p>Python's <a href="https://docs.python.org/3.5/library/datetime.html" rel="nofollow">documentation on the <code>datetime</code> module</a>, particularly the <code>datetime</code> class states that the <code>datetime</code> object can have attribute values in the following range:</p> <blockquote> <pre><code>MINYEAR &...
5
2016-05-30T08:49:19Z
[ "python", "datetime", "strftime" ]
How to format '0000-00-00 00:00:00' using strftime() in python?
37,521,247
<p>formatting date as:</p> <pre><code>dob = datetime(0000, 00, 00) dob = dob.strftime("%Y-%m-%d") </code></pre> <p>but it gives error: <code>ValueError: year is out of range</code></p> <p>how can i format <code>datetime(0000,00,00)</code> using <code>strftime()</code> in python?</p>
-1
2016-05-30T08:41:52Z
37,521,414
<p>It is out of range - there's no <a href="https://en.wikipedia.org/wiki/0_%28year%29" rel="nofollow">year 0</a> in the Common Era, nor a month or day zero in the Gregorian calendar. Beyond that, if time_t is 32-bit you might not be able to process years before 1902 (a property of <a href="https://en.wikipedia.org/wik...
0
2016-05-30T08:50:01Z
[ "python", "datetime", "strftime" ]
How to format '0000-00-00 00:00:00' using strftime() in python?
37,521,247
<p>formatting date as:</p> <pre><code>dob = datetime(0000, 00, 00) dob = dob.strftime("%Y-%m-%d") </code></pre> <p>but it gives error: <code>ValueError: year is out of range</code></p> <p>how can i format <code>datetime(0000,00,00)</code> using <code>strftime()</code> in python?</p>
-1
2016-05-30T08:41:52Z
37,521,434
<p>Date, Month and Year cannot be 0. If you wish to give some sort of default value , consider giving it a backdated value like 1st Jan 1970 or any other date that has year in range 1-9999, date in range 1-30(28,29,31 as applicable) and month in range 1-12</p>
0
2016-05-30T08:50:50Z
[ "python", "datetime", "strftime" ]
Python send data Serial to Microcontroller STM32F4
37,521,336
<p>So this is the script I am using to send each 2 seconds for four time the Time in microsecond to the microcontroller stm32f4 but unfoturnately it only sends some numbers(from 1-->4) which are not the same as when I do a print,it is like random numbers .</p> <pre><code>import time import serial from datetime impor...
1
2016-05-30T08:46:33Z
37,522,069
<p>I cannot see anything obviously wrong at first sight. I have a almost identical snippet of code running here that works. My guess would be that the settings of the serial port do not match. Double check that the baudrate, parity and stopbit settings match.</p> <p>Second guess would be a mess-up with encodings. Have...
0
2016-05-30T09:23:25Z
[ "python", "pyserial", "uart", "stm32f4" ]
Pandas series removing duplicates issue
37,521,354
<p>I have a series with duplicates which I am trying to get rid of</p> <pre><code>0 RWAY001 1 RWAY001 2 RWAY002 3 RWAY002 ... 112 RWAY057 113 RWAY057 114 RWAY058 115 RWAY058 Length: 116 </code></pre> <p>Drop.duplicates() seems to cut the length to 58 but the index still seems to go from 0...
1
2016-05-30T08:47:29Z
37,521,383
<p>I think you need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reset_index.html" rel="nofollow"><code>reset_index</code></a> with parameter <code>drop=True</code>:</p> <pre><code>fields.reset_index(inplace=True, drop=True) </code></pre> <p>Or:</p> <pre><code>fields = fields.reset...
1
2016-05-30T08:48:47Z
[ "python", "pandas", "series" ]
Importing a PyQt-GUI that can save values into another script
37,521,375
<p>I created a GUI using QtDesigner, converted the .ui into a .py and created a wrapper for it. The GUI consists of 3 DoubleSpinBoxes, two check boxes, OK, Cancel and a few labels. The ui-file (called gyroidUI.py) is bit lengthy, so I'll omit it here. The wrapper looks like this:</p> <pre><code># gyroidUI_module.py im...
-1
2016-05-30T08:48:18Z
37,524,667
<p>It seems like I found my answer:</p> <pre><code>app = gyroidUI_module.AppWindow() app.show() result = app.exec_() if result == 1: fill_ratio = app.ui.fill_ratio_box.value() contour_value = app.ui.contour_value_box.value() contours = int(app.ui.contours_box.value()) if app.ui.check_contour_value.ch...
-1
2016-05-30T11:34:12Z
[ "python", "qt", "user-interface", "module", "pyqt" ]
Django Restframework N to N Table
37,521,454
<p>I have two classes in my model.py:</p> <pre><code>class Table(models.Model): name = models.CharField(max_length=100, blank=True) class Activity(models.Model): name = models.CharField(max_length=100, blank=False) process = models.CharField(max_length=100, blank=True, default='') </code></pre> <p>For th...
0
2016-05-30T08:51:28Z
37,521,628
<p>You shouldn't create class TableActivity. You can add field <code>activtiy = models.ManyToManyField('Activity')</code> to table <code>Table</code> or add field <code>table = models.ManyToManyField('Table')</code> to table <code>Activity</code>. And you should use <a href="http://www.django-rest-framework.org/api-gui...
1
2016-05-30T09:00:54Z
[ "python", "django", "rest" ]
Error Installing Pyproj in Python 3.5
37,521,682
<p>From last couple of day, I am trying to install the <strong>pyproj</strong> package of python using pip. But I am getting the below quoted error. I have tried all the relevant solution available but was unable to install it. Thanks in Advance</p> <pre><code>C:\Users\ashujaimini\PycharmProjects\untitled1&gt;pip ins...
1
2016-05-30T09:04:16Z
37,522,053
<p>Try this</p> <pre><code>easy_install pyproj </code></pre> <p>or </p> <pre><code>sudo easy_install pyproj </code></pre> <p>or download the tar file from <a href="https://pypi.python.org/pypi/pyproj?" rel="nofollow">pyproj</a> and try to run</p> <pre><code>pip install [path to downloaded tar file] </code></pre>
1
2016-05-30T09:22:44Z
[ "python", "pip", "proj4" ]
Error Installing Pyproj in Python 3.5
37,521,682
<p>From last couple of day, I am trying to install the <strong>pyproj</strong> package of python using pip. But I am getting the below quoted error. I have tried all the relevant solution available but was unable to install it. Thanks in Advance</p> <pre><code>C:\Users\ashujaimini\PycharmProjects\untitled1&gt;pip ins...
1
2016-05-30T09:04:16Z
37,522,178
<p>Pyproj needs a compiler (<code>vcvarsall.bat</code> hints towards a Visual C in Windows), which you don't seem to have installed. Instead of installing from source, I suggest downloading a <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyproj" rel="nofollow">pre-compiled wheel</a> and <a href="http://stackoverf...
0
2016-05-30T09:28:34Z
[ "python", "pip", "proj4" ]
Django Rest Framework serialization of many generates NoneType instances of serialized relation
37,521,708
<p>I'm quite new on Django Rest Framework, and I've been trying to write a serializer for one of my models. For my project I intend to output the json result according to the JSON API Standards, and, for doing so, I am using the SerializerMethodField in which I call the method <code>get_data()</code> as follows:</p> <...
2
2016-05-30T09:05:17Z
37,527,606
<p>Attribute name in serialzier: <code>root_level_set</code>. In model: <code>level_set</code>. </p> <p>DRF tries to find attribute <code>root_level_set</code> in group, does not find it and replace it by <code>None</code>. Thats why you get such error.</p> <p>Fix:</p> <ol> <li>Rename <code>root_level_set</code> -> ...
0
2016-05-30T14:01:44Z
[ "python", "django", "serialization", "django-rest-framework" ]
Django Rest Framework serialization of many generates NoneType instances of serialized relation
37,521,708
<p>I'm quite new on Django Rest Framework, and I've been trying to write a serializer for one of my models. For my project I intend to output the json result according to the JSON API Standards, and, for doing so, I am using the SerializerMethodField in which I call the method <code>get_data()</code> as follows:</p> <...
2
2016-05-30T09:05:17Z
37,626,852
<p>why designing everything yourself? let djrf do some magic :)</p> <pre><code>class LevelSerializer(serializers.ModelSerializer): type = serializers.SerializerMethodField() attributes = serializers.SerializerMethodField() relationships = serializers.SerializerMethodField() def get_type(self, instance...
1
2016-06-04T05:51:15Z
[ "python", "django", "serialization", "django-rest-framework" ]
Qt GUI clickable Qframe or QWidget or Groupbox
37,521,724
<p>I have a problem with my code :/ My program needs to click a QFrame, QWidget or QGroupBox. At the moment I use mouseReleaseEvent but it only works when my function doesn't have values set.</p> <pre><code>def testc(self,e): print(e) #when I use this code: self.frame.mousePressEvent = self.testc; #it's okey #but wh...
0
2016-05-30T09:05:53Z
37,522,378
<h1>Create a function that does not take arguments</h1> <p>You have to assign a function to <code>mousePressEvent</code> and <code>self.testc("ssssss")</code> does (probably) not return a function.</p> <p>What you can do is to create another function</p> <pre><code>def f(self): return self.testc("ssssss") </code...
1
2016-05-30T09:38:46Z
[ "python", "qt", "python-3.x" ]
Execute a bash command with parameter in Python
37,521,778
<p>This is a bash command that I run in python and get the expected result:</p> <pre><code>count = subprocess.Popen("ps -ef | grep app | wc -l", stdout=subprocess.PIPE, shell=True) </code></pre> <p>but when I'd like to pass an argument (count in this case) cannot figure out how to do it. I tried:</p> <pre><code>pid ...
0
2016-05-30T09:09:47Z
37,521,941
<p>You're mixing opening and closing quotations and you pass a colon by mistake on your other attempts among other things.</p> <p>Try this for a fix:</p> <pre><code>pid = subprocess.call("ps -ef | grep app | awk -v n=" + str(count) + " NR==n | awk '{print $2}'", shell=True) </code></pre> <p>You opened the command pa...
2
2016-05-30T09:17:56Z
[ "python", "bash", "subprocess" ]
Execute a bash command with parameter in Python
37,521,778
<p>This is a bash command that I run in python and get the expected result:</p> <pre><code>count = subprocess.Popen("ps -ef | grep app | wc -l", stdout=subprocess.PIPE, shell=True) </code></pre> <p>but when I'd like to pass an argument (count in this case) cannot figure out how to do it. I tried:</p> <pre><code>pid ...
0
2016-05-30T09:09:47Z
37,522,035
<p>An other vay is using format:</p> <pre><code>pid = subprocess.call("ps -ef | grep app | awk -v n={} NR==n | awk '{{print $2}}'".format(str(count)), shell=True) </code></pre>
0
2016-05-30T09:21:36Z
[ "python", "bash", "subprocess" ]
Execute a bash command with parameter in Python
37,521,778
<p>This is a bash command that I run in python and get the expected result:</p> <pre><code>count = subprocess.Popen("ps -ef | grep app | wc -l", stdout=subprocess.PIPE, shell=True) </code></pre> <p>but when I'd like to pass an argument (count in this case) cannot figure out how to do it. I tried:</p> <pre><code>pid ...
0
2016-05-30T09:09:47Z
37,528,060
<p>Your Awk pipeline could be simplified a great deal - if the goal is to print the last match, <code>ps -ef | awk '/app/ { p=$2 } END { print p }'</code> does that. But many times, running Awk from Python is just silly, and performing the filtering in Python is convenient and easy, as well as obviously more efficient ...
0
2016-05-30T14:25:34Z
[ "python", "bash", "subprocess" ]
using Python with Twilio how can I implement reject() and callback?
37,521,814
<p>I want to call my Twilio number from my cellphone, Twilio recognizes my number, rejects the call and then calls me back. Here is the code:</p> <pre><code>@application.route("/test", methods=['GET', 'POST']) def test(): whitelist = ['81808730xxxx', '44753810xxxx', '+44753810xxxx', '+44792834xxxx', '44792834xxxx'...
3
2016-05-30T09:11:38Z
37,824,145
<p>I'd love to better understand your use case but I'm going to give this a go using the <a href="https://www.twilio.com/docs/libraries/python" rel="nofollow">Twilio Python Helper Library</a>. </p> <p>As far as <a href="https://www.twilio.com/docs/api/twiml/reject" rel="nofollow"><code>&lt;Reject&gt;</code> TwiML</a> ...
1
2016-06-15T00:12:16Z
[ "python", "twilio" ]
Is compiling untrusted code in CPython considered safe?
37,521,824
<p>In Python its possible to compile a Python script without executing (using <code>py_compile</code> module, <code>Py_CompileString</code> in C).</p> <p>A lot is written on issues attempting to sand-box CPython (and how difficult it is), however, I'm interested to know if there are known security risks in <em>compili...
2
2016-05-30T09:12:16Z
37,524,531
<p>No, it is not safe. CPython has lots of known bugs that lead to stack overflows and other nasty conditions. A SIGSEGV should be considered potentially exploitable.</p>
0
2016-05-30T11:27:13Z
[ "python", "security", "python-3.x" ]
travis secure env variables not used in tox
37,521,881
<p>I can see in my travis build log that env variables are exported correctly :</p> <pre><code>Setting environment variables from .travis.yml $ export K_API_KEY=[secure] $ export K_PRIVATE_KEY=[secure] $ export TOXENV=py27 </code></pre> <p>However they aren't picked in my tests which use a basic config.py file that j...
-1
2016-05-30T09:14:55Z
37,522,926
<p>As righlty pointed by @jonrsharpe the solution is to use the <code>passenv</code> option in tox.ini as described in the <a href="https://testrun.org/tox/latest/example/basic.html#passing-down-environment-variables" rel="nofollow">documentation</a></p> <pre><code>[testenv] setenv = PYTHONPATH = {toxinidir}:{toxi...
1
2016-05-30T10:05:20Z
[ "python", "travis-ci", "tox" ]
best way to work with large dataset in python
37,521,956
<p>I am working with a large financial dataset (15gb for now but will be 200 gb later). what will be the best way to work with it. In particular, I want to do some statistical tests and produce some graphs using millisecond data. So far I have used sqlite3 for the shake of easiness but it seems not able to handle the s...
1
2016-05-30T09:18:28Z
37,522,237
<p>sqlite is not a good alternative if you want to manage large ammounts of data (actually I wouldn't use sqlite for something other than prototyping or running tests).</p> <p>You can try using amazon RDS to store the database <a href="http://aws.amazon.com/es/rds/" rel="nofollow">http://aws.amazon.com/es/rds/</a> and...
0
2016-05-30T09:31:43Z
[ "python", "bigdata", "pycharm", "large-files", "large-data" ]
Tukey Boxplots in Matplotlib - outlier logic in the code?
37,522,002
<p>While reading the answers to <a href="http://stackoverflow.com/questions/17725927/boxplots-in-matplotlib-markers-and-outliers/20096945">a related question in StackOverflow</a>, I saw the code used in matplotlib <a href="https://github.com/matplotlib/matplotlib/blob/a2600586c40ab0444cf7677fe3c348f695bc580d/lib/matplo...
1
2016-05-30T09:20:12Z
37,523,252
<p>The interquartile range can be biased. "The upper adjacent value can be less than Q3, which forces the whisker to be drawn from Q3 into the box. The lower adjacent value can also be greater than Q1, which forces the whisker to be drawn from Q1 into the box." (<a href="http://support.minitab.com/en-us/minitab/17/topi...
1
2016-05-30T10:21:23Z
[ "python", "matplotlib", "boxplot", "iqr", "tukey" ]
Tukey Boxplots in Matplotlib - outlier logic in the code?
37,522,002
<p>While reading the answers to <a href="http://stackoverflow.com/questions/17725927/boxplots-in-matplotlib-markers-and-outliers/20096945">a related question in StackOverflow</a>, I saw the code used in matplotlib <a href="https://github.com/matplotlib/matplotlib/blob/a2600586c40ab0444cf7677fe3c348f695bc580d/lib/matplo...
1
2016-05-30T09:20:12Z
37,631,146
<p>The example output below (driven from matplotlib test data, in fact) shows the problem:</p> <pre><code>$ ipython2 Python 2.7.11 (default, Mar 31 2016, 06:18:34) IPython 4.2.0 -- An enhanced Interactive Python. In [1]: import numpy as np In [2]: import matplotlib In [3]: a=[3, 9000, 150, 88, 350, 200000, 1400, 9...
0
2016-06-04T14:03:48Z
[ "python", "matplotlib", "boxplot", "iqr", "tukey" ]
Use optimize.minimize from scipy with 2 variables and interpolated function
37,522,050
<p>I didn't find a way to perform optimize.minimize from scipy with a multidimensional function. In nearly all examples an analytical function is optimized while my function is interpolated. The test data set looks like this:</p> <pre><code>x = np.array([2000,2500,3000,3500]) y = np.array([10,15,25,50]) z = np.array([...
0
2016-05-30T09:22:33Z
37,523,030
<p>First, to find global maximum (instead of minimum) you need to interpolate your function with opposite sign:</p> <pre><code>F2 = interp2d(x, y, -z) </code></pre> <p>Second, the callable in <code>minimize</code> takes a tuple of arguments, and <code>interp2d</code> object needs input coordinates to be given as sepa...
1
2016-05-30T10:10:35Z
[ "python", "numpy", "optimization", "scipy" ]
How can I calculate a list modulo a numer in python?
37,522,115
<p>In Python I have a list: <code>[11,42,122,1919, 17, 4]</code> and want to calculate its modulo a number (e.g. 10) to give the result as a list: <code>[1,2,2,9,7,4]</code></p>
-6
2016-05-30T09:25:21Z
37,522,223
<p>Even though it's a homework question, you can do it as:</p> <p><code>[a%10 for a in l]</code></p>
1
2016-05-30T09:30:49Z
[ "python", "python-2.7", "mod" ]
How can I calculate a list modulo a numer in python?
37,522,115
<p>In Python I have a list: <code>[11,42,122,1919, 17, 4]</code> and want to calculate its modulo a number (e.g. 10) to give the result as a list: <code>[1,2,2,9,7,4]</code></p>
-6
2016-05-30T09:25:21Z
37,522,797
<p>You can also do it without list comprehension, like this:</p> <pre><code> num_list = [11,42,122,1919, 17, 4] result = [] for num in num_list: result.append(num%10) print(result) # Output [1, 2, 2, 9, 7, 4] </code></pre> <p>If you're new to python then this sort of structure with co...
0
2016-05-30T10:00:13Z
[ "python", "python-2.7", "mod" ]
Sklearn : How to balance classification using DecisionTreeClassifier?
37,522,191
<p>I have a data set where the classes are unbalanced. The classes are either <code>0</code>, <code>1</code> or <code>2</code>. </p> <p>How can I calculate the <code>prediction error</code> for each class and then re-balance <code>weights</code> accordingly in <code>Sklearn</code>.</p>
0
2016-05-30T09:29:04Z
37,522,252
<p>If you want to fully balance (treat each class as equally important) you can simply pass <code>class_weight='balanced'</code>, as it is stated in the <a href="http://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html" rel="nofollow">docs</a>:</p> <blockquote> <p>The “balanced” ...
0
2016-05-30T09:32:31Z
[ "python", "machine-learning", "scikit-learn", "decision-tree" ]
Pandas - how to slice value_counts?
37,522,323
<p>I would like to slice a pandas value_counts() : </p> <pre><code>&gt;sur_perimetre[col].value_counts() 44341006.0 610 14231009.0 441 12131001.0 382 12222009.0 364 12142001.0 354 </code></pre> <p>But I get an error : </p> <pre><code>&gt; sur_perimetre[col].value_counts()[:5] KeyError: 5.0 </code></pr...
0
2016-05-30T09:35:43Z
37,522,875
<p><strong>Method 1:</strong></p> <p>You need to observe that value_counts() returns a Series object. You can process it like any other series and get the values. You can even construct a new dataframe out of it.</p> <pre><code>In [1]: import pandas as pd In [2]: df = pd.DataFrame([1,2,3,3,4,5], columns=['C1']) In ...
2
2016-05-30T10:03:22Z
[ "python", "pandas" ]
How to use gcloud on google app engine?
37,522,493
<p>I'm trying to use client and buckets of gcloud on google app engine. First, I install gcloud.</p> <pre><code>pip install gcloud -t my_project_directory </code></pre> <p>Second,I start to import gcloud and use it. Here is my code:</p> <pre><code>from gcloud import storage class printstr(webapp2.RequestHandler): ...
1
2016-05-30T09:44:36Z
37,546,360
<p>There is a better way to do that. You can use cloudstorage python client api to connect your app engine with your cloud storage buckets.</p> <p><strong>Using pip:</strong> pip install GoogleAppEngineCloudStorageClient -t your_app_directory/lib</p> <p><strong>Using git:</strong> git clone <a href="https://github.co...
1
2016-05-31T12:54:09Z
[ "python", "google-app-engine", "protocol-buffers", "gcloud-python", "google-cloud-python" ]
How to iterate over GQLQuery objects when an attribute exists for only some of them
37,522,508
<p>So I'm building a basic blog where I've also implemented an IP address API to store the user's location. I've used <a href="http://ip-api.com" rel="nofollow">this website</a>'s API to get the latitude and longitude of the user. This is the <code>Entries</code> class which is used to store each entry - </p> <pre><co...
0
2016-05-30T09:45:27Z
37,524,034
<p>I managed to solve the problem. </p> <p>I used a <code>filter</code> instead of the <code>for</code> loop inside <code>MainPage</code>. </p> <pre><code>points = filter(None, (e.coords for e in entries)) </code></pre> <p>This seemed to work and displayed the list of coordinates. (Though I still do not understand w...
1
2016-05-30T11:01:24Z
[ "python", "python-2.7", "api", "google-app-engine", "google-cloud-datastore" ]
Check if sys.argv are defined inside a function
37,522,537
<p>I would like to define a function that checks whether any argv were give to a command line, otherwise would print a string or return two strings. Here is the code:</p> <pre><code>import sys def get_input(): if len(sys.argv) &gt; 1: path_input_text = sys.argv[1] path_basic_conf = sys.argv[2] ...
0
2016-05-30T09:46:58Z
37,522,643
<p>In one case you return nothing, you should return something: None for example.</p> <pre><code>elif len(sys.argv) ==1: print "Takes at least two arguments" </code></pre> <p>Should be:</p> <pre><code>elif len(sys.argv) ==1: print "Takes at least two arguments" return None,None </code></pre> <p><strong>...
0
2016-05-30T09:52:55Z
[ "python", "function", "argv" ]
Check if sys.argv are defined inside a function
37,522,537
<p>I would like to define a function that checks whether any argv were give to a command line, otherwise would print a string or return two strings. Here is the code:</p> <pre><code>import sys def get_input(): if len(sys.argv) &gt; 1: path_input_text = sys.argv[1] path_basic_conf = sys.argv[2] ...
0
2016-05-30T09:46:58Z
37,523,024
<p>argv[0] is the script name (it is operating system dependent whether this is a full pathname or not). If the command was executed using the -c command line option to the interpreter, argv[0] is set to the string '-c'. If no script name was passed to the Python interpreter, argv[0] is the empty string. (reference : <...
1
2016-05-30T10:10:13Z
[ "python", "function", "argv" ]
Conflict while importing packages in Python
37,522,609
<p>I have two projects, each one with a Python folder where I have another folder named lib_py with some shared libraries Python files. Note that even lib_py is a set of shared libraries, each project can have older/newer version of lib_py files (basing on its needs). So that's why each project needs to have its lib_py...
0
2016-05-30T09:50:43Z
37,522,713
<p>Well you could do something like this</p> <p>Referring <a href="http://stackoverflow.com/a/14509415/1887603">this answer</a></p> <pre><code>from os import path import sys sys.path.append(path.abspath('../Foo')) sys.path.append(path.abspath('../Foo2')) from Project1.python.lib_py import example as proj1ex from...
2
2016-05-30T09:56:00Z
[ "python" ]
Conflict while importing packages in Python
37,522,609
<p>I have two projects, each one with a Python folder where I have another folder named lib_py with some shared libraries Python files. Note that even lib_py is a set of shared libraries, each project can have older/newer version of lib_py files (basing on its needs). So that's why each project needs to have its lib_py...
0
2016-05-30T09:50:43Z
37,522,771
<p>Just give the path from project level and alias it with other name</p> <pre><code>from project1.python.lib_py import example as ex1 from project2.python.lib_py import example as ex2 </code></pre> <p>and start using ex1 and ex2</p>
1
2016-05-30T09:59:16Z
[ "python" ]
Executing Python script from Java - Issues with parameter passing
37,522,646
<p>I'm trying to execute a python script from Java. When I manually execute the python script, it works normally. When I execute it from Java, it has issues with the parameters: in fact, python responds with the "Usage" error, as if I didn't pass the parameters.</p> <p>Java code:</p> <pre><code> String pyt...
0
2016-05-30T09:53:00Z
37,522,811
<p>As far as I remember you have to split your commandline into a String[] like this:</p> <pre><code>Runtime.getRuntime().exec(new String[]{"python","/path/to/myscript.py", "--key", "value list here", "-otherparam", "param"}); </code></pre>
0
2016-05-30T10:00:43Z
[ "java", "python", "parameters", "parameter-passing" ]
Install tensorflow on Windows with anaconda
37,522,676
<p>I am trying to install Tensorflow on my Windows PC. Since I have already install and used Anaconda on Python (3.5), I have followed the instructions <a href="https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#anaconda-environment-installation" rel="nofollow">https://www.tensorflow.org/versions/r0.8/g...
3
2016-05-30T09:54:11Z
37,526,169
<p>It looks like you need to activate the virtual environment that TensorFlow was installed in. When you activate the virtual environment, it will appear in parenthesis in your command prompt, like in the example tutorial:</p> <pre><code>$ source activate tensorflow (tensorflow)$ # Your prompt should change </code></...
1
2016-05-30T12:52:15Z
[ "python", "anaconda", "tensorflow" ]
Install tensorflow on Windows with anaconda
37,522,676
<p>I am trying to install Tensorflow on my Windows PC. Since I have already install and used Anaconda on Python (3.5), I have followed the instructions <a href="https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#anaconda-environment-installation" rel="nofollow">https://www.tensorflow.org/versions/r0.8/g...
3
2016-05-30T09:54:11Z
37,552,712
<p>TensorFlow is <a href="https://github.com/tensorflow/tensorflow/issues/17" rel="nofollow">not currently supported on Windows</a>, and none of the official binary packages work on Windows. We are currently working on adding support for Windows, but this effort is in the early stages.</p> <p>See the answers to <a hre...
3
2016-05-31T18:05:01Z
[ "python", "anaconda", "tensorflow" ]
Update oracle CLOB column with large string
37,522,678
<p>I have a table <code>systesttab</code> that contains a few columns. One of those columns is of type CLOB and it's supposed to hold a string of a base64 encoded image.</p> <pre><code>CREATE TABLE systesttab( ... f_picture CLOB DEFAULT ' ' NOT NULL, ... ) </code></pre> <p>However, when I try to...
0
2016-05-30T09:54:13Z
37,882,598
<p>I have solved this by using SQL Bindings. It seems the character limit does not apply then.</p> <p>In python the statement now looks like this:</p> <pre><code>pic = 'data:image/png;base64,iVBORw0KGgoASU ...' sql = "UPDATE systesttab SET f_picture = ?" cursor.execute( sql, [pic] ) </code></pre> <p>This also works ...
0
2016-06-17T13:17:37Z
[ "python", "oracle", "pyodbc", "clob", "lob" ]
How to fetch company data by tag from Highrise pass the API limits?
37,522,707
<p>First of all, thanks for your help guys;</p> <p>I tried to do 3 things ; 1. Get companies name from highrise 2. Do it by their tags 3. And overcome Highrise 500 API call limits</p> <p>I tried wrappers like A__https://github.com/feedmagnet/pyrise which let me do 1 and 2 </p> <p>B__https://github.com/seibert-media/...
0
2016-05-30T09:55:40Z
37,549,765
<p>When retrieving companies, the lists are paginated using offsets. If you add <code>?n=500</code>to the end of your request, you'll return the next 500 companies. </p> <p>See also <a href="https://github.com/basecamp/highrise-api/blob/master/sections/companies.md#get-companies" rel="nofollow">documentation for <code...
0
2016-05-31T15:26:24Z
[ "python", "api", "basecamp", "highrise", "37-signals" ]
Matplotlib change bar color
37,522,788
<p>Matplotlib changes the color of the bar when there are more values plotted : With 5 columns I get the expected red bars : </p> <pre><code>ax = vc[vc.index[:5]].plot(color='red', kind='bar', title=col+('(count)')) ax.set_axis_bgcolor('white') </code></pre> <p><a href="http://i.stack.imgur.com/fzGkV.png" rel="...
0
2016-05-30T10:00:00Z
37,523,307
<p>They probably become gray because of the edge colors of the bars:</p> <pre><code>import matplotlib.pylab as pl import numpy as np import pandas as p pl.figure() x = np.arange(5) y = np.random.random(x.size) vc1 = p.DataFrame(data=y, index=x) x = np.arange(100) y = np.random.random(x.size) vc2 = p.DataFrame(data=...
0
2016-05-30T10:24:26Z
[ "python", "matplotlib" ]
MD5 password fail in scapy based EAP-MD5 authentication scrtip
37,522,810
<p>Now I'm programming EAP-MD5 authentication testing script based on scapy in my private network.</p> <p>But, I've failed on 'response md5-challange' status with 'password fail'.</p> <p>my script code is same below. On this routine, parameter 'pkt' is from the requested MD5-Challange EAP packet </p> <h1>==========...
0
2016-05-30T10:00:43Z
37,562,273
<p>I found solution myself. On below code, </p> <pre><code>mychallegne = str(eap.id) + mypass + raw.load[1:] </code></pre> <p>I've made mistake for 'eap.id' handling. I should use pack("!B", eap.id) insted of the str() function.</p>
0
2016-06-01T07:36:19Z
[ "python", "authentication", "scapy" ]
Neopets login with Python Requests module
37,522,821
<p>I am trying to login to this website with the following code:</p> <pre><code>import requests def ReadNeopets(): username = 'notarealone' LoginUrl = 'http://www.neopets.com/login/' with requests.Session() as s: s.get(LoginUrl) payload = {'destination': '', 'username': username, 'passwor...
1
2016-05-30T10:01:12Z
37,523,346
<p>The post request goes to a different url, once you change the data as below your login will be successful:</p> <pre><code> login_url = 'http://www.neopets.com/login.phtml' with requests.Session() as s: payload = {'destination': '', 'username': username, 'password': 'notrealeither'} r = s.post...
0
2016-05-30T10:25:54Z
[ "python", "python-requests" ]
Counting objects into the list
37,522,851
<p>I have this scenario.</p> <p><code>[{'dots': True, 'already': True, 'had': True, 'syndrome': True, 'my': True, 'i': True}, 'pos']</code></p> <p>How can I count objects into first part of the list?</p> <p>I want this output.</p> <pre><code>Count: 6 Objects: dots, already, had, syndrome, my, i </code></pre>
0
2016-05-30T10:02:29Z
37,522,920
<p>your_list =[{'dots': True, 'already': True, 'had': True, 'syndrome': True, 'my': True, 'i': True}, 'pos']</p> <p>You can try something like this:</p> <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; len(your_list[0]) 6 </code></pre> <p>and for objects:</p> <pre class="lang-py prettyprint-override"><c...
0
2016-05-30T10:05:10Z
[ "python", "list", "counting" ]
Counting objects into the list
37,522,851
<p>I have this scenario.</p> <p><code>[{'dots': True, 'already': True, 'had': True, 'syndrome': True, 'my': True, 'i': True}, 'pos']</code></p> <p>How can I count objects into first part of the list?</p> <p>I want this output.</p> <pre><code>Count: 6 Objects: dots, already, had, syndrome, my, i </code></pre>
0
2016-05-30T10:02:29Z
37,523,108
<p>You could do something like this:</p> <pre><code> my_list = [{'dots': True, 'already': True, 'had': True, 'syndrome': True, 'my': True, 'i': True}, 'pos'] print("Count:", len(my_list[0].keys())) objects = [key for key in my_list[0]] print("Objects:", objects) # Output Count: 6 Objects...
0
2016-05-30T10:14:33Z
[ "python", "list", "counting" ]
Counting objects into the list
37,522,851
<p>I have this scenario.</p> <p><code>[{'dots': True, 'already': True, 'had': True, 'syndrome': True, 'my': True, 'i': True}, 'pos']</code></p> <p>How can I count objects into first part of the list?</p> <p>I want this output.</p> <pre><code>Count: 6 Objects: dots, already, had, syndrome, my, i </code></pre>
0
2016-05-30T10:02:29Z
37,523,173
<p>let me explain a little bit.</p> <p>I using this code.</p> <pre><code>for line in base_pos.split('\n'): line = line.lower() pos_words = word_tokenize(line) pos_words = [return_feature(pos_words), "pos"] posfeatures.append(pos_words) </code></pre> <p>base_pos = text file with some t...
0
2016-05-30T10:17:52Z
[ "python", "list", "counting" ]
Train a network on python wrraper caffe?
37,522,852
<p>I would like to train a caffe network with the python interface. The main reason behind this is I use multi dimentional input of a few Tbs of data and I dont want to convert all this to LMDB and train it.</p> <p>I have found a this <a href="http://stackoverflow.com/questions/31385427/how-to-train-a-caffe-model">one...
1
2016-05-30T10:02:29Z
37,534,704
<p>Beside using <code>PythonLayer</code> , one thing you can do is use <code>MemoryData</code> layer and feed in each batch of data at a time by using <code>solver.net.set_input_arrays(your_data)</code> after however many iteration is needed to go through one batch of data.</p> <p>Remember, you can always restore the ...
0
2016-05-30T23:18:00Z
[ "python", "numpy", "machine-learning", "deep-learning", "caffe" ]
Sqlite3 not reading from database
37,522,919
<p>I have a database with two columns .One is a primary key auto increment and another is a column for urls. the first is named 'id' and second is named 'longurls'. I have runned the following code to retrieve a 'id' record where longurls = 'X' value . </p> <pre><code>import sqlite3 long_url = 'http://www.google.com' ...
0
2016-05-30T10:05:09Z
37,523,085
<p>I've not yet used sqlite in Python but the bit of your code that looks strange to me is</p> <pre><code>for stuff in k: id = stuff[0] print (id) </code></pre> <p>what happens if you define id outside the loop?</p> <pre><code>id = 0 for stuff in k: id = stuff[0] print (id) </code></pre> <p>If you could ret...
0
2016-05-30T10:13:22Z
[ "python", "mysql", "database", "sqlite", "sqlite3" ]
Sqlite3 not reading from database
37,522,919
<p>I have a database with two columns .One is a primary key auto increment and another is a column for urls. the first is named 'id' and second is named 'longurls'. I have runned the following code to retrieve a 'id' record where longurls = 'X' value . </p> <pre><code>import sqlite3 long_url = 'http://www.google.com' ...
0
2016-05-30T10:05:09Z
37,523,504
<pre><code>import sqlite3 as lite import sys long_url = 'http://www.google.com' con = lite.connect('database.db') with con: cur = con.cursor() cur.execute("SELECT * FROM stuff WHERE longurls=?",(long_url,)) rows = cur.fetchall() for row in rows: print row </code></pre>
0
2016-05-30T10:32:59Z
[ "python", "mysql", "database", "sqlite", "sqlite3" ]
Is it possible to upgrade a portable Python 32 bit install to a 64 bit install?
37,522,943
<p>I've been working on a single program for a few months now, which now requires some additional functionality. Originally, a 32 bit install was just fine, but since I'm now working with <em>massive</em> matrices in scipy, I simply do not have the required RAM in 32bit. </p> <p>The other problem I have is that my lit...
0
2016-05-30T10:06:01Z
37,530,517
<p>No, it is not possible to upgrade a 32bit Python installation to a 64bit one. </p> <p>Still, there is something that you can do in order to speedup installation of a new 64bit version.</p> <p>Run <code>pip freeze &gt; packages.txt</code> on the old installation in order to generate a list of all installed packages...
0
2016-05-30T16:52:03Z
[ "python", "64bit", "32-bit" ]
Python, create plot from DataFrame
37,522,970
<p>I have a DataFrame that looks as follows:</p> <pre><code> C gamma precision 0 1.0 0.00001 0.044040 1 1.0 0.00010 0.044063 2 1.0 0.00100 0.349788 3 1.0 0.01000 0.359441 4 1.0 0.10000 0.367857 5 10.0 0.00001 0.090369 6 10.0 0.00010 0.347510 7 10.0 0.00100 ...
0
2016-05-30T10:07:26Z
37,525,753
<p>For plotting each line with a unique <code>C</code> you could do something like this:</p> <pre><code>pl.figure() ax=pl.gca() for c in df['C'].unique(): df.loc[df['C'] == c].plot(ax=ax, x='gamma', y='precision', label='C: {}'.format(c)) </code></pre> <p><code>df['C'].unique()</code> creates an array with all un...
3
2016-05-30T12:31:18Z
[ "python", "matplotlib" ]
Django celery tasks working very long
37,522,991
<p>I use celery, supervisor and flower</p> <p>supervisor conf:</p> <p><code>command=/web/venv/bin/python manage.py celeryd -E -l info -c 2 --maxtasksperchild=1 -Ofair</code></p> <pre><code>directory=/web/ stdout_logfile=/web/log/ redirect_stderr=true user=web killasgroup=true stopasgroup=true </code></pre> <p>Probl...
-1
2016-05-30T10:08:36Z
37,525,826
<p>you can achieve the same by adding celery from admin, that might solution</p> <pre><code>http://www.yourhost.com/admin/djcelery/ </code></pre>
0
2016-05-30T12:34:59Z
[ "python", "django", "celery", "django-celery", "supervisor" ]
Unique list without spliting entries based on spaces in python
37,523,018
<p>Here is the CSS I want to scrap </p> <pre><code>&lt;a id="phone-lead" class="callseller-description-link" rel="050 395 7996" href="#"&gt;Show Phone Number&lt;/a&gt; </code></pre> <p>Purpose: </p> <p>To get the phone numbers whereever they are in the CSS. (Note, there are multiple instances of this type of phone...
0
2016-05-30T10:10:01Z
37,523,218
<p>It seems that <code>a['rel']</code> returns a list like <code>['050', '395', '7996']</code>. So inside you for loop you could do something like:</p> <pre><code>phone_result.append(''.join(a['rel'])) </code></pre> <p>note that <code>list.append</code> add an element to the end of the list (and does not return anyth...
0
2016-05-30T10:19:53Z
[ "python", "beautifulsoup", "python-2.x", "bs4" ]
Unique list without spliting entries based on spaces in python
37,523,018
<p>Here is the CSS I want to scrap </p> <pre><code>&lt;a id="phone-lead" class="callseller-description-link" rel="050 395 7996" href="#"&gt;Show Phone Number&lt;/a&gt; </code></pre> <p>Purpose: </p> <p>To get the phone numbers whereever they are in the CSS. (Note, there are multiple instances of this type of phone...
0
2016-05-30T10:10:01Z
37,523,331
<p>I dont know this library but it seems like you are creating the phone_result list a few times.</p> <pre><code>phone_result = [] # creating phone_result list try: phone_result = soup.find('a', {'id': 'phone-lead', 'rel':True}).get('rel') # dont know if this creates a list but phone_result is declared again fo...
0
2016-05-30T10:25:28Z
[ "python", "beautifulsoup", "python-2.x", "bs4" ]
Unique list without spliting entries based on spaces in python
37,523,018
<p>Here is the CSS I want to scrap </p> <pre><code>&lt;a id="phone-lead" class="callseller-description-link" rel="050 395 7996" href="#"&gt;Show Phone Number&lt;/a&gt; </code></pre> <p>Purpose: </p> <p>To get the phone numbers whereever they are in the CSS. (Note, there are multiple instances of this type of phone...
0
2016-05-30T10:10:01Z
37,523,987
<p>You missunderstood my <a href="http://stackoverflow.com/a/37520225/3100115">answer here</a>. You don't need to use both <code>find</code> and <code>find_all</code>. Simply use <code>find_all</code> if you want to retrieve all descendants that match your filters. And, as I said you need to use <code>str.join</code> t...
0
2016-05-30T10:58:44Z
[ "python", "beautifulsoup", "python-2.x", "bs4" ]
Unable to import Flask to Kivy iOS
37,523,039
<p>I want to import <a href="https://facebook.github.io/react/" rel="nofollow">ReactJS</a> to Kivy iOS project and create a server on iPad.</p> <p>But when I'm running I had this error: </p> <pre><code>Traceback (most recent call last): File "/Users/macuser/kivy-ios...
0
2016-05-30T10:10:58Z
39,561,712
<p>Using <a href="https://facebook.github.io/react-native/" rel="nofollow">React Native</a> allow you to write Native Android/ IOS applications. You can however use React Native, <a href="http://redux.js.org/" rel="nofollow">Redux</a> and <a href="https://flask-restless.readthedocs.io/en/stable/" rel="nofollow">Flask R...
0
2016-09-18T19:21:20Z
[ "python", "ios", "ipad", "flask", "kivy" ]
how to choose python version accordingly in pycharm?
37,523,054
<p>In last project, I used python 2.7. The new one have to run in python 3.5 so I installed 3.5. I choose Python 3.5 in Setting-->Python interpreter, and I got <code>Error : Django is not importable in this environment.</code> Then I tried to run</p> <pre><code> pip install django Requirement already satisfied (use --...
1
2016-05-30T10:11:55Z
37,523,760
<p>Just go with <code>pip3</code> suited for Python 3x envs:</p> <pre><code> pip3 install Django </code></pre>
0
2016-05-30T10:45:50Z
[ "python", "django", "python-3.x", "ide", "pycharm" ]
how to choose python version accordingly in pycharm?
37,523,054
<p>In last project, I used python 2.7. The new one have to run in python 3.5 so I installed 3.5. I choose Python 3.5 in Setting-->Python interpreter, and I got <code>Error : Django is not importable in this environment.</code> Then I tried to run</p> <pre><code> pip install django Requirement already satisfied (use --...
1
2016-05-30T10:11:55Z
37,523,772
<p>It's probably because the pip command points to python2.7 version of pip, and as django is already installed for python 2.7, you are getting the message you mentioned.</p> <p>You need to install django for python3.5. To do that, either directly run pip executable inside python3.5 folder, or choose python3.5 as the ...
1
2016-05-30T10:46:29Z
[ "python", "django", "python-3.x", "ide", "pycharm" ]