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
Selenium leaves behind running processes?
38,518,998
<p>When my selenium program crashes due to some error, it seems to leave behind running processes. </p> <p>For example, here is my process list:</p> <pre><code>carol 30186 0.0 0.0 103576 7196 pts/11 Sl 00:45 0:00 /home/carol/test/chromedriver --port=51789 carol 30322 0.0 0.0 102552 7160 pts/11 Sl ...
2
2016-07-22T05:43:15Z
38,536,238
<p>Whats happening is that your code is throwing an exception, halting the python process from continuing on. As such, the close/quit methods never get called on the browser object, so the chromedrivers just hang out indefinitely.</p> <p>You need to use a try/except block to ensure the close method is called every tim...
0
2016-07-22T22:43:43Z
[ "python", "python-2.7", "selenium", "selenium-webdriver", "selenium-chromedriver" ]
Convert an american style minute string into integer value
38,519,086
<p>I got an american format string showing seconds of an elapsed event, like <code>4,942.221s</code>. How would be the most pythonic way to convert this into an integer without parsing and removing comma. I want to get the plain seconds, which in this case would be <code>4942</code>, ms can be truncated.</p>
1
2016-07-22T05:50:48Z
38,519,263
<p>You could use float first and then convert to int as below</p> <pre><code>&gt;&gt;&gt;a= '4,942.221s' &gt;&gt;&gt;int(float(a.replace(',', '').replace('s',''))) &gt;&gt;&gt;4942 </code></pre>
1
2016-07-22T06:05:21Z
[ "python", "string", "data-type-conversion" ]
Convert an american style minute string into integer value
38,519,086
<p>I got an american format string showing seconds of an elapsed event, like <code>4,942.221s</code>. How would be the most pythonic way to convert this into an integer without parsing and removing comma. I want to get the plain seconds, which in this case would be <code>4942</code>, ms can be truncated.</p>
1
2016-07-22T05:50:48Z
38,522,971
<p>You could achieve this using the <a href="https://docs.python.org/3.5/library/locale.html" rel="nofollow"><code>locale</code></a> library, which </p> <blockquote> <p>allows programmers to deal with certain cultural issues in an application, without requiring the programmer to know all the specifics of each co...
1
2016-07-22T09:31:27Z
[ "python", "string", "data-type-conversion" ]
Python parse text help- beginner
38,519,152
<p>I have only used Linux/ Python for a couple weeks so I am very new at this. I have a large file that is named "python.test". In the file I am trying to write code so that it tells me how many times a certain word appears in the files. For example the word is help. I am using Linux with Python and have tried several ...
-1
2016-07-22T05:55:16Z
38,519,285
<p>In this case, your file should be a .py file (ie <strong>YOURFILENAME.py</strong>). Then to run it in the terminal type <code>$ python yourfile.py</code> Please upload the code, it could be caused by of many other issues too </p>
0
2016-07-22T06:08:03Z
[ "python", "coding-style" ]
random.choice with a list
38,519,240
<p>I have a list of 30 strings. I want to use the choice method of the random module and generate a new string from the list they are stored in. I don't want to repeat any strings and I want to print all the unique strings once. I am trying to make a chat bot but I can only get 1 string to print over and over every tim...
0
2016-07-22T06:03:06Z
38,519,511
<p>You need "random selection without replacement." This function, called on a list of strings, will return a random string. Called more than once, it won't ever return the same item.</p> <pre><code>import random def choose_one(poss): """ Remove a randomly chosen item from the given list, and return it. ...
0
2016-07-22T06:22:21Z
[ "python", "random", "nlp" ]
random.choice with a list
38,519,240
<p>I have a list of 30 strings. I want to use the choice method of the random module and generate a new string from the list they are stored in. I don't want to repeat any strings and I want to print all the unique strings once. I am trying to make a chat bot but I can only get 1 string to print over and over every tim...
0
2016-07-22T06:03:06Z
38,519,572
<p>Don't use <code>random.choice()</code>. Use <code>random.shuffle()</code> instead to put the (unique) words in random order instead, then repeatedly take from that list. That ensures that a) you use all the words, and b) don't repeat any picks:</p> <pre><code>random_greetings = greetings[:] # create a copy random....
0
2016-07-22T06:25:35Z
[ "python", "random", "nlp" ]
file doesnt exists in routes Http directory laravel 5
38,519,305
<p>I have a python script beside 'routes.php' and I want to execute that from 'routes.php' file . when i use exec() function it does not work correctly . so , i try <code>file_exists()</code> : </p> <pre><code>Route::get('/py', function(){ if (file_exists( "new.py" )) echo "succeed"; else ech...
0
2016-07-22T06:09:18Z
38,519,399
<p>You need to use the absolute path, try with</p> <pre><code> file_exists(__DIR__.'/new.py') </code></pre> <p>Assuming that it is in the same directory as routes.php</p>
0
2016-07-22T06:15:40Z
[ "php", "python", "laravel", "laravel-5", "routing" ]
file doesnt exists in routes Http directory laravel 5
38,519,305
<p>I have a python script beside 'routes.php' and I want to execute that from 'routes.php' file . when i use exec() function it does not work correctly . so , i try <code>file_exists()</code> : </p> <pre><code>Route::get('/py', function(){ if (file_exists( "new.py" )) echo "succeed"; else ech...
0
2016-07-22T06:09:18Z
38,519,484
<p>The file path you are giving is not correct. <strong>file_exists()</strong> will check the file inside the <strong>public</strong> folder in laravel. If you are placed the <strong>py</strong> inside your public folder , then give the exact path to the file. </p>
0
2016-07-22T06:20:51Z
[ "php", "python", "laravel", "laravel-5", "routing" ]
Python27 how to batch read dictionary to execute command
38,519,373
<p><strong>I just need help with how to work with <em>X</em> rows at a time.</strong></p> <p>i have a task to parse a 10000 line csv file -> convert it to dictionary -> then process 100 rows at a time making an API call. For this example lets just output to <strong><em>print</em></strong> function. i will need to exec...
0
2016-07-22T06:13:54Z
38,519,548
<p>Sounds like you need to break up a list into fixed-length chunks, without loading the whole list into memory? This is possible using some help from the <code>itertools</code> module. This is taken from the <a href="https://docs.python.org/2/library/itertools.html#recipes" rel="nofollow">Python docs</a>:</p> <pre><c...
0
2016-07-22T06:24:34Z
[ "python", "csv", "parsing", "dictionary" ]
Python27 how to batch read dictionary to execute command
38,519,373
<p><strong>I just need help with how to work with <em>X</em> rows at a time.</strong></p> <p>i have a task to parse a 10000 line csv file -> convert it to dictionary -> then process 100 rows at a time making an API call. For this example lets just output to <strong><em>print</em></strong> function. i will need to exec...
0
2016-07-22T06:13:54Z
38,519,599
<p>One possibility:</p> <pre><code>from itertools import islice d = { 'majorkey1': [ { 'name':'j','age':'3','height':'6feet' }, { 'name':'r','age':'4','height':'5feet' }, { 'name':'o','age':'5','height':'3feet' }, ], 'majorkey2': [ { 'name':'n','...
0
2016-07-22T06:27:22Z
[ "python", "csv", "parsing", "dictionary" ]
How to pass a URL parameter using python, Flask, and the command line
38,519,475
<p>I am having a lot of trouble passing a URL parameter using request.args.get. </p> <p>My code is the following: </p> <pre><code>from flask import Flask, request app= Flask(__name__) @app.route('/post?id=post_id', methods=["GET"]) def show_post(): post_id=1232 return request.args.get('post_id') if __name__...
0
2016-07-22T06:20:26Z
38,519,543
<p><code><a href="http://flask.pocoo.org/docs/0.11/api/#flask.Request.args" rel="nofollow">request.args</a></code> is what you are looking for.</p> <pre><code>@app.route('/post', methods=["GET"]) def show_post() post_id = request.args.get('id') </code></pre> <p>request.args is get all the GET parameters and const...
0
2016-07-22T06:24:21Z
[ "python", "http", "command-line", "flask" ]
How to pass a URL parameter using python, Flask, and the command line
38,519,475
<p>I am having a lot of trouble passing a URL parameter using request.args.get. </p> <p>My code is the following: </p> <pre><code>from flask import Flask, request app= Flask(__name__) @app.route('/post?id=post_id', methods=["GET"]) def show_post(): post_id=1232 return request.args.get('post_id') if __name__...
0
2016-07-22T06:20:26Z
38,519,554
<p>You should leave the query parameters out of the route as they aren't part of it.</p> <pre><code>@app.route('/post', methods=['GET']) def show_post(): post_id = request.args.get('id') return post_id </code></pre> <p><code>request.args</code> is a dictionary containing all of the query parameters passed in ...
1
2016-07-22T06:24:47Z
[ "python", "http", "command-line", "flask" ]
How to generate HL7 message?
38,519,553
<p>I want to send the data of patient to the dcm4chee using the python code, Currently I am able to send the data to the modality worklist using the "MLLPClient" but I have HL7 message which is generated by the openMRS, can any one help to know that how can I generate custom HL7 message using the patient data in python...
0
2016-07-22T06:24:43Z
38,559,392
<p>Maybe Hapi could help you: <a href="http://hl7api.sourceforge.net/hapi-testpanel/install.html" rel="nofollow">http://hl7api.sourceforge.net/hapi-testpanel/install.html</a> . It generates HL7 messages and I guess it could build hL7 messages with your own data. </p> <p>Good luck!</p>
0
2016-07-25T03:44:25Z
[ "python", "openerp", "hl7", "hl7-v3" ]
How to generate HL7 message?
38,519,553
<p>I want to send the data of patient to the dcm4chee using the python code, Currently I am able to send the data to the modality worklist using the "MLLPClient" but I have HL7 message which is generated by the openMRS, can any one help to know that how can I generate custom HL7 message using the patient data in python...
0
2016-07-22T06:24:43Z
38,670,231
<p>Here is the blog which helps me to create HL7 message.</p> <p><a href="https://msarfati.wordpress.com/2015/06/22/python-hl7-v2-x-and-hl7apy-hl7-construction-with-ormo01-and-orur01-part-2/" rel="nofollow">https://msarfati.wordpress.com/2015/06/22/python-hl7-v2-x-and-hl7apy-hl7-construction-with-ormo01-and-orur01-par...
0
2016-07-30T04:04:15Z
[ "python", "openerp", "hl7", "hl7-v3" ]
Scikit-learn SVM digit recognition
38,519,716
<p>I want to make a program to <strong>recognize the digit</strong> in an image. I follow the tutorial in <a href="http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html">scikit learn</a> .</p> <p>I can <strong>train and fit the svm classifier</strong> like the following.</p> <p>F...
4
2016-07-22T06:35:10Z
38,521,182
<p>It's just a guess but... The Training set from Sk-Learn are <strong>black numbers</strong> on a <strong>white background</strong>. And you are trying to predict numbers which are white on a black background...</p> <p>I think you should either train on your training set, or train on the negative version of your pict...
1
2016-07-22T07:59:01Z
[ "python", "image", "image-processing", "scikit-learn" ]
Scikit-learn SVM digit recognition
38,519,716
<p>I want to make a program to <strong>recognize the digit</strong> in an image. I follow the tutorial in <a href="http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html">scikit learn</a> .</p> <p>I can <strong>train and fit the svm classifier</strong> like the following.</p> <p>F...
4
2016-07-22T06:35:10Z
38,576,947
<p>My best bet would be that there is a problem with your data types and array shapes.</p> <p>It looks like you are training on numpy arrays that are of the type <code>np.float64</code> (or possibly <code>np.float32</code> on 32 bit systems, I don't remember) and where each image has the shape <code>(64,)</code>.</p> ...
4
2016-07-25T20:32:44Z
[ "python", "image", "image-processing", "scikit-learn" ]
Scikit-learn SVM digit recognition
38,519,716
<p>I want to make a program to <strong>recognize the digit</strong> in an image. I follow the tutorial in <a href="http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html">scikit learn</a> .</p> <p>I can <strong>train and fit the svm classifier</strong> like the following.</p> <p>F...
4
2016-07-22T06:35:10Z
38,610,838
<p>1) You need to create your own training set - based on data similar to what you will be making predictions. The call to <code>datasets.load_digits()</code> in scikit-learn is loading a preprocessed version of the MNIST Digits dataset, which, for all we know, could have very different images to the ones that you are ...
3
2016-07-27T10:49:08Z
[ "python", "image", "image-processing", "scikit-learn" ]
Scikit-learn SVM digit recognition
38,519,716
<p>I want to make a program to <strong>recognize the digit</strong> in an image. I follow the tutorial in <a href="http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html">scikit learn</a> .</p> <p>I can <strong>train and fit the svm classifier</strong> like the following.</p> <p>F...
4
2016-07-22T06:35:10Z
38,611,859
<p>If you look at: <a href="http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html#sklearn.datasets.load_digits" rel="nofollow">http://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_digits.html#sklearn.datasets.load_digits</a></p> <p>you can see that each point in the matri...
1
2016-07-27T11:36:50Z
[ "python", "image", "image-processing", "scikit-learn" ]
Scikit-learn SVM digit recognition
38,519,716
<p>I want to make a program to <strong>recognize the digit</strong> in an image. I follow the tutorial in <a href="http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html">scikit learn</a> .</p> <p>I can <strong>train and fit the svm classifier</strong> like the following.</p> <p>F...
4
2016-07-22T06:35:10Z
38,612,384
<p>Hi in addition to @carrdelling respond, i will add that you may use the same training set, if you normalize your images to have the same range of value. For example you could binaries your data ( 1 if > 0, 0 else ) or you could divide by the maximum intensity in your image to have an arbitrary interval [0;1]. </p>
0
2016-07-27T12:01:36Z
[ "python", "image", "image-processing", "scikit-learn" ]
Scikit-learn SVM digit recognition
38,519,716
<p>I want to make a program to <strong>recognize the digit</strong> in an image. I follow the tutorial in <a href="http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html">scikit learn</a> .</p> <p>I can <strong>train and fit the svm classifier</strong> like the following.</p> <p>F...
4
2016-07-22T06:35:10Z
38,675,371
<p>You probably want to extract features relevant to to your data set from the images and train your model on them. One example I copied from <a href="http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_surf_intro/py_surf_intro.html" rel="nofollow">here.</a></p> <p><code>surf = cv2.SURF(400) kp, des = s...
0
2016-07-30T15:07:14Z
[ "python", "image", "image-processing", "scikit-learn" ]
Beautifulsoup loop through HTML
38,519,975
<p>As mentioned in the previous question, I am using Beautiful soup with python to retrieve weather data from a website.</p> <p>Here's how the website looks like:</p> <pre><code>&lt;channel&gt; &lt;title&gt;2 Hour Forecast&lt;/title&gt; &lt;source&gt;Meteorological Services Singapore&lt;/source&gt; &lt;description&gt...
0
2016-07-22T06:51:27Z
38,520,401
<p>1.To loop through all the areas,</p> <pre><code>areas = soup.select('area') for data in areas: print(data.get('name')) </code></pre> <p>Output</p> <pre><code>Ang Mo Kio Bedok Bishan Boon Lay Bukit Batok Bukit Merah </code></pre> <p>2.You can individually extact data as well</p> <pre><code>date = soup.select...
1
2016-07-22T07:16:50Z
[ "python", "beautifulsoup" ]
Beautifulsoup loop through HTML
38,519,975
<p>As mentioned in the previous question, I am using Beautiful soup with python to retrieve weather data from a website.</p> <p>Here's how the website looks like:</p> <pre><code>&lt;channel&gt; &lt;title&gt;2 Hour Forecast&lt;/title&gt; &lt;source&gt;Meteorological Services Singapore&lt;/source&gt; &lt;description&gt...
0
2016-07-22T06:51:27Z
38,520,413
<blockquote> <p>When I run my codes in python, it only retrieved the first area which is Ang Mo Kio</p> </blockquote> <p><code>findAll('weatherForecast')</code> will return a sequence of <strong>one</strong> element, given provided XML. You then proceed to iterate through this sequence and use <a href="https://www.c...
1
2016-07-22T07:17:28Z
[ "python", "beautifulsoup" ]
Unable to stream data from twitter using tweepy in python
38,520,067
<pre><code>from tweepy import Stream from tweepy import OAuthHandler from tweepy.streaming import StreamListener #consumer key, consumer secret, access token, access secret. ckey="" csecret="" atoken="" asecret="" class listener(StreamListener): def on_data(self, data): print(data) return(True) def on_error(self, statu...
-1
2016-07-22T06:57:38Z
38,527,347
<p>Your screenshot shows an SSL <code>VERIFY_CERTIFICATE_FAILED</code> error. Twitter requires that you connect to the streaming API endpoint using TLS.</p>
0
2016-07-22T13:10:59Z
[ "python", "twitter", "tweepy" ]
theano and lambda functions
38,520,143
<p>I am having some strange behaviour when I have a list of lambda functions which evaluate theano expressions. The code is below:</p> <pre><code># Equivalent functions (or at least I assume so) def tilted_loss(q,y,f): e = (y-f) return (q*tt.sum(e)-tt.sum(e[(e&lt;0).nonzero()]))/e.shape[0] def tilted_loss2(y,...
0
2016-07-22T07:01:09Z
38,520,306
<p>Is a common error, the <code>q</code> value in the lambda expresion will just take the last value from the comprehension loop, you better use <a href="https://docs.python.org/2/library/functools.html#functools.partial" rel="nofollow">partial</a>:</p> <pre><code>q_loss_f = [partial(tilted_loss, q=q) for q in qs] </...
1
2016-07-22T07:11:06Z
[ "python", "lambda", "theano" ]
How exactly does Python resolve "from X import Y" if there are multiple Ys in X?
38,520,210
<p>I have a package X which contains two different things named Y</p> <p>One is a module:</p> <pre><code># X/Y.py print 'hello' </code></pre> <p>The other is a variable:</p> <pre><code># X/__init__.py Y = 'world' </code></pre> <p>If I execute <code>from X import Y</code> which Y do I get and <em>why</em>? What det...
3
2016-07-22T07:05:12Z
38,520,290
<p>A name in the module will take precedence. From <a href="https://docs.python.org/3/tutorial/modules.html#packages" rel="nofollow">the Python tutorial</a>.</p> <blockquote> <p>Note that when using from package import item, the item can be either a submodule (or subpackage) of the package, or some other name defin...
1
2016-07-22T07:10:34Z
[ "python" ]
How exactly does Python resolve "from X import Y" if there are multiple Ys in X?
38,520,210
<p>I have a package X which contains two different things named Y</p> <p>One is a module:</p> <pre><code># X/Y.py print 'hello' </code></pre> <p>The other is a variable:</p> <pre><code># X/__init__.py Y = 'world' </code></pre> <p>If I execute <code>from X import Y</code> which Y do I get and <em>why</em>? What det...
3
2016-07-22T07:05:12Z
38,520,308
<p>Modules in packages, once imported, are also set as an attribute on the parent module object. The <code>from module import name</code> syntax, however, will <em>first</em> look at the attributes of the imported module object (the globals of <code>X</code>) to resolve <code>name</code>.</p> <p>So, the answer is that...
5
2016-07-22T07:11:10Z
[ "python" ]
How exactly does Python resolve "from X import Y" if there are multiple Ys in X?
38,520,210
<p>I have a package X which contains two different things named Y</p> <p>One is a module:</p> <pre><code># X/Y.py print 'hello' </code></pre> <p>The other is a variable:</p> <pre><code># X/__init__.py Y = 'world' </code></pre> <p>If I execute <code>from X import Y</code> which Y do I get and <em>why</em>? What det...
3
2016-07-22T07:05:12Z
38,520,333
<p>Python looks first on the current working directory for any file Y.py under X folder, then it looks for the installed libraries for X package to import Y file. If there is a Y variable in the package X then it is imported and then replaced by the content on file Y.py of that package</p>
-1
2016-07-22T07:12:34Z
[ "python" ]
KIVY language: multiple commands in a single line
38,520,218
<p>I have to do:</p> <pre><code>TextInput: on_text: something ; something_else </code></pre> <p>How can I perform this without getting errors in kv language?</p>
0
2016-07-22T07:05:27Z
38,520,572
<p>You could just add more <code>on_text</code> bindings, line by line:</p> <pre><code>TextInput: on_text: something on_text: something_else </code></pre> <p>But I'd prefer binding custom function call, because I'm not sure order of execution is always the same with the above example. Something like this:</p>...
1
2016-07-22T07:26:41Z
[ "python", "syntax", "kivy", "kivy-language" ]
How to access a file from python when the OS opens the script to handle opening that file?
38,520,278
<p>When I open an HTML file, for instance, I have it set such that it opens in Chrome. Now if I set a given python script to be the thing that opens a given filetype, how do I access this file in the script? Where is it available from?</p>
-4
2016-07-22T07:10:04Z
38,520,642
<p>When opening a file, the operating system starts the responsible opener program and passes the file(s) to be opened as <a href="https://en.wikipedia.org/wiki/Command-line_interface#Arguments" rel="nofollow">command line arguments</a>:</p> <pre><code>path/to/opener_executable path/to/file1_to_be_opened path/to/file2...
0
2016-07-22T07:30:24Z
[ "python", "python-3.x" ]
How to access a file from python when the OS opens the script to handle opening that file?
38,520,278
<p>When I open an HTML file, for instance, I have it set such that it opens in Chrome. Now if I set a given python script to be the thing that opens a given filetype, how do I access this file in the script? Where is it available from?</p>
-4
2016-07-22T07:10:04Z
38,522,140
<p>To prove <code>Rawing</code>'s point, on Linux, you "open with Other Application" and select your python script, which you made executable.<br> <code>sys.argv</code> provides the name of the script as argument 0 and thereafter a list of any other parameters. </p> <p>myopener.py </p> <pre><code>#!/usr/bin/env...
0
2016-07-22T08:51:02Z
[ "python", "python-3.x" ]
Why does my scrapy not scrape anything?
38,520,312
<p>I don't know where the issues lies probably super easy to fix since I am new to scrapy. I hope to find a solution. Thanks in advance.</p> <p>I am using utnutu 14.04, python 3.4</p> <p>My Spider:</p> <pre><code>import scrapy from scrapy.linkextractors import LinkExtractor from name.items import Actress class Actr...
1
2016-07-22T07:11:18Z
38,521,877
<p>In your stats, <code>'spider_exceptions/NameError': 9659,</code> looks suspicious.</p> <p>I believe the problem is in your <code>parse_actress_detail2</code> callback. In the first loop, <code>item</code> is not defined:</p> <pre><code>def parse_actress_detail2(self, response): for sel in response.xpath('//*[@...
1
2016-07-22T08:39:07Z
[ "python", "scrapy" ]
Python lxml: insert text at given position relatively to subelements
38,520,331
<p>I'd like to build the following XML element (in order to customize figure number formatting):</p> <pre><code>&lt;figcaption&gt; &lt;span class="fignum"&gt;Figura 1.2&lt;/span&gt; - Description of figure. &lt;/figcaption&gt; </code></pre> <p>but I don't know how to specify position of text. In fact, if I create the...
1
2016-07-22T07:12:27Z
38,520,471
<p>You need to use the <code>tail</code> property of the <code>span</code> element:</p> <pre><code>from lxml import etree as et fc = et.Element("figcaption") fn = et.SubElement(fc, "span", {'class':'fignum'}) fn.text = "Figure 1.2" fn.tail = " - Description of figure." print(et.tostring(fc)) </code></pre> <blockquot...
3
2016-07-22T07:20:48Z
[ "python", "xml", "lxml" ]
How to overlap wxStaticBitmap images in wxGridBagSizer using wxFormBuilder in wxPython
38,520,337
<p>I need to create an OR Gate by using 4 images(3 lines and Gate symbol). This requires overlapping of images placed in cells in wxGridBagSizer. How can I achieve that?</p> <p><a href="http://i.stack.imgur.com/eQNv9.png" rel="nofollow">Attempt using wxFormBuilder</a></p> <p>I am trying to set negative vgap and hgap ...
0
2016-07-22T07:12:57Z
38,574,382
<p>wxWidgets does not support overlapping sibling widgets (your <code>wx.StaticBitmaps</code> in this case,) and the behavior of what happens when you try to do so is undefined. In addition, sizers are not designed to be able to overlap items, that goes against their fundamental purpose IMO.</p> <p>However, you can ea...
1
2016-07-25T17:51:24Z
[ "python", "wxpython", "wxwidgets" ]
Converting from long to wide in python
38,520,482
<p>I think this a pretty simple question. I am new to python and I am unable to find the perfect answer. </p> <p>I have a dataframe :</p> <pre><code>A B C D E 203704 WkDay 00:00 0.247 2015 203704 WkDay 00:30 0.232 2015 203704 Wkend 00:00 0.102 2015 203704 W...
3
2016-07-22T07:21:18Z
38,520,560
<p>You can add multiple columns to list as argument of parameter <code>index</code>:</p> <pre><code>print (pd.pivot_table(df,index=['A', 'B', 'E'], columns='C',values='D').reset_index()) C A B E 00:00 00:30 0 203704 WkDay 2015 0.247 0.2320 1 203704 WkDay 2016 0.280 0.2670 2 203704 Wkend ...
3
2016-07-22T07:26:13Z
[ "python", "pandas" ]
Converting from long to wide in python
38,520,482
<p>I think this a pretty simple question. I am new to python and I am unable to find the perfect answer. </p> <p>I have a dataframe :</p> <pre><code>A B C D E 203704 WkDay 00:00 0.247 2015 203704 WkDay 00:30 0.232 2015 203704 Wkend 00:00 0.102 2015 203704 W...
3
2016-07-22T07:21:18Z
38,520,711
<p>Use <code>set_index</code> and <code>unstack</code></p> <pre><code>df.set_index(['A', 'B', 'E', 'C']).D.unstack().reset_index() </code></pre> <p><a href="http://i.stack.imgur.com/5ro4d.png" rel="nofollow"><img src="http://i.stack.imgur.com/5ro4d.png" alt="enter image description here"></a></p> <p>If you insist on...
2
2016-07-22T07:33:45Z
[ "python", "pandas" ]
how to detect spaces, special characters in html tags in python
38,520,570
<p>For the following input</p> <pre><code>I/O 1&lt; img &gt; '&lt; input &gt; I/O 1&lt;' img &gt; '&lt; input &gt; </code></pre> <p>I want the required output as below and this should happen if <code>&lt;</code> followed by space is present.</p> <pre><code>I/O 1&lt;img&gt;'&lt;input&gt; </cod...
-4
2016-07-22T07:26:39Z
38,520,651
<p>Try <code>&lt;\s+</code>, <code>\s+&gt;</code>, and <code>&gt;\s+</code>:</p> <pre><code>import re s = "I/O 1&lt; img &gt; '&lt; input &gt;" s = re.sub(r"&lt;\s+", "&lt;", s) s = re.sub(r"\s+&gt;", "&gt;", s) s = re.sub(r"&gt;\s+", "&gt;", s) print(s) </code></pre> <p>Output:</p> <pre><code>I/O 1&lt;...
2
2016-07-22T07:31:06Z
[ "python", "html", "regex" ]
how to detect spaces, special characters in html tags in python
38,520,570
<p>For the following input</p> <pre><code>I/O 1&lt; img &gt; '&lt; input &gt; I/O 1&lt;' img &gt; '&lt; input &gt; </code></pre> <p>I want the required output as below and this should happen if <code>&lt;</code> followed by space is present.</p> <pre><code>I/O 1&lt;img&gt;'&lt;input&gt; </cod...
-4
2016-07-22T07:26:39Z
38,561,914
<pre><code>s= "I/O 1&lt; img &gt; '&lt; input &gt;" </code></pre> <p>Find the starting of the html tag using s.find('&lt;') </p> <p>s[0 : s.find('&lt;')] will select the substring from 0 to an index before the start of the html tag</p> <p>s[s.find('&lt;'):] will select the substring beginning from start ...
0
2016-07-25T07:26:58Z
[ "python", "html", "regex" ]
Redraw a matplotlib figure with new rc params
38,520,641
<p>is there a conventient way to update an already existing matplotlib figure with new rcParams? Background is that i want to export figures with different properties (e.g. line-width, fonts ..). Is there something like a 'redraw()' option? Thank you!</p>
0
2016-07-22T07:30:17Z
38,530,792
<p>use <code>fig.canvas.draw()</code></p> <p>See <a href="http://stackoverflow.com/questions/4098131/how-to-update-a-plot-in-matplotlib">How to update a plot in matplotlib?</a> or <a href="http://stackoverflow.com/questions/20936817/how-do-i-redraw-an-image-using-pythons-matplotlib">how do I redraw an image using pyt...
0
2016-07-22T15:56:28Z
[ "python", "matplotlib" ]
Why does my code not return anything
38,520,662
<p>fairly new to programming and trying to learn Python at the moment. I have this code and I don't understand why I don't get a return value :(</p> <pre><code>balance = 3200 annualInterestRate = 0.2 monthlyInterestRate = (annualInterestRate/12 + 1) def f(x): m = 0 ba = balance while m &lt; 12: ...
-6
2016-07-22T07:31:39Z
38,520,730
<p>You have to explicitly use the <code>return</code> keyword. Probably where you currently have <code>print c</code>.</p> <p><code>f</code> needs to return <code>ba</code> after the while loop.</p>
1
2016-07-22T07:34:52Z
[ "python", "return" ]
Why does my code not return anything
38,520,662
<p>fairly new to programming and trying to learn Python at the moment. I have this code and I don't understand why I don't get a return value :(</p> <pre><code>balance = 3200 annualInterestRate = 0.2 monthlyInterestRate = (annualInterestRate/12 + 1) def f(x): m = 0 ba = balance while m &lt; 12: ...
-6
2016-07-22T07:31:39Z
38,520,815
<p>You're being unclear about what function you expect to return a value, but as I cannot comment and prod yet I'll provide a possible answer.</p> <p>First of all, in this code you never actually call any of the functions. I'm assuming this is done elsewhere.</p> <p>As for <code>f(x)</code>, there's no <code>return v...
0
2016-07-22T07:39:31Z
[ "python", "return" ]
Why does my code not return anything
38,520,662
<p>fairly new to programming and trying to learn Python at the moment. I have this code and I don't understand why I don't get a return value :(</p> <pre><code>balance = 3200 annualInterestRate = 0.2 monthlyInterestRate = (annualInterestRate/12 + 1) def f(x): m = 0 ba = balance while m &lt; 12: ...
-6
2016-07-22T07:31:39Z
38,520,861
<p>First you should add <code>return ba</code> to function <code>f</code> to make <code>f</code> return someting:</p> <pre><code>def f(x): m = 0 ba = balance while m &lt; 12: ba = (ba - x)*monthlyInterestRate m += 1 retrun ba </code></pre> <p>Then, add <code>bisection()</code> at th...
0
2016-07-22T07:41:46Z
[ "python", "return" ]
Why does my code not return anything
38,520,662
<p>fairly new to programming and trying to learn Python at the moment. I have this code and I don't understand why I don't get a return value :(</p> <pre><code>balance = 3200 annualInterestRate = 0.2 monthlyInterestRate = (annualInterestRate/12 + 1) def f(x): m = 0 ba = balance while m &lt; 12: ...
-6
2016-07-22T07:31:39Z
38,520,940
<p>First of all, in your function <code>f</code> you don't have the return statement that you need if you want to check the equality with 0.</p> <p>After add the return statement in the <code>f</code> function you have to write the body of your program because you just have two functions but you don't call them to get...
0
2016-07-22T07:44:58Z
[ "python", "return" ]
Why does my code not return anything
38,520,662
<p>fairly new to programming and trying to learn Python at the moment. I have this code and I don't understand why I don't get a return value :(</p> <pre><code>balance = 3200 annualInterestRate = 0.2 monthlyInterestRate = (annualInterestRate/12 + 1) def f(x): m = 0 ba = balance while m &lt; 12: ...
-6
2016-07-22T07:31:39Z
38,521,069
<p>Two reasons. One, your function f(x) does not have an explicit return statement. If a function doesn't contain an explicit return it will have an implicit one, that is "None" (None is a python object). Second, the only place where f(x) is called is in bisection() which itself is never being called. So, since none of...
0
2016-07-22T07:52:25Z
[ "python", "return" ]
Want to update document in reThinkDB using setInsert Python
38,520,752
<pre><code> r.db('usersData').table('smsRaw').get("3413b71c-1628-47eb-83fa-6a3cccdb3e62").update({"MESSAGE": r.row('MESSAGE').setInsert({"DATE":"20160111","MESSAGE":[{"ADDR":"LONDON","date":"1468385398746"}]})}) </code></pre> <p>This is what i am able to run on console.I want to convert it to python code.</p> <p>Be...
-1
2016-07-22T07:36:16Z
38,521,756
<p>You probably want <code>setInsert</code> to be <code>set_insert</code>.</p>
0
2016-07-22T08:32:19Z
[ "python", "rethinkdb", "rethinkdb-python" ]
Read a list from txt file in Python
38,520,884
<p>I need to read a list from a txt file and import as a list variable into my .py file. I could use the import function, but the program must be compiled and when it's compiled to an exe, all the imports ends converted into a non-modificable files, so the solution is to read from a txt. The code that I use is similar ...
0
2016-07-22T07:42:48Z
38,521,224
<p>try to use <code>ast.literal_eval</code> :</p> <pre><code>&gt;&gt;&gt; a = str([['preset1','a1','b1'],['preset2','a2','b2'],['preset3','a3','b3'],['preset4','a4','b4']]) &gt;&gt;&gt; a "[['preset1', 'a1', 'b1'], ['preset2', 'a2', 'b2'], ['preset3', 'a3', 'b3'], ['preset4', 'a4', 'b4']]" &gt;&gt;&gt; import ast &gt;...
2
2016-07-22T08:01:19Z
[ "python", "list", "file" ]
Python "TypeError: can only concatenate tuple (not "int") to tuple"
38,520,887
<p>I wrote a piece python code like this</p> <pre><code>import random val_hist = [] for i in range(100): val_hist.append(random.randint(0,1000)) def print__(x): print type(x[1]) map(lambda x: print__(x), list(enumerate(val_hist))) l_tmp = list(enumerate(val_hist)) idx_list = map(lambda x: x[0], l_tmp) val_...
1
2016-07-22T07:43:00Z
38,521,174
<p>You need to provide a third argument to reduce, which is the <code>initializer</code>. From the <a href="https://docs.python.org/2/library/functions.html#reduce" rel="nofollow">docs</a>:</p> <blockquote> <p>If initializer is not given and iterable contains only one item, the first item is returned.</p> </blockq...
2
2016-07-22T07:58:21Z
[ "python", "lambda" ]
How to take arbitrary number of parentheses from user for add function
38,520,900
<pre><code>add(5)(10)(20) </code></pre> <p>How can I to supply an arbitrary number of parentheses to add numbers?</p>
-4
2016-07-22T07:43:20Z
38,521,034
<p>It's impossible, or at least it <em>should</em> be if the language you're using is worth anything. You're asking for a function to return two different types, which is inviting a a disaster.</p> <ol> <li>sometimes it should return a function that takes the next number to add</li> <li>other times it should return th...
2
2016-07-22T07:50:04Z
[ "python" ]
How to take arbitrary number of parentheses from user for add function
38,520,900
<pre><code>add(5)(10)(20) </code></pre> <p>How can I to supply an arbitrary number of parentheses to add numbers?</p>
-4
2016-07-22T07:43:20Z
38,521,068
<p>You could create a class like so:</p> <pre><code>class add(object): def __init__(self, value): self.value= value def __call__(self, value): self.value+= value return self def __repr__(self): return str(self.value) print add(5)(10)(20) # output: 35 </code></pre>
3
2016-07-22T07:52:23Z
[ "python" ]
How to take arbitrary number of parentheses from user for add function
38,520,900
<pre><code>add(5)(10)(20) </code></pre> <p>How can I to supply an arbitrary number of parentheses to add numbers?</p>
-4
2016-07-22T07:43:20Z
38,521,276
<p>What you could do is this:</p> <pre><code>class add(object): def __init__(self, val): self.val= val def __call__(self, val=None): if not val: return self.val self.val += val return self add(5)(10)() &gt;&gt;&gt; 15 </code></pre>
-1
2016-07-22T08:04:20Z
[ "python" ]
Supervisord configuration for Django rq not working
38,520,957
<p>I am following : <a href="http://python-rq.org/patterns/supervisor/" rel="nofollow">Putting RQ under supervisor</a></p> <p>My job:</p> <pre><code>@job("default") def send_mail(subject, body, sender, receivers, cc=None, bcc=None, content_type='plain', class_name=None): """Send email to users.""" *code to s...
0
2016-07-22T07:45:49Z
38,657,858
<p>Answering my own question.</p> <p>So here is the example configuration i used in local and development servers. You can create this file using : </p> <p><code>sudo touch /etc/supervisor/conf.d/djangorq.conf</code></p> <p>Configuration for development server:</p> <pre><code>[program:djangorq] command=/root/.virt...
0
2016-07-29T11:36:49Z
[ "python", "django", "supervisord", "supervisor" ]
Limit number of displayed float digits in pyQT QLineEdit without sacrificing internal accuracy
38,520,962
<p>I'm using QLineEdit widgets in my application to enter and edit numeric (float) values. I would like to <em>display</em> a rounded version of the float value while keeping the full internal accuracy. Only when editing a QLineEdit field, the full number of digits should be displayed.</p> <p>This is needed for three ...
1
2016-07-22T07:46:13Z
38,529,773
<p>It seems that the behaviour should be this:</p> <ul> <li>When the line-edit <strong>loses</strong> input focus, display the stored value rounded</li> <li>When the line-edit <strong>gains</strong> input focus, display the stored value in full</li> <li>Whenever editing finishes, store the full current value in log fo...
0
2016-07-22T15:06:23Z
[ "python", "floating-point", "pyqt", "qlineedit" ]
Limit number of displayed float digits in pyQT QLineEdit without sacrificing internal accuracy
38,520,962
<p>I'm using QLineEdit widgets in my application to enter and edit numeric (float) values. I would like to <em>display</em> a rounded version of the float value while keeping the full internal accuracy. Only when editing a QLineEdit field, the full number of digits should be displayed.</p> <p>This is needed for three ...
1
2016-07-22T07:46:13Z
38,667,280
<p>I have tried to use a mix of signal-slot connections (<code>editingFinished</code>) and eventFilter. However, I ran into some strange bugs that may have been caused by some race conditions or simply because the logic behind the code became too warped. Anyway, the following snippet works great, maybe it is helpful fo...
0
2016-07-29T20:51:22Z
[ "python", "floating-point", "pyqt", "qlineedit" ]
Submitting a Form using Selenium in Python
38,520,970
<p>I need to scrape some data behind those hyperlinks from <a href="http://www.echemportal.org/echemportal/propertysearch/treeselect_input.action?queryID=PROQ3h3n" rel="nofollow">this Site</a>. However, those hyperlinks are <code>javascript function calls</code>, which later submits a <code>form</code> using <code>post...
0
2016-07-22T07:46:38Z
38,521,635
<p>You are trying to set value on <code>hidden</code> input is which not visible on the page, that's why error has occurred. If you want to set value on <code>hidden</code> field try using <code>execute_script</code> as below :-</p> <pre><code>treePath_tag = driver.find_element_by_name("treePath") driver.execute_scrip...
1
2016-07-22T08:25:52Z
[ "javascript", "python", "forms", "selenium" ]
Python Selenium - AttributeError : WebElement object has no attribute sendKeys
38,521,136
<p>I'm trying to pass through "ENTER" to a text field, using <code>Selenium</code> (Python). The text box requires that each phone number be entered on a new line, so it will look something like:</p> <pre><code>#Add the phone number# Webelement.sendKeys(Keys.ENTER) </code></pre> <p>I've imported the following library...
0
2016-07-22T07:56:19Z
38,521,249
<p>Try using <a href="http://selenium-python.readthedocs.io/api.html#selenium.webdriver.remote.webelement.WebElement.send_keys" rel="nofollow"><code>WebElement::send_keys()</code></a> instead of <code>sendKeys</code> as below :-</p> <pre><code>from selenium.webdriver.common.keys import Keys Webelement.send_keys(Keys....
3
2016-07-22T08:02:38Z
[ "python", "selenium", "selenium-webdriver", "sendkeys" ]
Have to manually start worker on heroku?
38,521,160
<p>In my Procfile I have the following:</p> <pre><code>worker: cd appname &amp;&amp; celery -A appname worker -l info --app=appname.celery_setup:app </code></pre> <p>However, when my app submits a task it never happens, but I think the celery worker is at least sort of working, because </p> <pre><code>heroku logs -...
0
2016-07-22T07:57:16Z
38,537,122
<p>I figured it out. Turns out you also have to do </p> <pre><code>heroku ps:scale worker=1 --app appname </code></pre> <p>Or else you won't actually be running a worker.</p>
1
2016-07-23T00:57:21Z
[ "python", "django", "heroku", "celery", "django-celery" ]
How can i call syntaxnet from python file?
38,521,181
<p>We have successfully installed syntaxnet and we are able to get the parsed output by calling the command <code>echo 'open Book, which I have written with laboratory writer, with libreoffice writer.' | syntaxnet/demo.sh</code>.</p> <p>Ideally what we want is calling syntaxnet from python file (more specifically from...
0
2016-07-22T07:59:00Z
38,533,083
<p>Apperently it is exactly like the example I have used in my <a href="http://stackoverflow.com/questions/37753980/how-to-use-syntaxnet-output-to-operate-an-executive-command-for-example-save-a/38444785#38444785">answer</a>. using <code>subprocess</code> module can help you to do call this command in your python file ...
0
2016-07-22T18:24:29Z
[ "python", "tensorflow", "syntaxnet" ]
Python not finding modules after installing with pip
38,521,214
<p>I have installed various third party modules with pip and they worked fine until I then ran ccleaner today. Now I cannot import any of these modules. </p> <p>I've added site-packages to the PATH variable: C:\Python27\;C:\Users\Rick\PythonScripts;C:\Python27\Scripts;C:\Python27\Lib;C:\Python27\Lib\site-packages\</p>...
-2
2016-07-22T08:00:41Z
38,521,936
<p>Your Path variable needs to modify. This is only used to find binary, not python standard library.</p> <p>Remove:</p> <pre><code>C:\Python27\;C:\Users\Rick\PythonScripts;C:\Python27\Scripts;C:\Python27\Lib;C:\Python27\Lib\site-packages\ </code></pre> <p>Add:</p> <pre><code>C:\Python27\;C:\Python27\Scripts; </cod...
0
2016-07-22T08:41:31Z
[ "python", "python-2.7" ]
use json in cherrpy
38,521,258
<p>I am new to creating API's in cherrypy.So,I am just making a simple API to add numbers and display the answer.</p> <p>I used this :</p> <pre><code> import cherrypy import json def add(b,c): return a+b class addition: exposed = True def POST(self,c,d): result=add(c,d) ...
0
2016-07-22T08:03:27Z
38,998,730
<p>First start without JSON to make sure your code works. Then update your code to work with JSON. Here is a working example of your calculator.</p> <p>This example shows it without JSON. Example with JSON is below.</p> <h1>Working example without JSON</h1> <p>Server side in cherrypy (<code>server1.py</code>):</p> ...
0
2016-08-17T13:55:18Z
[ "python", "json", "http", "post", "cherrypy" ]
OpenERP - Odoo - How to have the percentage of quote that become a sale orders
38,521,380
<p>Is it possible to have easily the percentage of sales orders / quotes per users?</p> <p>The objective it is to know what the percentage of quote that become a sale order per user.</p> <p>I have not a clue how I can do it. I am using OpenERP 7</p>
0
2016-07-22T08:09:44Z
38,689,879
<p>Yes it is possible by using status bar. In order for you to compute the percentage of sales order, you should determine how much is the quota for each sale order.</p>
0
2016-08-01T01:30:46Z
[ "python", "openerp", "openerp-7" ]
How to search through tree to find the maximum sum of a set of nodes' value
38,521,381
<pre><code> G B H A D E C I F 1 2 3 (level) </code></pre> <p>Suppose there is a Tree in the above structure.<br> Each node is linked with the nodes of their parent and children. Also each node is linked with one node previously added and somewhat related to ...
1
2016-07-22T08:10:14Z
38,522,046
<p><strike>Here is my understanding of your problem: You want to enumerate all groups of related nodes of size n, and find the maximum sum of the values of the nodes in such a group.</p> <p>Here is an algorithm: For each node keep a sorted list of its children, sorted with respect to the values of the children. Iterat...
0
2016-07-22T08:46:48Z
[ "python", "python-3.x", "tree" ]
How to change the sampling rate of the data
38,521,537
<p>How to change the sampling rate of the data in the list <code>result</code>.</p> <p>The current sampling rate is 256, but the desired sampling rate is 250.</p> <p>Given:</p> <ul> <li><code>result</code> - a list of data with a sampling frequency of 256.</li> <li><code>buf.size</code> - the amount of signal in the...
0
2016-07-22T08:19:23Z
38,524,822
<p>I'll try here since the comments are small and I think I'll answer you:</p> <p>As I was saying python lists are just that, lists, a collection of stuff (not necessarily numerical values) they don't know or care about what is inside and as such they don't know what sampling frequency even means. Once you accept that...
0
2016-07-22T11:01:54Z
[ "python", "python-2.7", "numpy", "scipy", "resampling" ]
How to change the sampling rate of the data
38,521,537
<p>How to change the sampling rate of the data in the list <code>result</code>.</p> <p>The current sampling rate is 256, but the desired sampling rate is 250.</p> <p>Given:</p> <ul> <li><code>result</code> - a list of data with a sampling frequency of 256.</li> <li><code>buf.size</code> - the amount of signal in the...
0
2016-07-22T08:19:23Z
38,612,066
<p>You must record the time (in seconds - <code>f.file_duration</code>). My answer:</p> <pre><code>x250 = np.arange(0, f.file_duration, 0.004) #frequency 250 x256 = np.arange(0, f.file_duration, 0.00390625) #frequency 256 result256 = np.interp(x256, x250, result) </code></pre>
0
2016-07-27T11:46:30Z
[ "python", "python-2.7", "numpy", "scipy", "resampling" ]
How to print out only records with intervals, from one file, not overlapping with those from another file
38,521,553
<p>I have two files representing records with intervals.</p> <p>file1.txt</p> <pre class="lang-none prettyprint-override"><code>a 5 10 a 13 19 a 27 39 b 4 9 b 15 19 c 20 33 c 39 45 </code></pre> <p>and</p> <p>file2.txt</p> <pre class="lang-none prettyprint-override"><code>something id1 a 4 9 commentx something id2...
4
2016-07-22T08:20:31Z
38,522,474
<p>For your code to work, you will have to change three things:</p> <ol> <li>Your loop over the position reader is only run once, because the reader runs through the file, the first time the loop is run. Afterwards, he searches for the next item at the end of the file. You'll have to rewind the file each time, before ...
0
2016-07-22T09:06:46Z
[ "python" ]
How to print out only records with intervals, from one file, not overlapping with those from another file
38,521,553
<p>I have two files representing records with intervals.</p> <p>file1.txt</p> <pre class="lang-none prettyprint-override"><code>a 5 10 a 13 19 a 27 39 b 4 9 b 15 19 c 20 33 c 39 45 </code></pre> <p>and</p> <p>file2.txt</p> <pre class="lang-none prettyprint-override"><code>something id1 a 4 9 commentx something id2...
4
2016-07-22T08:20:31Z
38,522,927
<p>Here is an algorithm working for you:</p> <pre><code>def is_overlapping(x, y): return len(range(max(x[0], y[0]), min(x[-1], y[-1])+1)) &gt; 0 position_file = r"file1.txt" positions = [line.strip().split() for line in open(position_file).read().split('\n')] protein_file = r"file2.txt" proteins = [(line.strip()...
0
2016-07-22T09:29:02Z
[ "python" ]
How to print out only records with intervals, from one file, not overlapping with those from another file
38,521,553
<p>I have two files representing records with intervals.</p> <p>file1.txt</p> <pre class="lang-none prettyprint-override"><code>a 5 10 a 13 19 a 27 39 b 4 9 b 15 19 c 20 33 c 39 45 </code></pre> <p>and</p> <p>file2.txt</p> <pre class="lang-none prettyprint-override"><code>something id1 a 4 9 commentx something id2...
4
2016-07-22T08:20:31Z
38,524,016
<p>Do looping in a loop is not a good way. Try to avoid to do such things. I think you could cache the content of file1 first use a dict object. Then, when looping file2 you can use the dict object to find your need things.So, i will code like bellow:</p> <pre><code>with open("file1.csv", "r") as protein, open("file2....
0
2016-07-22T10:22:17Z
[ "python" ]
How to print out only records with intervals, from one file, not overlapping with those from another file
38,521,553
<p>I have two files representing records with intervals.</p> <p>file1.txt</p> <pre class="lang-none prettyprint-override"><code>a 5 10 a 13 19 a 27 39 b 4 9 b 15 19 c 20 33 c 39 45 </code></pre> <p>and</p> <p>file2.txt</p> <pre class="lang-none prettyprint-override"><code>something id1 a 4 9 commentx something id2...
4
2016-07-22T08:20:31Z
38,524,264
<p>It might be overkill, but you could create a class to represent intervals and use it to make fairly readable code:</p> <pre><code>import csv class Interval(object): """ Representation of a closed interval. a &amp; b can be numeric, a datetime.date, or any other comparable type. """ def __init__...
1
2016-07-22T10:34:13Z
[ "python" ]
imshow resize + count white pixels
38,521,571
<p>This is a simple program to read video files from your computer. My original video is 1080p resolution. When I run the code, the program's screen (imshow) exceeds my pc's screen which is only 720p. How to resize it from 1080p to 720 or 480p. Second question, how to find the number of pixels in the screen?</p> <p>My...
0
2016-07-22T08:21:38Z
38,521,637
<p>You can use <code>cv2.resize()</code> to resize the image before <code>imshow()</code> to fit in the screen, and to get the total number of pixels in the Mat you can use <code>gray.shape[0] * gray.shape[1]</code></p> <pre><code>import numpy as np import cv2 cap = cv2.VideoCapture('apple.mp4') total_white_pixels_i...
1
2016-07-22T08:25:58Z
[ "python", "opencv" ]
What is the equivalent operator to `in` in the `operator` module?
38,521,669
<p>The module <code>operator</code> offers equivalent functions for almost all standard operations.</p> <p>I have not been able to find the equivalent for the <code>in</code> (<code>if x in y:</code>) operator.</p> <p>Can anyone point me in the right direction?</p>
0
2016-07-22T08:28:05Z
38,521,702
<p>In the python data model, the <code>in</code> operator is implemented via the <a href="https://docs.python.org/2/reference/datamodel.html#object.__contains__" rel="nofollow"><code>__contains__</code></a> hook. Operator follows suit so the method is <a href="https://docs.python.org/2/library/operator.html#operator.c...
3
2016-07-22T08:29:27Z
[ "python" ]
What is the equivalent operator to `in` in the `operator` module?
38,521,669
<p>The module <code>operator</code> offers equivalent functions for almost all standard operations.</p> <p>I have not been able to find the equivalent for the <code>in</code> (<code>if x in y:</code>) operator.</p> <p>Can anyone point me in the right direction?</p>
0
2016-07-22T08:28:05Z
38,521,714
<p>It is <a href="https://docs.python.org/2/library/operator.html#operator.contains" rel="nofollow"><code>operator.contains</code></a>:</p> <pre><code>if x in y: </code></pre> <p>Is equivalent to:</p> <pre><code>if operator.contains(y, x): # Note the reversed operand! </code></pre>
2
2016-07-22T08:29:50Z
[ "python" ]
Why can python not take unicode inputs on windows console?
38,521,808
<p>I have a python file named 'কাজ.py'. The file does nothing fancy. I am not concerned for that. The thing is when i try to run the file by copying and pasting the file name, it does not show 'কাজ.py' rather it shows some boxes </p> <pre><code>&gt; python [?][?][?].py </code></pre> <p>and it raises an e...
0
2016-07-22T08:35:06Z
38,523,259
<p>It depends whether the command uses internally the UNICODE or MBCS command line application interface. Assuming it is a C (or C++) program, it depends whether it uses a <code>main</code> or <code>wmain</code>. If it uses a unicode interface, it will get the true unicode characters (even if it cannot displays them an...
2
2016-07-22T09:45:22Z
[ "python", "git", "unicode" ]
click button on website using scrapy
38,521,864
<p>I want to ask how about (do crawling) clicking next button(change number page of website) (then do crawling more till the end of page number) from <a href="https://n0where.net/" rel="nofollow">this site</a> </p> <p>I've try to combining scrape with selenium,but its still error and says <code>"line 22 self.drive...
0
2016-07-22T08:38:32Z
38,522,107
<p>This is a indentation error. Look the lines near the error:</p> <pre><code> def parse2(self, response): self.driver.get(response.url) </code></pre> <p>The first of these two lines ends with a colon. So, the second line should be more indented than the first one.</p> <p>There are two possible fixes, dependi...
1
2016-07-22T08:49:20Z
[ "python", "selenium", "scrapy", "web-crawler" ]
click button on website using scrapy
38,521,864
<p>I want to ask how about (do crawling) clicking next button(change number page of website) (then do crawling more till the end of page number) from <a href="https://n0where.net/" rel="nofollow">this site</a> </p> <p>I've try to combining scrape with selenium,but its still error and says <code>"line 22 self.drive...
0
2016-07-22T08:38:32Z
38,525,624
<p>Ignoring the syntax and indentation errors you have an issue with your code logic in general.</p> <p>What you do is create webdriver and never use it. What your spider does here is:</p> <ol> <li>Create webdriver object.</li> <li>Schedule a request for every url in <code>self.start_urls</code>, in your case it's on...
1
2016-07-22T11:44:35Z
[ "python", "selenium", "scrapy", "web-crawler" ]
DJANGO Trouble to inject the MultipleChoiceField initial value
38,522,040
<p>I've a form, clicking the button "info" from a table, i get the user information and inject into the form, all of this works as well, but not for the <strong>MultipleChoiceField</strong>:</p> <pre><code>data = {'name': name_surname[0], 'surname': name_surname[1], 'c02': retrieved.c02, 'dep': retrieved.dept_no, ...
0
2016-07-22T08:46:33Z
38,522,763
<p>You only need to set the values, like:</p> <pre><code>initial = { ... "team_id": ['POCM_A09', ...] # list of all the values selected ... } </code></pre> <p>As per our chat discussion I'm updating the answer. </p> <p>You can override the choices of the "<em>MultipleChoiceField</em>" inside form <code>__in...
2
2016-07-22T09:20:51Z
[ "python", "django", "django-forms", "multiplechoicefield" ]
xml.etree.ElementTree.ParseError: not well-formed (invalid token) in Python
38,522,270
<p>I am trying to open an XML file using <code>ElementTree</code> but an error occurred: </p> <blockquote> <p>xml.etree.ElementTree.ParseError: not well-formed (invalid token)</p> </blockquote> <p>And here is my code:</p> <pre><code># -*- coding: utf-8 -*- import xml.etree.ElementTree as etree def main(): tre...
-1
2016-07-22T08:57:04Z
38,522,947
<p>The <a href="http://www.w3schools.com/xml/xml_syntax.asp" rel="nofollow">XML format rules</a> state that you have to have one root element. Your document has two of them, <code>pdml</code> and <code>packet</code>. I'm not familiar with PDML, but a XML parser probably will choke on that. </p>
0
2016-07-22T09:30:14Z
[ "python", "xml", "parsing", "elementtree" ]
xml.etree.ElementTree.ParseError: not well-formed (invalid token) in Python
38,522,270
<p>I am trying to open an XML file using <code>ElementTree</code> but an error occurred: </p> <blockquote> <p>xml.etree.ElementTree.ParseError: not well-formed (invalid token)</p> </blockquote> <p>And here is my code:</p> <pre><code># -*- coding: utf-8 -*- import xml.etree.ElementTree as etree def main(): tre...
-1
2016-07-22T08:57:04Z
38,523,033
<p>You are missing the closing <code>&lt;/pdml&gt;</code> tag at the end of the xml file.</p>
0
2016-07-22T09:34:07Z
[ "python", "xml", "parsing", "elementtree" ]
xml.etree.ElementTree.ParseError: not well-formed (invalid token) in Python
38,522,270
<p>I am trying to open an XML file using <code>ElementTree</code> but an error occurred: </p> <blockquote> <p>xml.etree.ElementTree.ParseError: not well-formed (invalid token)</p> </blockquote> <p>And here is my code:</p> <pre><code># -*- coding: utf-8 -*- import xml.etree.ElementTree as etree def main(): tre...
-1
2016-07-22T08:57:04Z
38,524,548
<p>Try to set the proper encoding ie:</p> <pre><code>etree.parse('test.xml', etree.XMLParser(encoding='utf-8')) </code></pre>
0
2016-07-22T10:48:01Z
[ "python", "xml", "parsing", "elementtree" ]
Remove empty sub plots in matplotlib figure
38,522,408
<p>How can I determine whether a subplot (<code>AxesSubplot</code>) is empty or not? I would like to deactivate empty axes of empty subplots and remove completely empty rows.</p> <p>For instance, in this figure only two subplots are filled and the remaining subplots are empty.</p> <pre><code>import matplotlib.pyplot ...
0
2016-07-22T09:03:30Z
38,522,888
<p>One way of achieving what you require is to use matplotlibs <a href="http://matplotlib.org/users/gridspec.html" rel="nofollow">subplot2grid</a> feature. Using this you can set the total size of the grid (3,7 in your case) and choose to only plot data in certain subplots in this grid. I have adapted your code below t...
1
2016-07-22T09:27:06Z
[ "python", "matplotlib" ]
Can pandas with MySQL support text indexes?
38,522,513
<p>If I try to store a dataframe with a text index in a MySQL database I get the error "BLOB/TEXT column used in key specification without a key length", for example:</p> <pre><code>import pandas as pd import sqlalchemy as sa df = pd.DataFrame( {'Id': ['AJP2008H', 'BFA2010Z'], 'Date': pd.to_datetime(['2010-0...
1
2016-07-22T09:08:53Z
38,524,884
<p>you can specify a <a href="http://docs.sqlalchemy.org/en/latest/core/type_basics.html" rel="nofollow">SQLAlchemy data type</a> explicitly, using <code>dtype</code> argument when calling <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_sql.html" rel="nofollow">to_sql()</a> method:</p...
1
2016-07-22T11:05:46Z
[ "python", "mysql", "pandas", "sqlalchemy" ]
How do I determine if current server time isn't within a specified range using Python ?
38,522,514
<p>I need to check in Python if the current time on the server isn't in the time range of 22:00PM - 04:00AM.</p> <p>What is the correct way to write this code ?</p> <p>Thanks !</p>
-1
2016-07-22T09:08:56Z
38,522,765
<p>Try this below:</p> <pre><code>import time def isWithinRange(): hour = time.localtime(time.time()).tm_hour return hour &gt;= 22 or hour &lt;= 4 </code></pre>
0
2016-07-22T09:20:55Z
[ "python" ]
RuntimeError: maximum recursion depth exceeded py2app
38,522,643
<p>I'm trying to create a standalone app using py2app 0.10 but a RuntimeError: maximum recursion depth exceeded error show creating my app. </p> <pre><code> File "build/bdist.macosx-10.5-x86_64/egg/modulegraph/modulegraph.py", line 947, in import_hook File "build/bdist.macosx-10.5-x86_64/egg/modulegraph/modulegraph...
-1
2016-07-22T09:14:35Z
38,522,673
<p>You have not implemented a stop condition in your recursion function. Without your posting code I cannot answer much further. See the <a class='doc-link' href="http://stackoverflow.com/documentation/python/1716/recursion#t=201607220918022936079&amp;a=remarks">remarks</a> section of recursion.</p>
0
2016-07-22T09:16:00Z
[ "python", "py2app" ]
A Flask-WTF form that does not send an email when the user submit the form
38,522,725
<p>I decided to follow this tutorial(<a href="http://www.boxcontrol.net/adding-contact-form-to-your-site-using-flask-and-python3.html" rel="nofollow">https://www.boxcontrol.net/adding-contact-form-to-your-site-using-flask-and-python3.html</a>) but create a different type of form where the user inputs their personal inf...
0
2016-07-22T09:18:26Z
38,526,740
<p>Break the problem down— at the moment you have a lot of moving parts. If you're not getting an error, my initial thought would be that your emails are getting sent to junk/spam.</p> <p>If you create a new view that just sends a static email, does it work?</p> <pre><code>@app.route('/testemail') def send_test_ema...
0
2016-07-22T12:41:48Z
[ "python", "flask", "flask-wtforms" ]
A Flask-WTF form that does not send an email when the user submit the form
38,522,725
<p>I decided to follow this tutorial(<a href="http://www.boxcontrol.net/adding-contact-form-to-your-site-using-flask-and-python3.html" rel="nofollow">https://www.boxcontrol.net/adding-contact-form-to-your-site-using-flask-and-python3.html</a>) but create a different type of form where the user inputs their personal inf...
0
2016-07-22T09:18:26Z
38,596,163
<p>If you are not receiving any errors and no email is being sent, set <code>MAIL_DEBUG=True</code>. Flask-Mail uses the <code>smtplib</code> module which can <a href="https://github.com/mattupstate/flask-mail/blob/master/flask_mail.py#L153" rel="nofollow">set</a> debug level. Also try updating <code>config</code> befo...
0
2016-07-26T17:17:20Z
[ "python", "flask", "flask-wtforms" ]
Error Code 1 While Loading Python Pillow Module
38,522,811
<p>I'm using python 3.6 64 bit. The python installation went down with no problem. But when I try to install pillow module using command prompt I get the "error 1". I googled It and couldn't find any explanations on this issue on windows. A youtube video shortly referred to it as "This issue is common if you're using w...
0
2016-07-22T09:23:18Z
38,523,055
<p>Try to <code>-- disable-</code> with installation.<br> And add to disable all traceback errors that You see in console. for example: <code>pip install Pillow --disable-zlib</code> and so on. I`m not installed Pillow on Windows. You can try just to install Anaconda 3.</p>
0
2016-07-22T09:35:29Z
[ "python", "pillow" ]
How to print color box on the console in python?
38,522,909
<p>I want to plot HeatMap on the console. For that purpose I want to plot small boxex of different colors i.e | | this size. I got different color Unicode symbols to plot HeatMap on the console but they are not working good. whenever I'm printing color on the 1st line it gets reflected on the 2nd line also. </p> <p><s...
0
2016-07-22T09:28:18Z
38,523,272
<p>That's not "unicode", they're called <a href="https://en.wikipedia.org/wiki/ANSI_escape_code" rel="nofollow">ANSI escape codes</a>.</p> <p>For your purpose, you can print a space character with a modified background color, and don't forget to set the colors back to normal afterwards (with <code>\033[0m</code>):</p>...
0
2016-07-22T09:46:16Z
[ "python", "unicode", "colors", "console" ]
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
38,522,939
<p>I cannot request a popular SSL site without geting the error <code>[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed</code>.</p> <p>The requests <a href="http://docs.python-requests.org/en/master/user/advanced/" rel="nofollow">documentation</a> states that</p> <blockquote> <p>By default Requests bundles...
1
2016-07-22T09:29:52Z
38,523,433
<pre><code>r = requests.get('https://www.example.com', proxies=proxies, verify=False) </code></pre> <p>Change this line and it will work.</p>
-2
2016-07-22T09:54:38Z
[ "python", "http", "ssl", "https", "python-requests" ]
Fastest way to query huge list in mongodb
38,523,087
<p>I want to get details of large set of users from mongodb. The user list is of more than 100 thousands. As mongodb dose not support very huge data query in one go. I want to know which is the best way to get the data.</p> <ol> <li>Divide list in groups and get data</li> </ol> <blockquote> <p><em>groups_of_list co...
0
2016-07-22T09:37:15Z
38,593,449
<p>IMHO you should probably separate into "reasonable sized" chunks as in the method 1 you pointed out, not so much for Mongo's limitations, but for your own machine's memory limitations.</p> <p>It should probably be something like this:</p> <pre><code>def get_user_slice_data(groups_of_list): for group in groups_...
1
2016-07-26T15:01:30Z
[ "python", "mongodb", "performance", "search", "pymongo" ]
Fastest way to query huge list in mongodb
38,523,087
<p>I want to get details of large set of users from mongodb. The user list is of more than 100 thousands. As mongodb dose not support very huge data query in one go. I want to know which is the best way to get the data.</p> <ol> <li>Divide list in groups and get data</li> </ol> <blockquote> <p><em>groups_of_list co...
0
2016-07-22T09:37:15Z
38,596,872
<p>You can use cursors with fixed limit and iterate over the results using the cursor. You can find more info here - <a href="https://docs.mongodb.com/v3.2/tutorial/iterate-a-cursor/" rel="nofollow">https://docs.mongodb.com/v3.2/tutorial/iterate-a-cursor/</a></p> <p>But actual code implementation depends on the langua...
0
2016-07-26T17:59:59Z
[ "python", "mongodb", "performance", "search", "pymongo" ]
implement of siftdown function violates heap formal definition?
38,523,099
<p>I am trying to understand the implementation of heap right now, and I look into heapq module of python.<br/> <a href="https://github.com/python-git/python/blob/master/Lib/heapq.py" rel="nofollow">https://github.com/python-git/python/blob/master/Lib/heapq.py</a> <br/> Line236 is the start of the code of siftdown, the...
0
2016-07-22T09:37:48Z
38,595,477
<p>It's just a nomenclature clash. What they call "siftup" is sifting towards the leaves. Perhaps the thinking is that in a min-heap, larger items move "up" towards the leaves.</p> <p>Their "siftdown" moves towards the root.</p> <p>It's upside-down from what we computer people normally (?) think of as a tree, but it'...
1
2016-07-26T16:39:51Z
[ "python", "heap" ]
regular expression is_fraction : Python : regex
38,523,110
<p>please help me with this:</p> <p>Is Fraction</p> <p>Create a function is_fraction that accepts a string and returns True if the string represents a fraction.</p> <p>By our definition a fraction consists of:</p> <p>An optional - character Followed by 1 or more digits Followed by a / Followed by 1 or more digits, ...
-1
2016-07-22T09:38:09Z
38,523,361
<p>Right, you need your denominator to be a sequence of digits, at least one of which is not <code>0</code>. This can be modeled using the regex <code>0*[1-9][0-9]*</code></p> <p>So your validation method now becomes:</p> <pre><code>def is_fraction(string): """Return True iff the string represents a valid fractio...
2
2016-07-22T09:51:02Z
[ "python", "regex" ]
Pandas: sum if columns values coincides
38,523,193
<p>I'm trying to do an, apparently, simple operation in python:</p> <p>I have some datasets, say 6, and I want to sum the values of one column if the values of the other two columns coincides. After that, I want to divide the values of the column which has been summed by the number of datasets I have, in this case, 6 ...
0
2016-07-22T09:42:17Z
38,526,272
<p>You could put all your data frames in a list and then use <code>reduce</code> to either <code>append</code> or <code>merge</code> them all. Take a look at reduce <a href="https://docs.python.org/2/library/functions.html#reduce" rel="nofollow">here</a>.</p> <p>First, below some functions are defined for sample data ...
1
2016-07-22T12:19:57Z
[ "python", "pandas" ]
Python Crash Course : Using int() to accept numerical input
38,523,285
<p>i am new to programming. According to my book, this code should get an error. </p> <pre><code>&gt;&gt;&gt; age = input("How old are you? ") How old are you? 21 &gt;&gt;&gt; age &gt;= 18 Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; vTypeError: unorderable types: str() &...
-5
2016-07-22T09:46:56Z
38,523,337
<p>You are using Python 2 and the book author is using Python 3.</p> <p>In Python 2 <code>input</code> tries to evaluate the entered value, so the string <code>'21'</code> actually becomes <code>21</code> as an <code>int</code>.</p> <p>As @Siddharth pointed out in the comments, <code>str &gt; int</code> will always e...
2
2016-07-22T09:49:39Z
[ "python" ]
How to reload a Flask app each time it's accessed
38,523,303
<p>I have a flask app that is accessed using the <code>/get_data</code> endpoint and providing a number as an id (<code>127.0.0.1:55555/get_data=56</code>) </p> <pre><code>@app.route('/get_data=&lt;id&gt;') def get_vod_tree(id): ... return render_template('index.html') </code></pre> <p>It invokes a funct...
0
2016-07-22T09:48:04Z
38,523,616
<p>If you set <code>app.run(debug=True)</code> in your test/dev environment, it will automatically reload your Flask app every time a code change happens.</p> <p>To reload the application when a static file changes, use the <code>extra_files</code> parameter. See <a href="http://werkzeug.pocoo.org/docs/0.10/serving/?h...
0
2016-07-22T10:03:10Z
[ "python", "d3.js", "flask" ]
How to reload a Flask app each time it's accessed
38,523,303
<p>I have a flask app that is accessed using the <code>/get_data</code> endpoint and providing a number as an id (<code>127.0.0.1:55555/get_data=56</code>) </p> <pre><code>@app.route('/get_data=&lt;id&gt;') def get_vod_tree(id): ... return render_template('index.html') </code></pre> <p>It invokes a funct...
0
2016-07-22T09:48:04Z
38,524,695
<p>Thanks for the answers. It helped getting to the bottom of this. It works now like this:</p> <pre><code>@app.after_request def apply_caching(response): response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' return response </code></pre> <p>So by disabling the cache the application can tr...
1
2016-07-22T10:55:10Z
[ "python", "d3.js", "flask" ]
AttributeError: '_io.TextIOWrapper' object has no attribute 'reader'
38,523,325
<p>Couldn't get what wrong in the code, as <code>csv</code> module has a <code>csv.reader()</code> function as per <a href="https://docs.python.org/3.4/library/csv.html" rel="nofollow">the documentation</a>. But I am still getting this error:</p> <pre><code>Traceback (most recent call last): File "test_csv.py", line...
0
2016-07-22T09:49:19Z
38,523,398
<p>You re-bound the name <code>csv</code> in the <code>as</code> target:</p> <pre><code>with open('test_csv.csv') as csv: </code></pre> <p>This masks the module name, so <code>csv.reader</code> is resolved <em>on the file object</em>.</p> <p>Use a different target:</p> <pre><code>with open('test_csv.csv') as csvfil...
0
2016-07-22T09:52:52Z
[ "python", "csv" ]
Multiple condition in domain is not working - OpenERP 7 - Odoo
38,523,363
<p>I am trying to use multiple condition for my domain but I got this error:</p> <p>ValueError: Invalid leaf ('&amp;', ('A', '=', True), ('B', '=', False)</p> <p>I have no idea why. Everything looks well. I would like to have (A &amp; !B) OR (C &amp; !D )</p> <p>This is my code (OpenERP 7):</p> <pre><code> &...
0
2016-07-22T09:51:05Z
38,544,740
<p>You're using extra brackets. Prefix Notation (AKA Polish notation) is all about discarding necessity of brackets. You should use proper <a href="https://www.google.com/search?q=prefix%20notation" rel="nofollow">"prefix notation"</a> in condition statement. In order to correct a syntax, we have to remove extra bracke...
0
2016-07-23T17:40:32Z
[ "python", "xml", "openerp", "openerp-7" ]
Not able to install numpy or nltk python-modules
38,523,385
<p>I am having a strange issue installing numpy or nltk python-modules in my windows-7 machine. I have successfully installed Python 2.7.12 but I get this error when I type <code>pip install numpy</code> as in this <a href="http://i.stack.imgur.com/9KAI0.png" rel="nofollow">screenshot</a>. I have also included the dire...
0
2016-07-22T09:52:22Z
38,529,960
<p>Installing such these things in windows are sometime difficult, specially for someone new to python packages(also for some experts!)</p> <p>Try to use Anaconda for windows: <a href="https://www.continuum.io/downloads#_windows" rel="nofollow">https://www.continuum.io/downloads#_windows</a> This install a python for ...
0
2016-07-22T15:14:30Z
[ "python", "windows", "numpy", "nltk" ]
How to put in a profile picture in django
38,523,456
<p>im following <a href="http://stackoverflow.com/questions/6396442/add-image-avatar-to-users-in-django">Add image/avatar to users in django</a> tip to have users upload their profile pictures, and to display the user's profile picture when a user log in.</p> <p><a href="http://stackoverflow.com/questions/28197051/add...
0
2016-07-22T09:55:58Z
38,524,753
<p>Example: models.py:</p> <pre><code>class YouModel(models.Model): .............You field ................ user_avatar = models.ImageField((upload_to="You/media/uploads", blank=True) # You need to configure media in settings.py ........... You fields .............. class YouModelForm(ModelForm) class...
2
2016-07-22T10:58:31Z
[ "python", "django" ]
Invalid operator '$size' in aggregation
38,523,546
<p>I got the following piece of code: </p> <pre><code>from pymongo import MongoClient client = MongoClient('ipOfServer') db = client.admin db.authenticate('login', 'password', source='admin_') heh = list(db.events.aggregate( [ {"$match": {"status": 'start'}}, {"$group": {"_id": "$eventName", "playe...
0
2016-07-22T09:59:28Z
38,525,739
<p>The reason is because the <a href="https://docs.mongodb.com/manual/reference/operator/aggregation/size/" rel="nofollow"><code>$size</code></a> array aggregation operator is new in MongoDB 2.6 and you are actually running MongoDB 2.4. </p> <p>I suggest you upgrade your MongoDB server to at least 3.0. But if for some...
0
2016-07-22T11:50:02Z
[ "python", "mongodb", "pymongo", "aggregation-framework" ]
Tensorflow + Matplotlib animation
38,523,596
<p>I am trying to implement the Game of Life using tensorflow and use matplotlib.animation to depict the animation. Although the image gets displayed but it is not animating for some reason. Below is the code I am using:</p> <p>Ref: <a href="http://learningtensorflow.com/lesson8/" rel="nofollow">http://learningtensorf...
0
2016-07-22T10:01:44Z
38,532,102
<p>When you are displaying the image, you are displaying the static image not the animation. You need to remove this line, as stated in the tutorial:</p> <pre><code>plot = plt.imshow(X, cmap='Greys', interpolation='nearest') </code></pre> <p><code>Hint: you will need to remove the plt.show() from the earlier code to ...
0
2016-07-22T17:20:16Z
[ "python", "animation", "matplotlib", "tensorflow", "conways-game-of-life" ]
Slideshow of web pages (python)
38,523,633
<p>I'm trying to make a simple slideshow in Python to view 0.html, 1.html and 2.html with 3 seconds delay between them.</p> <p>The script below shows 0.html in 3 seconds, then I get a "Segmentation fault (core dumped)" error. Any ideas?</p> <p><strong>My code so far:</strong></p> <pre><code>#!/usr/bin/python import ...
0
2016-07-22T10:03:59Z
38,530,447
<p>You cannot create more than one <code>QApplication</code>, which is why your example dumps core. But in any case, it's a rather poor design if your program needs to create a whole new browser window to display each page. What you should do is load each new page into the same browser.</p> <p>Here's a re-write of you...
0
2016-07-22T15:37:45Z
[ "python", "pyqt4", "urllib", "sys" ]