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 |
|---|---|---|---|---|---|---|---|---|---|
Zero date in mysql select using python | 39,363,548 | <p>I have a python script which selects some rows from a table and insert them into another table. One field has type of date and there is a problem with its data when its value is '0000-00-00'. python converts this value to None and so gives an error while inserting it into the second table.</p>
<p>How can I solve th... | 0 | 2016-09-07T07:18:36Z | 39,364,372 | <p>This is actually a None value in the data base, in a way. MySQL treats '0000-00-00' specially.
From <a href="http://dev.mysql.com/doc/refman/5.7/en/date-and-time-types.html" rel="nofollow">MySQL documentation</a>:</p>
<blockquote>
<p>MySQL permits you to store a âzeroâ value of '0000-00-00' as a âdummy
da... | 0 | 2016-09-07T08:01:44Z | [
"python",
"mysql",
"date",
"select"
] |
javascript-POST request using ajax in Django issue | 39,363,590 | <p>I am a beginner and self learned programmer and have written a code on my own. I am attempting to use Javascript post request using ajax and facing some continuous problem. There are lot of mistakes in code and want you guys to correct it with an explanation. Here is my base.js file:</p>
<pre><code>var user = {
sig... | 1 | 2016-09-07T07:20:20Z | 39,363,779 | <p>if you direct pass the data to the server you need to pass csrf token, or else just put {% csrf_token %} inside the form and submit the form data after the validation.</p>
<pre><code>var formData = new FormData($(this)[0]); ## Active
$.ajax({
url: "{% url 'apply_job' %}",
type: 'POST',
d... | 1 | 2016-09-07T07:29:59Z | [
"javascript",
"jquery",
"python",
"ajax",
"django"
] |
cx_freeze and docx - problems when freezing | 39,363,615 | <p>I have a simple program that takes input from the user and then does scraping with selenium. Since the user doesn't have Python environment installed I would like to convert it to *.exe. I usually use cx_freeze for that and I have successfully converted .py programs to .exe. At first it was missing some modules (lik... | 0 | 2016-09-07T07:21:39Z | 39,381,577 | <p>I expect you'll find the problem has to do with your freezing operation not placing the default Document() template in the expected location. It's stored as package data in the python-docx package as <code>docx/templates/default.docx</code> (see setup.py here: <a href="https://github.com/python-openxml/python-docx/b... | 0 | 2016-09-08T02:14:00Z | [
"python",
"python-3.x",
"cx-freeze",
"python-docx"
] |
python subprocess Popen behaving differently on local and remote system | 39,363,629 | <p>I am using django and sending a build to travis-ci which is failing the build on my tests. The line that is in question is in this function...</p>
<pre><code>from subprocess import Popen, PIPE
def make_mp3(path, blob):
process = Popen(
['lame', '-', '--comp', '40', path], stdin=PIPE, stdout=PIPE, stder... | 2 | 2016-09-07T07:22:02Z | 39,364,401 | <p>Reason it fails: execution command can't execute non-existent file. It's <code>lame</code> in your example. Quote from <a href="https://docs.python.org/2/library/subprocess.html#exceptions" rel="nofollow">doc section</a>:</p>
<blockquote>
<p>The most common exception raised is OSError. This occurs, for example, w... | 2 | 2016-09-07T08:02:48Z | [
"python",
"django",
"travis-ci"
] |
Replace userinput list elements from master dictionary? | 39,363,762 | <p>Here, i have a master dic whose value consist of list of list.</p>
<p>Whenever user inputs the value as a list of list, i want my program to replace those user input list from the master list.</p>
<p>I have tried and it is giving me expected output but it consists of lot of temporary lists which is annoying , Is t... | 2 | 2016-09-07T07:29:01Z | 39,377,442 | <p>I think this is what you want</p>
<pre><code>def array_replace(userinput,master_dic):
for i,data in enumerate(userinput):
if isinstance(data, list):
found=array_replace(data,master_dic)
if not isinstance(found, list):
userinput[i]=master_dic[found]
else:
... | 1 | 2016-09-07T19:09:34Z | [
"python",
"list",
"dictionary"
] |
Encoding/Decoding AES CTR between php and python | 39,363,782 | <p>I am connecting to an php API.
In their examples they encode everything with the following:</p>
<blockquote>
<p>$data=AesCtr::encrypt($data, 'api_key_for_project', 256)</p>
</blockquote>
<p>I would like to connect via pythons pycrypto module and do the equivalent to the above.</p>
<p>I have tried a few differen... | 0 | 2016-09-07T07:30:08Z | 39,366,163 | <p>Commonly, the counter values in CTR mode consist of:</p>
<ul>
<li>a prefix/nonce which must be unique for each message to be encrypted, but stays the same between blocks of one message. E.g. <code>os.urandom(8)</code> is a decent nonce (unless you encrypt more than about 2^32 messages with the same key).</li>
<li>t... | 1 | 2016-09-07T09:29:20Z | [
"php",
"python",
"encryption"
] |
Python: regular expressions in url | 39,363,786 | <p>I have some url like</p>
<pre><code>https://www.avito.ru/chelyabinsk/avtomobili/audi_a4_2014_818414044
</code></pre>
<p>And I need to get pattern from this. I know, that * is the symbol, that can replace any symbol, but when I try <code>https://www.avito.ru/*/avtomobili</code> it doesn't open this url.
How can I ... | -4 | 2016-09-07T07:30:19Z | 39,363,874 | <p><code>*</code> means match the last symbol zero or more times.</p>
<p>For example, <code>x*</code> matches 'xxxxxxx....', and <code>[a-z]*</code> matches 'abcsiiwdqhwid...'.</p>
<p>Why not try </p>
<pre><code>https://www.avito.ru/[a-z]*/avtomobili
</code></pre>
<p>or</p>
<pre><code>https://www.avito.ru/.*?/avto... | 0 | 2016-09-07T07:34:48Z | [
"python",
"regex"
] |
Python: regular expressions in url | 39,363,786 | <p>I have some url like</p>
<pre><code>https://www.avito.ru/chelyabinsk/avtomobili/audi_a4_2014_818414044
</code></pre>
<p>And I need to get pattern from this. I know, that * is the symbol, that can replace any symbol, but when I try <code>https://www.avito.ru/*/avtomobili</code> it doesn't open this url.
How can I ... | -4 | 2016-09-07T07:30:19Z | 39,365,240 | <p>From your example, to match </p>
<pre><code>https://www.avito.ru/chelyabinsk/avtomobili/audi_a4_2014_818414044
</code></pre>
<p>you would need to have a regex of</p>
<pre><code>https://www\.avito\.ru/.*?/avtomobili
</code></pre>
<p>in <code>https://www.avito.ru/XXXXXX/avtomobili</code> : <code>XXXXXX</code> can ... | 0 | 2016-09-07T08:47:16Z | [
"python",
"regex"
] |
reportlab add font with registerFont | 39,363,800 | <p>I've to use the registerFontFamily method from reportlab.pdfbase.pdfmetrics.
I tried to add two fonts to a family but I can't use the bold font with "<<em>b>sometext<</em>/b>". I need this feature for my report. I can only use the regular one and I don't know why. </p>
<p>Here's the code.</p>
<pre><code>regi... | 0 | 2016-09-07T07:30:56Z | 39,368,866 | <p>The first problem is that you made a typo in the <code>registerFontFamily</code>. To be more specific you register the normal font as being the bold by doing <code>bold='Own_Font'</code>.</p>
<p>The second problem is that your font family doesn't have fonts for all types (in this case italic and boldItalic). Accord... | 0 | 2016-09-07T11:37:11Z | [
"python",
"pdf",
"fonts",
"reportlab"
] |
Merging rows into one with same column cells and keep data from all into the merged row using python script | 39,363,836 | <p>I need to merge more rows into one but in the way i can keep all data in all columns into the merged row in my .csv file. The rows which i need to merge are one who have same email cells. The first table in the picture is how i have now and the second how should be.</p>
<p><a href="http://i.stack.imgur.com/tgpuh.pn... | 0 | 2016-09-07T07:33:09Z | 39,364,218 | <p>my idea: start at row 1, take the email and store it in a list. </p>
<p>Now compare each entry of the the hole email column with the email from row 1. If its equal then find out which fields in your row are empty and if the found entry has one of these filled out. </p>
<p>Write the concatenated row down and go on ... | 0 | 2016-09-07T07:54:16Z | [
"python",
"csv",
"merge",
"rows"
] |
Mimicing glib.spawn_async with Popen⦠| 39,364,128 | <p>The function <a href="http://www.pygtk.org/docs/pygobject/glib-functions.html#function-glib--spawn-async" rel="nofollow">glib.spawn_async</a> allows you to hook three callbacks which are called on event on <code>stdout</code>, <code>stderr</code>, and on process completion.</p>
<p><em>How can I mimic the same funct... | 13 | 2016-09-07T07:48:44Z | 39,485,708 | <p>asyncio has <a href="https://docs.python.org/3/library/asyncio-subprocess.html#asyncio.AbstractEventLoop.subprocess_exec" rel="nofollow">subprocess_exec</a>, there is no need to use the subprocess module at all:</p>
<pre><code>import asyncio
class Handler(asyncio.SubprocessProtocol):
def pipe_data_received(sel... | 4 | 2016-09-14T08:22:13Z | [
"python",
"multithreading",
"gtk",
"glib",
"python-asyncio"
] |
How to compile and package a python file into an execution file under windows 64bit | 39,364,224 | <p>Recently, I started to use theano to do some basic BP network. The theano was installed and my network based on theano works well in my PC.
In order to share my code among my colleagues, I am looking for a method to package the theano python file to one execution file which can be run under windows without python e... | 0 | 2016-09-07T07:54:29Z | 39,365,047 | <p>Try <a href="http://www.pyinstaller.org/" rel="nofollow">PyInstaller</a></p>
<p>PyInstaller is a program that freezes (packages) Python programs into stand-alone executables, under Windows, Linux, Mac OS X, FreeBSD, Solaris and AIX.</p>
| 0 | 2016-09-07T08:37:07Z | [
"python",
"package",
"exe",
"theano",
"py2exe"
] |
How to compile and package a python file into an execution file under windows 64bit | 39,364,224 | <p>Recently, I started to use theano to do some basic BP network. The theano was installed and my network based on theano works well in my PC.
In order to share my code among my colleagues, I am looking for a method to package the theano python file to one execution file which can be run under windows without python e... | 0 | 2016-09-07T07:54:29Z | 39,365,182 | <p>I use <code>cxFreeze</code> to convert my Python scripts to <code>.exe</code> Its a really good module. You can see its working <a href="https://www.youtube.com/watch?v=HosXxXE24hA" rel="nofollow">here</a>. </p>
| 0 | 2016-09-07T08:43:52Z | [
"python",
"package",
"exe",
"theano",
"py2exe"
] |
Spark join throws 'function' object has no attribute '_get_object_id' error. How could I fix it? | 39,364,283 | <p>I am making a query in Spark in Databricks, and I have a problema when I am trying to make a join between two dataframes. The two dataframes that I have are the next ones:</p>
<ul>
<li><p>"names_df" which has 2 columns: "ID", "title" that refer to the id and the title of films.</p>
<pre><code>+-------+------------... | 0 | 2016-09-07T07:57:39Z | 39,369,797 | <p>Adding comment as answer since it solved the problem. <code>count</code> is somewhat of a protected keyword in DataFrame API, so naming columns <em>count</em> is dangerous. In your case you could circumvent the error by not using the dot notation, but bracket based column access, e.g.</p>
<pre><code>info["count"]
<... | 2 | 2016-09-07T12:19:10Z | [
"python",
"sql",
"function",
"join",
"apache-spark"
] |
Python multiprocessing start method doesn't run the process | 39,364,485 | <p>I'm new to multiprocessing and I'm trying to check that I can run two process simultaneously with the following code :</p>
<pre><code>import random, time, multiprocessing as mp
def printer():
"""print function"""
z = random.randit(0,60)
for i in range(5):
print z
wait = 0.2
wait... | 0 | 2016-09-07T08:08:16Z | 39,508,146 | <p>I made the script run by adding </p>
<pre><code>from multiprocessing import Process
</code></pre>
<p>However, I don't have a random sequence of two numbers, the pattern is always A,B,A,B.. If you know how to show that the two process run simultaneously, any ideas are welcome !</p>
| 0 | 2016-09-15T09:56:17Z | [
"python",
"multithreading",
"python-2.7",
"multiprocessing"
] |
Keras - Fitting Neural Net with different Epoch number in a loop without starting over each time | 39,364,516 | <p>I am fitting a recurrent neural net in <code>python</code> using <code>keras</code> library. I am fitting the model with different <code>epoch</code> number by changing parameter <code>nb_epoch</code> in <code>Sequential.fit()</code> function. Currently I'm using <code>for</code> loop which starts over fitting each ... | 2 | 2016-09-07T08:09:53Z | 39,371,723 | <p>Continuously calling <code>fit</code> is training your model further, starting from the state it was left from the previous call. For it to <strong>not</strong> continue it would have to reset the weights of your model, which <code>fit</code> does not do. You are just not seeing that it does that, as it is always st... | 1 | 2016-09-07T13:48:56Z | [
"python",
"loops",
"neural-network",
"deep-learning",
"keras"
] |
Elasticsearch fix date field value. (change field value from int to string) | 39,364,625 | <p>I used python ship data from mongodb to elasticsearch.</p>
<p>There is a timestamp field named <code>update_time</code>, mapping like:</p>
<pre><code> "update_time" : {
"type": "date",
"format": "yyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
</code></pre>
<p><code>epoch_millis</code> is... | 0 | 2016-09-07T08:15:55Z | 39,442,509 | <p>I didn't know groovy was a lauguage and thought it only used for math method because ES doc only wrote about that.</p>
<p>The sulotion is simple, just convert int to long.</p>
<pre><code>curl -XPOST http://localhost:9200/my_index/_update_by_query -d '
{
"script": {
"inline": "ctx._source.update_time=(long)ct... | 0 | 2016-09-12T02:08:05Z | [
"python",
"elasticsearch",
"elasticsearch-query"
] |
Program won't run | 39,364,796 | <p>I have this exercise and the first part of the program was running fine but I must've done something because now when I try to run it will just show <code>None</code> and and nothing seems to be 'wrong'. I don't know enough to even figure out what's wrong.</p>
<pre><code>def main():
"""Gets the job done"""
#th... | -2 | 2016-09-07T08:24:44Z | 39,415,032 | <p>The only function you call is <code>main()</code>, but that has no statements in it, so your code will do nothing. To fix this, put some statements in your <code>main()</code> and rerun your code.</p>
| 1 | 2016-09-09T15:28:37Z | [
"python",
"python-3.x"
] |
Python index function | 39,364,804 | <p>I am writing a simple Python program which grabs a webpage and finds all the URL links in it. However I try to index the starting and ending delimiter (") of each href link but the ending one always indexed wrong.</p>
<pre><code># open a url and find all the links in it
import urllib2
url=urllib2.urlopen('right.ht... | 0 | 2016-09-07T08:25:04Z | 39,364,876 | <p><code>b</code> is relative to the substring from <code>a+1</code>, hence the access to the array should be:</p>
<pre><code>linklist.append(bodycontent[(a+1):(a+1+b)])
</code></pre>
<p>As mentioned in other answers, it's usually preferable to work with a designated library, like <a href="https://pypi.python.org/pyp... | 0 | 2016-09-07T08:28:49Z | [
"python"
] |
Python index function | 39,364,804 | <p>I am writing a simple Python program which grabs a webpage and finds all the URL links in it. However I try to index the starting and ending delimiter (") of each href link but the ending one always indexed wrong.</p>
<pre><code># open a url and find all the links in it
import urllib2
url=urllib2.urlopen('right.ht... | 0 | 2016-09-07T08:25:04Z | 39,364,878 | <p>I would suggest using a html parsing library instead of manually searching the DOM String.</p>
<p>Beautiful Soup is an excellent library for this purpose. Here is the reference <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/" rel="nofollow">link</a></p>
<p>With bs your link searching functionality ... | 3 | 2016-09-07T08:28:51Z | [
"python"
] |
Convert hashed password to string werkuzeug python | 39,364,819 | <p>I am using Werkzeug for password hashing so that the passwords entered by users will be safe(atleast).</p>
<p>Lets say my application is as follows:</p>
<p>When a user gets logged in I will use check_password_hash and then login the user inside.</p>
<p>After the user is logged in, I want to show them their passwo... | -1 | 2016-09-07T08:26:00Z | 39,364,875 | <blockquote>
<p>After the user is logged in, I want to show them their password.</p>
</blockquote>
<p>The whole purpose and reason of hashing a password is that you can never do this. Not you, not anyone else. </p>
<p>If someone has access or steals the database with the list of passwords, converting the hash back ... | 2 | 2016-09-07T08:28:45Z | [
"python",
"security",
"hash",
"werkzeug"
] |
Convert hashed password to string werkuzeug python | 39,364,819 | <p>I am using Werkzeug for password hashing so that the passwords entered by users will be safe(atleast).</p>
<p>Lets say my application is as follows:</p>
<p>When a user gets logged in I will use check_password_hash and then login the user inside.</p>
<p>After the user is logged in, I want to show them their passwo... | -1 | 2016-09-07T08:26:00Z | 39,365,023 | <p>We cannot get the original text back while using hashing. Generally all the passwords are stored as hash value, in order to make the passwords private (known only to the user). All the servers implement this. If you want to get the password back then you should use symmetric key cryptography. Where a secret key will... | 1 | 2016-09-07T08:35:29Z | [
"python",
"security",
"hash",
"werkzeug"
] |
How can I write 1 byte to a binary file in python | 39,364,905 | <p>I've tried everything to write just one byte to a file in python. </p>
<pre><code>i=10
fh.write( six.int2byte(i) )
</code></pre>
<p>will output '0x00 0x0a'</p>
<pre><code>fh.write( struct.pack('i', i) )
</code></pre>
<p>will output '0x00 0x0a 0x00 0x00'</p>
<p>I can't understand why this is so hard to do.</p>
| 0 | 2016-09-07T08:30:13Z | 39,364,994 | <p>You can just build a <code>bytes</code> object with that value:</p>
<pre><code>with open('my_file', 'wb') as f:
f.write(bytes([10]))
</code></pre>
<p>This works only in python3. If you replace <code>bytes</code> with <code>bytearray</code> it works in both python2 and 3.</p>
<p>Also: remember to open the file... | 4 | 2016-09-07T08:34:29Z | [
"python",
"filehandle",
"writing"
] |
How can I write 1 byte to a binary file in python | 39,364,905 | <p>I've tried everything to write just one byte to a file in python. </p>
<pre><code>i=10
fh.write( six.int2byte(i) )
</code></pre>
<p>will output '0x00 0x0a'</p>
<pre><code>fh.write( struct.pack('i', i) )
</code></pre>
<p>will output '0x00 0x0a 0x00 0x00'</p>
<p>I can't understand why this is so hard to do.</p>
| 0 | 2016-09-07T08:30:13Z | 39,365,081 | <p><code>struct.pack("=b",i)</code> (signed) and <code>struct.pack("=B",i)</code> (unsigned) pack an integer as a single byte which you can see in the <a href="https://docs.python.org/3/library/struct.html#format-characters" rel="nofollow">docs for struct</a>. (<code>"="</code> is for using standard size and ignoring a... | 0 | 2016-09-07T08:39:01Z | [
"python",
"filehandle",
"writing"
] |
pymc3: how to model correlated intercept and slope in multilevel linear regression | 39,364,919 | <p>In the Pymc3 example for multilevel linear regression (the example is <a href="http://pymc-devs.github.io/pymc3/notebooks/GLM-hierarchical.html" rel="nofollow">here</a>, with the <code>radon</code> data set from Gelman et al.âs (2007)), the intercepts (for different counties) and slopes (for apartment with and wit... | 0 | 2016-09-07T08:31:09Z | 39,386,592 | <p>You forgot to add one line when creating the covariance matrix you miss-specified the shape of the MvNormal. Your model should look something like this:</p>
<pre><code>with pm.Model() as correlation_model:
mu = pm.Normal('mu', mu=0., sd=10, shape=2)
sigma = pm.HalfCauchy('sigma', 5, shape=2)
C_triu = p... | 1 | 2016-09-08T08:55:23Z | [
"python",
"pymc",
"pymc3"
] |
Urllib2: how to get content of page | 39,364,933 | <p>I have some urls:</p>
<pre><code>http://www.avito.ru/ryazan/avtomobili?pmax=50000&f=188_893b13978
http://www.avito.ru/ryazan/avtomobili?pmax=50000&f=188_898b13978
http://www.avito.ru/ryazanskaya_oblast/avtomobili?pmax=50000&f=188_898b13978
http://www.avito.ru/ryazanskaya_oblast/avtomobili?pmax=50000&... | 1 | 2016-09-07T08:31:32Z | 39,365,123 | <p>Its working fine for me. I used <code>requests</code> module to get the page. Python <code>requests</code> is better. If you dont have <code>requests</code> module installed you can install it by <code>pip install requests</code></p>
<pre><code>import requests
for url in urls: # if you are using a list to hold you... | 0 | 2016-09-07T08:41:02Z | [
"python",
"urllib2"
] |
pandas group by ALL functionality? | 39,365,003 | <p>I'm using the <code>pandas groupby+agg</code> functionality to generate nice reports</p>
<pre><code>aggs_dict = {'a':['mean', 'std'], 'b': 'size'}
df.groupby('year').agg(aggs_dict)
</code></pre>
<p>I would like to use the same <code>aggs_dict</code> on the entire dataframe as a single group, with no division to ye... | 1 | 2016-09-07T08:34:54Z | 39,365,089 | <p>You could add a dummy column:</p>
<pre><code>df['dummy'] = 1
</code></pre>
<p>Then groupby + agg on it:</p>
<pre><code>df.groupby('dummy').agg(aggs_dict)
</code></pre>
<p>and then <a href="http://stackoverflow.com/questions/13411544/delete-column-from-pandas-dataframe">delete it</a> when you're done.</p>
| 2 | 2016-09-07T08:39:27Z | [
"python",
"pandas",
"group-by"
] |
pandas group by ALL functionality? | 39,365,003 | <p>I'm using the <code>pandas groupby+agg</code> functionality to generate nice reports</p>
<pre><code>aggs_dict = {'a':['mean', 'std'], 'b': 'size'}
df.groupby('year').agg(aggs_dict)
</code></pre>
<p>I would like to use the same <code>aggs_dict</code> on the entire dataframe as a single group, with no division to ye... | 1 | 2016-09-07T08:34:54Z | 39,370,321 | <p>Ami Tavory's answer is a great way to do it but just in case you wanted a solution that doesn't require creating new columns and deleting them afterwards you could do something like:</p>
<pre><code>df.groupby([True]*len(df)).agg(aggs_dict)
</code></pre>
| 3 | 2016-09-07T12:45:02Z | [
"python",
"pandas",
"group-by"
] |
pip install --editable with a VCS url | 39,365,080 | <p>In <code>man pip</code> it says under <code>--editable <path/url></code>, </p>
<blockquote>
<p>Install a project in editable mode (i.e. setuptools "develop mode")
from a local project path or a VCS url</p>
</blockquote>
<p>What does that mean? Can I give it a repo branch on Github, and it'll go get it a... | 0 | 2016-09-07T08:39:00Z | 39,365,347 | <p>If you just want to install package from git repo <a href="http://stackoverflow.com/questions/20101834/pip-install-from-github-repo-branch?rq=1">read</a></p>
<p><code>-e</code> or <code>--editable</code> is little bit different, it is used, as stated in docs, for setuptools's <a href="https://setuptools.readthedocs... | 0 | 2016-09-07T08:52:08Z | [
"python",
"git",
"package",
"pip"
] |
Running Multiple spiders in scrapy for 1 website in parallel? | 39,365,131 | <p>I want to crawl a website with 2 parts and my script is not as fast as i need.</p>
<p>is it possible to luanch 2 spiders, one for scraping the first part and the second one for the second part? </p>
<p>i tried to have 2 diffrent classes, and run them</p>
<pre><code>scrapy crwal firstSpider
scrapy crawl secondSpid... | 0 | 2016-09-07T08:41:25Z | 39,366,885 | <p>I think what you are looking for is something like this:</p>
<pre><code>import scrapy
from scrapy.crawler import CrawlerProcess
class MySpider1(scrapy.Spider):
# Your first spider definition
...
class MySpider2(scrapy.Spider):
# Your second spider definition
...
process = CrawlerProcess()
process... | 1 | 2016-09-07T10:03:36Z | [
"python",
"web-scraping",
"scrapy",
"web-crawler",
"scrapy-spider"
] |
Iterating over a nested dictionary | 39,365,148 | <p>Purpose this code that works to iterate over a <code>nested dictionary</code> but I'm looking for an output that gives a tuple or <code>list</code> of [keys] and then [values]. Here's the code:</p>
<pre><code>from collections import Mapping, Set, Sequence
string_types = (str, unicode) if str is bytes else (str, by... | 0 | 2016-09-07T08:42:10Z | 39,365,862 | <p>This seems to work:</p>
<pre><code>results = AddNestedDict()
for k,v in recurse(loansDict):
results.setdefault(k[:-1], []).append(v)
result_key, result_value = results.items()[0]
print('{} {}'.format(result_key, result_value)) # -> (15, 'A', 'B') [1, 2, 3, 4]
</code></pre>
<p>I renamed your class <code>Add... | 1 | 2016-09-07T09:16:05Z | [
"python",
"python-3.x"
] |
Find in which of multiple sets a value belongs to | 39,365,365 | <p>I have several sets of values, and need to check in which of some of them a given value is located, and return the name of that set.</p>
<pre><code>value = 'a'
set_1 = {'a', 'b', 'c'}
set_2 = {'d', 'e', 'f'}
set_3 = {'g', 'h', 'i'}
set_4 = {'a', 'e', 'i'}
</code></pre>
<p>I'd like to check if value exists in sets ... | 0 | 2016-09-07T08:52:57Z | 39,365,637 | <p><em>Don't</em> use an ugly hackish lambda which digs in <code>globals</code> so you can get a name; that will confuse anyone reading your code including yourself after a few weeks :-).</p>
<p>You want to be able to get a name for sets you have defined, well, this is why we have dictionaries. Make a dictionary out o... | 2 | 2016-09-07T09:05:31Z | [
"python",
"python-3.x",
"set"
] |
pypi not finding registered package | 39,365,424 | <p>I have a package that I submitted to Pypi using the <code>python setup.py register</code> command:
<a href="https://bitbucket.org/lskibinski/et3" rel="nofollow">https://bitbucket.org/lskibinski/et3</a></p>
<p>You can see it here:
<a href="https://pypi.python.org/pypi?name=et3&version=1.0&:action=display" ... | 0 | 2016-09-07T08:55:49Z | 39,366,998 | <p>ok, figured it out. <code>download_url</code> doesn't appear to do much at all. I had to do:</p>
<ul>
<li><code>python setup.py register</code></li>
<li><code>python setup.py sdist upload</code></li>
</ul>
<p>... and it now works. The documentation for all of this is terrible.</p>
| 0 | 2016-09-07T10:09:31Z | [
"python",
"pypi"
] |
Create a in-browser Python application with a GUI | 39,365,445 | <p>I am teaching a class soon and I want to have users try my platform without the need of installing Python in their computers and to run everything online. I have searched for platforms such as Skulpt, CodeMirror and Trinket and they seem ok for what I want to do. However, I want to develop a GUI for the users to inp... | 0 | 2016-09-07T08:56:28Z | 39,369,084 | <p>I guess <a href="http://jupyter.org/" rel="nofollow">Jupyter</a> could meet your needs. <a href="http://jupyter.readthedocs.io/en/latest/install.html" rel="nofollow">Getting started here</a>.</p>
<blockquote>
<p>The Jupyter Notebook is a web application that allows you to create and share documents that contain l... | 0 | 2016-09-07T11:47:04Z | [
"python",
"user-interface",
"browser"
] |
How to drop duplicated rows using pandas in a big data file? | 39,365,568 | <p>I have a csv file that too big to load to memory.I need to drop duplicated rows of the file.So I follow this way:</p>
<pre><code>chunker = pd.read_table(AUTHORS_PATH, names=['Author ID', 'Author name'], encoding='utf-8', chunksize=10000000)
for chunk in chunker:
chunk.drop_duplicates(['Author ID'])
</code... | 2 | 2016-09-07T09:02:23Z | 39,365,740 | <p>You could try something like this.</p>
<p>First, create your chunker.</p>
<pre><code>chunker = pd.read_table(AUTHORS_PATH, names=['Author ID', 'Author name'], encoding='utf-8', chunksize=10000000)
</code></pre>
<p>Now create a set of ids:</p>
<pre><code>ids = set()
</code></pre>
<p>Now iterate over the chunks:<... | 1 | 2016-09-07T09:10:15Z | [
"python",
"database",
"pandas",
"bigdata"
] |
Execute Jobs using Spark + Cassandra utilizing data locality | 39,365,641 | <p>I have an exec, which accepts a cassandra primary key as input.</p>
<pre><code>Cassandra Row: (id, date), clustering_key, data
./exec id date
</code></pre>
<p>Each exec can access multiple rows for given primary key. After performing execution on data, it stores results in a DB.</p>
<p>I have multiple such execs ... | 0 | 2016-09-07T09:05:45Z | 39,395,795 | <p>If you want to use Spark (with data locality), you have to write Spark program to do the same thing <code>exec</code> is doing. Spark driver (you can use DataStax Cassandra/Spark Connector) takes care of locality issues automatically. </p>
<p>If you want to exploit the data locality without writing Spark program, t... | 0 | 2016-09-08T16:13:21Z | [
"python",
"apache-spark",
"cassandra"
] |
Find eigenvalues of Complex valued matrix in python | 39,365,697 | <p>I need to find the eigenvvalues of of this matrix, and similar such matrices (spaces denote separators):</p>
<pre><code>[[1.0000 -0.7071*I 0 -0.7071*I 0 0 0 0 0]
[0.7071*I 0.5000 -0.7071*I 0 -0.70710*I 0 0 0 0]
[0 0.7071*I 1.0000 0 0 -0.7071*I 0 0 0]
[0.7071*I 0 0 0.5000 -0.7071*I 0 -0.7071*I 0 0] ... | 0 | 2016-09-07T09:08:06Z | 39,365,774 | <p>In numpy you get this for free</p>
<pre><code>import numpy as np
matrix = np.array([[1+1j,0+1j],[0+1j,1+1j]])
eingenvalues,eigenvectors=np.linalg.eig(matrix)
</code></pre>
<p>will give you both, eigenvalues and corresponding eigenvectosr</p>
<p>If you are really only interested in the eigen values you can use</p... | -1 | 2016-09-07T09:11:39Z | [
"python",
"numpy",
"matrix",
"linear-algebra",
"eigenvalue"
] |
Find eigenvalues of Complex valued matrix in python | 39,365,697 | <p>I need to find the eigenvvalues of of this matrix, and similar such matrices (spaces denote separators):</p>
<pre><code>[[1.0000 -0.7071*I 0 -0.7071*I 0 0 0 0 0]
[0.7071*I 0.5000 -0.7071*I 0 -0.70710*I 0 0 0 0]
[0 0.7071*I 1.0000 0 0 -0.7071*I 0 0 0]
[0.7071*I 0 0 0.5000 -0.7071*I 0 -0.7071*I 0 0] ... | 0 | 2016-09-07T09:08:06Z | 39,370,732 | <p>As more than one commenter has explained, your matrix works fine with <code>eigvalsh</code>.</p>
<pre><code>import numpy as np
from numpy.linalg import eigvalsh
I = 1j
arr = np.array([[1.0000, -0.7071*I, 0, -0.7071*I, 0, 0, 0, 0, 0],
[0.7071*I, 0.5000, -0.7071*I, 0, -0.70710*I, 0, 0, 0, 0],
[0, 0.7071*I, 1... | 1 | 2016-09-07T13:04:59Z | [
"python",
"numpy",
"matrix",
"linear-algebra",
"eigenvalue"
] |
How can I change outfile path? outfile = join(basename(image)) | 39,365,733 | <p>I can't figure out how to change the filepath on this code?</p>
<pre><code>import os
import glob
import time
import traceback
from time import sleep
import RPi.GPIO as GPIO
import picamera
import atexit
import sys
import socket
import pygame
from pygame.locals import QUIT, KEYDOWN, K_ESCAPE
import pytumblr
import c... | 0 | 2016-09-07T09:09:51Z | 39,378,887 | <p>Ok, so I have read the doc of PIL (all as expected) and You should try :</p>
<pre><code>outfile = join( <your_path> , basename(image) ) # replace your_path to actual path
Image.composite(layer, im, layer).save(outfile)
</code></pre>
| 0 | 2016-09-07T20:57:53Z | [
"python",
"path",
"filepath"
] |
MultiValueDictKeyError after trying to log in | 39,365,840 | <p>I'm getting a MultiValueDictKey error.</p>
<p>This is my view:</p>
<pre><code>from django.shortcuts import render
from django.contrib.auth import authenticate, login
from django.http import HttpResponse, HttpResponseRedirect
from bookonshelf import settings
def Login(request):
next = request.GET.get('next', '... | -1 | 2016-09-07T09:14:50Z | 39,366,186 | <p>You never give your inputs a name so they are never added to the post data</p>
<pre><code><input type="text" id="username" name="username">
<input type="password" id="password" name="password">
</code></pre>
<p><sub><sub>I removed some attributes for brevity</sub></sub></p>
<p>Also note:</p>
<ul>
<li... | 1 | 2016-09-07T09:30:17Z | [
"python",
"django"
] |
MultiValueDictKeyError after trying to log in | 39,365,840 | <p>I'm getting a MultiValueDictKey error.</p>
<p>This is my view:</p>
<pre><code>from django.shortcuts import render
from django.contrib.auth import authenticate, login
from django.http import HttpResponse, HttpResponseRedirect
from bookonshelf import settings
def Login(request):
next = request.GET.get('next', '... | -1 | 2016-09-07T09:14:50Z | 39,366,203 | <p>Put <code>name=</code> for both fields. Ex</p>
<pre><code><input type="text" name="username" id="username" class="form-control" placeholder="Username" required autofocus>
</code></pre>
| 1 | 2016-09-07T09:30:48Z | [
"python",
"django"
] |
Download all attachments received in the past 30 days | 39,365,885 | <p>Below is my code.</p>
<pre><code>import win32com.client,datetime
outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI")
inbox = outlook.GetDefaultFolder(6).Folders('Paper & CD')
messages = inbox.Items
date_now = datetime.datetime.now().date()
date_before = (datetime.datetime.now() + dat... | 0 | 2016-09-07T09:17:08Z | 39,376,069 | <p>Use <code>Items.Restrict</code> or <code>Items.Find/FindNext</code> with a restriction based on the <code>ReceivedTime</code> property.</p>
| 0 | 2016-09-07T17:32:54Z | [
"python",
"outlook"
] |
django inspectdb 'unique_together' refers to the non-existent field | 39,366,071 | <p>I have a legacy database that I wish to use as a second database in my django project. I added the database to my settings file, and ran:</p>
<pre><code>python manage.py inspectdb --database=images
</code></pre>
<p>The script finished in less than a second, and the results were astounding. It understood all my t... | 0 | 2016-09-07T09:25:31Z | 39,366,072 | <p>django's inspectdb took my legacy field names as the field names for unique_together. I changed this so it used the properties in the model, and that solved the problem. I also added the _ before the id, as stated in the google groups post listed above. But I am not sure if that underscore was relevant. Right no... | 0 | 2016-09-07T09:25:31Z | [
"python",
"django",
"inspectdb"
] |
django inspectdb 'unique_together' refers to the non-existent field | 39,366,071 | <p>I have a legacy database that I wish to use as a second database in my django project. I added the database to my settings file, and ran:</p>
<pre><code>python manage.py inspectdb --database=images
</code></pre>
<p>The script finished in less than a second, and the results were astounding. It understood all my t... | 0 | 2016-09-07T09:25:31Z | 39,366,324 | <p>This was a bug in Django 1.8, see <a href="https://code.djangoproject.com/ticket/25274" rel="nofollow">#25274</a>. It has been fixed in 1.8.8. You should upgrade to the latest 1.8.x version. </p>
<p>Note that minor version upgrades, from 1.8.x to 1.8.x+1, only include bugfixes and security updates. You should alway... | 2 | 2016-09-07T09:36:11Z | [
"python",
"django",
"inspectdb"
] |
Python: can't instantiate my object from inside another object: 'global name not defined' | 39,366,082 | <p>Hi all and thanks in advance for any help. </p>
<p>I am learning Python and working on a Zork style adventure game to practise.</p>
<p>Once I've defined classes my first actual instruction is</p>
<pre><code>ourGame = Game('githyargi.txt')
</code></pre>
<p>where githyargi.txt is a file containing all the game's s... | -1 | 2016-09-07T09:25:59Z | 39,366,170 | <p>It's a timing thing. When you do</p>
<pre><code>ourGame = Game('githyargi.txt')
</code></pre>
<p>Then first the Game instance is created, and only then is it assigned to ourGame.</p>
<p>Instead, pass the Game to use to the constructor of Scene, and pass <code>self</code> so it becomes something like</p>
<pre><co... | 0 | 2016-09-07T09:29:31Z | [
"python",
"nameerror"
] |
Numpy Cosine Similarity difference over big collections | 39,366,120 | <p>I need to use the Scikit-learn <strong>sklearn.metric.pairwise.cosine_similarity</strong> over big matrixes.
For some optimizations i need to compute only some rows of the matrixes, and so i tried different methods.</p>
<p>I found that in some cases <strong>the results were different depending on the size of the v... | 2 | 2016-09-07T09:27:38Z | 39,370,113 | <p>In order to compare <code>numpy.array</code> you have to use <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.isclose.html" rel="nofollow"><code>np.isclose</code></a> instead of equality operator. Try:</p>
<pre><code>from sklearn.metrics.pairwise import cosine_similarity
from scipy import spatial
... | 0 | 2016-09-07T12:34:27Z | [
"python",
"numpy",
"scikit-learn",
"cosine-similarity"
] |
How to store values retrieved from a loop in different variables in Python? | 39,366,134 | <p>Just a quick question.<br>
Suppose, I have a simple for-loop like </p>
<pre><code>for i in range(1,11):
x = raw_input()
</code></pre>
<p>and I want to store all the values of <em>x</em> that I will be getting throughout the loop in <em>different variables</em> such that I can use all these <em>different vari... | -1 | 2016-09-07T09:28:16Z | 39,366,187 | <p>You can store each input in a list, then access them later when you want.</p>
<pre><code>inputs = []
for i in range(1,11);
x = raw_input()
inputs.append(x)
# print all inputs
for inp in inputs:
print(inp)
# Access a specific input
print(inp[0])
print(inp[1])
</code></pre>
| 3 | 2016-09-07T09:30:19Z | [
"python",
"python-2.7",
"for-loop",
"iteration"
] |
How to store values retrieved from a loop in different variables in Python? | 39,366,134 | <p>Just a quick question.<br>
Suppose, I have a simple for-loop like </p>
<pre><code>for i in range(1,11):
x = raw_input()
</code></pre>
<p>and I want to store all the values of <em>x</em> that I will be getting throughout the loop in <em>different variables</em> such that I can use all these <em>different vari... | -1 | 2016-09-07T09:28:16Z | 39,366,192 | <p>You can form a list with them.</p>
<pre><code>your_list = [raw_input() for _ in range(1, 11)]
</code></pre>
<p>To print the list, do:</p>
<pre><code>print your_list
</code></pre>
<p>To iterate through the list, do:</p>
<pre><code>for i in your_list:
#do_something
</code></pre>
| 3 | 2016-09-07T09:30:23Z | [
"python",
"python-2.7",
"for-loop",
"iteration"
] |
How to store values retrieved from a loop in different variables in Python? | 39,366,134 | <p>Just a quick question.<br>
Suppose, I have a simple for-loop like </p>
<pre><code>for i in range(1,11):
x = raw_input()
</code></pre>
<p>and I want to store all the values of <em>x</em> that I will be getting throughout the loop in <em>different variables</em> such that I can use all these <em>different vari... | -1 | 2016-09-07T09:28:16Z | 39,366,217 | <p>Create a list before the loop and store x in the list as you iterate:</p>
<pre><code>l=[]
for i in range(1,11):
x = raw_input()
l.append(x)
print(l)
</code></pre>
| 3 | 2016-09-07T09:31:26Z | [
"python",
"python-2.7",
"for-loop",
"iteration"
] |
inherited function odoo python | 39,366,140 | <p>i want to inherit function in module 'hr_holidays' that calculate remaining leaves the function is :</p>
<h2>hr_holiday.py:</h2>
<pre><code>def _get_remaining_days(self, cr, uid, ids, name, args, context=None):
cr.execute("""SELECT
sum(h.number_of_days) as days,
h.employee_id
f... | 1 | 2016-09-07T09:28:30Z | 39,366,945 | <p>You have to call the right Class in super():</p>
<pre class="lang-py prettyprint-override"><code>res = super(HrHolidays, self)._get_remaining_days(
cr, uid, ids, name, args, context)
</code></pre>
| 0 | 2016-09-07T10:06:47Z | [
"python",
"openerp"
] |
inherited function odoo python | 39,366,140 | <p>i want to inherit function in module 'hr_holidays' that calculate remaining leaves the function is :</p>
<h2>hr_holiday.py:</h2>
<pre><code>def _get_remaining_days(self, cr, uid, ids, name, args, context=None):
cr.execute("""SELECT
sum(h.number_of_days) as days,
h.employee_id
f... | 1 | 2016-09-07T09:28:30Z | 39,370,623 | <p>You need to call super with <code>HrHolidays</code> and pass just name and args to <code>_get_remaining_days</code> method and override <code>remaining_leaves</code> field: </p>
<p><strong>Python</strong> </p>
<pre><code>class HrHolidays(models.Model):
_inherit = 'hr.employee'
@api.model
def _get_remaining_days... | 0 | 2016-09-07T12:59:45Z | [
"python",
"openerp"
] |
inherited function odoo python | 39,366,140 | <p>i want to inherit function in module 'hr_holidays' that calculate remaining leaves the function is :</p>
<h2>hr_holiday.py:</h2>
<pre><code>def _get_remaining_days(self, cr, uid, ids, name, args, context=None):
cr.execute("""SELECT
sum(h.number_of_days) as days,
h.employee_id
f... | 1 | 2016-09-07T09:28:30Z | 39,371,067 | <p>thanks for all ,
but i got problem in the field ,i want to award my function to my field i have done that but isn't work :</p>
<pre><code> remaining_leaves = fields.Function(_get_remaining_days,string='Leaves')
</code></pre>
<p>i got this error
<a href="http://i.stack.imgur.com/acICN.png" rel="nofollow"><img s... | 0 | 2016-09-07T13:20:49Z | [
"python",
"openerp"
] |
inherited function odoo python | 39,366,140 | <p>i want to inherit function in module 'hr_holidays' that calculate remaining leaves the function is :</p>
<h2>hr_holiday.py:</h2>
<pre><code>def _get_remaining_days(self, cr, uid, ids, name, args, context=None):
cr.execute("""SELECT
sum(h.number_of_days) as days,
h.employee_id
f... | 1 | 2016-09-07T09:28:30Z | 39,372,443 | <p>i think that function work but i couldnt show it by fields.function </p>
<pre><code> remaining_leaves = fields.Function(_get_remaining_days,string='Leaves')
</code></pre>
| 0 | 2016-09-07T14:20:14Z | [
"python",
"openerp"
] |
Trying to add two matrices with numbers entered as a string and then display solution, but trouble with stdin and stdout | 39,366,209 | <p>It's a programming task to enter two matrices using stdin and then display the result in stdout. I often found runtime error or no stdin or stdout to display while the program is running good.</p>
<p>This is my code for addition of two matrices.</p>
<pre><code> """The constraint is the numbers will be entere... | 0 | 2016-09-07T09:30:59Z | 39,368,245 | <p>You could have some problem with the indentation... I did not touch a line (other than adjust the indentation and it work as expected!)</p>
<pre><code>#!/usr/bin/env pyhton2
import sys
def main():
num1 = []
num2 = []
rc1 = raw_input().split(' ')
rc1_arr = [int(z) for z in rc1]
r1 = rc1_arr[0]... | 0 | 2016-09-07T11:07:17Z | [
"python",
"matrix",
"stdout",
"stdin",
"sys"
] |
raising error does not prevent try-except clause to get executed? | 39,366,264 | <p>I've got surprised while testing a piece of code that looked a bit like that:</p>
<pre><code>if x:
try:
obj = look-for-item-with-id==x in a db
if obj is None:
# print debug message
raise NotFound('No item with this id')
return obj
except Except... | 1 | 2016-09-07T09:33:19Z | 39,366,340 | <p>if obj is array please check if length or count of items is zero
this mean obj not none but not contain items</p>
| -1 | 2016-09-07T09:36:58Z | [
"python",
"exception",
"try-except",
"raise"
] |
raising error does not prevent try-except clause to get executed? | 39,366,264 | <p>I've got surprised while testing a piece of code that looked a bit like that:</p>
<pre><code>if x:
try:
obj = look-for-item-with-id==x in a db
if obj is None:
# print debug message
raise NotFound('No item with this id')
return obj
except Except... | 1 | 2016-09-07T09:33:19Z | 39,372,621 | <p>When you say <code>except Exception, e:</code>, you are explicitly catching (almost) <em>any</em> exception that might get raised within that block -- including your <code>NotFound</code>. </p>
<p>If you want the <code>NotFound</code> itself to propagate further up, you don't need to have a <code>try/except</code> ... | 1 | 2016-09-07T14:27:32Z | [
"python",
"exception",
"try-except",
"raise"
] |
JSON escape double quotes | 39,366,291 | <p>I know this title seems rather popular on here, but a quick browse through them usually involves situations where the asker has one isolated section of JSON.</p>
<p>There are situations where <code>"</code> is used to signify inches, or it wraps a phrase to signify a nickname of some sort, either way it appears in ... | -2 | 2016-09-07T09:34:42Z | 39,374,851 | <p>for some reason, using pythons builtin replace function achieved the desired result whereas re.sub did not properly escape the double quotes. (this was with using groups references in a raw string with a single escape or a regular string with double escapes). Either way, here is the working function. If someone has ... | 0 | 2016-09-07T16:13:19Z | [
"python",
"json",
"regex",
"escaping"
] |
Appending or Adding Rows in Pandas Dataframe | 39,366,558 | <p>In the following DataFrame I would like to add rows if the count of values in the column A is less than 10. </p>
<p>For eg., in the following Table column A group 60 appears 12 times, however gorup 61 appears 9 times. I would like to add a row after last record of group 61 and copy the value in column B,C,D from th... | 1 | 2016-09-07T09:47:38Z | 39,367,302 | <p>You can use:</p>
<pre><code>#cumulative count per group
df['G'] = df.groupby('A').cumcount()
df = df.groupby(['A','G'])
.first() #agregate first
.unstack() #reshape DataFrame
.ffill() #same as fillna(method='ffill')
.stack() #get original shape
.reset_index(drop=True, level... | 2 | 2016-09-07T10:23:05Z | [
"python",
"csv",
"pandas",
"append",
"pivot-table"
] |
Using AutoPep8 in pydev | 39,366,681 | <p>I'm trying to use autopep8.py as the code formatter for pydev but I don't seem to be able to supply the parameters correctly as the output isn't as I would expect. </p>
<p>I need to be able to supply two parameters <code>-a --max-line-length 100</code> but for some reason the formatter appears to be ignoring the li... | 0 | 2016-09-07T09:53:22Z | 39,416,546 | <p>Well, I'm specifying the following settings and it works for me:</p>
<pre><code>-a -a --max-line-length=100 --ignore=E309
</code></pre>
<p>So, I guess the problem in your case is missing the equals char after the <code>--max-line-length</code>.</p>
| 1 | 2016-09-09T17:05:51Z | [
"python",
"pydev",
"code-formatting",
"autopep8"
] |
How can I get a similar summary of a Pandas dataframe as in R? | 39,366,878 | <p>Different scales allow different types of operations. I would like to specify the scale of a column in a dataframe <code>df</code>. Then, <code>df.describe()</code> should take this into account.</p>
<h2>Examples</h2>
<ul>
<li><strong>Nominal scale</strong>: A nominal scale only allows to check for equivalence. Ex... | 2 | 2016-09-07T10:03:26Z | 39,370,071 | <p>You could have something like:</p>
<pre><code>def summary_lookalike(frame):
frame.index = frame.index.map(str)
return (frame.astype(str).apply(lambda x: frame.index.values + ': ' + x))
def descriptive_stats(df1, df2):
df2 = df2.apply(lambda x: x.value_counts())
df1, df2 = summary_lookalike(df1), ... | 0 | 2016-09-07T12:32:46Z | [
"python",
"pandas",
"dataframe"
] |
How to create domain ontology lexicon by getting all the classes name attribute relations and save it in the lists | 39,366,879 | <p>I am new to the ontology and semantic analysis. currently, I have one public ontology source which was from BBC website. the source is in " .ttl " format.
I was also to load the source in Jena by using eclipse. However, i was a little lost when i see the code. </p>
<p>Here is some example:</p>
<pre><code><http... | 2 | 2016-09-07T10:03:26Z | 39,570,430 | <pre><code>for subj, pred, obj in g:
subname = subj.split("/")[-1]
</code></pre>
<p>This way you can get the name of the subject.</p>
| 1 | 2016-09-19T10:04:12Z | [
"python",
"eclipse",
"jena",
"ontology",
"apache-jena"
] |
Why /usr/local/bin is not recognisable in my C++ program? | 39,366,943 | <p>My C++ code:</p>
<pre><code>int main(int argc, const char * argv[])
{
system("python test.py");
return 0;
}
</code></pre>
<p>I have a program <code>foo</code> in /usr/local/bin, and I can just type <code>foo</code> in Unix console and it starts.</p>
<p>The following Python script (test.py) works:</p>
<pr... | 3 | 2016-09-07T10:06:26Z | 39,367,578 | <p>Thanks to @ilent2, his answer solved my problem. I was using an IDE to run the C++ code and never realised that I had to tell the IDE my paths. When I ran the same program directly in the console, it worked.</p>
| 3 | 2016-09-07T10:36:01Z | [
"python",
"c++"
] |
NetworkX - path around a node | 39,367,036 | <p>I use <a href="http://networkx.readthedocs.io/en/latest/" rel="nofollow">NetworkX</a> to create the following graph.</p>
<p><a href="http://i.stack.imgur.com/C69Jr.png" rel="nofollow"><img src="http://i.stack.imgur.com/C69Jr.png" alt="Networkx graph"></a></p>
<p>The graph is created using:</p>
<pre><code>G = nx.g... | 4 | 2016-09-07T10:11:17Z | 39,367,790 | <p>I believe that in this specific case would suffice to find which neighbours your neighbours have in common. </p>
<p>the code would be : </p>
<pre><code>in_loop = set()
root = (1,1)
for neighb in G.neighbors(root):
others = [n for n in G.neighbors((1,1)) if n != neighb]
for other in others:
if nei... | 1 | 2016-09-07T10:46:23Z | [
"python",
"networkx"
] |
select certain monitor for going fullscreen with gtk | 39,367,246 | <p>I intend to change the monitor where I show a fullscreen window.
This is especially interesting when having a projector hooked up.</p>
<p>I've tried to use <a href="https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-fullscreen-on-monitor" rel="nofollow"><code>fullscreen_on_monitor</code></a> but that... | 4 | 2016-09-07T10:20:38Z | 39,386,341 | <p>The problem seems to be that Gtk just ignores the monitor number, it will always fullscreen the window on the monitor on which the window currently is positioned. This sucks, but we can use that to make it work the way we want to.</p>
<p>But first some theory about multiple monitors, they aren't actually separate m... | 3 | 2016-09-08T08:41:31Z | [
"python",
"gtk",
"fullscreen",
"gtk3"
] |
Using named arguments as variables | 39,367,278 | <p>I am using django but I think this question primarily belongs to Python itself.</p>
<p>I have something like:</p>
<pre><code>def get(self, request, arg, *args, **kwargs):
if kwargs['m0'] == 'death':
if kwargs['m1'] == 'year':
result = Artists.objects.filter(death_year=arg)
elif kwargs['m1... | 1 | 2016-09-07T10:21:51Z | 39,367,848 | <p>From what I can make out you can construct the key and then pass in an arg to construct the dict, then include that in the filter</p>
<pre><code>key = '%s_%s' % (kwargs['m0'], kwargs['m1'])
result = Artists.objects.filter(**{key: arg})
</code></pre>
| 5 | 2016-09-07T10:48:29Z | [
"python",
"django"
] |
Using named arguments as variables | 39,367,278 | <p>I am using django but I think this question primarily belongs to Python itself.</p>
<p>I have something like:</p>
<pre><code>def get(self, request, arg, *args, **kwargs):
if kwargs['m0'] == 'death':
if kwargs['m1'] == 'year':
result = Artists.objects.filter(death_year=arg)
elif kwargs['m1... | 1 | 2016-09-07T10:21:51Z | 39,371,856 | <p>The basic and incredibly powerful idea in Python is that you can pass a list of positional arguments without writing <code>args[0], args[1],...</code> and/or a dict of keyword arguments without writing <code>foo=kwargs["foo"], bar=kwargs["bar"],...</code> by using <code>*</code> and <code>**</code> as in <code>func(... | 1 | 2016-09-07T13:54:36Z | [
"python",
"django"
] |
Python SQLAlchemy attribute-events - How to check oldvalue equals NO_VALUE? | 39,367,329 | <p>The <a href="http://docs.sqlalchemy.org/en/latest/orm/events.html#attribute-events" rel="nofollow">official documentation</a> of SQLAlchemy states:</p>
<blockquote>
<p>oldvalue â the previous value being replaced. This may also be the
symbol <code>NEVER_SET</code> or <code>NO_VALUE</code>. If the listener is ... | 0 | 2016-09-07T10:24:30Z | 39,405,614 | <p>use </p>
<pre><code>from sqlalchemy.orm.base import NO_VALUE
if oldvalue is NO_VALUE:
//login here
</code></pre>
<p>works for me </p>
| 0 | 2016-09-09T07:00:55Z | [
"python",
"sqlalchemy",
"flask-sqlalchemy"
] |
Get "TypeError: cannot create mph' When Using sympy.nsolve() | 39,367,450 | <p>I am attempting to determine the time, angle and speed that something would have to travel to intersect with a moving ellipse. (I actually want these conditions for the minimum time). Right now I was trying to use Sympy to help with this adventure. The following is the code which I am executing:</p>
<pre><code>i... | 1 | 2016-09-07T10:30:22Z | 39,419,144 | <p>The variables <code>x</code> and <code>y</code> are still symbolic in the equations. <code>nsolve</code> requires all variables to be specified, and at least as many equations as variables. So you either need to include values for them in <code>mysubs</code>, or else solve for them (but to do that with <code>nsolve<... | 0 | 2016-09-09T20:19:23Z | [
"python",
"sympy"
] |
Python - How to hide labels and keep legends matplotlib? | 39,367,481 | <p>I would like to remove the labels of a pie chart and keep the legends only. Currently, my code has both. Any idea how to remove the labels?</p>
<p>I've tried the code below: </p>
<pre><code>plt.legend(labels, loc="best")
and
labels=None
</code></pre>
<p>Bu didn't work.</p>
<p>My full code is:</p>
<pre><cod... | 0 | 2016-09-07T10:31:39Z | 39,367,824 | <p>If I understand your question correctly this should solve it.
Removing the labels from the pie chart creation and adding the labels to the legend - </p>
<pre class="lang-py prettyprint-override"><code>plt.pie(percent, # data
explode=explode, # offset parameters
colors=colors, # array ... | 0 | 2016-09-07T10:47:17Z | [
"python",
"matplotlib",
"legend",
"pie-chart"
] |
Python - How to hide labels and keep legends matplotlib? | 39,367,481 | <p>I would like to remove the labels of a pie chart and keep the legends only. Currently, my code has both. Any idea how to remove the labels?</p>
<p>I've tried the code below: </p>
<pre><code>plt.legend(labels, loc="best")
and
labels=None
</code></pre>
<p>Bu didn't work.</p>
<p>My full code is:</p>
<pre><cod... | 0 | 2016-09-07T10:31:39Z | 39,369,353 | <p>If you alter your code to the following, it should remove the labels and keep the legend:</p>
<pre><code>plt.pie(percent, # data
explode=explode, # offset parameters
labels=None, # OR omit this argument altogether
colors=colors, # array of colours
autopct='%1.0f%%', # pri... | 1 | 2016-09-07T11:58:51Z | [
"python",
"matplotlib",
"legend",
"pie-chart"
] |
Django 1.95 template i18n not working | 39,367,492 | <p>I am trying to translate the string from English to zh-hans</p>
<p>In the <code>settings.py</code></p>
<pre><code>LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
</code></pre>
<p>I have run the <code>python manage.py makemessages -l zh-hans</code> and <code>python ma... | 0 | 2016-09-07T10:31:58Z | 39,381,282 | <p>It's a very silly mistake.</p>
<p>Although in the <code>setting.py</code> the Chinese language code can be set as 'zh-hans', to implement the i18n, it should be makemessages -l zh_hans instead of zh-hans.</p>
| 0 | 2016-09-08T01:30:32Z | [
"python",
"django",
"internationalization"
] |
Importing modules used in a package in __init__.py | 39,367,497 | <p>I have the following directory structure:</p>
<pre><code>funniest/
setup.py
funniest/
__init__.py
ModuleA.py
ModuleB.py
</code></pre>
<pre><code># __init__.py
from numba import jit
from .ModuleA import ClassA
</code></pre>
<pre><code># ModuleA.py
import funniest.ModuleB... | 3 | 2016-09-07T10:32:06Z | 39,367,643 | <p>The imports you put in <code>funniest/__init__.py</code> are only imported when you do <code>import funniest</code>, not automatically inside submodules. So <code>ModuleB</code> doesn't know about <code>jit</code>.</p>
<p>What you need to do here is to move <code>from numba import jit</code> from <code>__init__.py<... | 4 | 2016-09-07T10:39:45Z | [
"python"
] |
Importing modules used in a package in __init__.py | 39,367,497 | <p>I have the following directory structure:</p>
<pre><code>funniest/
setup.py
funniest/
__init__.py
ModuleA.py
ModuleB.py
</code></pre>
<pre><code># __init__.py
from numba import jit
from .ModuleA import ClassA
</code></pre>
<pre><code># ModuleA.py
import funniest.ModuleB... | 3 | 2016-09-07T10:32:06Z | 39,367,755 | <p>The name <code>jit</code> is not known inside <code>ModuleB</code>. Python imports doesn't work like C/C++ includes that roll-out the code in place of the <code>import</code>. A new module creates a new namespace with a map inside - a map with functions, classes, etc.</p>
<p>So when you did <code>import funniest</c... | 3 | 2016-09-07T10:44:28Z | [
"python"
] |
Repeating a for in line loop python | 39,367,593 | <p>How would I repeat this (excluding the opening of the file and the setting of the variables)?
this is my code in python3 </p>
<pre><code>file = ('file.csv','r')
count = 0 #counts number of times i was equal to 1
i = 0 #column number
for line in file:
line = line.split(",")
if line[i] == 1:
... | -4 | 2016-09-07T10:37:00Z | 39,367,685 | <p>If I understand the question, try this and adjust for however you want to format. Replace <code>NUM_COLUMNS</code> with the number of times you want it repeating</p>
<pre><code>file = open('file.csv','r')
data = file.readlines()
for i in range(NUM_COLUMNS):
count = 0
for line in data:
line = line... | 0 | 2016-09-07T10:41:38Z | [
"python",
"list",
"python-3.x",
"csv",
"repeat"
] |
Repeating a for in line loop python | 39,367,593 | <p>How would I repeat this (excluding the opening of the file and the setting of the variables)?
this is my code in python3 </p>
<pre><code>file = ('file.csv','r')
count = 0 #counts number of times i was equal to 1
i = 0 #column number
for line in file:
line = line.split(",")
if line[i] == 1:
... | -4 | 2016-09-07T10:37:00Z | 39,367,779 | <p>The following function will return the number of fields in the csv file <code>file_name</code> whose value is <code>field_value</code>, which is what I think you are trying to do:</p>
<pre><code>import csv
def get_count(file_name, field_value):
count = 0
with open(file_name) as f:
reader = csv.rea... | 0 | 2016-09-07T10:45:49Z | [
"python",
"list",
"python-3.x",
"csv",
"repeat"
] |
Save binary image after watershed | 39,367,655 | <p>I have problems storing my image after watershed segmentation as a binary image. When I plot the segmentation with cmap=plt.cm.gray it shows a binary image but I don't know how to store the image (without to display it).</p>
<pre><code>import cv2
import numpy as np
from matplotlib import pyplot as plt
from skimage.... | 0 | 2016-09-07T10:40:16Z | 39,371,049 | <p>In short, you can save it similarly to how you are displaying it using (see <a href="http://stackoverflow.com/questions/30941350/how-are-images-actually-saved-with-skimage-python">here</a> for reference):</p>
<pre><code>plt.imsave('test.png', segmentation, cmap = plt.cm.gray)
</code></pre>
<p>Note however, that <c... | 1 | 2016-09-07T13:20:07Z | [
"python",
"image-segmentation",
"watershed",
"skimage"
] |
How to use Python Matplotlib with OSx and virtualenv? | 39,367,776 | <p>I just started learning Python's libraries for data analysis (Numpy, Pandas and Matplotlib) but have already stumbled across my first problem - getting the Matplotlib to work with <code>virtualenv</code>. </p>
<p>When working with Python I always create a new virtual environment, get my desired Python version and l... | 2 | 2016-09-07T10:45:26Z | 39,369,009 | <p>You are almost correct. From personal experience, Matplotlib doesn't require the system Python to run on macOS. </p>
<p>As such, to install and use Matplotlib you can:</p>
<ol>
<li>Create a new virtual env and activate it with <code>source virtualenv/bin/activate</code>.</li>
<li>Install Matplotlib with <code>pip ... | 1 | 2016-09-07T11:44:04Z | [
"python",
"osx",
"shell",
"matplotlib",
"virtualenv"
] |
How to save webpages text content as a text file using python | 39,367,963 | <p>I did python script:</p>
<pre><code> from string import punctuation
from collections import Counter
import urllib
from stripogram import html2text
myurl = urllib.urlopen("https://www.google.co.in/?gfe_rd=cr&ei=v-PPV5aYHs6L8Qfwwrlg#q=samsung%20j7")
html_string = myurl.read()
text = ht... | 1 | 2016-09-07T10:54:05Z | 39,368,155 | <pre><code> import urllib
urllib.urlretrieve("http://www.example.com/test.html", "test.txt")
</code></pre>
| 0 | 2016-09-07T11:02:49Z | [
"python"
] |
How to save webpages text content as a text file using python | 39,367,963 | <p>I did python script:</p>
<pre><code> from string import punctuation
from collections import Counter
import urllib
from stripogram import html2text
myurl = urllib.urlopen("https://www.google.co.in/?gfe_rd=cr&ei=v-PPV5aYHs6L8Qfwwrlg#q=samsung%20j7")
html_string = myurl.read()
text = ht... | 1 | 2016-09-07T10:54:05Z | 39,368,166 | <p>What do you mean with "webpage text"?
It seems you don't want the full HTML-File. If you just want the text you see in your browser, that is not so easily solvable, as the parsing of a HTML-document can be very complex, especially with JavaScript-rich pages.
That starts with assessing if a String between "<" and... | 1 | 2016-09-07T11:03:16Z | [
"python"
] |
How to save webpages text content as a text file using python | 39,367,963 | <p>I did python script:</p>
<pre><code> from string import punctuation
from collections import Counter
import urllib
from stripogram import html2text
myurl = urllib.urlopen("https://www.google.co.in/?gfe_rd=cr&ei=v-PPV5aYHs6L8Qfwwrlg#q=samsung%20j7")
html_string = myurl.read()
text = ht... | 1 | 2016-09-07T10:54:05Z | 39,369,122 | <p>You dont need to write any hard algorithms to extract data from search result. Google has a API to do this.<br>
Here is an example:<br><a href="https://github.com/google/google-api-python-client/blob/master/samples/customsearch/main.py" rel="nofollow">https://github.com/google/google-api-python-client/blob/master/sa... | 0 | 2016-09-07T11:49:01Z | [
"python"
] |
SQLAlchemy: undefer column via joinedload technique | 39,368,018 | <p>Here is my query.</p>
<pre><code>query = dbsession.query(Parent)\
.options(joinedload(Parent.child))\
.first()
</code></pre>
<p>Model <code>Child</code> is available through <code>Parent.child</code> relationship and has deffered column named 'column'. How to undefer and load that column using query listed... | 0 | 2016-09-07T10:56:33Z | 39,368,314 | <p>Chain the undefer option through the joined load with</p>
<pre><code>joinedload(Parent.child).undefer('column')
</code></pre>
<p>See <a href="http://docs.sqlalchemy.org/en/latest/orm/loading_relationships.html#loading-along-paths" rel="nofollow">"Loading Along Paths"</a> and the documentation on <a href="http://do... | 1 | 2016-09-07T11:10:52Z | [
"python",
"sqlalchemy"
] |
what went wrong with my get and set properties? | 39,368,268 | <p>Please I need help. I code with PyCharm and it keeps showing me unresolved reference 'model'. Parameter 'model' value is not used and getter signature should be (self). Please how do I get around this.</p>
<pre><code>class ProductObject:
def __init__(self, product, brand, car, model, year):
self.produc... | 0 | 2016-09-07T11:08:23Z | 39,368,478 | <p>You need change parameters of methods. Get method needs only <strong>self</strong> and set method need <strong>self</strong> and <strong>model</strong> as parameter.</p>
<pre><code>def set_model(self, model):
self.model = model.title()
def get_model(self):
return self.model
</code></pre>
<p><strong>EDIT</... | 0 | 2016-09-07T11:18:48Z | [
"python"
] |
Unable to detect face and eye with OpenCV in Python | 39,368,307 | <p>This code is to detect face and eyes using webcam but getting this error</p>
<pre><code>Traceback (most recent call last):
File "D:/Acads/7.1 Sem/BTP/FaceDetect-master/6.py", line 28, in <module>
eyes = eyeCascade.detectMultiScale(roi)
NameError: name 'roi' is not defined
</code></pre>
<p>but whe... | 0 | 2016-09-07T11:10:26Z | 39,368,777 | <p>I think it is just a problem of indentation.</p>
<p><code>roi</code> is out of scope when you go out of the <code>faces</code> loop.</p>
<pre><code>for (x, y, w, h) in faces:
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
roi = frame[y:y+h, x:x+w]
# eyes detection runs for each face
eyes... | 2 | 2016-09-07T11:32:14Z | [
"python",
"opencv",
"face-detection",
"nameerror",
"eye-detection"
] |
How can I set the value for request.authenticated_userid in pyramid framework of python | 39,368,342 | <p>I am getting an error when I try to set the attribute for authenticated_userid as a request parameter. Its actually a nosetest I am using to mock up the request and see the response.</p>
<pre><code>Traceback (most recent call last):
File "/web/core/pulse/wapi/tests/testWapiUtilities_integration.py", line 652, in ... | 2 | 2016-09-07T11:12:14Z | 39,420,596 | <p><code>authenticated_userid</code> is reified attribute set by authentication framework.</p>
<p>See <a href="http://docs.pylonsproject.org/projects/pyramid/en/latest/quick_tutorial/authentication.html" rel="nofollow">Logins with authentication for basic information</a>.</p>
<p>Please include more code how you set u... | 0 | 2016-09-09T22:36:52Z | [
"python",
"pyramid"
] |
How can I set the value for request.authenticated_userid in pyramid framework of python | 39,368,342 | <p>I am getting an error when I try to set the attribute for authenticated_userid as a request parameter. Its actually a nosetest I am using to mock up the request and see the response.</p>
<pre><code>Traceback (most recent call last):
File "/web/core/pulse/wapi/tests/testWapiUtilities_integration.py", line 652, in ... | 2 | 2016-09-07T11:12:14Z | 39,424,366 | <p>Finally I got the solution.</p>
<p>I added <code>self.config = testing.setUp()</code></p>
<pre><code>self.config.testing_securitypolicy(
userid=self.data['user'].userAccount.id, permissive=True
)
</code></pre>
<p>Added the userAccountId as mock up value for testing security policy.</p>
<pre><code>@attr(can_... | 1 | 2016-09-10T08:54:52Z | [
"python",
"pyramid"
] |
pypi pakcage automatically uninstalling and upgrading other things? | 39,368,443 | <p>I have a pypi package that I distribute that requires django, in my setup.py I have this...</p>
<pre><code>install_requires = ["Django"]
</code></pre>
<p>then in the egg I have a requires.txt file that is like this...</p>
<pre><code>Django
</code></pre>
<p>Now I just made a new version and uploaded it to <code>p... | 0 | 2016-09-07T11:17:25Z | 39,368,980 | <p>Specify your version dependencies like</p>
<pre><code>install_requires = ["Django>=1.8"]
</code></pre>
<p>So that if the user has <code>Django</code> less than <code>1.8</code> then only it will upgrade.</p>
| 2 | 2016-09-07T11:42:50Z | [
"python",
"django"
] |
Python - TypeError: float() argument must be a string or a number, not 'list | 39,368,446 | <p>Python newbie here. I am trying to operate on lists which contain floating point numbers. <code>avg</code> is a list parameter that is returned from a different method. However, when I tried doing the following, it throws me an error that float() should have a string or a number and not a list. <code>avg1</code> sho... | 0 | 2016-09-07T11:17:35Z | 39,368,801 | <p>Please check return type of avg I think it's return type is list's of list.</p>
| 0 | 2016-09-07T11:34:01Z | [
"python",
"python-3.x"
] |
Python - TypeError: float() argument must be a string or a number, not 'list | 39,368,446 | <p>Python newbie here. I am trying to operate on lists which contain floating point numbers. <code>avg</code> is a list parameter that is returned from a different method. However, when I tried doing the following, it throws me an error that float() should have a string or a number and not a list. <code>avg1</code> sho... | 0 | 2016-09-07T11:17:35Z | 39,368,948 | <p>Instead of <code>avg1 = [float(i) for i in avg]</code> use below code.</p>
<pre><code>avg1 = []
for i in avg:
for j in i:
avg1.append(float(j))
</code></pre>
<p>or can use below list comprehension.</p>
<pre><code>avg1 = [float(i) for val in avg for i in val]
</code></pre>
| 0 | 2016-09-07T11:41:05Z | [
"python",
"python-3.x"
] |
Python - TypeError: float() argument must be a string or a number, not 'list | 39,368,446 | <p>Python newbie here. I am trying to operate on lists which contain floating point numbers. <code>avg</code> is a list parameter that is returned from a different method. However, when I tried doing the following, it throws me an error that float() should have a string or a number and not a list. <code>avg1</code> sho... | 0 | 2016-09-07T11:17:35Z | 39,368,957 | <p>To convert a list of lists to float, you need to use two list comprehensions, like this:</p>
<pre><code>avg1 = [[float(i) for i in val] for val in avg]
</code></pre>
| 0 | 2016-09-07T11:41:39Z | [
"python",
"python-3.x"
] |
Python - TypeError: float() argument must be a string or a number, not 'list | 39,368,446 | <p>Python newbie here. I am trying to operate on lists which contain floating point numbers. <code>avg</code> is a list parameter that is returned from a different method. However, when I tried doing the following, it throws me an error that float() should have a string or a number and not a list. <code>avg1</code> sho... | 0 | 2016-09-07T11:17:35Z | 39,369,119 | <p>For example if you have list = [ [1,2],[4,5] ]
then you can use
[[float(s) for s in xs] for xs in list]
and it's output is:
[[1.0, 2.0], [4.0, 5.0]] </p>
| -1 | 2016-09-07T11:48:46Z | [
"python",
"python-3.x"
] |
Python parse_known_args with named arguments | 39,368,641 | <p>I would like to pass an arbitrary set of arguments in the format <code>--arg1 value1</code> to my python script and retrieve them in a dictionary of the kind <code>{'arg1': 'value1}</code>. I want to use <code>argparse</code> to achieve that. The function <code>parse_known_args</code> allows for extra args, but they... | -1 | 2016-09-07T11:26:04Z | 39,369,112 | <p>A better idea is to define <em>one</em> option that takes two arguments, a name and a value, and use a custom action to update a dictionary using those two arguments.</p>
<pre><code>class OptionAppend(Action):
def __call__(self, parser, namespace, values, option_string):
d = getattr(namespace, self.dest... | 2 | 2016-09-07T11:48:28Z | [
"python",
"argparse"
] |
Python parse_known_args with named arguments | 39,368,641 | <p>I would like to pass an arbitrary set of arguments in the format <code>--arg1 value1</code> to my python script and retrieve them in a dictionary of the kind <code>{'arg1': 'value1}</code>. I want to use <code>argparse</code> to achieve that. The function <code>parse_known_args</code> allows for extra args, but they... | -1 | 2016-09-07T11:26:04Z | 39,375,736 | <p>The question of handling arbitrary key/value pairs has come up a number of times. <code>argparse</code> does not have a builtin mechanism for that.</p>
<p><a href="http://stackoverflow.com/questions/37367331/argparse-arbitrary-optional-arguments">argparse - Arbitrary optional arguments</a> (almost a duplicate fro... | 0 | 2016-09-07T17:10:16Z | [
"python",
"argparse"
] |
how to properly run Python script with crontab on every system startup | 39,368,748 | <p>I have a Python script that should open my Linux terminal, browser, file manager and text editor on system startup. I decided <code>crontab</code> is a suitable way to automatically run the script. Unfortunately, it doesn't went well, nothing happened when I reboot my laptop. So, I captured the output of the script ... | 1 | 2016-09-07T11:30:47Z | 39,369,451 | <p>No, <code>cron</code> is not suitable for this. The <code>cron</code> daemon has no connection to your user's desktop session, which will not be running at system startup, anyway.</p>
<p>My recommendation would be to hook into your desktop environment's login scripts, which are responsible for starting various desk... | 1 | 2016-09-07T12:03:02Z | [
"python",
"cron"
] |
Python Paramiko Child Process | 39,368,763 | <p>I've written a script that uses PARAMIKO library to log on to a server and executes a command. This command actually invokes the server to execute another python script (resulting in a child process I believe). I believe the server returns back signal indicating that the command was executed successfully, however i... | 0 | 2016-09-07T11:31:18Z | 39,369,100 | <p>Without the code this will be difficult. I think you should create a rest service . So you would POST to <a href="http://0.0.0.0/runCode" rel="nofollow">http://0.0.0.0/runCode</a> and this would kick off a process in a different thread. That would end that call. The thread is still running ...when done do a post to ... | 1 | 2016-09-07T11:47:45Z | [
"python",
"shell",
"process",
"subprocess",
"paramiko"
] |
How to install package via pip requirements.txt from VCS into current directory? | 39,368,789 | <p>For example, we have project <code>Foo</code> with dependency <code>Bar</code> (that in private Git repo) and we want install <code>Bar</code> into <code>Foo</code> directory via <code>pip</code> from <code>requirements.txt</code>. </p>
<p>We can manually install <code>Bar</code> with console command:</p>
<p><code... | 0 | 2016-09-07T11:33:03Z | 39,369,148 | <p>The best way to do this would be to clone the repository, or just donwload the <code>requirements.txt</code> file, and then run <code>pip install -r requirements.txt</code> to install all the modules dependencies. </p>
| 0 | 2016-09-07T11:50:15Z | [
"python",
"git",
"pip"
] |
Tkinter/matplotlib multiple active windows on osx | 39,368,979 | <p>I have a script as follows that executes on my windows machine</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
import tkinter
class main(tkinter.Frame): #main window
def __init__(self, root): # initialise
tkinter.Frame.__init__(self)
self.root = root
tkinter.Button(s... | 2 | 2016-09-07T11:42:45Z | 39,375,001 | <p>I found a solution to this issue -- it seems matplotlib defaults to the TkAgg backend on Windows (I'm unsure whether this is a general Windows thing, or specific to whatever particular install is on the machine).</p>
<p>Adding the following lines to the top of the script forces the TkAgg backend and leads to the sa... | 1 | 2016-09-07T16:21:06Z | [
"python",
"windows",
"osx",
"matplotlib",
"tkinter"
] |
Python GUI class structure calls | 39,369,039 | <p>Let's say for example I have two classes, <code>A</code> and <code>B</code>.</p>
<p>Class <code>A</code> is the one I called <code>class main</code> and <code>B</code> is a <code>GUI</code> class(lets say its called <code>class main_gui</code>).</p>
<p>GUI class contains method that initiates and sets all views, b... | 0 | 2016-09-07T11:45:14Z | 39,369,391 | <p>not sure if this is what your are looking for but :</p>
<p>A simple view :</p>
<pre><code>class Home(QtWidgets.QFrame, Ui_home):
"""Home view."""
def __init__(self, parent=None):
"""Initializer."""
super(Home, self).__init__()
self._parent = parent
self.setupUi(self)
</code></pre>
<p>Ui_home is t... | 0 | 2016-09-07T12:00:30Z | [
"python",
"qt",
"python-3.x",
"pyqt",
"qt-creator"
] |
softlayer api: How to get the status(finish or processing) when copy os image cross IDC? | 39,369,135 | <p>When I call <code>SoftLayer_Virtual_Guest_Block_Device_Template_Group:addLocations</code> to copy private image_A cross <code>IDC</code>, this function returns <code>True</code> immediately. So it is known that the operation is asynchronous.</p>
<p>The question is how can I know that this async operation is finishe... | 0 | 2016-09-07T11:49:48Z | 39,371,791 | <p>You need to make the following call</p>
<pre><code>https://$user:[email protected]/rest/v3.1/SoftLayer_Virtual_Guest_Block_Device_Template_Group/$templateGroupId/getChildren?objectMask=mask[transaction]
Method: Get
</code></pre>
<p>Replace: <strong>$user</strong>, <strong>$apiKey</strong> and <strong>$tem... | 0 | 2016-09-07T13:51:32Z | [
"python",
"api",
"softlayer"
] |
Is there a mode of python that traces each line executed, similar to 'bash -x'? | 39,369,346 | <p>I am running a python script in crontab that works fine from the command line but appears to not be running at all when it runs in cron. If this was a bash script, I would add 'bash -x' to the crontab and pipe STOUT and STDERR to a log file. Is there a similar mode of python that will capture the execution of each i... | 1 | 2016-09-07T11:58:31Z | 39,369,368 | <p><a href="https://docs.python.org/2/library/trace.html" rel="nofollow">The trace module</a> does this.</p>
<pre><code>python -m trace --trace yourscript.py
</code></pre>
| 3 | 2016-09-07T11:59:37Z | [
"python",
"debugging"
] |
Beginner in Python, can't get this for loop to stop | 39,369,347 | <pre><code>Bit_128 = 0
Bit_64 = 0
Bit_32 = 0
Bit_64 = 0
Bit_32 = 0
Bit_16 = 0
Bit_8 = 0
Bit_4 = 0
Bit_2 = 0
Bit_1 = 0
Number = int(input("Enter number to be converted: "))
for power in range(7,0,-1):
if (2**power) <= Number:
place_value = 2**power
if place_value == 128:
Bit_128 = 1
elif place_value == 64:
... | 0 | 2016-09-07T11:58:39Z | 39,369,511 | <p>If you want a loop to go to the next value, all you need to do is use the continue keyword:</p>
<pre><code>...
for power in range(7,0,-1):
if (2**power) <= Number:
place_value = 2**power
continue
...
</code></pre>
| 0 | 2016-09-07T12:05:51Z | [
"python",
"for-loop"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.