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
Find a HTML tag that contains certain text
39,529,983
<p>So I am trying to find a particular string in website html source file.</p> <p>Ex) If I have following html tag</p> <pre><code>&lt;div class="rev" data="123456789adfdfdfdfadf"&gt;&lt;/div&gt; </code></pre> <p>I want to be able to find this particular line that contain <code>div class = "rev"</code> and data that ...
2
2016-09-16T11:06:49Z
39,532,152
<p>You are mixing your data (as attribute) and the text you're looking for.<br> With the <code>div</code> given, you should find it with:</p> <pre><code>print [item["data"] for item in soup.find_all('div', {'_class': 'rev'}) if "data" in item.attrs] </code></pre> <p>Or, a bit more accurate:</p> <pre>...
1
2016-09-16T12:59:18Z
[ "python", "html", "python-2.7" ]
Emitting event from socketIo python
39,529,993
<p>I'm stuck in development of socket.io with Python. I'm using this <a href="http://python-socketio.readthedocs.io/en/latest/" rel="nofollow">lib</a> </p> <p>I got a chat app running by using <a href="https://github.com/sreejesh79/android-socket.io-demo" rel="nofollow">this</a> android part and with the lib sample. I...
0
2016-09-16T11:07:20Z
39,532,878
<p>Send a message from Android client. Does your Python code get it? If not, check if you have connected to the same namespace.</p>
0
2016-09-16T13:35:38Z
[ "python", "node.js", "socket.io", "chat", "real-time" ]
Is it possible to create a polynomial through Numpy's C API?
39,530,054
<p>I'm using SWIG to wrap a C++ library with its own polynomial type. I'd like to create a typemap to automatically convert that to a numpy polynomial. However, browsing the docs for the numpy C API, I'm not seeing anything that would allow me to do this, only numpy arrays. Is it possible to typemap to a polynomial?</p...
0
2016-09-16T11:10:01Z
39,576,294
<p>Numpy's polynomial package is largely a collection of functions that can accept array-like objects as the polynomial. Therefore, it is sufficient to convert to a normal ndarray, where the value at index n is the coefficient for the term with exponent n.</p>
0
2016-09-19T14:59:44Z
[ "python", "c++", "numpy", "swig" ]
How to chain a queryset together in Django correctly
39,530,081
<p>Using the example below, I'm trying to use a queryset and append/chain filters together. To my understanding last <code>queryset.count()</code> should have just 1 instance, but it always had the original 10 in it. </p> <p>Expected output of last <code>queryset.count()</code> is 1:</p> <pre><code># Set a default q...
1
2016-09-16T11:11:30Z
39,530,465
<p>You never assign the filter to anything so it doesn't update it</p> <pre><code> queryset = queryset.filter(id=1) </code></pre> <p>Yes this is the correct way because you are creating a new query, otherwise you need to call the count on the end of the previous filter call</p>
3
2016-09-16T11:33:26Z
[ "python", "django" ]
Py2.7: Tkinter have code for pages in separate files
39,530,107
<p>I have code that opens up a window and has three buttons for page 1, page 2, and page 3. However I also have Four .py files (Dashboard, PageOne, PageTwo. PageThree). Dashboard will be the file that used to run the application. I want it so that the code from each file is only runs/displayed when the user clicks on t...
-1
2016-09-16T11:12:38Z
39,534,704
<p>The error messages tell you everything you need to know in order to fix the problem. This is a simple problem that has nothing to do with tkinter, and everything to do with properly organizing and using your code. </p> <p>For example, what is <code>Page is not defined</code> telling you? It's telling you, quite lit...
0
2016-09-16T15:04:51Z
[ "python", "python-2.7", "tkinter" ]
Camera calibration for Structure from Motion with OpenCV (Python)
39,530,110
<p>I want to calibrate a car video recorder and use it for 3D reconstruction with Structure from Motion (SfM). The original size of the pictures I have took with this camera is 1920x1080. Basically, I have been using the source code from the <a href="http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/p...
2
2016-09-16T11:12:43Z
39,533,639
<p><strong>Question #2:</strong></p> <p>With <code>cv::getOptimalNewCameraMatrix(...)</code> you can compute a new camera matrix according to the free scaling parameter <code>alpha</code>.</p> <p>If <code>alpha</code> is set to <code>1</code> then all the source image pixels are retained in the undistorted image that...
0
2016-09-16T14:11:09Z
[ "python", "opencv", "camera-calibration", "3d-reconstruction", "structure-from-motion" ]
Python numpy nonzero cumsum
39,530,157
<p>I want to do nonzero <code>cumsum</code> with <code>numpy</code> array. Simply skip zeros in array and apply <code>cumsum</code>. Suppose I have a np. array </p> <pre><code>a = np.array([1,2,1,2,5,0,9,6,0,2,3,0]) </code></pre> <p>my result should be</p> <pre><code>[1,3,4,6,11,0,20,26,0,28,31,0] </code></pre> <p>...
1
2016-09-16T11:16:24Z
39,530,202
<p>You need to mask the original array so only the non-zero elements are overwritten:</p> <pre><code>In [9]: a = np.array([1,2,1,2,5,0,9,6,0,2,3,0]) a[a!=0] = np.cumsum(a[a!=0]) a Out[9]: array([ 1, 3, 4, 6, 11, 0, 20, 26, 0, 28, 31, 0]) </code></pre> <p>Another method is to use <code>np.where</code>:</p> <pr...
2
2016-09-16T11:19:05Z
[ "python", "numpy" ]
Python numpy nonzero cumsum
39,530,157
<p>I want to do nonzero <code>cumsum</code> with <code>numpy</code> array. Simply skip zeros in array and apply <code>cumsum</code>. Suppose I have a np. array </p> <pre><code>a = np.array([1,2,1,2,5,0,9,6,0,2,3,0]) </code></pre> <p>my result should be</p> <pre><code>[1,3,4,6,11,0,20,26,0,28,31,0] </code></pre> <p>...
1
2016-09-16T11:16:24Z
39,530,363
<p>Just trying to simplify it:)</p> <pre><code>b=np.cumsum(a) [b[i] if ((i &gt; 0 and b[i] != b[i-1]) or i==0) else 0 for i in range(len(b))] </code></pre>
0
2016-09-16T11:27:47Z
[ "python", "numpy" ]
Python numpy nonzero cumsum
39,530,157
<p>I want to do nonzero <code>cumsum</code> with <code>numpy</code> array. Simply skip zeros in array and apply <code>cumsum</code>. Suppose I have a np. array </p> <pre><code>a = np.array([1,2,1,2,5,0,9,6,0,2,3,0]) </code></pre> <p>my result should be</p> <pre><code>[1,3,4,6,11,0,20,26,0,28,31,0] </code></pre> <p>...
1
2016-09-16T11:16:24Z
39,530,868
<p>To my mind, jotasi's suggestion in a comment to the OP is the most idiomatic. Here are some timings, though note that Shawn. L's answer returns a Python list, not a NumPy array, so they are not strictly comparable.</p> <pre><code>import numpy as np def jotasi(a): b = np.cumsum(a) b[a==0] = 0 return b def Ed...
1
2016-09-16T11:54:20Z
[ "python", "numpy" ]
python bs4 requests: ValueError: unconverted data remains:
39,530,159
<p>i did go through the existing questions, but for my code there is no hint given after the <strong>ValueError</strong> as to where exactly the data remained unconverted. code below. please help:</p> <pre><code>str_time = 'Fri, 16 Sep 2016 14:28:14 +0530' obj_time = datetime.datetime.strptime(str_time[:25],'%a, %d %b...
0
2016-09-16T11:16:29Z
39,530,344
<p>What do you mean no hint?:</p> <p>It is in line 340</p> <p>this is the same problem:</p> <p><a href="http://stackoverflow.com/questions/20327937/valueerror-unconverted-data-remains-0205">ValueError: unconverted data remains: 02:05</a></p>
0
2016-09-16T11:26:35Z
[ "python", "datetime" ]
Plotting linesegments with Pysal in a map
39,530,189
<p>I am using Pysal to visualize geospatial data. I want to plot segments between individuals (network) but I don't know how to plot my list of LineSegment shapes (lc). So how can I display those LineSegment in my map ? (Below, the plotting code)</p> <pre><code>data_table = ps.pdio.read_files("cartes/departements/DEPA...
0
2016-09-16T11:18:27Z
39,592,720
<h2>Solved</h2> <p>I didn't use correctly the pysal plotting framework. The only thing needed was to use the LineCollection(l,alpha=0.1) method, and then add it to the setup_ax.</p> <pre><code>from pysal.contrib.viz import mapping as maps data_table = ps.pdio.read_files("cartes/departements/DEPARTEMENT.shp") dt = da...
0
2016-09-20T11:20:09Z
[ "python", "networking", "gis", "pysal" ]
Everything seems correct but I get "ValueError: time data" when parsing a timestamp
39,530,273
<p>It seems that the format is correct but I still get this error. What could be the problem here?</p> <pre><code>ValueError: time data '2016-09-16 11:36:28' does not match format '%y-%m-%d %H:%M:%S' </code></pre>
0
2016-09-16T11:22:40Z
39,530,338
<p>You need to use <code>%Y</code> for 4-digit years:</p> <pre><code>In [10]: d='2016-09-16 11:36:28' dt.datetime.strptime(d, '%Y-%m-%d %H:%M:%S') Out[10]: datetime.datetime(2016, 9, 16, 11, 36, 28) </code></pre> <p>see the docs: <a href="https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior...
1
2016-09-16T11:26:13Z
[ "python", "timestamp" ]
Transform JSON key:value pairs in flat structure into key:value tree structure
39,530,279
<p>It is possible to transform list of key:value pairs of data in the same "level" (flat structure) into a tree structure key:value of that data?</p> <p>Example:</p> <p>From:</p> <pre><code>[{"COD": "20000", "VAL": "Fanerozoico"}, {"COD": "23000", "VAL": "Cenozoico"}, {"COD": "23300", "VAL": "Quaternario"}, {"COD": ...
0
2016-09-16T11:22:58Z
39,532,950
<p>My attempt (that works but might not be the best solution):</p> <pre><code>mylist = [ {"COD": "20000", "VAL": "Fanerozoico"}, {"COD": "23000", "VAL": "Cenozoico"}, {"COD": "23300", "VAL": "Quaternario"}, {"COD": "23310", "VAL": "Pleistocenico"}, {"COD": "23314", "VAL": "Pleistocenico Superior"},...
0
2016-09-16T13:38:29Z
[ "python", "json", "data-structures" ]
Kivy POPUP and Button text
39,530,341
<p>First I'm new to kivy. myApp is based on <code>kivy-example/demo/kivycatlog</code> and I was modifying <code>PopupContainer.kv</code>, but my code doesn't work.</p> <p><strong>PopupContainer.kv</strong></p> <pre><code>BoxLayout: id: bl orientation: "vertical" popup: popup.__self__ canvas: C...
0
2016-09-16T11:26:22Z
39,544,334
<p>You could get the text of your ShowPopup's buttons from your code. I mean declare a variable in your code named <code>popups_text</code> and in your .kv file try accesing it using <code>root.popups_text</code>. then create a method in your code that changes this text every time the button is pressed.</p>
0
2016-09-17T07:52:32Z
[ "python", "kivy" ]
How to call scala from python?
39,530,375
<p>I would like to build my project in Scala and then use it in a script in Python for my data hacking (as a module or something like that). I have seen that there are ways to integrate python code into JVM languages with Jython (only Python 2 projects though). What I want to do is the other way around though. I found ...
0
2016-09-16T11:28:17Z
39,531,868
<p>General solution -- use some RPC/IPC (sockets, protobuf, whatever).</p> <p>However, you might want to look at Spark's solution -- how they translate Python code in Scala's APIs (<a href="https://www.py4j.org/" rel="nofollow">https://www.py4j.org/</a>) .</p>
0
2016-09-16T12:44:49Z
[ "python", "scala" ]
django form wizard, ValidationError: ['ManagementForm data is missing or has been tampered.']
39,530,458
<p>I'm using django wizard for a multiple form signup which in the end will be 4 or 5 pages of forms. However I'm getting validation errors that may relate to the form action somehow, which I'm not sure how to solve.</p> <p>The error seems to stem from line 282 here: <a href="https://github.com/django/django-formtools...
0
2016-09-16T11:33:07Z
39,530,576
<p>The form wizard requires that you include the management form in the form tag in your template:</p> <pre><code>{{ wizard.management_form }} </code></pre> <p>See <a href="http://django-formtools.readthedocs.io/en/latest/wizard.html?highlight=management_form#creating-templates-for-the-forms" rel="nofollow">the docs<...
3
2016-09-16T11:37:58Z
[ "python", "django", "forms" ]
wxpython: detect whether a dialog has been closed
39,530,471
<p>I am using wxpython to create a GUI and I have the following customized dialog class:</p> <pre><code>class GetDataDlg(wx.Dialog): def __init__(self, *args, **kwargs): self.parameters = kwargs.pop('parameters', None) request = kwargs.pop('request', None) assert self.parameters is not Non...
1
2016-09-16T11:33:35Z
39,536,150
<p>You are not binding the close event.<br> Have you tried inserting a <code>self.Bind(wx.EVT_CLOSE, self.OnQuit)</code> where OnQuit returns wx.ID_CANCEL</p>
0
2016-09-16T16:24:36Z
[ "python", "user-interface", "dialog", "modal-dialog", "wxpython" ]
results are not showing in taiga front end
39,530,493
<p>I am working on customization of taiga project management system. I have code downloaded from <a href="https://github.com/taigaio" rel="nofollow">github of taiga.io</a>. </p> <p>I am making changes in below code:</p> <pre><code>&lt;pre&gt;{{ user}}&lt;/pre&gt; &lt;div class="create-options"&gt; &lt;a href="#" n...
0
2016-09-16T11:34:28Z
39,653,606
<p>I resolved issue by placing <code>\</code> in <code>ng-if</code> then error was removed.</p> <p>Like:</p> <pre><code>ng-if="user.full_name==\'Administrator\'" </code></pre>
0
2016-09-23T06:02:04Z
[ "python", "angularjs", "django", "taiga" ]
Python - Supervisor how to log the standard output -
39,530,567
<p>I'm not expert about python, could someone explain where is the problem?</p> <p>I'd like to collect the stdout through supervisor <a href="http://supervisord.org/" rel="nofollow">http://supervisord.org/</a></p> <p>I've made 3 different scripts that print output, for bash and PHP I can collect the output, without ...
0
2016-09-16T11:37:36Z
39,532,147
<p>ok...python output is buffered use after print</p> <pre><code>sys.stdout.flush() </code></pre> <p>or ( python 3 )</p> <pre><code>print(something, flush=True) </code></pre> <p>or more better </p> <pre><code>import logging logging.warning('Watch out!') </code></pre> <p><a href="https://docs.python.org/3/howto/lo...
0
2016-09-16T12:59:00Z
[ "python", "linux", "python-3.x", "unix", "supervisord" ]
Selecting certain features from a dataset according to a list.
39,530,617
<p>I have a <strong>dataset "h_train"</strong> which has about 26 features and I have a <strong>list</strong> <strong>H</strong> which has some selected features from the dataset "h_train". I would only like to keep those features in the "h_train" which are present in list H. </p> <pre><code>h_train #Dataset with 26 f...
0
2016-09-16T11:40:10Z
39,530,805
<p>You can transfrom the list into the tuple datastructure and than sue its operators</p> <pre><code>a = tuple(h_train) b = tuple(H) c = a &amp; b only_H_features_left = list(c) </code></pre>
0
2016-09-16T11:51:12Z
[ "python", "pandas", "scikit-learn" ]
Selecting certain features from a dataset according to a list.
39,530,617
<p>I have a <strong>dataset "h_train"</strong> which has about 26 features and I have a <strong>list</strong> <strong>H</strong> which has some selected features from the dataset "h_train". I would only like to keep those features in the "h_train" which are present in list H. </p> <pre><code>h_train #Dataset with 26 f...
0
2016-09-16T11:40:10Z
39,545,236
<p>Assuming <code>h_train</code> is a <code>pd.DataFrame</code> you can just do</p> <pre><code>h_train = h_train[H] </code></pre>
0
2016-09-17T09:37:14Z
[ "python", "pandas", "scikit-learn" ]
Firebase Streaming using Python, connection times out when there is huge amount of data under the child.
39,530,707
<p>I am listening to data from firebase, under a path that contains enormous amount of data, using this library <a href="https://github.com/andrewsosa001/firebase-python-streaming" rel="nofollow">firebase-python-streaming</a>.However every time I start streaming, it gets hung on the call and nothing is returned leading...
0
2016-09-16T11:44:56Z
39,533,243
<p>If you get problems because of the large amount of data you're trying to retrieve, the solution will be to retrieve less data.</p> <p>One way to do this would be to listen to a point <strong>lower</strong> in your database tree. E.g.</p> <pre><code>custom_callback = fb.child("views/201609").listener(p) </code></pr...
0
2016-09-16T13:53:08Z
[ "python", "firebase", "listener", "firebase-database" ]
Tox running command based on env variable
39,530,802
<p>My current workflow is github PRs and Builds tested on Travis CI, with tox testing pytest and reporting coverage to codeclimate. </p> <p><strong>travis.yml</strong></p> <pre><code>os: - linux sudo: false language: python python: - "3.3" - "3.4" - "3.5" - "pypy3" - "pypy3.3-5.2-alpha1" - "nightly" install: pip inst...
3
2016-09-16T11:51:02Z
39,562,141
<p>You can have two <code>tox.ini</code> files and call that from <code>travis.yml</code></p> <p><code>script: if [ $TRAVIS_PULL_REQUEST ]; then tox -c tox_nocodeclimate.ini; else tox -c tox.ini; fi</code></p>
0
2016-09-18T20:03:56Z
[ "python", "travis-ci", "tox", "code-climate" ]
Tox running command based on env variable
39,530,802
<p>My current workflow is github PRs and Builds tested on Travis CI, with tox testing pytest and reporting coverage to codeclimate. </p> <p><strong>travis.yml</strong></p> <pre><code>os: - linux sudo: false language: python python: - "3.3" - "3.4" - "3.5" - "pypy3" - "pypy3.3-5.2-alpha1" - "nightly" install: pip inst...
3
2016-09-16T11:51:02Z
39,663,483
<p>My solution is going through setup.py command which takes care of everything</p> <p>Tox.ini</p> <pre><code>[testenv:py35] commands = python setup.py testcov passenv = ... </code></pre> <p>setup.py</p> <pre><code>class PyTestCov(Command): description = "run tests and report them to codeclimate" user_o...
0
2016-09-23T14:38:15Z
[ "python", "travis-ci", "tox", "code-climate" ]
Sublime text change text color
39,530,825
<p>I am currently trying to extract information (manually) from a text file. The text file has a decent format (parsable), but it contains something like 'random chars'. These random chars are not completely random, by running an algorithm on them I am able to collect information. I am giving each char a positive integ...
0
2016-09-16T11:52:18Z
39,533,921
<p>While I don't have any experience working with the Sublime API directly, I've had plugins that highlight things in my files with a rectangle/outline. It appears from the <a href="https://www.sublimetext.com/docs/3/api_reference.html" rel="nofollow">api reference</a> that Regions are used to handle this. There is a...
0
2016-09-16T14:24:52Z
[ "python", "sublimetext3", "sublime-text-plugin" ]
Sublime text change text color
39,530,825
<p>I am currently trying to extract information (manually) from a text file. The text file has a decent format (parsable), but it contains something like 'random chars'. These random chars are not completely random, by running an algorithm on them I am able to collect information. I am giving each char a positive integ...
0
2016-09-16T11:52:18Z
39,537,299
<p>In order to set the color of a <a href="http://www.sublimetext.com/docs/3/api_reference.html#sublime.Region" rel="nofollow"><code>Region</code></a> of text, you'll need to have a customized <a href="http://docs.sublimetext.info/en/latest/extensibility/syntaxdefs.html#scopes" rel="nofollow">scope selector</a> in your...
1
2016-09-16T17:40:16Z
[ "python", "sublimetext3", "sublime-text-plugin" ]
Sublime text change text color
39,530,825
<p>I am currently trying to extract information (manually) from a text file. The text file has a decent format (parsable), but it contains something like 'random chars'. These random chars are not completely random, by running an algorithm on them I am able to collect information. I am giving each char a positive integ...
0
2016-09-16T11:52:18Z
39,626,287
<p>It's possible in <strong>CudaText</strong> app, with Python API. API has <code>on_change_slow</code> event to run your code. And your code must find text x/y position, then call <code>ed.attr()</code> to highlight substring at x/y with any color. It's simple.</p>
0
2016-09-21T20:45:40Z
[ "python", "sublimetext3", "sublime-text-plugin" ]
python code to create a merged file
39,530,937
<p>I want to create a a file from two input files. Input1 is a single line file which contains 18 words separated by space. Input2 is multiple lines file which holds different size strings separated by space. The Output shall contains the presence (1) and absence (0) the 18 words in the Input2. Here is how it shall loo...
-6
2016-09-16T11:58:07Z
39,531,298
<p>Assuming you can read the data from file and hold it into two string say input1 and input2 below code should do what you are looking for</p> <pre><code>word_list_1 = input1.split(" ") for str in input2.split("\n"): word_list_2 = str.split(" ") for word in word_list_1: if word in word_list_2: ...
0
2016-09-16T12:15:33Z
[ "python" ]
Find minimum value of edge property for all edges connected to a given node
39,531,007
<p>I have a network where each of my edges is labelled with a date. I want to now also label my vertices so that each vertex has a date assigned to it corresponding to the minimum date of all edges incident and emanating from it. Is there an inbuilt function to find this which would be faster than me looping over all v...
2
2016-09-16T12:02:06Z
39,531,342
<p>There is hardly any solution that would not need to check all the edges to find the minimum. </p> <p>You could however optimize your calls to <code>min</code> by making a single call on the entire data instead of multiple calls and you also wouldn't need <code>lowest_year</code> any longer:</p> <pre><code>from ite...
2
2016-09-16T12:18:13Z
[ "python", "graph-tool" ]
Find minimum value of edge property for all edges connected to a given node
39,531,007
<p>I have a network where each of my edges is labelled with a date. I want to now also label my vertices so that each vertex has a date assigned to it corresponding to the minimum date of all edges incident and emanating from it. Is there an inbuilt function to find this which would be faster than me looping over all v...
2
2016-09-16T12:02:06Z
39,728,831
<p>This discussion (<a href="http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Find-minimum-value-of-edge-property-for-all-edges-connected-to-a-given-node-td4026722.html" rel="nofollow">http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Find-minimum-value-of-edge-prope...
0
2016-09-27T15:37:05Z
[ "python", "graph-tool" ]
Python calling and using windows dll’s
39,531,243
<p>HelloI have to ask 1 question about python and dll functions. which I am a bit frustrated about. The question is can I load dll functions from windows using python? I heard of Ctype to do that, but I can’t find good tutorials for this Is there another way to use dll files from windows to get extra functionali...
-2
2016-09-16T12:12:50Z
39,531,506
<p>Yes you can. The <code>ctypes</code> library is indeed what you need. The official doc is here <a href="https://docs.python.org/3/library/ctypes.html" rel="nofollow">https://docs.python.org/3/library/ctypes.html</a> . Loading DLLs pretty straightforward, but calling the functions inside can be a pain depending on t...
0
2016-09-16T12:26:42Z
[ "python", "windows", "dll", "dllimport" ]
How to use tf.cond in combination with batching operations / queue runners
39,531,367
<h1>Situation</h1> <p>I want to train a specific network architecture (a <a href="https://arxiv.org/abs/1406.2661" rel="nofollow">GAN</a>) that needs inputs from different sources during training.</p> <p>One input source is examples loaded from disk. The other source is a generator sub-network creating examples.</p> ...
0
2016-09-16T12:19:51Z
39,533,583
<p>If you're using a queue when loading your data and follow it up with a batch input then this shouldn't be a problem as you can specify the max amount to have loaded or stored in the queue.</p> <pre><code>input = tf.WholeFileReader(somefilelist) # or another way to load data return tf.train.batch(input,batch_size=10...
0
2016-09-16T14:08:42Z
[ "python", "tensorflow" ]
Using regex to detect a sku
39,531,548
<p>I'm new to regex and I have some trouble dectecting the sku (unique ids) of a product in a column. My skus can take any form: all they have in common basically is:</p> <ol> <li>to be words made of a combination of letters and numbers</li> <li>to have 6 characters</li> </ol> <p>Here is an example of what I have in...
0
2016-09-16T12:28:51Z
39,531,709
<p>If I understand correctly you mean that it must have at least on digit, and at least one letter and be exactly 6 characters... Try</p> <pre><code>^(?=.*\d)(?=.*[a-z])[a-z\d]{6}$ </code></pre> <p>It uses two look-aheads to ensure there's at least one digit and one letter in the string. then it simply matches 6 char...
1
2016-09-16T12:36:07Z
[ "python", "regex" ]
gzip file with splitting the record into columns when the one of the column value in double quote
39,531,607
<p>I have gzip file which contains columns separated by comma, but when the column value is within double quotes the commas should be kept as it is. I wrote the following code:</p> <pre><code> input = gzip.open(file, "rb") reader = codecs.getreader("utf-8") ...
0
2016-09-16T12:31:33Z
39,531,806
<p>Use <a href="https://docs.python.org/2/library/csv.html" rel="nofollow">csv</a>.</p> <p><strong>Demo</strong></p> <pre><code>&gt;&gt;&gt; import StringIO &gt;&gt;&gt; import csv &gt;&gt;&gt; line = '4798151,1137351,nam_p0,2762913,nam_r000,"NAM_Rack, Power &amp; Cooling",3' &gt;&gt;&gt; handler = StringIO.StringIO(...
0
2016-09-16T12:41:35Z
[ "python", "python-2.7" ]
Running a program using tensorflow
39,531,719
<p>I was trying to run a program using a tensoflow installed on a virtual machine but it gives me the following errors and I couldn't be able to get solution from Google :) Can anyone help me with this? Thanks. </p> <p>Here is the error: </p> <pre><code>ImportError: /usr/local/lib/python2.7/dist-packages/tensorflow/p...
0
2016-09-16T12:36:33Z
39,535,210
<p>You most likely installed the wrong version of tensorflow check <a href="https://www.tensorflow.org/versions/r0.10/get_started/os_setup.html" rel="nofollow">the download page</a> and make sure that you installed the version that matches your device.</p>
0
2016-09-16T15:31:24Z
[ "python", "tensorflow" ]
Can't install pycurl==7.19.0 on ubuntu 16.04 python 2.7.12
39,531,891
<p>Ubuntu - 16.04 Python - 2.7.12</p> <p>Hi guys, I'm trying install pycurl==7.19.0 from setup.py, but catch this stack trace:</p> <pre><code>Downloading https://pypi.python.org/packages/11/73/abcfbbb6e1dd7087fa53042c301c056c11264e8a737a4688f834162d731e/pycurl-7.19.0.tar.gz#md5=074cd44079bb68697f5d8751102b384b Best m...
0
2016-09-16T12:46:21Z
39,532,274
<p>Try: <code>sudo apt-get install python-dev</code></p>
-1
2016-09-16T13:05:59Z
[ "python", "pycurl" ]
Can't install pycurl==7.19.0 on ubuntu 16.04 python 2.7.12
39,531,891
<p>Ubuntu - 16.04 Python - 2.7.12</p> <p>Hi guys, I'm trying install pycurl==7.19.0 from setup.py, but catch this stack trace:</p> <pre><code>Downloading https://pypi.python.org/packages/11/73/abcfbbb6e1dd7087fa53042c301c056c11264e8a737a4688f834162d731e/pycurl-7.19.0.tar.gz#md5=074cd44079bb68697f5d8751102b384b Best m...
0
2016-09-16T12:46:21Z
39,533,224
<p>These lines:</p> <pre><code>/usr/bin/ld: cannot find -lidn /usr/bin/ld: cannot find -lrtmp /usr/bin/ld: cannot find -lgssapi_krb5 /usr/bin/ld: cannot find -lkrb5 /usr/bin/ld: cannot find -lk5crypto /usr/bin/ld: cannot find -lcom_err /usr/bin/ld: cannot find -llber /usr/bin/ld: cannot find -llber /usr/bin/ld: cannot...
1
2016-09-16T13:52:08Z
[ "python", "pycurl" ]
Can't install pycurl==7.19.0 on ubuntu 16.04 python 2.7.12
39,531,891
<p>Ubuntu - 16.04 Python - 2.7.12</p> <p>Hi guys, I'm trying install pycurl==7.19.0 from setup.py, but catch this stack trace:</p> <pre><code>Downloading https://pypi.python.org/packages/11/73/abcfbbb6e1dd7087fa53042c301c056c11264e8a737a4688f834162d731e/pycurl-7.19.0.tar.gz#md5=074cd44079bb68697f5d8751102b384b Best m...
0
2016-09-16T12:46:21Z
39,611,274
<p>I don't know, i tried everything, i think that i had problem with pip install, i usually use sudo pip install.... so maybe some libraries don't have permissions to read. I restored snapshot with empty ubuntu and install all libraries again, without 'SUDO' pip install, thanx a lot for all answers.</p>
0
2016-09-21T08:29:23Z
[ "python", "pycurl" ]
Upgrade python 3.4 to 3.5 (latest) in ubuntu 14.04
39,531,917
<p>How to upgrade Python 3.4 to the latest version available on ubuntu 14.04</p>
0
2016-09-16T12:48:04Z
39,531,955
<p>The best way to do it, in my opinion, is using <a href="https://www.continuum.io/downloads" rel="nofollow">ANACONDA</a>. Very, very convenient.</p>
-1
2016-09-16T12:49:57Z
[ "python", "python-2.7", "python-3.x", "ubuntu-14.04" ]
Upgrade python 3.4 to 3.5 (latest) in ubuntu 14.04
39,531,917
<p>How to upgrade Python 3.4 to the latest version available on ubuntu 14.04</p>
0
2016-09-16T12:48:04Z
39,532,081
<p>I would recommend adding an additional installation and not actually upgrading the <code>python3</code> binary past where ubuntu expects it. Anything system use of python that depends on python3.4 but breaks under 3.5, will make your life tough.</p> <p><a href="https://github.com/yyuu/pyenv" rel="nofollow">pyenv</a...
1
2016-09-16T12:55:37Z
[ "python", "python-2.7", "python-3.x", "ubuntu-14.04" ]
Can't run kivy file on Komodo
39,532,034
<p>I'm trying to run a Kivy python file on Komodo IDE (for Mac) but its giving me this error <code>import kivy ImportError: No module named kivy</code> although if I drag-drop the file on the Kivy app its running normally,</p> <p>any ideas ?, thanks</p>
1
2016-09-16T12:53:45Z
39,532,351
<p>Try going to <strong>Edit > Preferences > Languages > Python > Additional Python Import Directories</strong>, and adding the directory where Kivy is installed. I am not sure on a Mac where this would be. To find out, in a python interpreter (or elsewhere - wherever you are able to successfully import <code>kivy</cod...
0
2016-09-16T13:10:08Z
[ "python", "python-3.x", "kivy", "komodo", "kivy-language" ]
Can't run kivy file on Komodo
39,532,034
<p>I'm trying to run a Kivy python file on Komodo IDE (for Mac) but its giving me this error <code>import kivy ImportError: No module named kivy</code> although if I drag-drop the file on the Kivy app its running normally,</p> <p>any ideas ?, thanks</p>
1
2016-09-16T12:53:45Z
39,537,143
<p>This only works for Komodo code intelligence. Run time is still limited to PYTHONPATH. To run a script that's using Kivy, even in your command line, the kivy source has to be on your PYTHONPATH.</p> <p>You can add items to your PYTHONPATH in Komodo using <strong>Edit > Preferences > Environment</strong> then crea...
0
2016-09-16T17:29:02Z
[ "python", "python-3.x", "kivy", "komodo", "kivy-language" ]
Scrapy: Rules set inside __init__ are ignored by CrawlSpider
39,532,119
<p>I've been stuck on this for a few days, and it's making me go crazy.</p> <p>I call my scrapy spider like this:</p> <pre><code>scrapy crawl example -a follow_links="True" </code></pre> <p>I pass in the "follow_links" flag to determine whether the entire website should be scraped, or just the index page I have defi...
0
2016-09-16T12:57:47Z
39,553,044
<p>The problem here is that <code>CrawlSpider</code> constructor (<code>__init__</code>) is also handling the <code>rules</code> parameter, so if you need to assign them, you'll have to do it before calling the default constructor.</p> <p>In other words do everything you need before calling <code>super(ExampleSpider, ...
1
2016-09-18T00:41:27Z
[ "python", "scrapy", "scrapy-spider" ]
Guess Random Number Why i m not able to enter input - python
39,532,171
<p>Below is my code to generate random number between 0 - 9 and checking with user input whether it is higher lower or equal. When I run the code, it is not taking input and showing</p> <blockquote> <p>error in 'guessNumber = int(input("Guess a Random number between 0-9")) File "", line 1 ...
-6
2016-09-16T13:00:27Z
39,532,587
<p>You didn't get the new input into a variable - <code>input(...)</code> needs to be assigned to a variable so you can operate with the input.</p> <p>Use </p> <pre><code>guessNumber = input("You have Guessed the number higher than secretNumber. Guess Again!") </code></pre> <p>When the user guesses higher/ lower num...
0
2016-09-16T13:22:17Z
[ "python" ]
Guess Random Number Why i m not able to enter input - python
39,532,171
<p>Below is my code to generate random number between 0 - 9 and checking with user input whether it is higher lower or equal. When I run the code, it is not taking input and showing</p> <blockquote> <p>error in 'guessNumber = int(input("Guess a Random number between 0-9")) File "", line 1 ...
-6
2016-09-16T13:00:27Z
39,532,833
<p>I think <code>guessRandom()</code> was meant to be outside of the method definition, in order to call the method. The <code>guessNumber</code> variable never changes since the inputs are not assigned to be <code>guessNumber</code>, thus it will continuously check the initial guess. Also, the less than / greater than...
0
2016-09-16T13:33:32Z
[ "python" ]
How can i route my URL to a common method before passing to actual view in Django
39,532,173
<p>Here is my code looks like :-</p> <p>url.py file :-</p> <pre><code>from rest_framework import routers from view_user import user_signup,user_login router = routers.DefaultRouter() urlpatterns = [ url(r'^api/v1/user_signup',csrf_exempt(user_signup)), url(r'^api/v1/user_login',csrf_exempt(user_login)) ] </co...
0
2016-09-16T13:00:29Z
39,532,250
<p>Annotate the concerned views with a <a href="https://wiki.python.org/moin/PythonDecorators" rel="nofollow">decorator</a> that contains the logic you want to execute before the views are called.</p> <p>See <a href="http://stackoverflow.com/questions/20945366/python-decorators">Python - Decorators</a> for a head star...
2
2016-09-16T13:04:46Z
[ "python", "django", "django-models", "django-views", "django-rest-framework" ]
any middleware in django to perform the abilities of security.yml in symfony2?
39,532,334
<p>Can i declare the auth for all the apis in django, group wise from one file just like <a href="http://symfony.com/doc/current/security/access_control.html" rel="nofollow">security.yml</a> allows us in symfony2</p>
0
2016-09-16T13:08:27Z
39,534,886
<p>Have a look at the package <a href="https://github.com/mgrouchy/django-stronghold" rel="nofollow">django-stronghold</a>. It allows you to require login for all views.</p>
1
2016-09-16T15:13:53Z
[ "python", "django", "symfony2", "django-middleware" ]
Python 3 changing variable in function from another function
39,532,350
<p>I would like to access the testing variable in main from testadder, such that it will add 1 to testing after testadder has been called in main.</p> <p>For some reason I can add 1 to a list this way, but not variables. The nonlocal declaration doesn't work since the functions aren't nestled.</p> <p>Is there a way t...
1
2016-09-16T13:10:08Z
39,532,489
<p>Lists are mutable, but integers are not. Return the modified variable and reassign it. </p> <pre><code>def testadder(test, testing): test.append(1) return testing + 1 def main(): test = [] testing = 1 testing = testadder(test, testing) print(test, testing) main() </code></pre>
1
2016-09-16T13:16:44Z
[ "python", "python-3.x", "python-nonlocal" ]
Find index position of characters in string
39,532,420
<p>I am trawling through a storage area and the paths look a lot like this: storagearea/storage1/ABC/ABCDEF1/raw/2013/05/ABCFGM1 </p> <p>I wont always know what year is it. I need to find the starting index position of the year </p> <p>Therefor I am looking for where I find the following in the file name (2010, 2011...
-3
2016-09-16T13:12:57Z
39,532,482
<p><a href="https://docs.python.org/2/library/string.html#string.index" rel="nofollow">Python string.index</a></p> <pre><code>string.index(s, sub[, start[, end]])¶ Like find() but raise ValueError when the substring is not found. </code></pre>
0
2016-09-16T13:16:24Z
[ "python" ]
Find index position of characters in string
39,532,420
<p>I am trawling through a storage area and the paths look a lot like this: storagearea/storage1/ABC/ABCDEF1/raw/2013/05/ABCFGM1 </p> <p>I wont always know what year is it. I need to find the starting index position of the year </p> <p>Therefor I am looking for where I find the following in the file name (2010, 2011...
-3
2016-09-16T13:12:57Z
39,532,795
<p>Instead of using a generator expression (which has its own scope), use a traditional loop and then print the found word's index and <code>break</code> when you find a match:</p> <pre><code>list_ = ['2010', '2011','2012','2013','2014', '2015', '2016'] for word in list_: if word in file: print file.index(...
1
2016-09-16T13:32:04Z
[ "python" ]
Find index position of characters in string
39,532,420
<p>I am trawling through a storage area and the paths look a lot like this: storagearea/storage1/ABC/ABCDEF1/raw/2013/05/ABCFGM1 </p> <p>I wont always know what year is it. I need to find the starting index position of the year </p> <p>Therefor I am looking for where I find the following in the file name (2010, 2011...
-3
2016-09-16T13:12:57Z
39,532,800
<p>I'd suggest <code>join</code>ing those years to a <a href="https://docs.python.org/3/library/re.html" rel="nofollow">regular expression</a> using <code>'|'</code> as a delimiter...</p> <pre><code>&gt;&gt;&gt; list_ = ['2010', '2011','2012','2013','2014', '2015', '2016'] &gt;&gt;&gt; p = "|".join(list_) &gt;&gt;&gt;...
1
2016-09-16T13:32:17Z
[ "python" ]
Why does Python call both functions?
39,532,534
<p>I have some problems to understand what happens here.</p> <p>This is my source:</p> <pre><code>class Calc(): def __init__(self,Ideal,Limit,Value,Debug=None): self.Ideal = Ideal self.Limit = Limit self.Value = Value self.Debug = Debug self.Grade = self.GetGrade() ...
-7
2016-09-16T13:18:58Z
39,532,578
<p>You create an instance of <code>Calc()</code>, and whenever you do that, <code>Calc.__init__()</code> is called for that new instance.</p> <p>Your <code>Calc.__init__()</code> method calls both <code>self.GetGrade()</code> and <code>self.GetLenGrade()</code>:</p> <pre><code>self.Grade = self.GetGrade() self.LenGra...
2
2016-09-16T13:21:44Z
[ "python" ]
Why does Python call both functions?
39,532,534
<p>I have some problems to understand what happens here.</p> <p>This is my source:</p> <pre><code>class Calc(): def __init__(self,Ideal,Limit,Value,Debug=None): self.Ideal = Ideal self.Limit = Limit self.Value = Value self.Debug = Debug self.Grade = self.GetGrade() ...
-7
2016-09-16T13:18:58Z
39,532,604
<p>In your object initialisation code, you have the following:</p> <pre><code>self.Grade = self.GetGrade() self.LenGrade = self.GetLenGrade() </code></pre> <p>This means "set the value of the data member Grade to the value obtained by calling the method GetGrade" and the same for LenGrade.</p> <p>It should not be su...
1
2016-09-16T13:23:04Z
[ "python" ]
raise exception wave python
39,532,555
<p>I use the wave module for example .</p> <pre><code> import wave origAudio = wave.open("son.wav",'r') </code></pre> <p>get output </p> <pre><code> raise Error, 'file does not start with RIFF id' wave.Error: file does not start with RIFF id </code></pre> <p>I know the file is not good,but I ...
0
2016-09-16T13:20:22Z
39,533,124
<p>If you wish to continue after an expection has been raised you must catch it:</p> <pre><code> import wave try: origAudio = wave.open("son.wav",'r') except wave.Error as e: # if you get here it means an error happende, maybe you should warn the user # but doing pass will silently ignore it pass </code>...
1
2016-09-16T13:48:23Z
[ "python", "exception", "wave" ]
How can I save and read variable size images in TensorFlow's protobuf format
39,532,568
<p>I'm trying to write variable size images in TensorFlow's protobuf format with the following code:</p> <pre><code>img_feature = tf.train.Feature( bytes_list=tf.train.BytesList(value=[ img.flatten().tostring()])) # Define how the sequence length is stored seq_len_feature = tf.train.Feature( int64_list...
0
2016-09-16T13:21:02Z
39,579,574
<p>First, I was not able to reproduce the error. The following code works just fine:</p> <pre><code>import tensorflow as tf import numpy as np image_height = 100 img = np.random.randint(low=0, high=255, size=(image_height,200), dtype='uint8') IMG_FEATURE_NAME = 'image/raw' with tf.Graph().as_default(): img_feature...
0
2016-09-19T18:11:28Z
[ "python", "tensorflow", "protocol-buffers" ]
insert key-pair value into nested dict without overwriting after delimiter of key which produce duplicate key
39,532,609
<p>Assume that I have a nested dict like:</p> <pre><code>D={'Germany': {'1972-05-23': 'test1', '1969-12-27': 'test2'}, 'Morocco|Germany': {'1978-01-14':'test3'}} </code></pre> <p>I want to get a new dict like:</p> <pre><code>{'Germany': {'1972-05-23': 'test1', '1969-12-27': 'test2', '1978-01-14':'test3'} 'Morocc...
1
2016-09-16T13:23:12Z
39,532,658
<p>you could use:</p> <pre><code>if not index in new_dict: new_dict[index] = {} new_dict[index].update(D[item]) </code></pre>
2
2016-09-16T13:25:28Z
[ "python", "dictionary", "split", "overwrite" ]
Changing PYTHONHOME causes ImportError: No module named site
39,532,705
<p>I am trying to deploy a Flask web app via mod_wsgi on Apache. I cannot use the default Python environment because it was compiled with UCS-2 Unicode instead of UCS-4, and I cannot recompile it for this one case. Thus, a virtual environment. Virtual environments would have been used anyway, but that error means that ...
0
2016-09-16T13:27:55Z
39,580,230
<p>Resolution found: The issue seems to have been in trying to use a virtual environment built from something other than the local python install on the system.</p> <p>Solved by pushing the problem of "local python install on the deployment VM doesn't have pip installed" up the chain to someone with the permissions re...
0
2016-09-19T18:57:28Z
[ "python", "centos", "mod-wsgi", "fabric", "importerror" ]
Using python to send email through TLS
39,532,708
<p>I am trying to automate sending email through a python script. I am presently using an expect script to use openssl s_client to connect to the server. Presently we only use a certificate file along with the username password and it allows me to send the email. I found another question in which it was mentioned that ...
0
2016-09-16T13:28:14Z
39,532,826
<p>You need to remove the key pass phrase first using -</p> <pre><code>openssl rsa -in key.pem -out tempkey.pem </code></pre> <p>And then type passphrase once more - </p> <pre><code>openssl rsa -in mycert.pem -out tempkey.pem openssl x509 -in mycert.pem &gt;&gt;tempkey.pem </code></pre> <p>Refer <a href="https://ww...
0
2016-09-16T13:33:16Z
[ "python", "email", "ssl" ]
Using python to send email through TLS
39,532,708
<p>I am trying to automate sending email through a python script. I am presently using an expect script to use openssl s_client to connect to the server. Presently we only use a certificate file along with the username password and it allows me to send the email. I found another question in which it was mentioned that ...
0
2016-09-16T13:28:14Z
39,533,435
<blockquote> <pre><code>smtpobj = smtplib.SMTP("mymailserver.com",465) smtplib.SMTPServerDisconnected: Connection unexpectedly closed: [WinError 10054] An existing connection was forcibly closed by the remote host </code></pre> </blockquote> <p>This error has nothing to do with validation of the certificate. It is sim...
0
2016-09-16T14:01:50Z
[ "python", "email", "ssl" ]
Alternative data model to using sorted set in redis (for a Django/Python project)
39,532,732
<p>I have a web application where users post text messages for others to read (kind of like Twitter).</p> <p>I need to save the 50 latest <code>message_id</code> and the poster's <code>user_id</code> pairs (for processing later). I use redis backend and realized I can save these 50 latest pairs in a sorted set: <code>...
0
2016-09-16T13:29:18Z
39,533,735
<p>First, i think that you misunderstood the "NX" flag meaning. That is the sorted <strong>set</strong> - you can't have the same values with different scores. The "NX" flag only ensures, that if you will try to add value again with different score, then it will not modify the score of the existing element.</p> <p>You...
1
2016-09-16T14:15:29Z
[ "python", "redis" ]
Python BS4 with SDMX
39,532,776
<p>I would like to retrieve data given in a SDMX file (like <a href="https://www.bundesbank.de/cae/servlet/StatisticDownload?tsId=BBK01.ST0304&amp;its_fileFormat=sdmx&amp;mode=its" rel="nofollow">https://www.bundesbank.de/cae/servlet/StatisticDownload?tsId=BBK01.ST0304&amp;its_fileFormat=sdmx&amp;mode=its</a>). I tried...
0
2016-09-16T13:31:21Z
39,533,371
<p><code>soup.findAll("bbk:series")</code> would return the result.</p> <p>In fact, in this case, even you use <code>lxml</code> as the parser, BeautifulSoup still parse it as html, since html tags are case insensetive, BeautifulSoup downcases all the tags, thus <code>soup.findAll("bbk:series")</code> works. See <a hr...
0
2016-09-16T13:58:47Z
[ "python", "python-2.7", "xml-parsing", "bs4" ]
Remove final characters from string recursively - What's the best way to do this?
39,532,974
<p>I am reading lines from a file one at a time and before i store each, i wanna modify them according to the following simple rule:</p> <ul> <li>if the last character is not any of, e.g., <code>{'a', 'b', 'c'}</code> store the line.</li> <li>if that is not the case, remove the character (pop-like) and check again.</l...
3
2016-09-16T13:40:23Z
39,533,040
<p>Not the direct answer to the question, but one alternative option would be to use <em>regular expressions</em> to remove the bad characters at the end of the string:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; &gt;&gt;&gt; example_line = 'jkhasdkjashdasjkd|abbbabbababcbccc' &gt;&gt;&gt; bad_chars = {'a', 'b'...
2
2016-09-16T13:44:01Z
[ "python" ]
Remove final characters from string recursively - What's the best way to do this?
39,532,974
<p>I am reading lines from a file one at a time and before i store each, i wanna modify them according to the following simple rule:</p> <ul> <li>if the last character is not any of, e.g., <code>{'a', 'b', 'c'}</code> store the line.</li> <li>if that is not the case, remove the character (pop-like) and check again.</l...
3
2016-09-16T13:40:23Z
39,533,254
<p>I understand what you mean by <em>excessive</em>, but I think in general, it looks good. The alternative would be to work with indices, which is not very readable. (I also happen to think that regexes are not very readable either...)</p> <p>You could, however, use a <code>memoryview</code> if you have a <code>bytes...
1
2016-09-16T13:53:44Z
[ "python" ]
Remove final characters from string recursively - What's the best way to do this?
39,532,974
<p>I am reading lines from a file one at a time and before i store each, i wanna modify them according to the following simple rule:</p> <ul> <li>if the last character is not any of, e.g., <code>{'a', 'b', 'c'}</code> store the line.</li> <li>if that is not the case, remove the character (pop-like) and check again.</l...
3
2016-09-16T13:40:23Z
39,533,264
<p>Slicing creates lots of unnecessary temporary copies of string. Recursion would be even worse - copies would still be made, and on top of it function call overhead would be intruduced. Both approaches are not that great.</p> <p>You may find an <code>rstrip</code> implementation in <a href="https://github.com/python...
2
2016-09-16T13:54:12Z
[ "python" ]
Remove final characters from string recursively - What's the best way to do this?
39,532,974
<p>I am reading lines from a file one at a time and before i store each, i wanna modify them according to the following simple rule:</p> <ul> <li>if the last character is not any of, e.g., <code>{'a', 'b', 'c'}</code> store the line.</li> <li>if that is not the case, remove the character (pop-like) and check again.</l...
3
2016-09-16T13:40:23Z
39,533,365
<p>Another nearly fast approach to <code>re.sub</code> albeit more intuitive (<em>it sounds like the <code>pop</code> you're asking for</em>) is <a href="https://docs.python.org/2/library/itertools.html#itertools.dropwhile" rel="nofollow"><code>itertools.dropwhile</code></a>:</p> <blockquote> <p>Make an iterator tha...
4
2016-09-16T13:58:32Z
[ "python" ]
Python function redefines variables that are not passed
39,532,978
<p>I made a function that operates on a numpy array of latitude/longitude values. </p> <pre><code>from __future__ import division, print_function import pandas as pd, numpy as np def regrid2(lats, lons, lat_res=0.25, lon_res=0.25): # round lat/lon values to nearest decimal degree according to specified # ...
0
2016-09-16T13:40:56Z
39,533,339
<p>You're passing mutable data to the function, then mutating it. </p> <p>You could use </p> <pre><code>def regrid2(lats, lons, lat_res=0.25, lon_res=0.25): lats, lons = np.copy(lats), np.copy(lons) </code></pre> <p>to work with copies instead?</p>
1
2016-09-16T13:57:34Z
[ "python", "arrays", "pandas", "numpy" ]
Issues in Plotting Intraday OHLC Chart with Matplotlib
39,533,004
<p>I am trying to plot OHLC candlestick chart (1Min) for complete one day and want to show 'Hours' as Major locator and Min as minor locator. Hour locator should be displayed as till end of data Major Locator 09:00 10:00 11:00 and so on.</p> <p><a href="http://i.stack.imgur.com/3K6A9.png" rel="nofollow"><img src="http...
0
2016-09-16T13:42:05Z
39,536,333
<p>I was doing mistake in defining the xlimits and width in the plotting of graph. I fixed after reading documentation and some hit and trial and got the output as desired. <a href="http://i.stack.imgur.com/nZkdy.png" rel="nofollow"><img src="http://i.stack.imgur.com/nZkdy.png" alt="enter image description here"></a></...
0
2016-09-16T16:35:33Z
[ "python", "pandas", "numpy", "matplotlib", "plot" ]
Handling a timeout exception in Python
39,533,022
<p>I'm looking for a way to handle timeout exceptions for my Reddit bot which uses PRAW (Python). It times out at least once every day, and it has a variable coded in so I have to update the variable and then manually run the bot again. I am looking for a way to automatically handle these exceptions. I looked into try:...
1
2016-09-16T13:43:05Z
39,533,139
<p>It depends on what you want to do when a timeout occurs.</p> <p>you can make a <code>pass</code> to do nothing and continue with the loop.</p> <pre><code>try: run_bot() except: pass </code></pre> <p>In your case it would be better to write it explicitly as </p> <pre><code>try: run_bot() except: c...
1
2016-09-16T13:48:58Z
[ "python", "exception", "timeout", "handle", "praw" ]
Handling a timeout exception in Python
39,533,022
<p>I'm looking for a way to handle timeout exceptions for my Reddit bot which uses PRAW (Python). It times out at least once every day, and it has a variable coded in so I have to update the variable and then manually run the bot again. I am looking for a way to automatically handle these exceptions. I looked into try:...
1
2016-09-16T13:43:05Z
39,534,278
<p>Moving the sleep to finally will solve your issue, I guess. finally block will run irrespective of whether there is an exception happened or not.</p> <pre><code>def run_bot(): # Arbitrary Bot Code Here # This is at the bottom of the code, and it runs the above arbitrary code every 10 seconds while True: ...
0
2016-09-16T14:43:57Z
[ "python", "exception", "timeout", "handle", "praw" ]
Difference between chain(*iter) vs chain.from_iterable(iter)
39,533,052
<p>I have been really fascinated by all the interesting iterators in itertools and one confusion I have had is the difference between these two functions and why chain.from_iterator exists.</p> <pre><code>from itertools import chain def foo(n): for i in range(n): yield [i, i**2] chain(*foo(5)) chain.fro...
4
2016-09-16T13:44:41Z
39,533,104
<p><code>chain(*foo(5))</code> unpacks the whole generator, packs it into a tuple and processes it then.</p> <p><code>chain.from_iterable(foo(5))</code> queries the generator created from <code>foo(5)</code> value for value.</p> <p>Try <code>foo(1000000)</code> and watch the memory usage go up and up.</p>
4
2016-09-16T13:47:37Z
[ "python" ]
Difference between chain(*iter) vs chain.from_iterable(iter)
39,533,052
<p>I have been really fascinated by all the interesting iterators in itertools and one confusion I have had is the difference between these two functions and why chain.from_iterator exists.</p> <pre><code>from itertools import chain def foo(n): for i in range(n): yield [i, i**2] chain(*foo(5)) chain.fro...
4
2016-09-16T13:44:41Z
39,533,108
<p><code>*</code> unpacks the iterator, meaning it iterates the iterator in order to pass its values to the function. <code>chain.from_iterable</code> iterates the iterator one by one lazily.</p>
1
2016-09-16T13:47:53Z
[ "python" ]
Difference between chain(*iter) vs chain.from_iterable(iter)
39,533,052
<p>I have been really fascinated by all the interesting iterators in itertools and one confusion I have had is the difference between these two functions and why chain.from_iterator exists.</p> <pre><code>from itertools import chain def foo(n): for i in range(n): yield [i, i**2] chain(*foo(5)) chain.fro...
4
2016-09-16T13:44:41Z
39,533,120
<p>The former can only handle unpackable iterables. The latter can handle iterables that cannot be fully unpacked, such as infinite generators.</p> <p>Consider</p> <pre><code>&gt;&gt;&gt; from itertools import chain &gt;&gt;&gt; def inf(): ... i=0 ... while True: ... i += 1 ... yield i ... &g...
4
2016-09-16T13:48:13Z
[ "python" ]
Python/CSV unique rows with unique values per row in a column
39,533,144
<p>Have this dataset, dataset is fictional:</p> <pre><code>cat sample.csv id,fname,lname,education,gradyear,attributes "6F9619FF-8B86-D011-B42D-00C04FC964FF",john,smith,mit,2003,qa "6F9619FF-8B86-D011-B42D-00C04FC964FF",john,smith,harvard,2007,"test|admin,test" "6F9619FF-8B86-D011-B42D-00C04FC964FF",john,smith,harva...
1
2016-09-16T13:49:10Z
39,534,032
<p>Your first file is sorted, while the second is not. Please see <a href="http://stackoverflow.com/questions/8116666/itertools-groupby">this discussion</a></p> <p>All you need is this:</p> <pre><code>t = list(t) t[1:] = sorted(t[1:]) </code></pre>
1
2016-09-16T14:31:21Z
[ "python", "csv" ]
Python/CSV unique rows with unique values per row in a column
39,533,144
<p>Have this dataset, dataset is fictional:</p> <pre><code>cat sample.csv id,fname,lname,education,gradyear,attributes "6F9619FF-8B86-D011-B42D-00C04FC964FF",john,smith,mit,2003,qa "6F9619FF-8B86-D011-B42D-00C04FC964FF",john,smith,harvard,2007,"test|admin,test" "6F9619FF-8B86-D011-B42D-00C04FC964FF",john,smith,harva...
1
2016-09-16T13:49:10Z
39,534,237
<p>Here's my simple minded solution to your problem (as I understand it), using a dictionary:</p> <pre><code>import csv t = csv.reader(open("sample2.csv", 'rb')) t = list(t) def parsecsv(data): # Assumes that the first column is the unique id and that the first # row contains the column titles and that all...
0
2016-09-16T14:42:01Z
[ "python", "csv" ]
Python and RSS feeds - parse feeder
39,533,226
<p>I'm using feed parser in python and I'm a beginner in python.</p> <pre><code>for post in d.entries: if test_word3 and test_word2 in post.title: print(post.title) </code></pre> <p>What I'm trying to do is make feed parser find a couple of words inside titles in the RSS feeds.</p>
0
2016-09-16T13:52:11Z
39,579,777
<p>Note that <strong>and</strong> does not distribute across the <strong>in</strong> operator.</p> <pre><code>if test_word3 in post.title and test_word2 in post.title: </code></pre> <p>should solve your problem. What you wrote is evaluated as</p> <pre><code>if test_word3 and (test_word2 in post.title): </code></...
0
2016-09-19T18:26:12Z
[ "python", "parsing", "rss", "feed", "feedparser" ]
How to export regression tree with two features as matrix?
39,533,229
<p>I have a problem which is suitable for the application of a regression tree. The final result needs to be in matrix, though, not a tree. Is there an easy way in R or Python to export a regression tree which has only two features (in my case weight and distance) to a matrix where rows would be the weight classes, col...
-1
2016-09-16T13:52:22Z
39,548,993
<p>I don't really know what you mean by "exporting the tree to a matrix"; I have no idea how a regression tree could be represented as a matrix. I guess you want to show the prediction of the tree for multiple combinations of your (two) features/input variables?</p> <p>If so, you need first need to create all combinat...
0
2016-09-17T16:16:06Z
[ "python", "matrix", "tree", "regression" ]
Django - Get data from a form that is not a django.form
39,533,387
<p>I am working with Django in order to do a quite simple web application. </p> <p>I am currently trying to have a succession of forms so that the user completes the information bits by bits. I first tried to do it only in HTML because I wanted to really have the hand on the presentation. Here is my code. </p> <p>I ...
0
2016-09-16T13:59:36Z
39,533,446
<p>Your field in your form in your template has to have name attribute in order to pass it to your request.</p> <p>Then you will be able to get it in your view like this:</p> <p><code>site_name = request.POST.get('site_name')</code></p>
2
2016-09-16T14:02:11Z
[ "python", "html", "django", "forms" ]
Django - Get data from a form that is not a django.form
39,533,387
<p>I am working with Django in order to do a quite simple web application. </p> <p>I am currently trying to have a succession of forms so that the user completes the information bits by bits. I first tried to do it only in HTML because I wanted to really have the hand on the presentation. Here is my code. </p> <p>I ...
0
2016-09-16T13:59:36Z
39,533,575
<p>Your form field needs a name attribute.</p> <pre><code> &lt;input id="site_name" name="site_name" class="form-control" placeholder="Name" required="" autofocus="" type="text"&gt; </code></pre> <p>Alternatively, if you want to use Django forms, you can set the CSS class of a form field by explicitly defi...
1
2016-09-16T14:08:12Z
[ "python", "html", "django", "forms" ]
Access Common Block variables from ctypes
39,533,409
<p>I am trying to access the data stored in a Fortran 77 common block from a Python script. The question is that I don't know where this data is stored. The Python application that I am developing makes use of different libraries. These libraries contain functions with the following directives:</p> <pre><code>#include...
0
2016-09-16T14:00:31Z
39,540,375
<p>According to <a href="http://www.yolinux.com/TUTORIALS/LinuxTutorialMixingFortranAndC.html" rel="nofollow">this page</a> (particularly how to access Fortran common blocks from C) and some <a href="http://stackoverflow.com/questions/35346835/how-to-access-to-c-global-variable-structure-by-python-and-ctype">Q/A page</...
2
2016-09-16T21:32:12Z
[ "python", "fortran", "ctypes" ]
Bokeh server and on.click (on.change) doing nothing
39,533,452
<p>I am trying to get Bokeh server to print out, however all I get is an instance running on <a href="http://localhost:5006/?bokeh-session-id=default" rel="nofollow">http://localhost:5006/?bokeh-session-id=default</a> with the radio buttons. When I click the buttons nothing happens. Is there something I am missing?</p>...
0
2016-09-16T14:02:21Z
39,533,971
<p>You need to sync the server and the current session to get informations back.</p> <pre><code>from bokeh.client import push_session from bokeh.models.widgets import RadioButtonGroup from bokeh.plotting import curdoc, figure, show, output_server def my_radio_handler(new): print 'Radio button ' + str(new) + ' op...
1
2016-09-16T14:27:28Z
[ "python", "bokeh" ]
Bokeh server and on.click (on.change) doing nothing
39,533,452
<p>I am trying to get Bokeh server to print out, however all I get is an instance running on <a href="http://localhost:5006/?bokeh-session-id=default" rel="nofollow">http://localhost:5006/?bokeh-session-id=default</a> with the radio buttons. When I click the buttons nothing happens. Is there something I am missing?</p>...
0
2016-09-16T14:02:21Z
39,535,545
<p>The answer above shows how this can properly be accomplished with <code>bokeh.client</code> and <code>push_session</code> and <code>session.loop_until_closed</code>.</p> <p>I'd like to add a few more comments for context. (I am a core developer of the Bokeh project)</p> <p>There are two general ways that Bokeh app...
1
2016-09-16T15:50:37Z
[ "python", "bokeh" ]
Python Web Scraping - Table with Dynamic Data
39,533,543
<p>I want to scrape data from a dynamic changing table.</p> <p>The table is empty when you first open the website, but gets updated every 1-2 seconds with new values.</p> <p>I tried doing that with the requests and lxml python package (Hitchiker's Guide to Python), but I only get the empty table. </p> <p>Then I did ...
0
2016-09-16T14:06:52Z
39,533,658
<p>Instead of starting up a new browser every time, why not use something similar to <a href="http://phantomjs.org/" rel="nofollow">PhantomJS</a>. It would speed up your code with Selenium. Or try <a href="https://github.com/scrapinghub/splash" rel="nofollow">Splash</a> with Scrappy instead of Selenium. At the end of t...
0
2016-09-16T14:11:41Z
[ "python", "selenium" ]
PyopenCL 3D RGBA image from numpy array
39,533,635
<p>I want to construct an OpenCL 3D RGBA image from a numpy array, using pyopencl. I know about the <code>cl.image_from_array()</code> function, that basically does exactly that, but doesn't give any control about command queues or events, that is exposed by <code>cl.enqueue_copy()</code>. So I really would like to use...
1
2016-09-16T14:10:57Z
39,637,325
<p>I adapted the <code>cl.image_from_array()</code> function to be able to return an event, which was basically straightforward:</p> <pre><code>def p_Array(queue_s, name, ary, num_channels=4, mode="w", norm_int=False,copy=True): q = eval(queue_s) if not ary.flags.c_contiguous: raise ValueError("array m...
0
2016-09-22T11:06:46Z
[ "python", "image", "numpy", "opencl", "pyopencl" ]
Unable to Install Python Package
39,533,880
<p>In trying to install a python package via pip I get the error:</p> <pre><code> Failed building wheel for atari-py Running setup.py clean for atari-py Failed to build atari-py Installing collected packages: atari-py, PyOpenGL Running setup.py install for atari-py ... error Complete output from command C:\Us...
0
2016-09-16T14:22:34Z
39,533,991
<p><code>make</code> is not in your PATH. Do <code>echo %PATH%</code> and check if the path to your msys utilities is in there. Otherwise you can edit this variable by following the instructions here: <a href="https://stackoverflow.com/questions/9546324/adding-directory-to-path-environment-variable-in-windows">Adding d...
1
2016-09-16T14:28:30Z
[ "python", "windows", "pip", "mingw", "anaconda" ]
How to dump YAML with explicit references?
39,534,101
<p>Recursive references work great in <code>ruamel.yaml</code> or <code>pyyaml</code>: </p> <pre><code>$ ruamel.yaml.dump(ruamel.yaml.load('&amp;A [ *A ]')) '&amp;id001 - *id001' </code></pre> <p>However it (obviously) does not work on normal references: </p> <pre><code>$ ruamel.yaml.dump(ruamel.yaml.load("foo: &amp...
2
2016-09-16T14:34:47Z
39,535,871
<p>If you want to create something like that, at least in ruamel.yaml ¹, you should use round-trip mode, which also preserves the merges. The following doesn't throw an assertion error:</p> <pre><code>import ruamel.yaml yaml_str = """\ foo: &amp;xyz a: 42 bar: &lt;&lt;: *xyz """ data = ruamel.yaml.round_trip_lo...
2
2016-09-16T16:06:53Z
[ "python", "yaml", "pyyaml", "ruamel.yaml" ]
change index value in pandas dataframe
39,534,129
<p>How can I change the value of the index in a pandas dataframe?</p> <p>for example, from this:</p> <pre><code>In[1]:plasmaLipo Out[1]: Chyloquantity ChyloSize VLDLquantity VLDLSize LDLquantity \ Sample 1010107 1.07 87.0 ...
1
2016-09-16T14:36:21Z
39,534,260
<p>You can convert the index to <code>str</code> dtype using <code>astype</code> and then slice the string values, cast back again using <code>astype</code> and overwrite the index attribute:</p> <pre><code>In [30]: df.index = df.index.astype(str).str[:4].astype(int) df Out[30]: Chyloquantity ChyloSize VLDL...
0
2016-09-16T14:43:17Z
[ "python", "pandas" ]
Adding data to an existing apache spark dataframe from a csv file
39,534,214
<p>i have a spark dataframe that has two columns: name, age as follows:</p> <pre><code>[Row(name=u'Alice', age=2), Row(name=u'Bob', age=5)] </code></pre> <p>The dataframe was created using </p> <pre><code>sqlContext.createDataFrame() </code></pre> <p>What i need to do next is to add a third column 'UserId' from an ...
-1
2016-09-16T14:40:36Z
39,534,990
<p>You can do this by join of two data frame but for that you need to have in booth tables either ids or other keys. I would suggest to just copy it to an excel file if the location of lines is the same other wise you do not have enough information to merge them.</p>
0
2016-09-16T15:19:27Z
[ "python", "apache-spark", "pyspark", "spark-dataframe" ]
Adding data to an existing apache spark dataframe from a csv file
39,534,214
<p>i have a spark dataframe that has two columns: name, age as follows:</p> <pre><code>[Row(name=u'Alice', age=2), Row(name=u'Bob', age=5)] </code></pre> <p>The dataframe was created using </p> <pre><code>sqlContext.createDataFrame() </code></pre> <p>What i need to do next is to add a third column 'UserId' from an ...
-1
2016-09-16T14:40:36Z
39,537,578
<p>I used pandas to make this work. It allows to join dataframes in many different ways.</p> <p>1) We need first to import only that extra column (after we remove headers, although this can also be done after the import) and convert it into an RDD</p> <pre><code>from pyspark.sql.types import StringType from pyspark i...
0
2016-09-16T18:01:03Z
[ "python", "apache-spark", "pyspark", "spark-dataframe" ]
how can I save super large array into many small files?
39,534,246
<p>In linux 64bit environment, I have very big float64 array (single one will be 500GB to 1TB). I would like to access these arrays in numpy with uniform way: a[x:y]. So I do not want to access the array as segments file by file. Is there any tools that I can create memmap over many different files? Can hdf5 or pytable...
1
2016-09-16T14:42:22Z
39,534,448
<p>I would use hdf5. In h5py, you can specify a chunk size which makes retrieving small pieces of the array efficient:</p> <p><a href="http://docs.h5py.org/en/latest/high/dataset.html?#chunked-storage" rel="nofollow">http://docs.h5py.org/en/latest/high/dataset.html?#chunked-storage</a></p>
1
2016-09-16T14:52:57Z
[ "python", "numpy", "filesystems", "hdf5", "pytables" ]
how can I save super large array into many small files?
39,534,246
<p>In linux 64bit environment, I have very big float64 array (single one will be 500GB to 1TB). I would like to access these arrays in numpy with uniform way: a[x:y]. So I do not want to access the array as segments file by file. Is there any tools that I can create memmap over many different files? Can hdf5 or pytable...
1
2016-09-16T14:42:22Z
39,539,165
<p>You can use <a href="http://dask.pydata.org/en/latest/index.html" rel="nofollow"><code>dask</code></a>. <code>dask</code> <a href="http://dask.pydata.org/en/latest/array.html" rel="nofollow">arrays</a> allow you to create an object that behaves like a single big numpy array but represents the data stored in <a href...
1
2016-09-16T19:51:35Z
[ "python", "numpy", "filesystems", "hdf5", "pytables" ]
Storing data from a tag in Python with BeautifulSoup4
39,534,371
<p>Using BeautifulSoup4, I can isolate: </p> <pre><code>&lt;a href="#" data-nutrition="{ &amp;quot;serving-name&amp;quot;:&amp;quot;Milk, 2%&amp;quot;, &amp;quot;serving-size&amp;quot;:&amp;quot;16 FL OZ&amp;quot;, &amp;quot;calories&amp;quot;:&amp;quot;267&amp;quot;}"&gt; Milk, 2% &lt;i class="icon-leaf i...
1
2016-09-16T14:48:43Z
39,534,409
<p>Locate the element and use <a href="https://docs.python.org/2/library/json.html#json.loads" rel="nofollow"><code>json.loads()</code></a> to load the <code>data-nutrition</code> attribute value into the Python dictionary:</p> <pre><code>import json from bs4 import BeautifulSoup data = """ &lt;a href="#" data-nutri...
1
2016-09-16T14:50:59Z
[ "python", "beautifulsoup" ]
Python Numpy - Reading elements of a Vector Numpy Array as numerical values rather than as Numpy Arrays
39,534,395
<p>Suppose I have a Numpy Array that has dimensions of nx1 (n rows, 1 column). My usage of this is for implementing 3D vectors as 3x1 Matrices using Numpy, but the application can be extended for nx1 Vector Matrices:</p> <pre><code>In [0]: import numpy as np In [1]: foo = np.array([ ['a11'], ['a21'], ['a31'], ..., ['...
0
2016-09-16T14:50:11Z
39,534,644
<p>You could use the <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tolist.html" rel="nofollow">numpy.ndarray.tolist()</a> function:</p> <pre><code>In [1]: foo = np.array([ ['a11'], ['a21'], ['a31'] ]) In [2]: foo.tolist() Out[2]: [['an1'], ['a2n'], ['a3n']] In [3]: foo.tolist()[0] Out[3]:...
0
2016-09-16T15:01:51Z
[ "python", "arrays", "numpy", "vector", "dereference" ]
Python Numpy - Reading elements of a Vector Numpy Array as numerical values rather than as Numpy Arrays
39,534,395
<p>Suppose I have a Numpy Array that has dimensions of nx1 (n rows, 1 column). My usage of this is for implementing 3D vectors as 3x1 Matrices using Numpy, but the application can be extended for nx1 Vector Matrices:</p> <pre><code>In [0]: import numpy as np In [1]: foo = np.array([ ['a11'], ['a21'], ['a31'], ..., ['...
0
2016-09-16T14:50:11Z
39,535,125
<p>Your <code>foo</code> is a 2d array of strings:</p> <pre><code>In [354]: foo = np.array([ ['a11'], ['a21'], ['a31'], ['an1'] ]) In [355]: foo.shape Out[355]: (4, 1) In [356]: foo[0] # selects a 'row' Out[356]: array(['a11'], dtype='&lt;U3') In [357]: foo[0,:] # or more explicitly with the column : Out[...
0
2016-09-16T15:26:26Z
[ "python", "arrays", "numpy", "vector", "dereference" ]
scrollbar does not work in recent chaco releases
39,534,402
<p>This program was running fine in chaco 3.2, but with chaco 4, scrollbar does not show at all.</p> <p>I would like either to find the problem or find a workaround.</p> <p>PanTool may be a workaround, but this will conflict with some linecursors used with mouse.</p> <pre><code>#!/usr/bin/env python # Major library...
0
2016-09-16T14:50:33Z
39,992,297
<p>We investigated and found some problems in the code of enable api (<a href="https://github.com/enthought/enable" rel="nofollow">https://github.com/enthought/enable</a>), that had disallowed the scrollbar to display in wx backend.</p> <p>The following patch solves the problem.</p> <p>There are other issues, like he...
0
2016-10-12T06:56:26Z
[ "python", "plot", "enthought", "chaco" ]
Simple Radius server on Python
39,534,494
<p>I am new to python and I am trying to use the python library pyrad ( <a href="https://github.com/wichert/pyrad" rel="nofollow">https://github.com/wichert/pyrad</a> ) to implement a very simple Radius server to test one application. The only thing it has to do is to check if the password is equals to 123. I am able t...
1
2016-09-16T14:55:15Z
39,559,619
<p>I friend of mine helped me to solve this issue.</p> <p>These two approaches do what I need:</p> <pre><code> pwd = map(pkt.PwDecrypt,pkt['Password']) print('User: %s Pass: %s' % (pkt['User-Name'], pwd)) pwd = pkt.PwDecrypt(pkt['Password'][0]) print('User: %s Pass: %s' % (pkt['User-Name'], pwd)) <...
0
2016-09-18T15:54:34Z
[ "python", "radius" ]
ImportError: No module named cv2.cv
39,534,496
<p><strong>python 3.5 and windows 10</strong></p> <p>I installed open cv using this command :</p> <pre><code>pip install opencv_python-3.1.0-cp35-cp35m-win_amd64.whl </code></pre> <p>This command in python works fine :</p> <pre><code>import cv2 </code></pre> <p>But when i want to import cv2.cv :</p> <pre><code>im...
1
2016-09-16T14:55:18Z
39,534,936
<p>as @Miki said :</p> <p><code>cv2.cv</code> has been removed in OpenCV3 and functions have changed</p> <p>And this is OpenCV Documention:<a href="http://opencv.org/documentation.html" rel="nofollow">http://opencv.org/documentation.html</a></p>
1
2016-09-16T15:16:19Z
[ "python", "python-3.x", "opencv", "windows-10" ]
Modify Django settings programmatically
39,534,505
<p>I have Django project. I need to add app to <code>INSTALLED_APPS</code> or change template config using another python script. What is the best way to do that?</p> <p>I have several ideas.</p> <ul> <li>Open <code>settings.py</code> as text file from Python and modify it. Seems to be wheel reinvention and opens box...
1
2016-09-16T14:55:47Z
39,534,970
<p>A better (meaning more safe and clean) approach would be to generate a python module and then use it in settings.py. For example, have your script create a file with these contents:</p> <pre><code>ADDITIONAL_APPS = [ 'foo', 'bar', ] </code></pre> <p>Save it as, say, additional_settings.py and put it in the...
0
2016-09-16T15:18:15Z
[ "python", "django" ]
ASCII error with my Django API
39,534,564
<p>I'm learning a tutorial in order to study Django so I'm really new with that. I started a project which is named <code>etat_civil</code> and I created an application which is named <code>blog</code>.</p> <p>I get this kind of things :</p> <p><a href="http://i.stack.imgur.com/mdpIw.jpg" rel="nofollow"><img src="htt...
0
2016-09-16T14:58:39Z
39,534,747
<p>There is an extra space in your source code encoding definition</p> <p>Change this:</p> <pre><code>#-*- coding : utf-8 -*- </code></pre> <p>To this:</p> <pre><code>#-*- coding: utf-8 -*- </code></pre>
2
2016-09-16T15:06:44Z
[ "python", "django" ]
Navigating pagination with selenium
39,534,584
<p>I am getting stuck on a weird case of pagination. I am scraping search results from <a href="https://cotthosting.com/NYRocklandExternal/LandRecords/protected/SrchQuickName.aspx" rel="nofollow">https://cotthosting.com/NYRocklandExternal/LandRecords/protected/SrchQuickName.aspx</a></p> <p>I have search results that ...
1
2016-09-16T14:59:24Z
39,535,606
<p>First of all you have to know what page are you at. To achieve it:</p> <p>Find element with current page number, using xpath:</p> <pre><code>currentPageElement = driver.find_element(By.XPATH, '//table[./tbody/tr/td[text()='Page: ']]//span') </code></pre> <p>Then extract the number:</p> <pre><code>currentPageNumb...
1
2016-09-16T15:53:49Z
[ "python", "loops", "selenium", "selenium-webdriver", "pagination" ]
Navigating pagination with selenium
39,534,584
<p>I am getting stuck on a weird case of pagination. I am scraping search results from <a href="https://cotthosting.com/NYRocklandExternal/LandRecords/protected/SrchQuickName.aspx" rel="nofollow">https://cotthosting.com/NYRocklandExternal/LandRecords/protected/SrchQuickName.aspx</a></p> <p>I have search results that ...
1
2016-09-16T14:59:24Z
39,535,665
<p>What you should do is to count the number of results in a page and use the value from total results to estimate the total number of pages by dividing.</p> <p>If you will inspect the page you will see: `</p> <p><code>Displaying records <strong>1 - 500</strong> of <strong>32563</strong> at <strong>10:08 AM ET</stron...
1
2016-09-16T15:56:42Z
[ "python", "loops", "selenium", "selenium-webdriver", "pagination" ]