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
Opencv detect quadrilateral in Python
37,942,132
<p>I am using Python 2.7 and OpenCV 3.0. I am doing a project to <strong>detecting the car license plate</strong>. </p> <p>I am now checking the number of vertex of the contours. If there are 4 vertex(number of elements in approx), then it is more likely to be a <strong>rectangle</strong>/ <strong>parallelogram</stron...
2
2016-06-21T10:37:20Z
37,953,716
<p>As suggested by <a href="http://stackoverflow.com/users/4606294/user89161">http://stackoverflow.com/users/4606294/user89161</a> in his comment <a href="http://stackoverflow.com/questions/37942132/opencv-detect-quadrilateral-in-python/37953716#comment63334235_37942132">Opencv detect quadrilateral in Python</a> mayb...
1
2016-06-21T20:10:13Z
[ "python", "image", "opencv", "image-processing", "polygon" ]
Retrieve object sent from Python client to an Azure Service Bus Topic
37,942,141
<p>I am subscribed to an Azure Service Bus Topic and I am trying to retrieve objects sent from my Python client. But in my receiving end all I get is something like this:</p> <pre><code>&lt;__main__.User object at 0x02F694F0&gt; &lt;models.AssetPayload object at 0x038EA930&gt; </code></pre> <p>I have tried receiving ...
0
2016-06-21T10:37:47Z
37,959,550
<p>A simple solution would be to call <code>bytes()</code> on the <code>.__dict__</code> member of that instance. That is a standard Python <code>dict</code>and if your class is simple it will be JSON like serializable to <code>"{'user_id': '123456', 'name': 'Shaphil'}"</code>.</p> <p>Please try the following code sni...
0
2016-06-22T05:50:06Z
[ "c#", "python", "azure", "azure-servicebus-topics" ]
Error 'Module_six_moves_urllib_parse' object has no attribute 'urlsplit'
37,942,182
<p>Error Running Sphinx with Six. When I run Make HTML in project docs, I get the error </p> <pre><code> Running Sphinx v1.4.1 making output directory... 1.4.1 loading pickled environment... not yet created Exception occurred: File "/Library/Python/2.7/site-packages/sphinx/ext/intersphinx.py", line 148, in _strip_b...
0
2016-06-21T10:39:37Z
37,949,145
<p>Just found the issue. I needed to update Sphinx to 1.4.4</p>
0
2016-06-21T15:53:15Z
[ "python", "pip", "python-sphinx", "six", "urlsplit" ]
How to serve previously uploaded video files in Django
37,942,244
<p>I'm developing a Django site which allows users to upload PDF, image and video files. Django is able to serve the pdf and image files comfortably for my purposes but cannot cope with the video downloads. Is there a way to load video files via Django but them serve them using a different server?</p>
0
2016-06-21T10:42:15Z
37,942,478
<blockquote> <p>Is there a way to load video files via Django but them serve them using a different server?</p> </blockquote> <p>You should define what you mean by "different server". but I assume, you mean different project that is not written in Django. </p> <p>Since video files land in file system ( if you de...
0
2016-06-21T10:53:46Z
[ "python", "django", "video" ]
How to show distance between residues in Pymol
37,942,272
<p>With the <a href="http://www.filedropper.com/pdp4gg6cd1i" rel="nofollow"><strong>this PDB file</strong></a> and the following <a href="http://www.pymolwiki.org/index.php/Main_Page" rel="nofollow">PyMOL</a> code:</p> <pre><code>cd /Users/foo/Desktop/ reinitialize load pdp_4gg6CD1_I.pdb as cartoon select chainI, cha...
1
2016-06-21T10:44:10Z
38,110,945
<ul> <li>Let's use <code>cmd.iterate</code> to get all the atoms in a selection (chain C and chain I) and write the coordinates and atom name to dictionaries for later use. </li> <li>Then we can calculate all the distances between all atoms and write the closest residues and atom names to two lists (<code>min_c</code> ...
1
2016-06-29T22:14:48Z
[ "python", "pymol" ]
(Jython) Problems to run python script from java
37,942,277
<p>I wrote 2 python scripts named runner.py and connect.py. The runner script starts a traffic simulation with a specific port and the other one connects and is able to send commands. Both scripts work fine in my python IDE. But i want to start both scripts from java to recieve data.</p> <pre><code>import org.python.c...
2
2016-06-21T10:44:31Z
38,075,615
<p>You stumbled on a <a href="http://bugs.jython.org/issue2273" rel="nofollow">jython bug</a> which was masked away by SUMO hiding the error message of the failed socket connection. Unfortunately you can not work around it easily other than editing SUMO/tools/traci/connection.py in line 49.</p> <p>Just replace <code>s...
0
2016-06-28T11:58:10Z
[ "java", "python", "jython" ]
Python Format Date issue
37,942,295
<p>Something which I thought would be simple has become such a struggle. I'm trying to format a datetime object.</p> <pre><code>From this 2016-06-17 09:56:53.289000+00:00 to 2016-06-17 09:56:53 </code></pre> <p>This code I tried doesn't make any changes to the output. It skips right past it.</p> <pre><code>if type(f...
0
2016-06-21T10:45:21Z
37,942,471
<pre><code>d = '2016-06-17 09:56:53.289000+00:00' print(datetime.strptime(d[:19], '%Y-%m-%d %H:%M:%S').strftime('%Y-%m-%d %H:%M:%S')) </code></pre>
0
2016-06-21T10:53:24Z
[ "python", "django" ]
Python Format Date issue
37,942,295
<p>Something which I thought would be simple has become such a struggle. I'm trying to format a datetime object.</p> <pre><code>From this 2016-06-17 09:56:53.289000+00:00 to 2016-06-17 09:56:53 </code></pre> <p>This code I tried doesn't make any changes to the output. It skips right past it.</p> <pre><code>if type(f...
0
2016-06-21T10:45:21Z
37,942,499
<p>Try removing the <code>.utcnow()</code> call you added before your <code>.strftime()</code> calls. <code>new_value.utcnow()</code> invokes <code>datetime.datetime.utcnow</code>, which returns an entirely new datetime.datetime object representing the current time, which has nothing to do with <code>new_value</code> o...
1
2016-06-21T10:54:40Z
[ "python", "django" ]
Python Format Date issue
37,942,295
<p>Something which I thought would be simple has become such a struggle. I'm trying to format a datetime object.</p> <pre><code>From this 2016-06-17 09:56:53.289000+00:00 to 2016-06-17 09:56:53 </code></pre> <p>This code I tried doesn't make any changes to the output. It skips right past it.</p> <pre><code>if type(f...
0
2016-06-21T10:45:21Z
37,942,698
<p>Just a simple snippet based on your code </p> <pre><code>In [11]: from datetime import datetime In [12]: mytime = now.strftime("%Y-%m-%d %H:%M:%S") In [13]: print(mytime) 2016-06-21 16:44:32 </code></pre>
0
2016-06-21T11:03:45Z
[ "python", "django" ]
GTK track signals and events
37,942,323
<p>I am trying to track GTK signals and events. I have found <a href="http://stackoverflow.com/questions/11373914/gobject-add-emission-hook-only-works-once">this</a> question, which does what I want. However, it seems to me that the emission hook will have to be declared for each signal of each kind of object. This wil...
0
2016-06-21T10:46:26Z
38,177,740
<p>You can use the <a href="https://wiki.gnome.org/Projects/GTK%2B/Inspector" rel="nofollow">GTK Inspector</a> to track all the signals that are emitted on an object. Pick the object in the inspector, go to the "Signals" tab, and click the Record button.</p>
0
2016-07-04T05:54:36Z
[ "python", "events", "gtk", "signals" ]
In python, how to change the element data type of a list
37,942,498
<p>Working with python3.4.3 &amp; psycopg2</p> <p>I have the following SQL query</p> <pre><code>SELECT somestring1, somestring2, float1, float2, float3 FROM table </code></pre> <p>I want to merge float1,float2,float3 into one single float[] then use <code>UPDATE</code> to get it back to datab...
1
2016-06-21T10:54:40Z
37,943,486
<p>You are passing a list of tuples. A tuple is adapted by Psycopg to a record. You need to pass a list of lists as a list is adapted to an array:</p> <pre><code>vector = list(map(lambda x:list(x[2:]),res)) </code></pre>
1
2016-06-21T11:43:24Z
[ "python", "python-3.x", "psycopg2" ]
Choose one key arbitrarily in a dictionary without iteration
37,942,550
<p>I just wanna make sure that in Python dictionaries there's no way to get just a key (with no specific quality or relation to a certain value) but doing iteration. As much as I found out you have to make a list of them by going through the whole dictionary in a loop. Something like this:</p> <pre><code>list_keys=[k ...
1
2016-06-21T10:56:39Z
37,942,598
<p>You can use <code>random.choice</code></p> <pre><code>rand_key = random.choice(dict.keys()) </code></pre> <p>And this will only work in python 2.x, in python 3.x dict.keys returns an iterator, so you'll have to do cast it into a list - </p> <pre><code>rand_key = random.choice(list(dict.keys())) </code></pre> <p>...
2
2016-06-21T10:58:48Z
[ "python", "dictionary" ]
Choose one key arbitrarily in a dictionary without iteration
37,942,550
<p>I just wanna make sure that in Python dictionaries there's no way to get just a key (with no specific quality or relation to a certain value) but doing iteration. As much as I found out you have to make a list of them by going through the whole dictionary in a loop. Something like this:</p> <pre><code>list_keys=[k ...
1
2016-06-21T10:56:39Z
37,942,638
<p>How about something like this:</p> <pre><code>import random arbitrary_key = random.choice( dic.keys() ) </code></pre> <p>BTW, your use of a list comprehension there really makes no sense:</p> <pre><code>dic.keys() == [k for k in dic.keys()] </code></pre>
0
2016-06-21T11:00:35Z
[ "python", "dictionary" ]
Choose one key arbitrarily in a dictionary without iteration
37,942,550
<p>I just wanna make sure that in Python dictionaries there's no way to get just a key (with no specific quality or relation to a certain value) but doing iteration. As much as I found out you have to make a list of them by going through the whole dictionary in a loop. Something like this:</p> <pre><code>list_keys=[k ...
1
2016-06-21T10:56:39Z
37,942,666
<p>check the length of dictionary like this, this should do !!</p> <pre><code>import random if len(yourdict) &gt; 0: randomKey = random.sample(yourdict,1) print randomKey[0] else: do something </code></pre> <p>randomKey will return a list, as we have passed 1 so it will return list with 1 key and then ge...
-4
2016-06-21T11:01:42Z
[ "python", "dictionary" ]
Choose one key arbitrarily in a dictionary without iteration
37,942,550
<p>I just wanna make sure that in Python dictionaries there's no way to get just a key (with no specific quality or relation to a certain value) but doing iteration. As much as I found out you have to make a list of them by going through the whole dictionary in a loop. Something like this:</p> <pre><code>list_keys=[k ...
1
2016-06-21T10:56:39Z
37,942,943
<p>You are correct: there is not a way to get a random key from an ordinary <code>dict</code> without using iteration. Even solutions like <code>random.choice</code> must iterate through the dictionary in the background. </p> <p>However you could use a sorted dict:</p> <pre><code>from sortedcontainers import SortedD...
1
2016-06-21T11:16:45Z
[ "python", "dictionary" ]
Choose one key arbitrarily in a dictionary without iteration
37,942,550
<p>I just wanna make sure that in Python dictionaries there's no way to get just a key (with no specific quality or relation to a certain value) but doing iteration. As much as I found out you have to make a list of them by going through the whole dictionary in a loop. Something like this:</p> <pre><code>list_keys=[k ...
1
2016-06-21T10:56:39Z
37,970,019
<p>A lot of the answers here produce a <strong>random</strong> key but the original question asked for an <strong>arbitrary</strong> key. There's quite a difference between those two. Randomness has a handful of mathematical/statistical guarantees.</p> <p>Python dictionaries are not ordered in any meaningful way. So, ...
1
2016-06-22T13:47:10Z
[ "python", "dictionary" ]
Convert raw SQL to Django QuerySet
37,942,583
<p>Could someone show how to convert the following SQL query to the Django QuerySet call? I'm a new to Django and I could use the raw query, but it's interesting for me to know how do this query could be written as a native Django call.</p> <p>There are 2 models User &amp; Profile 1:1 I need to fetch the emails from ...
0
2016-06-21T10:58:05Z
37,944,684
<pre><code>from myapp.models import Profile from django.db.models import Count qs = Profile.objects.exclude( phone='' ).exclude( phone__isnull=True ).values('phone').annotate( phone_count=Count('user_id') ).filter( phone_count__gt=1 ).values_list('phone', flat=True) # the above will get you a list of p...
0
2016-06-21T12:38:40Z
[ "python", "django", "django-models", "django-queryset" ]
Monkey Patch private instance function in python 2 with calling old function
37,942,613
<p>I want to monkey patch a function which private and part of a class but I also want to call the patched function.</p> <p>Example:</p> <pre><code>class SomeClass: def __some_function(self, foo): return do_something() </code></pre> <p>Now I want to write something like</p> <pre><code>def new_function(s...
0
2016-06-21T10:59:37Z
37,944,010
<p>Attributes with double underscore <code>__</code> are name mangled and need to be accessed by the mangled name as described in <a href="https://docs.python.org/2/tutorial/classes.html#private-variables-and-class-local-references" rel="nofollow">the documentation</a>:</p> <blockquote> <p>Since there is a valid use...
1
2016-06-21T12:08:16Z
[ "python", "mocking", "private", "monkey", "patching" ]
Encoding id and storing it as a unique code and store in table on creation of row
37,942,690
<p>Essentially, I'm trying to eliminate the need to show the id of a 'listing' to the user. I'm using <a href="https://pypi.python.org/pypi/hashids///" rel="nofollow">Hashids</a> to encode the automatically created id as a unique code.</p> <p>To show a single listing, I've been currently doing this:</p> <pre><code>@a...
0
2016-06-21T11:03:17Z
37,946,946
<p>Within your <code>Listing</code> model, you could define a function such as:</p> <pre><code>def getHashId(self): return hashid.encode(self.id) </code></pre> <p>Now, anywhere in your Jinja2 template that you are using an instance of <code>Listing</code>, you can call <code>listing.getHashId()</code> to return t...
1
2016-06-21T14:17:37Z
[ "python", "flask", "jinja2", "peewee", "flask-peewee" ]
how to extract the borders of an image (OCT/retinal scan image)
37,942,697
<p>I have an (OCT) image like shown below (original). As you can see, it mainly has 2 layers. I want to produce an image (shown in the 3rd picture), in which the red line indicates the top border of 1st layer, the green shows the brightest part of the 2nd layer.</p> <p><a href="http://i.stack.imgur.com/PBnOj.png" rel=...
3
2016-06-21T11:03:39Z
37,963,338
<p>Do not have too much time for this right now but you can start with this:</p> <ol> <li><p><strong>blur the image a bit (remove noise)</strong></p> <p>simple convolution will do for example few times with matrix</p> <pre><code>0.0 0.1 0.0 0.1 0.6 0.1 0.0 0.1 0.0 </code></pre></li> <li><p><strong>do color derivatio...
3
2016-06-22T09:05:04Z
[ "python", "matlab", "opencv", "image-processing", "image-segmentation" ]
how to extract the borders of an image (OCT/retinal scan image)
37,942,697
<p>I have an (OCT) image like shown below (original). As you can see, it mainly has 2 layers. I want to produce an image (shown in the 3rd picture), in which the red line indicates the top border of 1st layer, the green shows the brightest part of the 2nd layer.</p> <p><a href="http://i.stack.imgur.com/PBnOj.png" rel=...
3
2016-06-21T11:03:39Z
37,964,826
<p>The following set of instructions (using Matlab Image processing toolbox) seems to work well for your image:</p> <ol> <li><p>Blur your image (Im) with a median filter to decrease the noise:</p> <pre><code>ImB=medfilt2(Im,[20 20]); </code></pre></li> <li><p>Find the edges using sobel mask and dilate them a little b...
3
2016-06-22T10:05:44Z
[ "python", "matlab", "opencv", "image-processing", "image-segmentation" ]
how to extract the borders of an image (OCT/retinal scan image)
37,942,697
<p>I have an (OCT) image like shown below (original). As you can see, it mainly has 2 layers. I want to produce an image (shown in the 3rd picture), in which the red line indicates the top border of 1st layer, the green shows the brightest part of the 2nd layer.</p> <p><a href="http://i.stack.imgur.com/PBnOj.png" rel=...
3
2016-06-21T11:03:39Z
37,978,046
<p>A full working implementation in Octave:</p> <pre><code>pkg load image pkg load signal median_filter_size = 10; min_vertical_distance_between_layers = 35; min_bright_level = 100/255; img_rgb = imread("oct.png");% it's http://i.stack.imgur.com/PBnOj.png img = im2double(img_rgb(:,:,1)); img=medfilt2(img,[median_fil...
2
2016-06-22T20:52:50Z
[ "python", "matlab", "opencv", "image-processing", "image-segmentation" ]
Format JSON correctly
37,942,892
<p>I have this JSON, which when fed into online JSON formatter websites, says JSON data not accurate.</p> <pre><code> { "Hospitals":[ { "name":"Centre" "url":"www.example.com" }, { "name":"jdbcd" "url":"www.example.net" } ] } </code></pre> <p>I know the Correct JSON data is b...
-2
2016-06-21T11:13:55Z
37,943,184
<p>There are supersets of json, such as <a href="http://hjson.org/" rel="nofollow">hjson</a>, that are less strict. I think hjson will work for you:</p> <pre><code>&gt;&gt;&gt; import hjson &gt;&gt;&gt; hjson.loads(""" { "Hospitals":[ { "name":"Centre" "url":"www.example.com" }, { "name":"...
3
2016-06-21T11:28:14Z
[ "python", "json" ]
Translate JS for Python on Android
37,942,935
<p>I try to get a javascript generated href from "dlbutton" only with python and bs4. I don't can use a heavy javascript parser because I'm on Android. </p> <pre><code>&lt;script type="text/javascript"&gt; var n = 2; var b = 413132; document.getElementById('dlbutton').href = "/n/abc/"+(n + n * 2 + b)+"3/67...
1
2016-06-21T11:16:29Z
37,943,292
<p>Once you have the script tag using bs4 you could regex and then exec/eval the code:</p> <pre><code>import re h = """&lt;script type="text/javascript"&gt; var n = 2; var b = 413132; document.getElementById('dlbutton').href = "/n/abc/"+(n + n * 2 + b)+"3/6775808test.txt"; } &lt;/script&gt;""" var = ...
1
2016-06-21T11:32:54Z
[ "python", "beautifulsoup", "bs4" ]
JIRA Python API Report : Sprint Burndown Information
37,943,021
<p>I am trying to get the Sprint Information for a Burndown chart from JIRA via its REST API using the python lib found here: jira python documentation</p> <p>It seems I cannot get the chart itself back via the API so, I’d like to get all information to draw it myself. </p> <p>Without the Lib I got a view things w...
0
2016-06-21T11:20:41Z
37,985,549
<p>I found out you can acces the estimated Storry Points via </p> <blockquote> <p>issue.fields.customfield_10663</p> </blockquote> <p>and itterate through the wohle sprint to get the sprint goal:</p> <pre><code># Calculate Incompleted Issues sum_incompl = 0 for element in jira.incompleted_issues(board_id, sprint_i...
0
2016-06-23T08:01:49Z
[ "python", "api", "rest", "jira", "python-jira" ]
Python how to rerun code after it stops
37,943,053
<p>i am newbie to Programming,i am running this python code in my computer Normally it runs correctly, but sometimes the code stops due to network conditions. once it stopped i have to run the code manually. Does anyone know how to modify this code to retry if the code fails to run </p> <p>This is the code </p> <pre>...
0
2016-06-21T11:22:02Z
37,943,211
<p>The code in Noel's answer makes it more likely that the program doesn't stop until the loop goes through every item in <code>f</code>.</p> <p>The problem though is that an exception could occur in the line after <code>except</code> and the program would stop again.</p> <p>try this:</p> <pre><code>i = 0 while i &...
2
2016-06-21T11:29:09Z
[ "python", "python-2.7", "for-loop", "cmd", "try-catch" ]
How to use ask open file name with open function then take that file into another function?
37,943,077
<p>I'm making a program that takes two file comparing them then find the percentage of similarity,now I'm having hard time to take the file name THEN Pass IT TO open function to read it THEN PASSING THE DATA Generated into another function ,it shows me that error</p> <pre><code>IOError: [Errno 22] invalid mode ('r') o...
0
2016-06-21T11:23:11Z
37,943,560
<p>As @Stefans commented you, there is a problem when you tried to open the file <code>Copied_File</code> because by the moment you run the <code>with open((Copied_File), 'r')as file_1:</code>, you have <code>Copied_File =</code>. </p> <p>This means:</p> <p><code>with open((Copied_File), 'r')as file_1:</code> is equa...
0
2016-06-21T11:47:27Z
[ "python", "python-2.7", "tkinter" ]
Tensorflow Machine translation REST webservice loading models for each call
37,943,201
<p>Is there any way in which I can be in the same tensorflow session between webservice hits?</p> <p>I have used the translate.py script in tensorflow and trained a model for English to french translation. And I have also written a webservice through which I am getting the English sentence and translating it to French...
0
2016-06-21T11:28:51Z
37,954,745
<p>Did you try <a href="https://tensorflow.github.io/serving/serving_basic" rel="nofollow">TensorFlow Serving</a>?</p>
0
2016-06-21T21:18:54Z
[ "python", "web-services", "amazon-web-services", "amazon-ec2", "tensorflow" ]
CREATE TABLE with DECIMAL column using Access ODBC
37,943,237
<p>I am using pypyodbc module to create a database and add a table in it.</p> <p>The code I use is the following:</p> <pre><code>import pypyodbc pypyodbc.win_create_mdb('D:\\test.mdb') connection_string = 'Driver={Microsoft Access Driver (*.mdb)};DBQ=D:\\test.mdb' connection = pypyodbc.connect(connection_string) SQL ...
1
2016-06-21T11:30:25Z
37,944,940
<p>There are a number of deficiencies with DDL handling in the Access ODBC driver and unfortunately you have encountered one of them. If you want to create a table with a DECIMAL column you will need to use <code>adodbapi</code> from <a href="https://pypi.python.org/pypi/pywin32" rel="nofollow">pywin32</a> (release 211...
2
2016-06-21T12:49:48Z
[ "python", "sql", "ms-access", "decimal", "pypyodbc" ]
Separate data per client request in flask
37,943,243
<p>I have created a flask application that open up Database connections and stores some data in global variables. The data in these global variables is used by subsequent ajax requests in the page. However I am running into serious issues with concurrency. I tried using both uwsgi and gunicorn to run the flask applicat...
1
2016-06-21T11:30:37Z
37,943,542
<p>If you're going to store something as a global in your web worker, you better make sure that the life cycle of that variable starts and ends with a request. </p> <p>Else what you get is you store something from a request, then another request comes in possibly with a different context (e.g. different user), and the...
1
2016-06-21T11:46:43Z
[ "python", "flask", "multiprocessing", "uwsgi", "gunicorn" ]
Separate data per client request in flask
37,943,243
<p>I have created a flask application that open up Database connections and stores some data in global variables. The data in these global variables is used by subsequent ajax requests in the page. However I am running into serious issues with concurrency. I tried using both uwsgi and gunicorn to run the flask applicat...
1
2016-06-21T11:30:37Z
37,944,261
<p>As bakkal pointed out global variables will break when using threads.</p> <p>Instead you can give the user a cookie with the data you want to carry over:</p> <pre><code>session["a"] = "a" # or whatever </code></pre> <p>Of course this will not scale indefinitely so instead you should store some (database-) session...
0
2016-06-21T12:19:25Z
[ "python", "flask", "multiprocessing", "uwsgi", "gunicorn" ]
parsing xml using python / elementree
37,943,247
<p>The xml I need to search specifies but does not use a namespace:</p> <pre><code> &lt;WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"&gt; &lt;DATA&gt; &lt;PROTECTINFO&gt; &lt;KEYLEN&gt;16&lt;/KEYLEN&gt; &lt;ALGID&gt;AESCTR&lt;/ALGID&...
1
2016-06-21T11:30:46Z
37,943,595
<p>Create a namespace dict:</p> <pre><code>x = """&lt;WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"&gt; &lt;DATA&gt; &lt;PROTECTINFO&gt; &lt;KEYLEN&gt;16&lt;/KEYLEN&gt; &lt;ALGID&gt;AESCTR&lt;/ALGID&gt; &lt;/PROTECTINFO&gt; ...
1
2016-06-21T11:48:41Z
[ "python", "xml", "elementtree" ]
parsing xml using python / elementree
37,943,247
<p>The xml I need to search specifies but does not use a namespace:</p> <pre><code> &lt;WRMHEADER xmlns="http://schemas.microsoft.com/DRM/2007/03/PlayReadyHeader" version="4.0.0.0"&gt; &lt;DATA&gt; &lt;PROTECTINFO&gt; &lt;KEYLEN&gt;16&lt;/KEYLEN&gt; &lt;ALGID&gt;AESCTR&lt;/ALGID&...
1
2016-06-21T11:30:46Z
37,944,967
<p>I'm wondering if this will also work. Please post your comments on pros and cons of this approach.</p> <pre><code>from xml.dom.minidom import parse import xml.dom.minidom # Open XML document using minidom parser DOMTree = xml.dom.minidom.parse("xmlquestion.xml") tn = DOMTree.documentElement print tn.namespaceURI ...
1
2016-06-21T12:50:58Z
[ "python", "xml", "elementtree" ]
Tensorflow - Python : How can I use my own data with TensorFlow?
37,943,293
<p>I'm new with TensorFow, but i have to use it, so i have a question.</p> <p>I have to use specific data in a csv file which looks like :</p> <p>0.5,1,0,0,Slow_Start</p> <p>1,2,0,0,Slow_Start</p> <p>1.5,4,0,0,Slow_Start</p> <p>2,8,0,0,Slow_Start</p> <p>(Slow_Start is one of the label i have to use).</p> <p>I su...
2
2016-06-21T11:33:00Z
38,121,206
<p>There are plenty of examples available on <a href="https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/skflow" rel="nofollow">skflow examples</a>. Make sure you have your data in the correct format.</p>
0
2016-06-30T11:01:12Z
[ "python", "tensorflow" ]
How to format the list items of QCompleter's popup list properly?
37,943,310
<p>I want to investigate how to make a small user interface in which a user can type some letters and gets some suggestions based on a given data source (list here) which makes searches easier. For this purpose i am using Qt's <code>QCompleter</code> class.</p> <p>In the matching elements the typed letters shall be hi...
1
2016-06-21T11:34:07Z
38,028,318
<p>Finally i found another way to realize it using the idea of <a href="http://stackoverflow.com/a/8036666/1504082">http://stackoverflow.com/a/8036666/1504082</a>. Its much more forward for me without all this custom drawing things which i dont understand yet :)</p> <pre><code>from PySide import QtCore, QtGui class ...
0
2016-06-25T12:03:06Z
[ "python", "qt", "pyside", "qstyleditemdelegate" ]
Comparing two integeres bu use of if condition in Python
37,943,332
<p>I have written below code and tried running in python, it works well if I give input as a =56 b = 67, but it gives wrong comparison if input given as a = 789,b =45566 - </p> <p>Below is the code written</p> <pre><code>def max(a,b): if a&gt;b: print(a+" is greater than "+b) else: print(b +...
-2
2016-06-21T11:35:21Z
37,943,410
<p>Change </p> <pre><code>to = max(o1,o2) </code></pre> <p>to</p> <pre><code>to = max(int(o1), int(o2)) </code></pre>
0
2016-06-21T11:38:55Z
[ "python", "if-statement" ]
Comparing two integeres bu use of if condition in Python
37,943,332
<p>I have written below code and tried running in python, it works well if I give input as a =56 b = 67, but it gives wrong comparison if input given as a = 789,b =45566 - </p> <p>Below is the code written</p> <pre><code>def max(a,b): if a&gt;b: print(a+" is greater than "+b) else: print(b +...
-2
2016-06-21T11:35:21Z
37,943,411
<p>You're comparing strings. Just cast them to integers using the function <code>int</code> when calling <code>max</code>. Like that: <code>max(int(o1), int(o2))</code>.</p>
2
2016-06-21T11:39:05Z
[ "python", "if-statement" ]
Comparing two integeres bu use of if condition in Python
37,943,332
<p>I have written below code and tried running in python, it works well if I give input as a =56 b = 67, but it gives wrong comparison if input given as a = 789,b =45566 - </p> <p>Below is the code written</p> <pre><code>def max(a,b): if a&gt;b: print(a+" is greater than "+b) else: print(b +...
-2
2016-06-21T11:35:21Z
37,943,420
<p>you are not comparing integers but string. Cast them to integers and you will have the result you want</p>
2
2016-06-21T11:39:36Z
[ "python", "if-statement" ]
Comparing two integeres bu use of if condition in Python
37,943,332
<p>I have written below code and tried running in python, it works well if I give input as a =56 b = 67, but it gives wrong comparison if input given as a = 789,b =45566 - </p> <p>Below is the code written</p> <pre><code>def max(a,b): if a&gt;b: print(a+" is greater than "+b) else: print(b +...
-2
2016-06-21T11:35:21Z
37,943,467
<p>The problem is that you're reading strings from raw_input, and the comparison is a lexicographic one. So since '7' > '4', you get the result that '789' is greater than '45566'.</p> <p>Have a look at this code to get some insight:</p> <pre><code>def max(a,b): if a&gt;b: print(str(a) + " is greater than ...
1
2016-06-21T11:42:15Z
[ "python", "if-statement" ]
Comparing two integeres bu use of if condition in Python
37,943,332
<p>I have written below code and tried running in python, it works well if I give input as a =56 b = 67, but it gives wrong comparison if input given as a = 789,b =45566 - </p> <p>Below is the code written</p> <pre><code>def max(a,b): if a&gt;b: print(a+" is greater than "+b) else: print(b +...
-2
2016-06-21T11:35:21Z
37,943,488
<p>If you want your input to be a integer you have to use :</p> <pre><code>o1 = input("Enter your first number : ") </code></pre> <p>Because raw_input is for a input of type string whereas input is for input of type integer</p>
-1
2016-06-21T11:43:37Z
[ "python", "if-statement" ]
Django Rest Framework : How to add a custom field to the response of the GET request?
37,943,339
<p>I'm new to DRF and have just started building an API. </p> <p>I've a model called <strong>Shop</strong>. And I've two user different user types : <strong>Customer</strong> and <strong>Supplier</strong>.</p> <ol> <li>I want to add a custom field <strong>distance</strong> to the response of the GET request <strong>/...
2
2016-06-21T11:35:39Z
37,944,195
<p>You can define a <code>distance</code> <a href="http://www.django-rest-framework.org/api-guide/fields/#serializermethodfield" rel="nofollow"><code>SerializerMethodField</code></a>, and there access the current user location using serializer's <code>context</code>. Then compute distance using current user location an...
2
2016-06-21T12:16:51Z
[ "python", "django", "django-rest-framework" ]
any different between original xgboost and sklearn XGBClassifier
37,943,403
<p>I use the xgboots sklearn interface below to create and train an xgb model-1.</p> <pre><code>clf = xgb.XGBClassifier(n_estimators = 100, objective= 'binary:logistic',) clf.fit(x_train, y_train, early_stopping_rounds=10, eval_metric="auc", eval_set=[(x_valid, y_valid)]) </code></pre> <p>And the xgboost model ...
2
2016-06-21T11:38:31Z
37,943,602
<p>Results should be the same, as <code>XGBClassifier</code> is only a <code>sklearn</code>'s interface that in the end calls to the <code>xgb</code> library.</p> <p>You can try to add the same <code>seed</code> to both approaches in order to get same results. For example, in your <code>sklearn</code>'s interface: </...
1
2016-06-21T11:49:10Z
[ "python", "scikit-learn", "xgboost" ]
any different between original xgboost and sklearn XGBClassifier
37,943,403
<p>I use the xgboots sklearn interface below to create and train an xgb model-1.</p> <pre><code>clf = xgb.XGBClassifier(n_estimators = 100, objective= 'binary:logistic',) clf.fit(x_train, y_train, early_stopping_rounds=10, eval_metric="auc", eval_set=[(x_valid, y_valid)]) </code></pre> <p>And the xgboost model ...
2
2016-06-21T11:38:31Z
39,074,258
<p>As I understand, there are many differences between default parameters in xgb and in its sklearn interface. For example: default xgb has eta=0.3 while the other has eta=0.1. You can see more about default parameters of each implements here:</p> <p><a href="https://github.com/dmlc/xgboost/blob/master/doc/parameter.m...
0
2016-08-22T08:08:05Z
[ "python", "scikit-learn", "xgboost" ]
Celery Tasks not being assigned by Broker
37,943,408
<p>I have integrated an API with my Django website. For a complete order via the API, there are 5 request and responses that needs to be sent and received. The last 2 requests are not super important to be sent out sequentially. I have assigned those 2 requests to a celery task.</p> <p>Scenario: I send out a request t...
0
2016-06-21T11:38:49Z
38,568,317
<p>replace </p> <pre><code>process_jobs.delay(self, job, **response_arg) </code></pre> <p>with </p> <pre><code>process_jobs.delay(job, **response_arg) </code></pre> <p>If this don't solve your problem,then please share more detail to find solution.</p>
0
2016-07-25T12:52:37Z
[ "python", "django", "celery", "django-celery", "celery-task" ]
Scripting for LinkedIn Sales Navigator
37,943,416
<p>I'm not a programmer (I'm starting to learn some coding, but I'm an absolute beginner). </p> <p>Thing is that my work has lots of things that could be automated with scripting. I have to search lots of companies in Linkedin Sales Navigator which leads me to absolute boredom and alienation. I have to grab a spreadsh...
-1
2016-06-21T11:39:22Z
37,943,704
<p>Python is perfect the task the described above, I would recommend looking at following:</p> <p><a href="http://learnpythonthehardway.org/" rel="nofollow">http://learnpythonthehardway.org/</a> </p> <p>Automate the boring stuff with python (book)</p> <p>These should get you started.</p>
0
2016-06-21T11:53:02Z
[ "python", "scripting" ]
How I can get related model for custom column in admin list_display with prefetch_related?
37,943,460
<p>Hi I have two models with <code>m2m</code> link through third model: </p> <pre><code>class Group(UsefulAbstractModel): hotels = models.ManyToManyField( Hotel, through='HotelDetails', related_name='groups', ) class Hotel(UsefulAbstractModel): name = models.CharField( max_len...
2
2016-06-21T11:41:48Z
37,944,038
<p>The problem is that you are filtering the prefetched results with <code>filter(num=1)</code>. This causes Django to do a new query.</p> <p>You can use a <code>Prefetch</code> object to fetch the correct queryset. Note you should override the model admin's <a href="https://docs.djangoproject.com/en/1.9/ref/contrib/a...
2
2016-06-21T12:09:44Z
[ "python", "django", "django-admin" ]
Isn't a class with class methods and attributes is singleton in python?
37,943,516
<p>I already read many articles that explain how to implement singleton in python,like <a href="http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python">Creating a singleton in Python</a></p> <p>I was wondering, isn't a class with class methods and attributes is a singleton class.</p> <p>e.g. </p> ...
1
2016-06-21T11:45:10Z
37,943,685
<blockquote> <p>I was wondering, isn't a class with class methods and attributes is a singleton class.</p> </blockquote> <p>No.</p> <p>By definition a singleton class is a class which you can't create more than 1 instance of.</p> <p>Let's put it to the test:</p> <pre><code>class my_singleton_class(object): _l...
6
2016-06-21T11:52:22Z
[ "python", "python-2.7" ]
Isn't a class with class methods and attributes is singleton in python?
37,943,516
<p>I already read many articles that explain how to implement singleton in python,like <a href="http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python">Creating a singleton in Python</a></p> <p>I was wondering, isn't a class with class methods and attributes is a singleton class.</p> <p>e.g. </p> ...
1
2016-06-21T11:45:10Z
37,944,807
<p>Thechnically, your example is not a singleton. A singleton is a unique instance of a class that will be accessed throughout the whole application. In Python a singleton class is a class that can only build one single instance.</p> <p>But your class <em>can be used as a singleton</em> because you will directly use t...
1
2016-06-21T12:44:29Z
[ "python", "python-2.7" ]
python virtualenv different behavior from activate and bin/python
37,943,522
<p>I created virtualenv for few months. And I encountered a problem. </p> <p>When I activate virtual environment I have access to lib like django : </p> <pre><code>source virtualenv/jsms/bin/activate (jsms)local% python Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) [GCC 4.2.1 (Apple Inc. build 5666) (dot...
0
2016-06-21T11:45:32Z
37,944,306
<p>activate is just a bash script, so you can always take a look at the activate file and see what it is doing, but I think what you’re looking for is the env variable <code>PYTHONHOME</code>. I would try:</p> <pre><code>export OLD_PYTHON_HOME="$PYTHONHOME" unset PYTHONHOME virtualenv/jsms/bin/python3.4 --version <...
2
2016-06-21T12:21:55Z
[ "python", "django", "virtualenv" ]
no response for a http packet using scapy
37,943,543
<p>i have used the following code in order to send a HTTP GET request: </p> <pre><code>syn = IP(dst='www.google.com') / TCP(dport=80, flags='S') syn_ack = sr1(syn) getStr = 'GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n' request = IP(dst='www.google.com') / TCP(dport=80, sport=syn_ack[TCP].dport,seq=syn_ack[TCP].ack,...
0
2016-06-21T11:46:44Z
40,111,819
<p>It might have something to do with the fact that you are not following proper TCP protocol. Reading you code it looks like you forgot the ACK in the 3-way handshake (SYN-SYN_ACK-ACK). So your sending it data, but its just going to ignore it because you have not finished setting up the connection. Try doing something...
0
2016-10-18T15:05:11Z
[ "python", "http", "tcp", "get", "scapy" ]
Python -Remove capitalized words from long string
37,943,611
<p>I have long string (28MB) of normal sentences. I want to remove all words what are fully in capital letters (like TNT, USA, OMG).</p> <p>So from sentance: </p> <pre><code>Jump over TNT in There. </code></pre> <p>I would like to get:</p> <pre><code>Jump over in There. </code></pre> <p>Is there any way, how to d...
1
2016-06-21T11:49:25Z
37,943,844
<p>I would do something like this: </p> <pre><code>import string def onlyUpper(word): for c in word: if not c.isupper(): return False return True s = "Jump over TNT in There." for char in string.punctuation: s = s.replace(char, ' ') words = s.split() good_words = [] for w in words: ...
1
2016-06-21T11:59:46Z
[ "python", "string" ]
Python -Remove capitalized words from long string
37,943,611
<p>I have long string (28MB) of normal sentences. I want to remove all words what are fully in capital letters (like TNT, USA, OMG).</p> <p>So from sentance: </p> <pre><code>Jump over TNT in There. </code></pre> <p>I would like to get:</p> <pre><code>Jump over in There. </code></pre> <p>Is there any way, how to d...
1
2016-06-21T11:49:25Z
37,943,907
<p>Use the module <a href="https://docs.python.org/2/library/re.html" rel="nofollow"><strong><code>re</code></strong></a>,</p> <pre><code>import re line = 'Jump over TNT in There.' new_line = re.sub(r'[A-Z]+(?![a-z])', '', line) print(new_line) # Output Jump over in There. </code></pre>
2
2016-06-21T12:03:01Z
[ "python", "string" ]
Python -Remove capitalized words from long string
37,943,611
<p>I have long string (28MB) of normal sentences. I want to remove all words what are fully in capital letters (like TNT, USA, OMG).</p> <p>So from sentance: </p> <pre><code>Jump over TNT in There. </code></pre> <p>I would like to get:</p> <pre><code>Jump over in There. </code></pre> <p>Is there any way, how to d...
1
2016-06-21T11:49:25Z
37,944,033
<p>You can use the set of capital letters <code>[A-Z]</code> captured with word boundary <code>\b</code>:</p> <pre><code>import re line = 'Jump over TNT in There NOW' m = re.sub(r'\b[A-Z]+\b', '', line) #'Jump over in There ' </code></pre>
2
2016-06-21T12:09:37Z
[ "python", "string" ]
Equal or higher multiple of a number, Python
37,943,618
<p>I have been challenged with designing a code which validates a GTIN-8 code. I have looked on how to find the equal or higher multiple of a 10 and I have had no success so far, hope you guys can help me!</p> <p>Here is a small piece of code, I need to find the equal or higher multiple of 10.</p> <pre><code>NewNumbe...
-2
2016-06-21T11:49:56Z
37,943,670
<p>Generally speaking You can find multiples with the <a href="https://en.wikipedia.org/wiki/Modulo_operation" rel="nofollow">modulo</a> operation:</p> <pre><code>if number % 10 == 0: do something </code></pre>
0
2016-06-21T11:51:59Z
[ "python", "numbers" ]
Equal or higher multiple of a number, Python
37,943,618
<p>I have been challenged with designing a code which validates a GTIN-8 code. I have looked on how to find the equal or higher multiple of a 10 and I have had no success so far, hope you guys can help me!</p> <p>Here is a small piece of code, I need to find the equal or higher multiple of 10.</p> <pre><code>NewNumbe...
-2
2016-06-21T11:49:56Z
37,944,142
<p>I'm guessing you what the smallest multiple of 10 that is higher or equal than NewNumber. If that's the case, do:</p> <pre><code>last_digit = NewNumber % 10 bigger = NewNumber - last_digit if last_digit != 0: bigger += 10 </code></pre> <p>Also, you shouldn't use capital letters to start variable names, those ar...
0
2016-06-21T12:14:47Z
[ "python", "numbers" ]
Equal or higher multiple of a number, Python
37,943,618
<p>I have been challenged with designing a code which validates a GTIN-8 code. I have looked on how to find the equal or higher multiple of a 10 and I have had no success so far, hope you guys can help me!</p> <p>Here is a small piece of code, I need to find the equal or higher multiple of 10.</p> <pre><code>NewNumbe...
-2
2016-06-21T11:49:56Z
37,944,174
<p>Trying using this:</p> <pre><code># method 1 for integers n = NewNumber / 10 * 10 if n &lt; NewNumber: n += 10 # method 2 for floats, decimals import math n = math.ceil(NewNumber / 10) * 10 </code></pre>
0
2016-06-21T12:15:55Z
[ "python", "numbers" ]
Equal or higher multiple of a number, Python
37,943,618
<p>I have been challenged with designing a code which validates a GTIN-8 code. I have looked on how to find the equal or higher multiple of a 10 and I have had no success so far, hope you guys can help me!</p> <p>Here is a small piece of code, I need to find the equal or higher multiple of 10.</p> <pre><code>NewNumbe...
-2
2016-06-21T11:49:56Z
37,944,252
<p>If you mean find the smallest multiple of 10 that is greater than or equal to your number, try</p> <pre><code>def round_up_by_10s(num): return -((-num) // 10) * 10 </code></pre> <p>That works for positive and negative numbers, integer or float, in Python 2.x or Python 3.x. It also avoids an if statement and ca...
0
2016-06-21T12:19:09Z
[ "python", "numbers" ]
Function not called by reference causes self.root to be None
37,943,629
<pre><code>class node: def __init__(self,data): self.data=data self.left=None self.right=None class btree: def __init__(self): self.root=None def insertt(self,root, data): if root==None: root=node(data) elif root.data &gt; data: self....
0
2016-06-21T11:50:16Z
37,943,720
<p>you have a return statement before the assignment to the root in the function "insertt"</p>
0
2016-06-21T11:53:52Z
[ "python", "python-2.7", "binary-search-tree", "pass-by-reference" ]
Function not called by reference causes self.root to be None
37,943,629
<pre><code>class node: def __init__(self,data): self.data=data self.left=None self.right=None class btree: def __init__(self): self.root=None def insertt(self,root, data): if root==None: root=node(data) elif root.data &gt; data: self....
0
2016-06-21T11:50:16Z
37,944,307
<p>Here's my solution to this. Note that I changed the class names to mixed case to follow standard conventions and to make it easier to avoid name conflicts.</p> <pre><code>class Node(object): def __init__(self, data): self.data = data self.left = None self.right = None class BTree(objec...
1
2016-06-21T12:21:56Z
[ "python", "python-2.7", "binary-search-tree", "pass-by-reference" ]
Function not called by reference causes self.root to be None
37,943,629
<pre><code>class node: def __init__(self,data): self.data=data self.left=None self.right=None class btree: def __init__(self): self.root=None def insertt(self,root, data): if root==None: root=node(data) elif root.data &gt; data: self....
0
2016-06-21T11:50:16Z
37,944,580
<p>Here is the working code, I'll explain the problems in the comments. </p> <pre><code>class node: def __init__(self,data): self.data=data self.left=None self.right=None class btree: def __init__(self): self.root = None def insertt(self, root, data): if root==None...
1
2016-06-21T12:34:02Z
[ "python", "python-2.7", "binary-search-tree", "pass-by-reference" ]
Crash when calling PyArg_ParseTuple on a Numpy array
37,943,699
<p>I wrote a simple Python extension function in C that just reads a Numpy array and it crashes.</p> <pre><code>static PyObject *test(PyObject *self, PyObject *args) { PyArrayObject *array = NULL; if (!PyArg_ParseTuple(args, "O!", &amp;PyArray_Type, &amp;array)) // Crash return NULL; return Py_Bu...
2
2016-06-21T11:52:59Z
37,944,168
<p>I think the error is in the code you did not include in your example: have you remembered to call <code>import_array()</code> in your module init function:</p> <blockquote> <p>... this subroutine must also contain calls to import_array() and/or import_ufunc() depending on which C-API is needed. Forgetting to plac...
3
2016-06-21T12:15:46Z
[ "python", "c", "arrays", "numpy" ]
How to set/get pandas.DataFrame to/from redis?
37,943,778
<p>After setting DatFrame to redis,then get from it,redis returns a string,and I can't figure out a way to convert this str to DataFrame,so how to do these two appropriately?Thanks.</p>
2
2016-06-21T11:56:37Z
37,957,490
<p>set</p> <pre><code>redisConn.put("key", df.to_msgpack(compress='zlib')) </code></pre> <p>get</p> <pre><code>pd.read_msgpack(redisConn.get("key")) </code></pre>
3
2016-06-22T02:20:10Z
[ "python", "pandas", "redis" ]
Stream tweets using tweepy (python) using emoji
37,943,800
<p>I am trying to create an application in python (using tweepy apis) to listen for tweets that include Emojis. </p> <p>I would like to retrieve all tweets that include the Emoji: 😃, 'U+1F603', '\xF0\x9F\x98\x83'. </p> <p>The problem is trying to set up the listener to listen for these tweets. </p> <p>I am usin...
1
2016-06-21T11:57:46Z
37,947,356
<p>After a lot of research the answer seems quite obvious so I will post it encase others get stuck on a simular problem. </p> <p>The problem lies with how you handle unicode characters. While some emoji's are 5 characters long they need to be changed. </p> <pre><code>stream.filter(track=[u"\u1F602"]) </code></pre> ...
1
2016-06-21T14:34:52Z
[ "python", "twitter", "tweepy", "emoji" ]
PyUSB send HID report
37,943,825
<hr> <p>UPDATE</p> <hr> <p>I managed it to send the data properly. For anyone how ran into the same problem, I used the following code:</p> <pre><code>data=[0x00, 0x04, 0x04, 0xFF, 0xFF, 0xFF, 0x00, 0x00] result=dev.ctrl_transfer(0x21, 0x9, wValue=0x200, wIndex=0x00, data_or_wLength=data) </code></pre> <p>(this is...
0
2016-06-21T11:58:58Z
38,042,885
<p>Don't use PyUSB (unless you need other protocols too). Managing HID isn't difficult, but there is a much easier solution. </p> <p><a href="http://www.signal11.us/oss/hidapi/" rel="nofollow">HIDAPI is a C-library</a> which manages the protocol, and there is <a href="https://pypi.python.org/pypi/hidapi/" rel="nofollo...
1
2016-06-26T20:28:47Z
[ "python", "windows", "usb", "hid", "pyusb" ]
badly formed hexadecimal UUID string with Adafruit library
37,943,887
<h2>The issue</h2> <p>I am trying to play with a Bluefruit LE Friend dongle (Adafruit).</p> <p>They provide a <a href="https://learn.adafruit.com/bluefruit-le-python-library/usage" rel="nofollow">python library</a> to communicate with it.</p> <p>Unfortunately, the example they provide doesn't work:</p> <pre><code>u...
0
2016-06-21T12:01:59Z
37,944,388
<p>This code depends on D-Bus, specifically the 'properties' offered by it. I would to say that the problem is here:</p> <p><code>uuids = self._props.Get(_INTERFACE, 'UUIDs')</code> <a href="https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/master/Adafruit_BluefruitLE/bluez_dbus/device.py#L131" rel="nofollo...
0
2016-06-21T12:24:57Z
[ "python", "uuid" ]
badly formed hexadecimal UUID string with Adafruit library
37,943,887
<h2>The issue</h2> <p>I am trying to play with a Bluefruit LE Friend dongle (Adafruit).</p> <p>They provide a <a href="https://learn.adafruit.com/bluefruit-le-python-library/usage" rel="nofollow">python library</a> to communicate with it.</p> <p>Unfortunately, the example they provide doesn't work:</p> <pre><code>u...
0
2016-06-21T12:01:59Z
39,749,079
<p>Well u have two ways to fix it.</p> <p>Right way read more about <a href="https://www.bluetooth.com/specifications/gatt/services" rel="nofollow">this</a> and configure your adafruit bluetooth.</p> <p>Or bad way u can just comment this <code>if</code> statement check </p> <pre><code>if len(hex) != 32: raise Va...
0
2016-09-28T13:32:57Z
[ "python", "uuid" ]
Python rolling log to a variable
37,944,111
<p>I have an application that makes use of multi-threading and is run in the background on a server. In order to monitor the application without having to log on to the server, I decided to include <a href="http://bottlepy.org">Bottle</a> in order to respond to a few HTTP endpoints and report status, perform remote shu...
6
2016-06-21T12:13:36Z
37,952,182
<p>Use the technique described in <a href="http://alanwsmith.com/capturing-python-log-output-in-a-variable" rel="nofollow">Capturing Python Log Output In A Variable</a>, but capture it into a custom stream that throws away old data.</p> <p>Like so:</p> <pre><code># Adapted from http://alanwsmith.com/capturing-python-...
2
2016-06-21T18:40:16Z
[ "python", "python-3.x", "logging" ]
Python rolling log to a variable
37,944,111
<p>I have an application that makes use of multi-threading and is run in the background on a server. In order to monitor the application without having to log on to the server, I decided to include <a href="http://bottlepy.org">Bottle</a> in order to respond to a few HTTP endpoints and report status, perform remote shu...
6
2016-06-21T12:13:36Z
37,967,421
<p>Going further on Andrew Guy's suggestion, I subclassed <code>logging.Handler</code> and implemented a handler that uses <code>collections.deque</code> with a fixed length to keep a record of the log messages.</p> <pre><code>import logging import collections class TailLogHandler(logging.Handler): def __init__...
0
2016-06-22T12:00:15Z
[ "python", "python-3.x", "logging" ]
psycopg2.ProgrammingError: cannot cast type record to geometry
37,944,141
<p>I've a query that find nearest POI from a linestring. The query is like this:</p> <pre><code>import psycopg2 conn = psycopg2.connect("dbname=TestGIS user=postgis") cur = conn.cursor() cur.execute("SELECT poi.name,poi.city,ST_AsTEXT(poi.the_geog), ST_AsText(ST_ClosestPoint(road.the_geog::geometry, poi....
0
2016-06-21T12:14:47Z
37,944,749
<p>Give the column an alias so you can refer to it:</p> <pre><code>FROM ( SELECT ST_GeographyFromText( 'SRID=4326;LINESTRING(85.280194 23.296728,85.281572 23.297479)' ) as road ) AS road </code></pre>
0
2016-06-21T12:41:40Z
[ "python", "sql", "postgresql", "postgis" ]
Subprocess doesn't respect arguments when using multiprocessing
37,944,170
<p>The main objective here is to create a daemon-spawning function. The daemons need to run arbitrary programs (i.e. use <code>subprocess</code>).</p> <p>What I have so far in my <code>daemonizer.py</code> module is:</p> <pre><code>import os from multiprocessing import Process from time import sleep from subprocess i...
0
2016-06-21T12:15:49Z
37,944,563
<p>Your arguments are being "used up" by the printing of them!</p> <p>First, you do this:</p> <pre><code>args = (str(a) for a in args) </code></pre> <p>That creates a generator, not a list or tuple. So when you later do this:</p> <pre><code>list(args) </code></pre> <p>That consumes the arguments, and they will no...
2
2016-06-21T12:33:12Z
[ "python", "linux", "multithreading", "bash", "subprocess" ]
convert my python code to windows application (right-click menu)
37,944,198
<p>For example, I have written a code which gets an import folder directory and a destination folder, and rotates all images in the import folder by 45 degrees clockwise, and saves them rotated in the destination folder. It works great, but you must have python in order to use it. I want to have an option when you pres...
2
2016-06-21T12:16:56Z
37,944,495
<ol> <li>You can use PyInstaller to package your Python program into a stand-alone executable. <a href="http://www.pyinstaller.org" rel="nofollow">http://www.pyinstaller.org</a></li> <li>Then, read the answer to this older question. It should give you more information on how to add Context Menus in the Windows File Exp...
1
2016-06-21T12:30:10Z
[ "python" ]
convert my python code to windows application (right-click menu)
37,944,198
<p>For example, I have written a code which gets an import folder directory and a destination folder, and rotates all images in the import folder by 45 degrees clockwise, and saves them rotated in the destination folder. It works great, but you must have python in order to use it. I want to have an option when you pres...
2
2016-06-21T12:16:56Z
37,944,565
<p>This is more related to Windows API then Python or whatever framework you are using.</p> <p>Actually you can do something similar by:</p> <ol> <li>Freezing your code. You can choose any but I use <code>cx_freeze</code>.</li> <li>Package the app using Inno Setup. It provides some "shortcuts" to work with Windows, i...
1
2016-06-21T12:33:18Z
[ "python" ]
Sum of n lambda functions
37,944,419
<p>I have a list of lambda functions. Lets say this one</p> <pre><code>l = [lambda x:x**i for i in range(n)] </code></pre> <p>For every n I need to be able to sum them so I'd have a function like this:</p> <pre><code>f = lambda x: x + x**2 + x**3 + ... + x**n </code></pre> <p>Is there any way?</p> <p>Edit: I wasn'...
1
2016-06-21T12:26:42Z
37,944,595
<p>Is this the solution you're looking for?</p> <p>Python 3.x:</p> <pre><code>n = 5 g = lambda y: sum( f(y) for f in (lambda x: x**i for i in range(n)) ) print(g(5)) # 781 </code></pre> <p>Python 2.x:</p> <pre><code>n = 5 g = lambda y: sum( f(y) for f in (lambda x: x**i for i in xrange(n)) ) print g(5) # 781 </...
3
2016-06-21T12:34:45Z
[ "python", "python-3.x" ]
Sum of n lambda functions
37,944,419
<p>I have a list of lambda functions. Lets say this one</p> <pre><code>l = [lambda x:x**i for i in range(n)] </code></pre> <p>For every n I need to be able to sum them so I'd have a function like this:</p> <pre><code>f = lambda x: x + x**2 + x**3 + ... + x**n </code></pre> <p>Is there any way?</p> <p>Edit: I wasn'...
1
2016-06-21T12:26:42Z
37,944,601
<p>If you mean a finite sum, up to <code>x**n</code>, use the mathematical shortcut</p> <pre><code>f = lambda x: (x**(n+1) - 1) / (x - 1) if x != 1 else n </code></pre>
3
2016-06-21T12:35:01Z
[ "python", "python-3.x" ]
Sum of n lambda functions
37,944,419
<p>I have a list of lambda functions. Lets say this one</p> <pre><code>l = [lambda x:x**i for i in range(n)] </code></pre> <p>For every n I need to be able to sum them so I'd have a function like this:</p> <pre><code>f = lambda x: x + x**2 + x**3 + ... + x**n </code></pre> <p>Is there any way?</p> <p>Edit: I wasn'...
1
2016-06-21T12:26:42Z
37,944,617
<pre><code>f = lambda x,n: sum( x**i for i in range(n) ) print f(3,4) &gt;&gt; 40 </code></pre>
2
2016-06-21T12:35:51Z
[ "python", "python-3.x" ]
Sum of n lambda functions
37,944,419
<p>I have a list of lambda functions. Lets say this one</p> <pre><code>l = [lambda x:x**i for i in range(n)] </code></pre> <p>For every n I need to be able to sum them so I'd have a function like this:</p> <pre><code>f = lambda x: x + x**2 + x**3 + ... + x**n </code></pre> <p>Is there any way?</p> <p>Edit: I wasn'...
1
2016-06-21T12:26:42Z
37,944,805
<p>The simplest way to do this is to avoid creating the list of lambda functions, and to instead sum over a single function. Assuming you've defined <code>x</code> and <code>n</code>, you can do:</p> <pre><code>f = lambda x, i: x**i sum(f(x, i) for i in range(n)) </code></pre> <p>In your original example, you have a...
0
2016-06-21T12:44:22Z
[ "python", "python-3.x" ]
Storing an int in odoo
37,944,578
<p>I'd like to know if their is a way to store an integer somewhere in odoo, without having to create an new objet. I'd like to keep a number in order to show only partner with an id superior to that number. But I don't want to add a field in every single record of res.partner. How can I have a number I can acces into ...
1
2016-06-21T12:33:55Z
37,947,938
<p>You can use the model <code>ir.config_parameter</code> for such cases. Get used to the medhod set_param() and get_param().</p> <p>The parameter holds his value as string, so for my example it will be parsed into integer. The xml id will be <code>my_module.test_parameter</code>.</p> <p>But using this within the vie...
1
2016-06-21T14:58:55Z
[ "python", "xml", "openerp" ]
How to stream a gzip built on the fly in Python?
37,944,801
<p>I'd like to stream a big log file over the network using asyncio. I retrieve the data from the database, format it, compress it using python's zlib and stream it over the network.</p> <p>Here is basically the code I use:</p> <pre><code>@asyncio.coroutine def logs(requests): # ... yield from resp.prepare(...
0
2016-06-21T12:44:00Z
37,949,658
<p>Your gzip header is wrong (8 bytes instead of 10), and you follow it with a zlib stream which uses a different header and trailer. Even had you had a correct gzip header, and if you had a raw deflate stream instead of a gzip stream, you would still have not written a gzip trailer.</p> <p>To do this right, do not at...
1
2016-06-21T16:19:35Z
[ "python", "streaming", "zlib", "gunzip", "zcat" ]
Python 3 and base64 encoding of a binary file
37,944,806
<p>I'm new to Python and I do have an issue that is bothering me.</p> <p>I use the following code to get a base64 string representation of my zip file.</p> <pre><code>with open( "C:\\Users\\Mario\\Downloads\\exportTest1.zip",'rb' ) as file: zipContents = file.read() encodedZip = base64.encodestring(zipContent...
0
2016-06-21T12:44:27Z
37,945,059
<p>From the <a href="https://docs.python.org/3.5/library/base64.html" rel="nofollow">base64 package doc</a>:</p> <p><a href="https://docs.python.org/3.5/library/base64.html#base64.encodestring" rel="nofollow"><code>base64.encodestring</code></a>:</p> <p><em>"Encode the bytes-like object s, which can contain arbitrary...
2
2016-06-21T12:54:22Z
[ "python", "python-3.x", "base64", "binaries" ]
Python 3 and base64 encoding of a binary file
37,944,806
<p>I'm new to Python and I do have an issue that is bothering me.</p> <p>I use the following code to get a base64 string representation of my zip file.</p> <pre><code>with open( "C:\\Users\\Mario\\Downloads\\exportTest1.zip",'rb' ) as file: zipContents = file.read() encodedZip = base64.encodestring(zipContent...
0
2016-06-21T12:44:27Z
37,945,077
<p>Use <code>b64encode</code> to encode without the newlines and then decode the resulting binary string with <code>.decode('ascii')</code> to get a normal string.</p> <pre><code>encodedZip = base64.b64encode(zipContents).decode('ascii') </code></pre>
2
2016-06-21T12:55:12Z
[ "python", "python-3.x", "base64", "binaries" ]
Basic questions about nested blockmodel in graph-tool
37,944,901
<p>Very briefly, two-three basic questions about the <a href="https://graph-tool.skewed.de/static/doc/inference.html#graph_tool.inference.minimize_nested_blockmodel_dl" rel="nofollow"><code>minimize_nested_blockmodel_dl</code></a> function in <a href="https://graph-tool.skewed.de/" rel="nofollow"><code>graph-tool libra...
4
2016-06-21T12:47:55Z
37,954,201
<p>Regarding your first question, it is fairly straightforward: The <code>minimize_nested_blockmodel_dl()</code> function returns a <code>NestedBlockState</code> object:</p> <pre><code> g = collection.data["football"] state = minimize_nested_blockmodel_dl(g) </code></pre> <p>you can query the group membership of the...
5
2016-06-21T20:41:27Z
[ "python", "graph-theory", "graph-tool" ]
How to run multiple commands using subprocess.check_call at one go
37,944,949
<p>I am trying to run multiple commands at one go using subprocess.ckeck_call in my python script but not working.</p> <pre><code>&gt;&gt;&gt; subprocess.check_call("testdriver ssh scaler-1"; "mkdir deb" shell=True) File "&lt;stdin&gt;", line 1 subprocess.check_call("testdriver ssh scaler-1"; "mkdir deb" shell=T...
1
2016-06-21T12:50:03Z
37,944,995
<p>Surely you meant</p> <pre><code>subprocess.check_call("testdriver ssh scaler-1; mkdir deb", shell=True) </code></pre>
2
2016-06-21T12:52:21Z
[ "python", "subprocess" ]
Css selector for an attribute whose value has whitespaces
37,944,963
<p>I am writing code in python using a library_Beautiful Soup and I want to select this tag (using CSS Selector)</p> <pre><code>&lt;div&gt; ... &lt;div&gt; ... &lt;div style=" height:80px; width:700px; "&gt; ... </code></pre> <p>I am trying to do: </p> <pre><code>soup.select('div div div[style*="height:...
0
2016-06-21T12:50:46Z
37,945,230
<p>You can use <code>find</code>:</p> <pre><code>.find("div", style=" height:80px; width:700px; ")) </code></pre> <p>Using multiple attributes in a select does not work with bs4, you are also limited to what you can pass when searching by attribute, the best you could do would be pick one <code>.select_one("div[style...
0
2016-06-21T13:02:33Z
[ "python", "css", "beautifulsoup" ]
Error when try writing to excel
37,944,966
<p>I try <code>df.to_excel()</code> and get error <code>UnicodeDecodeError: 'utf8' codec can't decode byte 0xd1 in position 175: invalid continuation byte</code>. Next I try <code>df.to_excel(encoding='utf-8')</code>, but error didn't dissapear/ What's wrong?</p>
0
2016-06-21T12:50:54Z
37,946,749
<p>You could try</p> <pre><code>import sys reload(sys) sys.setdefaultencoding("latin-1") </code></pre> <p>Failing that, try <code>sys.setdefaultencoding('utf-8')</code></p>
0
2016-06-21T14:09:21Z
[ "python", "pandas" ]
Python Requests - authentication after redirect
37,945,057
<p>I have a quick question regarding HTTP Basic Authentication after a redirect.</p> <p>I am trying to login to a website which, for operational reasons, immediately redirects me to a central login site using an HTTP 302 response. In my testing, it appears that the Requests module does not send my credentials to the ...
2
2016-06-21T12:54:20Z
37,990,889
<p>My solution to this would be use of "Session". Here is how you can implement Session.</p> <pre><code>import requests s = requests.session() url_login = "&lt;loginUrl&gt;" payload = { "username": "&lt;user&gt;", "password": "&lt;pass&gt;" } req1 = s.post(url_login, data=payload) # Now to make sure you do...
1
2016-06-23T11:54:30Z
[ "python", "authentication", "redirect", "python-requests" ]
How can I check each row of a large csv and write the row if a certain column contains a certain value?
37,945,092
<p>I am working with a large (3.5GB) .csv file that I can't process entirely in memory and want to:</p> <ul> <li>Read in one row of data</li> <li>Check if a field is equal to a given criteria</li> <li>If true, append that row to new .csv file. If false, skip to next row</li> <li>Loop until end of original file is reac...
-3
2016-06-21T12:55:40Z
37,945,594
<p>Try the code below. Set appropriate number of records (that your machine allows) as chunk size.</p> <pre><code>chunksize = 10 ** 5 for chunk in pd.read_csv(filename, chunksize=chunksize): df=df.append (chunk [chunk.field==criterion]) </code></pre>
1
2016-06-21T13:17:56Z
[ "python", "pandas" ]
How can I check each row of a large csv and write the row if a certain column contains a certain value?
37,945,092
<p>I am working with a large (3.5GB) .csv file that I can't process entirely in memory and want to:</p> <ul> <li>Read in one row of data</li> <li>Check if a field is equal to a given criteria</li> <li>If true, append that row to new .csv file. If false, skip to next row</li> <li>Loop until end of original file is reac...
-3
2016-06-21T12:55:40Z
37,946,081
<p>I would do it this way:</p> <pre><code>chunksize = 10**6 // 2 # you may want to adjust it ... for chunk in pd.read_csv(filename, chunksize=chunksize): (chunk.query('condition1 &amp; condition2 &amp; ... ') .to_csv('output.csv', mode='a', index=False)) </code></pre> <p>The trick is <code>mode='a'</c...
2
2016-06-21T13:39:37Z
[ "python", "pandas" ]
How can I check each row of a large csv and write the row if a certain column contains a certain value?
37,945,092
<p>I am working with a large (3.5GB) .csv file that I can't process entirely in memory and want to:</p> <ul> <li>Read in one row of data</li> <li>Check if a field is equal to a given criteria</li> <li>If true, append that row to new .csv file. If false, skip to next row</li> <li>Loop until end of original file is reac...
-3
2016-06-21T12:55:40Z
38,079,921
<p>I found that the following worked for me. Note that this also produced a separate output file for each criteria value in the list.</p> <pre><code>import csv # criteria is the column number from the source data to check against the values list criteria = 4 valueslist= ['criteria1','criteria2','criteria3'] for ite...
0
2016-06-28T15:08:00Z
[ "python", "pandas" ]
Python lambda with list comprehension
37,945,295
<p>I've a doubt about lambda expression with internal list comprehension operation.</p> <p>In the following code, the lambda will instantiate a list for each item every time?</p> <pre><code>def _find_items_not_present_in_store(self, store_today, store_yesterday): # finding what items are not in the store anym...
0
2016-06-21T13:05:26Z
37,945,507
<p>Every call of the <code>lambda</code> function will re-create that list, so moving that construction outside the <code>lambda</code> will improve performance.</p> <p>Moreover using a <code>list</code> to check for <code>in</code> isn't a good idea, since it takes linear time. Consider using a <code>set</code> inste...
1
2016-06-21T13:14:38Z
[ "python", "python-2.7", "lambda", "list-comprehension" ]
Python lambda with list comprehension
37,945,295
<p>I've a doubt about lambda expression with internal list comprehension operation.</p> <p>In the following code, the lambda will instantiate a list for each item every time?</p> <pre><code>def _find_items_not_present_in_store(self, store_today, store_yesterday): # finding what items are not in the store anym...
0
2016-06-21T13:05:26Z
37,945,522
<p>You are performing a linear search for each item in your list - and that is definitely sub-optimal. For a store with 1 million items in stock, hat can lead to the order of (1000000)² comparisons, which can be quite a burden even to fast computers. That is just to start</p> <p>The thing to do is to create a set wit...
1
2016-06-21T13:15:12Z
[ "python", "python-2.7", "lambda", "list-comprehension" ]
Python lambda with list comprehension
37,945,295
<p>I've a doubt about lambda expression with internal list comprehension operation.</p> <p>In the following code, the lambda will instantiate a list for each item every time?</p> <pre><code>def _find_items_not_present_in_store(self, store_today, store_yesterday): # finding what items are not in the store anym...
0
2016-06-21T13:05:26Z
37,945,545
<p>The way you've written it, the list is part of the lambda expression, so it will be evaluated each time the lambda is invoked.</p> <p>Here's the most efficient way to implement your function:</p> <pre><code>def _find_items_not_present_in_store(self, store_today, store_yesterday): s = set(item2.item_id for item...
1
2016-06-21T13:16:07Z
[ "python", "python-2.7", "lambda", "list-comprehension" ]
SQLAlchemy: query is giving error while passing integer parameter
37,945,338
<p>I am using SQLAchemy and python to dynamically run SQL query. But it is giving the error.</p> <p>This is my command to run the query:</p> <pre><code>data = engine.execute(m_query, week=Cohort_week, metric=metric, p1=val1, p2=val2).fetchall() </code></pre> <p>here Cohort_week, val1,val2 are integers and metric is ...
1
2016-06-21T13:07:24Z
37,950,662
<p>It looks like you want to compare the values in the column <code>pdp_views</code> with <code>p1</code> and <code>p2</code> but what you're actually doing is comparing the string <code>'pdp_views'</code> with <code>p1</code> and <code>p2</code>, which have incompatible types.</p> <p>You should build the query dynami...
0
2016-06-21T17:14:49Z
[ "python", "sql", "pandas", "sqlalchemy", "flask-sqlalchemy" ]
'Timestamp' object has no attribute 'timestamp'
37,945,430
<p>I'm following a course where I have to convert a date to a unix timestamp.</p> <pre><code>import pandas as pd df = pd.read_csv('file.csv') print type(df.iloc[-1].name) </code></pre> <p><strong>class 'pandas.tslib.Timestamp'</strong></p> <pre><code>ts = df.iloc[-1].name.timestamp() </code></pre> <p><strong>Attri...
0
2016-06-21T13:11:13Z
37,946,736
<p>You don't actually ask a question (tip for next time: be more explicit), but I assume you want an epoch / Unix timestamp from a Pandas Timestamp object.</p> <p>If you use the <code>pandas.tslib.Timestamp.value</code> method, you'll return the timestamp in microseconds (1/1,000,000 second):</p> <pre><code>In [1]: i...
0
2016-06-21T14:08:42Z
[ "python", "pandas", "timestamp" ]
'Timestamp' object has no attribute 'timestamp'
37,945,430
<p>I'm following a course where I have to convert a date to a unix timestamp.</p> <pre><code>import pandas as pd df = pd.read_csv('file.csv') print type(df.iloc[-1].name) </code></pre> <p><strong>class 'pandas.tslib.Timestamp'</strong></p> <pre><code>ts = df.iloc[-1].name.timestamp() </code></pre> <p><strong>Attri...
0
2016-06-21T13:11:13Z
37,947,246
<p>IIUC, you can do it this way:</p> <p>generate sample DF with datetime dtype</p> <pre><code>In [65]: x = pd.DataFrame({'Date': pd.date_range('2016-01-01', freq='5D', periods=5)}) In [66]: x Out[66]: Date 0 2016-01-01 1 2016-01-06 2 2016-01-11 3 2016-01-16 4 2016-01-21 </code></pre> <p>convert datetime to ...
0
2016-06-21T14:30:19Z
[ "python", "pandas", "timestamp" ]
Python matplotlib save as TIFF
37,945,495
<p>Does anyone know how to save a matplotlib figure as *.tiff? It seems that this format is not supported in Python, while the journals are quite often ask for that format.</p> <p>I am adding some minimal code:</p> <pre><code># -*- coding: utf-8 -*- from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as...
2
2016-06-21T13:13:56Z
37,962,106
<p>As a workaround, there would be nothing to stop you using the Python PIL package to save your image in TIFF format:</p> <pre><code># -*- coding: utf-8 -*- from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np from PIL import Image import cStringIO # fig setup fig = plt.figur...
3
2016-06-22T08:06:26Z
[ "python", "matplotlib", "tiff" ]
Python matplotlib save as TIFF
37,945,495
<p>Does anyone know how to save a matplotlib figure as *.tiff? It seems that this format is not supported in Python, while the journals are quite often ask for that format.</p> <p>I am adding some minimal code:</p> <pre><code># -*- coding: utf-8 -*- from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as...
2
2016-06-21T13:13:56Z
37,963,660
<p>This is great! Thanks ot <a href="http://stackoverflow.com/users/4985733/martin-evans">Martin Evans</a>. However, for those who would like to make it happen in <code>Python3.x</code>, small fixes (since <code>cStringIO</code> module is not available; and I would rather use <code>BytesIO</code>)</p> <pre><code># -*-...
0
2016-06-22T09:18:08Z
[ "python", "matplotlib", "tiff" ]
Python.h compiling error: collect2.exe Id returned 1 exit status
37,945,529
<p>So, I've searched all around the web and I couldn't find anything.</p> <p>I'm started with python, and I made a TKinter application. At first, I tried to compile it to an .exe file, but that didn't work. So now I'm embedding python in C++. Every single time I try to compile it (using Dev-C++), I get the error:</p> ...
0
2016-06-21T13:15:19Z
37,948,168
<p>The linker is complaining bacause it can't find a group of references about some python stuff, as a matter of fact I don't see any python library in the g++ invocation. </p> <p>You need to had something like this -lpython3.5.1 to tell g++ to link against the python library (assuming python is installed in your syst...
0
2016-06-21T15:08:57Z
[ "python", "c++", "dev-c++" ]
Get all objects created on same day till now
37,945,688
<p>I have a model which contains <code>created_at</code> DateTimeField. I want to filter the model to get all object created on this day, month till now.</p> <p>For Example : Date = 21/06/2016 Now I want to get all objects created on 21/06 till now irrespective of year.</p> <p>Edit: To be precise, I have model which ...
0
2016-06-21T13:22:09Z
37,945,843
<p>From what I can understand from your question, you want to get all objects with the same date as today, irrespective of the year.</p> <p>I would use something like this. See if this helps.</p> <pre><code>from datetime import datetime today = datetime.now() OneModel.objects.filter(created_at__day = today.day.__str...
-1
2016-06-21T13:29:00Z
[ "python", "django", "datetime", "django-models", "python-datetime" ]
Get all objects created on same day till now
37,945,688
<p>I have a model which contains <code>created_at</code> DateTimeField. I want to filter the model to get all object created on this day, month till now.</p> <p>For Example : Date = 21/06/2016 Now I want to get all objects created on 21/06 till now irrespective of year.</p> <p>Edit: To be precise, I have model which ...
0
2016-06-21T13:22:09Z
37,945,891
<p>An example of filtering outside of the queryset. Get the date u want and remove unwanted results</p> <pre><code>from datetime import datetime, timedelta twodaysago = str(datetime.strptime(str(datetime.now().date()-timedelta(days=2)), '%Y-%m-%d')).split()[0] </code></pre> <p>now do your query and filter it like th...
0
2016-06-21T13:31:06Z
[ "python", "django", "datetime", "django-models", "python-datetime" ]
Get all objects created on same day till now
37,945,688
<p>I have a model which contains <code>created_at</code> DateTimeField. I want to filter the model to get all object created on this day, month till now.</p> <p>For Example : Date = 21/06/2016 Now I want to get all objects created on 21/06 till now irrespective of year.</p> <p>Edit: To be precise, I have model which ...
0
2016-06-21T13:22:09Z
37,945,957
<p>Not sure if I understand the problem correctly, but try this:</p> <pre><code>before = datetime.date(2016, 06, 21) today = datetime.date.today() MyModel.objects.filter( created_at__month__range=(before.month, today.month), created_at__day__range=(before.day, today.day) ) </code></pre>
0
2016-06-21T13:34:28Z
[ "python", "django", "datetime", "django-models", "python-datetime" ]