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 listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 904,532 | <p>The itemgetter operator can help too, if you like map-reduce style python, rather than list comprehensions, for a little variety!</p>
<pre><code># tested in 2.4
from operator import itemgetter
def column(matrix,i):
f = itemgetter(i)
return map(f,matrix)
M = [range(x,x+5) for x in range(10)]
assert column(M... | 8 | 2009-05-24T19:57:39Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 7,578,114 | <pre><code>>>> import numpy as np
>>> A = np.array([[1,2,3,4],[5,6,7,8]])
>>> A
array([[1, 2, 3, 4],
[5, 6, 7, 8]])
>>> A[:,2] # returns the third columm
array([3, 7])
</code></pre>
<p>See also: "numpy.arange" and "reshape" to allocate memory</p>
<p>Example: (Allocating a arr... | 76 | 2011-09-28T03:55:53Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 7,766,288 | <p>If you have an array like </p>
<pre><code>a = [[1, 2], [2, 3], [3, 4]]
</code></pre>
<p>Then you extract the first column like that:</p>
<pre><code>[row[0] for row in a]
</code></pre>
<p>So the result looks like this:</p>
<pre><code>[1, 2, 3]
</code></pre>
| 32 | 2011-10-14T10:21:58Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 13,518,274 | <p>check it out!</p>
<pre><code>a = [[1, 2], [2, 3], [3, 4]]
a2 = zip(*a)
a2[0]
</code></pre>
<p>it is the same thing as above except somehow it is neater
the zip does the work but requires single arrays as arguments, the *a syntax unpacks the multidimensional array into single array arguments</p>
| 17 | 2012-11-22T18:25:45Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 18,545,262 | <p>Despite using <code>zip(*iterable)</code> to transpose a nested list, you can also use the following if the nested lists vary in length:</p>
<pre><code>map(None, *[(1,2,3,), (4,5,), (6,)])
</code></pre>
<p>results in:</p>
<pre><code>[(1, 4, 6), (2, 5, None), (3, None, None)]
</code></pre>
<p>The first column is ... | 1 | 2013-08-31T06:30:42Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 18,594,945 | <p>Well a 'bit' late ...</p>
<p>In case performance matters and your data is shaped rectangular, you might also store it in one dimension and access the columns by regular slicing e.g. ...</p>
<pre><code>A = [[1,2,3,4],[5,6,7,8]] #< assume this 4x2-matrix
B = reduce( operator.add, A ) #< get it one-dimensio... | 2 | 2013-09-03T14:33:28Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 19,592,994 | <p>One more way using matrices</p>
<pre><code>>>> from numpy import matrix
>>> a = [ [1,2,3],[4,5,6],[7,8,9] ]
>>> matrix(a).transpose()[1].getA()[0]
array([2, 5, 8])
>>> matrix(a).transpose()[0].getA()[0]
array([1, 4, 7])
</code></pre>
| 3 | 2013-10-25T14:47:27Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 23,232,138 | <pre><code>[matrix[i][column] for i in range(len(matrix))]
</code></pre>
| 3 | 2014-04-22T23:31:11Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 23,348,016 | <p>All columns from a matrix into a new list:</p>
<pre><code>N = len(matrix)
column_list = [ [matrix[row][column] for row in range(N)] for column in range(N) ]
</code></pre>
| 0 | 2014-04-28T17:57:50Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 28,364,590 | <p>You can use this as well:</p>
<pre><code>values = np.array([[1,2,3],[4,5,6]])
values[...,0] # first column
#[1,4]
</code></pre>
<p>Note: This is not working for built-in array and not aligned (e.g. np.array([[1,2,3],[4,5,6,7]]) )</p>
| 3 | 2015-02-06T11:18:11Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
How do you extract a column from a multi-dimensional array? | 903,853 | <p>Does anybody know how to extract a column from a multi-dimensional array in Python?</p>
| 80 | 2009-05-24T14:19:47Z | 29,165,287 | <p>I think you want to extract a column from an array such as an array below</p>
<pre><code>import numpy as np
A = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
</code></pre>
<p>Now if you want to get the third column in the format</p>
<pre><code>D=array[[3],
[7],
[11]]
</code></pre>
<p>Then you need to first make t... | 1 | 2015-03-20T11:18:47Z | [
"python",
"arrays",
"multidimensional-array",
"extraction"
] |
Python: Sending a large dictionary to a server | 903,885 | <p>I have an application that should communicate status information to a server. This information is effectively a large dictionary with string keys.</p>
<p>The server will run a web application based on Turbogears, so the server-side method called accepts an arbitrary number of keyword arguments.</p>
<p>In addition ... | 0 | 2009-05-24T14:30:59Z | 903,941 | <p>I think the best way is to encode your data in an appropriate transfer format (you should not use pickle, as it's not save, but it can be binary) and transfer it as a <a href="http://code.activestate.com/recipes/146306/" rel="nofollow">multipart post request</a></p>
<p>What I do not know if you can make it work wit... | 3 | 2009-05-24T14:58:50Z | [
"python",
"turbogears"
] |
Python: Sending a large dictionary to a server | 903,885 | <p>I have an application that should communicate status information to a server. This information is effectively a large dictionary with string keys.</p>
<p>The server will run a web application based on Turbogears, so the server-side method called accepts an arbitrary number of keyword arguments.</p>
<p>In addition ... | 0 | 2009-05-24T14:30:59Z | 903,942 | <p>Why don't you serialize the dictionary to a file, and upload the file? This way, the server can read the object back into a dictionary .</p>
| 2 | 2009-05-24T14:59:06Z | [
"python",
"turbogears"
] |
Python: Sending a large dictionary to a server | 903,885 | <p>I have an application that should communicate status information to a server. This information is effectively a large dictionary with string keys.</p>
<p>The server will run a web application based on Turbogears, so the server-side method called accepts an arbitrary number of keyword arguments.</p>
<p>In addition ... | 0 | 2009-05-24T14:30:59Z | 903,950 | <p>Have you tried using pickle on the data ?</p>
| 1 | 2009-05-24T15:02:18Z | [
"python",
"turbogears"
] |
Python: Sending a large dictionary to a server | 903,885 | <p>I have an application that should communicate status information to a server. This information is effectively a large dictionary with string keys.</p>
<p>The server will run a web application based on Turbogears, so the server-side method called accepts an arbitrary number of keyword arguments.</p>
<p>In addition ... | 0 | 2009-05-24T14:30:59Z | 903,958 | <p>Do a POST of your python data (use binary as suggested in other answers) and handle security using your webserver. Apache and Microsoft servers can both do authentication using a wide variety of methods (SSL client certs, Password, System accounts, etc...)</p>
<p>Serialising/Deserialising to text or XML is probably... | 2 | 2009-05-24T15:09:32Z | [
"python",
"turbogears"
] |
Python: Sending a large dictionary to a server | 903,885 | <p>I have an application that should communicate status information to a server. This information is effectively a large dictionary with string keys.</p>
<p>The server will run a web application based on Turbogears, so the server-side method called accepts an arbitrary number of keyword arguments.</p>
<p>In addition ... | 0 | 2009-05-24T14:30:59Z | 904,009 | <p>I agree with all the answers about avoiding pickle, if safety is a concern (it might not be if the sender gets authenticated before the data's unpickled -- but, when security's at issue, two levels of defense may be better than one); JSON is often of help in such cases (or, XML, if nothing else will do...!-).</p>
<... | 4 | 2009-05-24T15:35:24Z | [
"python",
"turbogears"
] |
Python: Sending a large dictionary to a server | 903,885 | <p>I have an application that should communicate status information to a server. This information is effectively a large dictionary with string keys.</p>
<p>The server will run a web application based on Turbogears, so the server-side method called accepts an arbitrary number of keyword arguments.</p>
<p>In addition ... | 0 | 2009-05-24T14:30:59Z | 904,304 | <p>I'd personally use SimpleJSON at both ends and just post the "file" (it would really just be a stream) over as multipart data.</p>
<p>But that's me. There are other options.</p>
| 2 | 2009-05-24T17:52:59Z | [
"python",
"turbogears"
] |
Chain-calling parent constructors in python | 904,036 | <p>Consider this - a base class A, class B inheriting from A, class C inheriting from B. What is a generic way to call a parent class constructor in a constructor? If this still sounds too vague, here's some code.</p>
<pre><code>class A(object):
def __init__(self):
print "Constructor A was called"
class B... | 211 | 2009-05-24T15:54:09Z | 904,078 | <p>The way you are doing it is indeed the recommended one (for Python 2.x). </p>
<p>The issue of whether the class is passed explicitly to <code>super</code> is a matter of style rather than functionality. Passing the class to <code>super</code> fits in with Python's philosophy of "explicit is better than implicit".</... | 136 | 2009-05-24T16:12:27Z | [
"python",
"oop",
"inheritance",
"constructor"
] |
Chain-calling parent constructors in python | 904,036 | <p>Consider this - a base class A, class B inheriting from A, class C inheriting from B. What is a generic way to call a parent class constructor in a constructor? If this still sounds too vague, here's some code.</p>
<pre><code>class A(object):
def __init__(self):
print "Constructor A was called"
class B... | 211 | 2009-05-24T15:54:09Z | 904,081 | <p>Python 3 includes an improved super() which allows use like this:</p>
<pre><code>super().__init__(args)
</code></pre>
| 134 | 2009-05-24T16:13:32Z | [
"python",
"oop",
"inheritance",
"constructor"
] |
Chain-calling parent constructors in python | 904,036 | <p>Consider this - a base class A, class B inheriting from A, class C inheriting from B. What is a generic way to call a parent class constructor in a constructor? If this still sounds too vague, here's some code.</p>
<pre><code>class A(object):
def __init__(self):
print "Constructor A was called"
class B... | 211 | 2009-05-24T15:54:09Z | 17,398,819 | <p>You can simply write : <br></p>
<pre><code>class A(object):
def __init__(self):
print "Constructor A was called"
class B(A):
def __init__(self):
A.__init__(self)
# A.__init__(self,<parameters>) if you want to call with parameters
print "Constructor B was called"
cl... | 12 | 2013-07-01T06:49:56Z | [
"python",
"oop",
"inheritance",
"constructor"
] |
Reading a UTF8 CSV file with Python | 904,041 | <p>I am trying to read a CSV file with accented characters with Python (only French and/or Spanish characters). Based on the Python 2.5 documentation for the csvreader (<a href="http://docs.python.org/library/csv.html">http://docs.python.org/library/csv.html</a>), I came up with the following code to read the CSV file ... | 50 | 2009-05-24T15:56:31Z | 904,085 | <p>The <code>.encode</code> method gets applied to a Unicode string to make a byte-string; but you're calling it on a byte-string instead... the wrong way 'round! Look at the <code>codecs</code> module in the standard library and <code>codecs.open</code> in particular for better general solutions for reading UTF-8 enc... | 79 | 2009-05-24T16:14:49Z | [
"python",
"utf-8",
"csv",
"character-encoding"
] |
Reading a UTF8 CSV file with Python | 904,041 | <p>I am trying to read a CSV file with accented characters with Python (only French and/or Spanish characters). Based on the Python 2.5 documentation for the csvreader (<a href="http://docs.python.org/library/csv.html">http://docs.python.org/library/csv.html</a>), I came up with the following code to read the CSV file ... | 50 | 2009-05-24T15:56:31Z | 904,169 | <p>Looking at the <a href="http://www.unicode.org/charts/PDF/U0080.pdf" rel="nofollow"><code>Latin-1</code> unicode table</a>, I see the character code <code>00E9</code> "<em>LATIN SMALL LETTER E WITH ACUTE</em>". This is the accented character in your sample data. A simple test in <code>Python</code> shows that <code>... | 0 | 2009-05-24T16:54:37Z | [
"python",
"utf-8",
"csv",
"character-encoding"
] |
Reading a UTF8 CSV file with Python | 904,041 | <p>I am trying to read a CSV file with accented characters with Python (only French and/or Spanish characters). Based on the Python 2.5 documentation for the csvreader (<a href="http://docs.python.org/library/csv.html">http://docs.python.org/library/csv.html</a>), I came up with the following code to read the CSV file ... | 50 | 2009-05-24T15:56:31Z | 904,382 | <p>The link to the help page is the same for python 2.6 and as far as I know there was no change in the csv module since 2.5 (besides bug fixes).
Here is the code that just works without any encoding/decoding (file da.csv contains the same data as the variable <em>data</em>). I assume that your file should be read corr... | 1 | 2009-05-24T18:29:41Z | [
"python",
"utf-8",
"csv",
"character-encoding"
] |
Reading a UTF8 CSV file with Python | 904,041 | <p>I am trying to read a CSV file with accented characters with Python (only French and/or Spanish characters). Based on the Python 2.5 documentation for the csvreader (<a href="http://docs.python.org/library/csv.html">http://docs.python.org/library/csv.html</a>), I came up with the following code to read the CSV file ... | 50 | 2009-05-24T15:56:31Z | 14,162,262 | <p>Using <strong>codecs.open</strong> as Alex Martelli suggested proved to be usefull to me.</p>
<pre><code>import csv, codecs
delimiter = ';'
reader = codecs.open("your_filename.csv", 'r', encoding='utf-8')
for line in reader:
row = line.split(delimiter)
#do something with your row ...
</code></pre>
| 1 | 2013-01-04T17:53:37Z | [
"python",
"utf-8",
"csv",
"character-encoding"
] |
Reading a UTF8 CSV file with Python | 904,041 | <p>I am trying to read a CSV file with accented characters with Python (only French and/or Spanish characters). Based on the Python 2.5 documentation for the csvreader (<a href="http://docs.python.org/library/csv.html">http://docs.python.org/library/csv.html</a>), I came up with the following code to read the CSV file ... | 50 | 2009-05-24T15:56:31Z | 14,786,752 | <h3>Python 2.X</h3>
<p>There is a <a href="https://github.com/jdunck/python-unicodecsv">unicode-csv</a> library which should solve your problems, with added benefit of not naving to write any new csv-related code.</p>
<p>Here is a example from their readme:</p>
<pre><code>>>> import unicodecsv
>>> ... | 23 | 2013-02-09T09:37:14Z | [
"python",
"utf-8",
"csv",
"character-encoding"
] |
Reading a UTF8 CSV file with Python | 904,041 | <p>I am trying to read a CSV file with accented characters with Python (only French and/or Spanish characters). Based on the Python 2.5 documentation for the csvreader (<a href="http://docs.python.org/library/csv.html">http://docs.python.org/library/csv.html</a>), I came up with the following code to read the CSV file ... | 50 | 2009-05-24T15:56:31Z | 24,793,945 | <p>Also checkout the answer in this post:
<a href="http://stackoverflow.com/a/9347871/1338557">http://stackoverflow.com/a/9347871/1338557</a></p>
<p>It suggests use of library called ucsv.py. Short and simple replacement for CSV written to address the encoding problem(utf-8) for Python 2.7. Also provides support for c... | 1 | 2014-07-17T02:31:28Z | [
"python",
"utf-8",
"csv",
"character-encoding"
] |
python-mysql : How to get interpolated query string? | 904,042 | <p>In diagnosing SQL query problems, it would sometimes be useful to be able to see the query string after parameters are interpolated into it, using MySQLdb's safe interpolation.</p>
<p>Is there a way to get that information from either a MySQL exception object or from the connection object itself?</p>
| 2 | 2009-05-24T15:56:38Z | 904,077 | <p>Use mysql's own ability to log the queries and watch for them.</p>
| 2 | 2009-05-24T16:12:27Z | [
"python",
"mysql"
] |
python-mysql : How to get interpolated query string? | 904,042 | <p>In diagnosing SQL query problems, it would sometimes be useful to be able to see the query string after parameters are interpolated into it, using MySQLdb's safe interpolation.</p>
<p>Is there a way to get that information from either a MySQL exception object or from the connection object itself?</p>
| 2 | 2009-05-24T15:56:38Z | 907,805 | <p>Perhaps You could use the <a href="http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html" rel="nofollow">slow_query_log</a>?</p>
<p>If You cannot turn on the mysql's internal ability to log all queries, You need to write down all the queries before You execute them... You can store them in an own log-file, or ... | 0 | 2009-05-25T19:31:40Z | [
"python",
"mysql"
] |
The wrong python interpreter is called | 904,170 | <p>I updated my python interpreter, but I think the old one is still called. When I check for the version I get:</p>
<pre><code>$ python -V
Python 3.0.1
</code></pre>
<p>But I believe the old interpreter is still being called. When I run the command:</p>
<pre><code>python myProg.py
</code></pre>
<p>The script runs ... | 9 | 2009-05-24T16:55:25Z | 904,182 | <p>run 'which python' - if this gives a different answer than /usr/bin/python, change #!/usr/bin/python to have that path instead.</p>
| 2 | 2009-05-24T16:59:07Z | [
"python",
"python-3.x"
] |
The wrong python interpreter is called | 904,170 | <p>I updated my python interpreter, but I think the old one is still called. When I check for the version I get:</p>
<pre><code>$ python -V
Python 3.0.1
</code></pre>
<p>But I believe the old interpreter is still being called. When I run the command:</p>
<pre><code>python myProg.py
</code></pre>
<p>The script runs ... | 9 | 2009-05-24T16:55:25Z | 904,183 | <p>Try <code>which python</code>. I will tell you which python interpreter is used in your environment.
If it is not <code>/usr/bin/python</code> like in the script, then your suspicion is confirmed.</p>
| 3 | 2009-05-24T16:59:26Z | [
"python",
"python-3.x"
] |
The wrong python interpreter is called | 904,170 | <p>I updated my python interpreter, but I think the old one is still called. When I check for the version I get:</p>
<pre><code>$ python -V
Python 3.0.1
</code></pre>
<p>But I believe the old interpreter is still being called. When I run the command:</p>
<pre><code>python myProg.py
</code></pre>
<p>The script runs ... | 9 | 2009-05-24T16:55:25Z | 904,185 | <p>According to the first line of the script, <code>#!/usr/bin/python</code>, you are calling the Python interpreter at <code>/usr/bin/python</code> (which is most likely the one that ships with Mac OS X). You have to change that path to the path where you installed your Python 3 interpreter (likely <code>/usr/local/bi... | 16 | 2009-05-24T16:59:38Z | [
"python",
"python-3.x"
] |
The wrong python interpreter is called | 904,170 | <p>I updated my python interpreter, but I think the old one is still called. When I check for the version I get:</p>
<pre><code>$ python -V
Python 3.0.1
</code></pre>
<p>But I believe the old interpreter is still being called. When I run the command:</p>
<pre><code>python myProg.py
</code></pre>
<p>The script runs ... | 9 | 2009-05-24T16:55:25Z | 904,188 | <p>Firstly, the recommended shebang line is:</p>
<pre><code>#!/usr/bin/env python
</code></pre>
<p>This will make sure the python interpreter that is invoked when you <code>./foo.py</code> is the same interpreter that is invoked when you invoke python from the command line.</p>
<p>From your description, I suspect th... | 6 | 2009-05-24T17:00:54Z | [
"python",
"python-3.x"
] |
The wrong python interpreter is called | 904,170 | <p>I updated my python interpreter, but I think the old one is still called. When I check for the version I get:</p>
<pre><code>$ python -V
Python 3.0.1
</code></pre>
<p>But I believe the old interpreter is still being called. When I run the command:</p>
<pre><code>python myProg.py
</code></pre>
<p>The script runs ... | 9 | 2009-05-24T16:55:25Z | 904,190 | <p>It's very possibly what you suspect, that the shebang line is calling the older version. Two things you might want to check:</p>
<p>1) what version is the interpreter at /usr/bin/python:</p>
<pre><code>/usr/bin/python -V
</code></pre>
<p>2) where is the python 3 interpreter you installed:</p>
<pre><code>which p... | 3 | 2009-05-24T17:01:38Z | [
"python",
"python-3.x"
] |
The wrong python interpreter is called | 904,170 | <p>I updated my python interpreter, but I think the old one is still called. When I check for the version I get:</p>
<pre><code>$ python -V
Python 3.0.1
</code></pre>
<p>But I believe the old interpreter is still being called. When I run the command:</p>
<pre><code>python myProg.py
</code></pre>
<p>The script runs ... | 9 | 2009-05-24T16:55:25Z | 1,218,338 | <p>It may be a bit odd providing a Perl script to answer a Python question, but it works for Python just as well as it does for Perl. This is a script called '<code>fixin</code>', meaning 'fix interpreter'. It changes the shebang line to the correct string for your current PATH.</p>
<pre><code>#!/Users/jleffler/perl... | 1 | 2009-08-02T07:20:35Z | [
"python",
"python-3.x"
] |
A problem with downloading a file with Python | 904,555 | <p>I try to automatically download a file by clicking on a link on the webpage.
After clicking on the link, I get the 'File Download' Window dialog with 'Open', 'Save' and 'Cancel' buttons. I would like to click the Save button.</p>
<p>I use watsup library in the following way:</p>
<pre><code>from watsup.winGuiAuto i... | 3 | 2009-05-24T20:08:58Z | 904,662 | <p>Try this:</p>
<pre><code>from watsup.winGuiAuto import *
optDialog = findTopWindow(wantedText="File Download")
SaveButton = findControl(optDialog, wantedClass="Button", wantedText="Submit")
clickButton(SaveButton)
</code></pre>
| 0 | 2009-05-24T21:08:55Z | [
"python",
"user-interface",
"file",
"download"
] |
A problem with downloading a file with Python | 904,555 | <p>I try to automatically download a file by clicking on a link on the webpage.
After clicking on the link, I get the 'File Download' Window dialog with 'Open', 'Save' and 'Cancel' buttons. I would like to click the Save button.</p>
<p>I use watsup library in the following way:</p>
<pre><code>from watsup.winGuiAuto i... | 3 | 2009-05-24T20:08:58Z | 906,134 | <p>It's possible that the save button is not always enabled. While it may look to your eye that it is, a program might see an initial state that you're missing. Check it's state and wait until it's enabled.</p>
<p>[EDIT] But it's possible that Robert is right and the dialog will just ignore you for security reasons. I... | 0 | 2009-05-25T10:05:08Z | [
"python",
"user-interface",
"file",
"download"
] |
A problem with downloading a file with Python | 904,555 | <p>I try to automatically download a file by clicking on a link on the webpage.
After clicking on the link, I get the 'File Download' Window dialog with 'Open', 'Save' and 'Cancel' buttons. I would like to click the Save button.</p>
<p>I use watsup library in the following way:</p>
<pre><code>from watsup.winGuiAuto i... | 3 | 2009-05-24T20:08:58Z | 907,869 | <p>Sasha,</p>
<p>The code at <a href="http://bytes.com/groups/python/23100-windows-dialog-box-removal" rel="nofollow">this link</a> is supposed to work. It uses ctypes instead of watsup.winGuiAuto, and relies on win32 calls. Here is the code:</p>
<pre><code>from ctypes import *
user32 = windll.user32
EnumWindowsPr... | 0 | 2009-05-25T19:56:23Z | [
"python",
"user-interface",
"file",
"download"
] |
A problem with downloading a file with Python | 904,555 | <p>I try to automatically download a file by clicking on a link on the webpage.
After clicking on the link, I get the 'File Download' Window dialog with 'Open', 'Save' and 'Cancel' buttons. I would like to click the Save button.</p>
<p>I use watsup library in the following way:</p>
<pre><code>from watsup.winGuiAuto i... | 3 | 2009-05-24T20:08:58Z | 908,036 | <p>Sasha,</p>
<p>It is highly likely that the file dialog you refer to (the <a href="http://images.google.com/images?hl=en&q=save%20security%20warning" rel="nofollow">Security Warning file download dialog</a>) will NOT respond to windows messages in this manner, for security reasons. The dialog is specifically de... | 1 | 2009-05-25T20:59:28Z | [
"python",
"user-interface",
"file",
"download"
] |
How to parse malformed HTML in python | 904,644 | <p>I need to browse the DOM tree of a parsed HTML document.</p>
<p>I'm using uTidyLib before parsing the string with lxml</p>
<p>a = tidy.parseString(html_code, options)
dom = etree.fromstring(str(a))</p>
<p>sometimes I get an error, it seems that tidylib is not able to repair malformed html.</p>
<p>how can I parse... | 12 | 2009-05-24T20:59:27Z | 904,655 | <p><a href="http://www.crummy.com/software/BeautifulSoup/">Beautiful Soup</a> does a good job with invalid/broken HTML</p>
<pre><code>>>> from BeautifulSoup import BeautifulSoup
>>> soup = BeautifulSoup("<htm@)($*><body><table <tr><td>hi</tr></td></body>&l... | 22 | 2009-05-24T21:06:13Z | [
"python",
"html",
"lxml"
] |
How to parse malformed HTML in python | 904,644 | <p>I need to browse the DOM tree of a parsed HTML document.</p>
<p>I'm using uTidyLib before parsing the string with lxml</p>
<p>a = tidy.parseString(html_code, options)
dom = etree.fromstring(str(a))</p>
<p>sometimes I get an error, it seems that tidylib is not able to repair malformed html.</p>
<p>how can I parse... | 12 | 2009-05-24T20:59:27Z | 904,821 | <p>Since you are already using lxml, have you tried <a href="http://lxml.de/" rel="nofollow">lxml's</a> <a href="http://lxml.de/elementsoup.html" rel="nofollow">ElementSoup</a> module?</p>
<p>If ElementSoup can't repair the HTML then you'll probably need to apply your own filters first that are based on your own obser... | 13 | 2009-05-24T22:52:08Z | [
"python",
"html",
"lxml"
] |
How to remove all characters after a specific character in python? | 904,746 | <p>I have a string. How do I remove all text after a certain character? (<em>In this case <code>...</code></em>) <br/>
The text after will <strong><code>...</code></strong> change so I that's why I want to remove all characters after a certain one.</p>
| 33 | 2009-05-24T21:56:49Z | 904,753 | <p>Without a RE (which I assume is what you want):</p>
<pre><code>def remafterellipsis(text):
where_ellipsis = text.find('...')
if where_ellipsis == -1:
return text
return text[:where_ellipsis + 3]
</code></pre>
<p>or, with a RE:</p>
<pre><code>import re
def remwithre(text, there=re.compile(re.escape('...... | 5 | 2009-05-24T22:00:24Z | [
"python",
"replace",
"python-2.6"
] |
How to remove all characters after a specific character in python? | 904,746 | <p>I have a string. How do I remove all text after a certain character? (<em>In this case <code>...</code></em>) <br/>
The text after will <strong><code>...</code></strong> change so I that's why I want to remove all characters after a certain one.</p>
| 33 | 2009-05-24T21:56:49Z | 904,756 | <p>Split on your separator at most once, and take the first piece:</p>
<pre><code>sep = '...'
rest = text.split(sep, 1)[0]
</code></pre>
<p>You didn't say what should happen if the separator isn't present. Both this and Alex's solution will return the entire string in that case.</p>
| 57 | 2009-05-24T22:01:34Z | [
"python",
"replace",
"python-2.6"
] |
How to remove all characters after a specific character in python? | 904,746 | <p>I have a string. How do I remove all text after a certain character? (<em>In this case <code>...</code></em>) <br/>
The text after will <strong><code>...</code></strong> change so I that's why I want to remove all characters after a certain one.</p>
| 33 | 2009-05-24T21:56:49Z | 904,758 | <p>Assuming your separator is '...', but it can be any string.</p>
<pre><code>text = 'some string... this part will be removed.'
head, sep, tail = text.partition('...')
>>> print head
some string
</code></pre>
<p>If the separator is not found, <code>head</code> will contain all of the original string.</p>
... | 35 | 2009-05-24T22:02:26Z | [
"python",
"replace",
"python-2.6"
] |
How to remove all characters after a specific character in python? | 904,746 | <p>I have a string. How do I remove all text after a certain character? (<em>In this case <code>...</code></em>) <br/>
The text after will <strong><code>...</code></strong> change so I that's why I want to remove all characters after a certain one.</p>
| 33 | 2009-05-24T21:56:49Z | 30,347,303 | <p>another easy way using re will be </p>
<p>import re, clr</p>
<p>text = 'some string... this part will be removed.'</p>
<p>text= re.search(r'(\A.*)....+',url,re.DOTALL|re.IGNORECASE).group(1)</p>
<p>// text = some string</p>
| 0 | 2015-05-20T10:42:08Z | [
"python",
"replace",
"python-2.6"
] |
How to remove all characters after a specific character in python? | 904,746 | <p>I have a string. How do I remove all text after a certain character? (<em>In this case <code>...</code></em>) <br/>
The text after will <strong><code>...</code></strong> change so I that's why I want to remove all characters after a certain one.</p>
| 33 | 2009-05-24T21:56:49Z | 32,574,818 | <p>If you want to remove everything after the last occurrence of character in a string I find this works well:</p>
<p><code>"<character_to_split>".join(string_to_split.split("<character_to_split>")[:-1])</code></p>
<p>For example, if <code>string_to_split</code> is a path like <code>root/location/child/t... | 2 | 2015-09-14T22:18:10Z | [
"python",
"replace",
"python-2.6"
] |
Problem with datetime module-Python | 904,852 | <p>How come this works:</p>
<pre><code>import datetime
now = datetime.datetime.now()
month = '%d' % now.month
print month
</code></pre>
<p>But this doesn't?</p>
<pre><code>import datetime
now = datetime.datetime.now()
month = '%m' % now.month
print month
</code></pre>
<p>Thanks!</p>
| 0 | 2009-05-24T23:20:22Z | 904,856 | <p>%m is not a supported format character for the % operator. Here is the list of supported <a href="http://docs.python.org/library/stdtypes.html#string-formatting-operations" rel="nofollow">formating characters</a> for this operator</p>
<p>%m is valid when your are using <a href="http://docs.python.org/library/time.h... | 3 | 2009-05-24T23:22:45Z | [
"python"
] |
Problem with datetime module-Python | 904,852 | <p>How come this works:</p>
<pre><code>import datetime
now = datetime.datetime.now()
month = '%d' % now.month
print month
</code></pre>
<p>But this doesn't?</p>
<pre><code>import datetime
now = datetime.datetime.now()
month = '%m' % now.month
print month
</code></pre>
<p>Thanks!</p>
| 0 | 2009-05-24T23:20:22Z | 904,861 | <p><code>'%d'</code> is a format character that insert a "signed integer decimal", <code>'%m'</code> has no such meaning. The possible format characters are listed <a href="http://docs.python.org/library/stdtypes.html#string-formatting" rel="nofollow">here</a>.</p>
| 1 | 2009-05-24T23:28:18Z | [
"python"
] |
How to do this with datetime & getpage in Python? | 904,894 | <p>Hey guys,
Currently having some problems-</p>
<pre><code>now = datetime.datetime.now()
month = now.strftime("%B")
site = wikipedia.getSite('en', 'wikiquote')
page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day:abc")
</code></pre>
<p>I need to get abc to change into the name of the month before it then tries... | 0 | 2009-05-24T23:50:55Z | 904,900 | <p>Would this work?</p>
<pre><code>page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day:" + month)
</code></pre>
| 2 | 2009-05-24T23:57:32Z | [
"python"
] |
How to do this with datetime & getpage in Python? | 904,894 | <p>Hey guys,
Currently having some problems-</p>
<pre><code>now = datetime.datetime.now()
month = now.strftime("%B")
site = wikipedia.getSite('en', 'wikiquote')
page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day:abc")
</code></pre>
<p>I need to get abc to change into the name of the month before it then tries... | 0 | 2009-05-24T23:50:55Z | 904,901 | <p>Did you try this:</p>
<pre><code>page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day:%s" % month )
</code></pre>
| 0 | 2009-05-24T23:58:29Z | [
"python"
] |
How to do this with datetime & getpage in Python? | 904,894 | <p>Hey guys,
Currently having some problems-</p>
<pre><code>now = datetime.datetime.now()
month = now.strftime("%B")
site = wikipedia.getSite('en', 'wikiquote')
page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day:abc")
</code></pre>
<p>I need to get abc to change into the name of the month before it then tries... | 0 | 2009-05-24T23:50:55Z | 904,903 | <p>The page URL format is actually <a href="http://en.wikiquote.org/wiki/Wikiquote:Quote%5Fof%5Fthe%5Fday/May" rel="nofollow"><code>Wikiquote:Quote_of_the_day/Month</code></a>. Try this:</p>
<pre><code>page = wikipedia.Page(site, u"Wikiquote:Quote_of_the_day/%s" % month)
</code></pre>
| 3 | 2009-05-24T23:59:31Z | [
"python"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 904,941 | <p>You can use <a href="http://docs.python.org/library/stdtypes.html#str.lstrip" rel="nofollow">left strip</a> to remove the leading zero's</p>
<pre><code>day = day.lstrip('0')
>>> day = '01'
>>> day.lstrip('0')
'1'
</code></pre>
| -11 | 2009-05-25T00:15:41Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 904,954 | <p>Some platforms may support width and precision specification between <code>%</code> and the letter (such as 'd' for day of month), according to <a href="http://docs.python.org/library/time.html">http://docs.python.org/library/time.html</a> -- but it's definitely a non-portable solution (e.g. doesn't work on my Mac;-... | 30 | 2009-05-25T00:22:43Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 904,958 | <p>Because Python really just calls the C language <code>strftime(3)</code> function on your platform, it might be that there are format characters you could use to control the leading zero; try <code>man strftime</code> and take a look. But, of course, the result will not be portable, as the Python manual will remind ... | 1 | 2009-05-25T00:23:21Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 907,607 | <p><a href="http://www.gnu.org/software/libc/manual/html%5Fnode/Formatting-Calendar-Time.html#index-strftime-2660">Here</a> is the documentation of the modifiers supported by <code>strftime()</code> in the GNU C library. (Like people said before, it might not be portable.) Of interest to you might be:</p>
<ul>
<li><co... | 14 | 2009-05-25T18:13:36Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 1,428,227 | <p>I find the Django template date formatting filter to be quick and easy. It strips out leading zeros. If you don't mind importing the Django module, check it out.</p>
<p><a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date">http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date</a></... | 8 | 2009-09-15T16:31:23Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 2,073,189 | <p>Actually I had the same problem and I realized that, if you add a hyphen between the <code>%</code> and the letter, you can remove the leading zero.</p>
<p>For example <code>%Y/%-m/%-d</code>.</p>
<p>Only works on Unix (Linux, OS X). Doesn't work in Windows (including Cygwin).</p>
| 271 | 2010-01-15T16:38:41Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 3,285,938 | <p>For <code>%d</code> you can convert to integer using <code>int()</code> then it'll automatically remove leading 0 and becomes integer. You can then convert back to string using <code>str()</code>.</p>
| 0 | 2010-07-19T23:33:10Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 5,900,593 | <pre><code>>>> import datetime
>>> d = datetime.datetime.now()
>>> d.strftime('X%d/X%m/%Y').replace('X0','X').replace('X','')
'5/5/2011'
</code></pre>
| 16 | 2011-05-05T15:46:24Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 7,698,783 | <p>Take a look at <code>-</code> bellow:</p>
<pre><code>>>> from datetime import datetime
>>> datetime.now().strftime('%d-%b-%Y')
>>> '08-Oct-2011'
>>> datetime.now().strftime('%-d-%b-%Y')
>>> '8-Oct-2011'
>>> today = datetime.date.today()
>>> today.strfti... | 3 | 2011-10-08T18:15:59Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 16,097,385 | <p>We can do this sort of thing with the advent of the <a href="https://docs.python.org/2/library/functions.html#format" rel="nofollow"><code>format</code></a> method since python2.6:</p>
<pre><code>>>> import datetime
>>> '{dt.year}/{dt.month}/{dt.day}'.format(dt = datetime.datetime.now())
'2013/4/1... | 115 | 2013-04-19T04:48:02Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 26,979,224 | <p>Based on Alex's method, this will work for both the start-of-string and after-spaces cases:</p>
<pre><code>re.sub('^0|(?<= )0', '', "01 January 2000 08:00am")
</code></pre>
<p>I like this better than .format or %-d because this is cross-platform and allows me to keep using strftime (to get things like "November... | 1 | 2014-11-17T18:19:31Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 27,125,022 | <p>quite late to the party but <code>%-d</code> works on my end.</p>
<p><code>datetime.now().strftime('%B %-d, %Y')</code> produces something like <strong>"November 5, 2014"</strong></p>
<p>cheers :)</p>
| 4 | 2014-11-25T11:08:03Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 31,748,295 | <p>On Windows, add a '#', as in '%#m/%#d/%Y %#I:%M:%S %p'</p>
<p>For reference: <a href="https://msdn.microsoft.com/en-us/library/fe06s4ak.aspx">https://msdn.microsoft.com/en-us/library/fe06s4ak.aspx</a></p>
| 7 | 2015-07-31T14:12:53Z | [
"python",
"padding",
"strftime"
] |
Python strftime - date without leading 0? | 904,928 | <p>When using Python <code>strftime</code>, is there a way to remove the first 0 of the date if it's before the 10th, ie. so <code>01</code> is <code>1</code>? Can't find a <code>%</code>thingy for that?</p>
<p>Thanks!</p>
| 125 | 2009-05-25T00:11:49Z | 38,662,476 | <p>Old question, but %l (lower-case L) worked for me in strftime: this may not work for everyone, though, as it's not listed in the Python documentation I found</p>
| 0 | 2016-07-29T15:29:35Z | [
"python",
"padding",
"strftime"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 905,015 | <p>Wingware for example implements auto-completion, see <a href="http://wingware.com/doc/edit/auto-completion">http://wingware.com/doc/edit/auto-completion</a> .</p>
| 5 | 2009-05-25T01:07:20Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 905,022 | <p>ctags + vim works ok, too, although it is not as powerful as intellisense. Using this with ipython, you can get online help, automatic name completion, etc... But that's obviously command-line oriented.</p>
<p>Eclipse + pydev can do it as well, but I have no experience with it: <a href="http://pydev.sourceforge.net... | 4 | 2009-05-25T01:13:06Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 905,036 | <p><a href="http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/">This</a> blog entry explains setting Vim up as a Python IDE, he covers Intellisense-like functionality:</p>
<p><img src="http://blog.dispatched.ch/wp-content/uploads/2009/05/omnicompletion.png" alt="Python Intellsense" /></p>
<p>This is standard in ... | 30 | 2009-05-25T01:25:42Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 905,053 | <p>The <a href="http://pydev.sf.net/">PyDev</a> environment for Eclipse has intellisense-like functionality for Python. Keeping an interactive console open, along with the <code>help(item)</code> function is very helpful.</p>
| 19 | 2009-05-25T01:34:23Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 905,076 | <p>I strongly recommend <a href="http://pydev.sourceforge.net">PyDev</a>. In Pydev you can put the module you are using in the <a href="http://www.fabioz.com/pydev/manual%5F101%5Finterpreter.html"><strong>Forced Buildins</strong></a>, mostly the code-completion will work better than in other IDEs like KOMODO EDIT.</p>
... | 9 | 2009-05-25T01:54:20Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 905,129 | <p>I'd recommend <a href="http://www.activestate.com/komodo%5Fedit/">Komodo Edit</a>. However, I should point something out: you're not going to get anything quite as good as what you're used to with Visual Studio's C# intellisense. Python's dynamic nature can make it difficult to do these kinds of features.</p>
| 5 | 2009-05-25T02:33:11Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 905,167 | <p>The <a href="http://en.wikipedia.org/wiki/IDLE%5F%28Python%29">IDLE editor</a> that comes with Python has an intellisense feature that auto-discovers imported modules, functions, classes and attributes.</p>
| 8 | 2009-05-25T02:55:47Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 905,206 | <p>The dynamic nature of the language tends to make autocomplete type analysis difficult, so the quality of the various completion facilities menitoned above varies wildly.</p>
<p>While it's not exactly what you asked for, the ipython shell is very good for exploratory work. When I'm working with a new module, I tend ... | 13 | 2009-05-25T03:22:07Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 910,623 | <p>Well, I think the most dynamic way to learn Python is to use <a href="http://ipython.scipy.org/moin/" rel="nofollow">iPython</a>.</p>
<p>You got autocompletion when using tab, dynamic behaviour because it's a shell and you can get the full documentation of any object / method typing :</p>
<pre><code>object.method ... | 3 | 2009-05-26T13:18:05Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 3,550,759 | <p><a href="http://code.google.com/p/pyscripter/" rel="nofollow">Pyscripter</a> has the best intellisense i have meet :)</p>
| 2 | 2010-08-23T18:54:19Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 6,963,061 | <p>Have a look at <a href="http://pytools.codeplex.com/">python tools for visual studio</a>, they provide code completion (a.k.a intellisense), debugging etc ...</p>
<p>Below is a screenshot of the interactive shell for python showing code completion.</p>
<p><img src="http://i.stack.imgur.com/UhMnP.png" alt="enter i... | 18 | 2011-08-05T22:00:12Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 14,027,081 | <p>IronPython is the way to go. Visual Studio has the best intellisense support and you can utilize that using IronPython</p>
| 0 | 2012-12-25T01:51:44Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 16,967,607 | <p><a href="http://www.jetbrains.com/pycharm/" rel="nofollow">PyCharm</a> is the best Python IDE with IntelliSense support.</p>
| 4 | 2013-06-06T16:41:39Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 16,969,088 | <p>For emacs and VI there's also <a href="https://github.com/tkf/emacs-jedi" rel="nofollow">https://github.com/tkf/emacs-jedi</a>.</p>
| 2 | 2013-06-06T18:06:32Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 22,394,389 | <p>I would recommend <a href="https://github.com/davidhalter/jedi-vim" rel="nofollow">jedi-vim</a>, it's perfect to me, try it and you won't regret.</p>
| 2 | 2014-03-14T01:23:54Z | [
"python",
"ide",
"intellisense"
] |
Python and Intellisense | 905,005 | <p>Is there an equivalent to 'intellisense' for Python?</p>
<p>Perhaps i shouldn't admit it but I find having intellisense really speeds up the 'discovery phase' of learning a new language. For instance switching from VB.net to C# was a breeze due to snippets and intellisense helping me along.</p>
| 56 | 2009-05-25T01:02:23Z | 40,068,447 | <p>Try visual Studio Code. It has very powerful Python and Django support and thousands of plugins for other languages used in a Python project such as CSS, HTML and Django templates. </p>
<p>Best of all, it is free:
<a href="https://code.visualstudio.com" rel="nofollow">https://code.visualstudio.com</a></p>
| 0 | 2016-10-16T08:36:46Z | [
"python",
"ide",
"intellisense"
] |
Resources concerning Python scripting in Vim | 905,020 | <p>I'm trying to learn a little about python scripting in GVim, but I'm having trouble with starting. Elementary things, really.</p>
<p>Are there any resources / tutorials concerting python scripting in Vim out there ? Simple examples which show the basic principles, would be welcomed also.</p>
| 34 | 2009-05-25T01:11:07Z | 905,026 | <p>Here is all I know of in terms of such docs:</p>
<ul>
<li><a href="http://www.tummy.com/Community/Presentations/vimpython-20070225/vim.html" rel="nofollow">A nice presentation by Sean Reifschneider</a></li>
<li><a href="http://vimdoc.sourceforge.net/htmldoc/if_pyth.html" rel="nofollow">The "official" VIM Python Int... | 23 | 2009-05-25T01:16:08Z | [
"python",
"vim"
] |
Resources concerning Python scripting in Vim | 905,020 | <p>I'm trying to learn a little about python scripting in GVim, but I'm having trouble with starting. Elementary things, really.</p>
<p>Are there any resources / tutorials concerting python scripting in Vim out there ? Simple examples which show the basic principles, would be welcomed also.</p>
| 34 | 2009-05-25T01:11:07Z | 905,088 | <p>Refer to the <em>Scripting</em> chapter in <a href="http://www.swaroopch.com/notes/vim/" rel="nofollow">'A Byte of Vim'</a>.</p>
| 3 | 2009-05-25T02:01:24Z | [
"python",
"vim"
] |
Resources concerning Python scripting in Vim | 905,020 | <p>I'm trying to learn a little about python scripting in GVim, but I'm having trouble with starting. Elementary things, really.</p>
<p>Are there any resources / tutorials concerting python scripting in Vim out there ? Simple examples which show the basic principles, would be welcomed also.</p>
| 34 | 2009-05-25T01:11:07Z | 905,091 | <p>:help python-vim is a good start. The best vim resource is always at your fingertips and the sooner you get used to referring to it the better you will get at vim overall.</p>
<p>I got better at searching vim help with this..</p>
<p><a href="http://stackoverflow.com/questions/526858/how-do-i-make-vim-do-normal-bas... | 4 | 2009-05-25T02:04:40Z | [
"python",
"vim"
] |
Resources concerning Python scripting in Vim | 905,020 | <p>I'm trying to learn a little about python scripting in GVim, but I'm having trouble with starting. Elementary things, really.</p>
<p>Are there any resources / tutorials concerting python scripting in Vim out there ? Simple examples which show the basic principles, would be welcomed also.</p>
| 34 | 2009-05-25T01:11:07Z | 9,173,894 | <h3>Vimscript The Hard Way</h3>
<p>Have you checked out <a href="http://www.vim.org/scripts/script.php?script_id=2914" rel="nofollow">Learn Vimscript The Hard Way</a>? It is an excellent read.</p>
<h3>Scripting Vim With Python</h3>
<p>vim 7.0 and above can be compiled with the <code>+python</code> flag, which gives... | 3 | 2012-02-07T09:36:35Z | [
"python",
"vim"
] |
Why does sys.exit() not exit when called inside a thread in Python? | 905,189 | <p>This could be a stupid question, but I'm testing out some of my assumptions about Python and I'm confused as to why the following code snippet would not exit when called in the thread, but would exit when called in the main thread.</p>
<pre><code>import sys, time
from threading import Thread
def testexit():
time.... | 43 | 2009-05-25T03:10:44Z | 905,224 | <p>sys.exit() raises the SystemExit exception, as does thread.exit(). So, when sys.exit() raises that exception inside that thread, it has the same effect as calling thread.exit(), which is why only the thread exits.</p>
| 35 | 2009-05-25T03:31:38Z | [
"python",
"python-2.6"
] |
Why does sys.exit() not exit when called inside a thread in Python? | 905,189 | <p>This could be a stupid question, but I'm testing out some of my assumptions about Python and I'm confused as to why the following code snippet would not exit when called in the thread, but would exit when called in the main thread.</p>
<pre><code>import sys, time
from threading import Thread
def testexit():
time.... | 43 | 2009-05-25T03:10:44Z | 905,280 | <p>Is the fact that "pre main exit, post thread exit" is printed what's bothering you?</p>
<p>Unlike some other languages (like Java) where the analog to <code>sys.exit</code> (<code>System.exit</code>, in Java's case) causes the VM/process/interpreter to immediately stop, Python's <code>sys.exit</code> just throws an... | 6 | 2009-05-25T04:07:21Z | [
"python",
"python-2.6"
] |
Why does sys.exit() not exit when called inside a thread in Python? | 905,189 | <p>This could be a stupid question, but I'm testing out some of my assumptions about Python and I'm confused as to why the following code snippet would not exit when called in the thread, but would exit when called in the main thread.</p>
<pre><code>import sys, time
from threading import Thread
def testexit():
time.... | 43 | 2009-05-25T03:10:44Z | 906,401 | <blockquote>
<p>What if I did want to exit the program
from the thread (not that I actually
want to, but just so I understand)?</p>
</blockquote>
<p>My preferred method is Erlang-ish message passing. Slightly simlified, I do it like this:</p>
<pre><code>import sys, time
import threading
import Queue # thread-s... | 12 | 2009-05-25T11:32:18Z | [
"python",
"python-2.6"
] |
Why does sys.exit() not exit when called inside a thread in Python? | 905,189 | <p>This could be a stupid question, but I'm testing out some of my assumptions about Python and I'm confused as to why the following code snippet would not exit when called in the thread, but would exit when called in the main thread.</p>
<pre><code>import sys, time
from threading import Thread
def testexit():
time.... | 43 | 2009-05-25T03:10:44Z | 5,120,178 | <blockquote>
<p>What if I did want to exit the program
from the thread?</p>
</blockquote>
<p>Apart from the method Deestan described you can call <code>os._exit</code> (notice the underscore). Before using it make sure that you understand that it does <em>no</em> cleanups (like calling <code>__del__</code> or simi... | 7 | 2011-02-25T16:58:10Z | [
"python",
"python-2.6"
] |
Why does sys.exit() not exit when called inside a thread in Python? | 905,189 | <p>This could be a stupid question, but I'm testing out some of my assumptions about Python and I'm confused as to why the following code snippet would not exit when called in the thread, but would exit when called in the main thread.</p>
<pre><code>import sys, time
from threading import Thread
def testexit():
time.... | 43 | 2009-05-25T03:10:44Z | 7,099,229 | <blockquote>
<p>What if I did want to exit the program from the thread (not that I
actually want to, but just so I understand)?</p>
</blockquote>
<p>At least on Linux you could do something like:</p>
<pre><code>os.kill(os.getpid(), signal.SIGINT)
</code></pre>
<p>This send a SIGINT to the main thread where it ca... | 3 | 2011-08-17T20:43:41Z | [
"python",
"python-2.6"
] |
os.system() execute command under which linux shell? | 905,221 | <p>I am using /bin/tcsh as my default shell. </p>
<p>However, the tcsh style command os.system('setenv VAR val') doesn't work for me. But os.system('export VAR=val') works.</p>
<p>So my question is how can I know the os.system() run command under which shell?</p>
| 8 | 2009-05-25T03:30:14Z | 905,258 | <p>These days you should be using the <a href="http://docs.python.org/library/subprocess.html">Subprocess</a> module instead of <code>os.system()</code>. According to the documentation there, the default shell is <code>/bin/sh</code>. I believe that <code>os.system()</code> works the same way.</p>
<p>Edit: I should al... | 9 | 2009-05-25T03:51:58Z | [
"python",
"linux",
"shell"
] |
os.system() execute command under which linux shell? | 905,221 | <p>I am using /bin/tcsh as my default shell. </p>
<p>However, the tcsh style command os.system('setenv VAR val') doesn't work for me. But os.system('export VAR=val') works.</p>
<p>So my question is how can I know the os.system() run command under which shell?</p>
| 8 | 2009-05-25T03:30:14Z | 905,294 | <p><code>os.system()</code> just calls the <code>system()</code> system call ("<code>man 3 system</code>"). On most *nixes this means you get <code>/bin/sh</code>.</p>
<p>Note that <code>export VAR=val</code> is technically not standard syntax (though <code>bash</code> understands it, and I think <code>ksh</code> does... | 4 | 2009-05-25T04:17:18Z | [
"python",
"linux",
"shell"
] |
os.system() execute command under which linux shell? | 905,221 | <p>I am using /bin/tcsh as my default shell. </p>
<p>However, the tcsh style command os.system('setenv VAR val') doesn't work for me. But os.system('export VAR=val') works.</p>
<p>So my question is how can I know the os.system() run command under which shell?</p>
| 8 | 2009-05-25T03:30:14Z | 906,286 | <p>If your command is a shell file, and the file is executable, and the file begins with "#!", you can pick your shell.</p>
<pre><code>#!/bin/zsh
Do Some Stuff
</code></pre>
<p>You can write this file and then execute it with <code>subprocess.Popen(filename,shell=True)</code> and you'll be able to use any shell you w... | 2 | 2009-05-25T11:00:53Z | [
"python",
"linux",
"shell"
] |
os.system() execute command under which linux shell? | 905,221 | <p>I am using /bin/tcsh as my default shell. </p>
<p>However, the tcsh style command os.system('setenv VAR val') doesn't work for me. But os.system('export VAR=val') works.</p>
<p>So my question is how can I know the os.system() run command under which shell?</p>
| 8 | 2009-05-25T03:30:14Z | 14,665,851 | <p>Was just reading <a href="http://www.rubyops.net/executing-bash-from-python">Executing BASH from Python</a>, then <a href="http://docs.python.org/2/library/subprocess.html#popen-constructor">17.1. subprocess â Subprocess management â Python v2.7.3 documentation</a>, and I saw the <code>executable</code> argument... | 8 | 2013-02-02T19:54:43Z | [
"python",
"linux",
"shell"
] |
Python - how to implement Bridge (or Adapter) design pattern? | 905,289 | <p>I'm struggling with implementing the Bridge design pattern (or an alternative such as Adapter) in Python</p>
<p>I want to be able to write code like this to dump database schemas based on a supplied URL:</p>
<pre><code>urls = ['sqlite://c:\\temp\\test.db', 'oracle://user:password@tns_name'];
for url in urls:
d... | 7 | 2009-05-25T04:12:43Z | 905,292 | <p>Use a Factory pattern instead:</p>
<pre><code>class Oracle(object):
...
class SQLite(object):
...
dbkind = dict(sqlite=SQLite, oracle=Oracle)
def Database(url):
db_type, rest = string.split(self.url, "://", 1)
return dbkind[db_type](rest)
</code></pre>
| 21 | 2009-05-25T04:16:29Z | [
"python",
"design-patterns"
] |
Is there any library to find out urls of embedded flvs in a webpage? | 905,403 | <p>I'm trying to write a script which can automatically download gameplay videos. The webpages look like dota.sgamer.com/Video/Detail/402 and www.wfbrood.com/movie/spl2009/movie_38214.html, they have flv player embedded in the flash plugin.
Is there any library to help me find out the exact flv urls? or any other ideas... | 1 | 2009-05-25T05:07:31Z | 905,451 | <p>if the embed player makes use of some variable where the flv path is set then you can download it, if not.. I doubt you find something to do it "automaticly" since every site make it's own player and identify the file by id not by path, which makes hard to know where the flv file is.</p>
| 0 | 2009-05-25T05:34:41Z | [
"python",
"download",
"flv"
] |
Is there any library to find out urls of embedded flvs in a webpage? | 905,403 | <p>I'm trying to write a script which can automatically download gameplay videos. The webpages look like dota.sgamer.com/Video/Detail/402 and www.wfbrood.com/movie/spl2009/movie_38214.html, they have flv player embedded in the flash plugin.
Is there any library to help me find out the exact flv urls? or any other ideas... | 1 | 2009-05-25T05:07:31Z | 905,552 | <p>It looks like <a href="http://undefined.org/python/#flashticle" rel="nofollow">Flashticle</a> (4th result on searching the cheese shop for "flash"), might be able to get the information you want, if it is there.</p>
<p>As to getting the file, you want to look at a html parser. I've heard good things about <a href=... | 1 | 2009-05-25T06:15:54Z | [
"python",
"download",
"flv"
] |
HttpResponseRedirect django + facebook | 905,803 | <p>I have a form with 2 buttons. depending on the button click user is
taken to different url.
view function is : </p>
<pre><code>friend_id = request.POST.get('selected_friend_id_list')
history = request.POST.get('statushistory')
if history:
print "dfgdfgdf"
return HttpResponseRedirect('../status/')
else:
... | 0 | 2009-05-25T07:53:37Z | 905,930 | <p>Why do you need to use relative urls? Can you not use absolute urls?</p>
| 0 | 2009-05-25T08:50:25Z | [
"python",
"django",
"facebook"
] |
HttpResponseRedirect django + facebook | 905,803 | <p>I have a form with 2 buttons. depending on the button click user is
taken to different url.
view function is : </p>
<pre><code>friend_id = request.POST.get('selected_friend_id_list')
history = request.POST.get('statushistory')
if history:
print "dfgdfgdf"
return HttpResponseRedirect('../status/')
else:
... | 0 | 2009-05-25T07:53:37Z | 906,265 | <p>"so my problem is page is not redirecting to the url . If I make HttpResponseRedirect('../') it gives me the correct page but url is not changing."</p>
<p>By "URL" I'm guessing you mean "The URL shown in the browser". It helps if your question is very precise.</p>
<p>First, you must provide an absolute URL. <a h... | 2 | 2009-05-25T10:56:03Z | [
"python",
"django",
"facebook"
] |
Why such import is not allowed? | 905,848 | <p>FILE: b.py</p>
<pre><code>class B:
def __init__(self):
print "B"
import a
a = A()
</code></pre>
<p>FILE: a.py</p>
<pre><code>class A(B): ###=> B is not defined
def __init__(self):
print "A"
</code></pre>
<p>When I try to execute <code>b.py</code>, it's said that B is no... | 3 | 2009-05-25T08:22:29Z | 905,887 | <p>Because python initializes class A in its own file. It is not like a C or PHP include where every imported module is essentially pasted into the original file.</p>
<p>You should put class B in the same file as class A to fix this problem. Or you can put class B in c.py and import it with "from c import B".</p>
| 5 | 2009-05-25T08:36:18Z | [
"python"
] |
Why such import is not allowed? | 905,848 | <p>FILE: b.py</p>
<pre><code>class B:
def __init__(self):
print "B"
import a
a = A()
</code></pre>
<p>FILE: a.py</p>
<pre><code>class A(B): ###=> B is not defined
def __init__(self):
print "A"
</code></pre>
<p>When I try to execute <code>b.py</code>, it's said that B is no... | 3 | 2009-05-25T08:22:29Z | 906,141 | <p>The closest working thing to your code would be:</p>
<pre><code>==== FILE: b.py ====
class B:
def __init__(self):
print "B"
import a
if __name__ == "__main__":
a = a.A()
==== FILE: a.py ====
import b
class A(b.B): ###=> B is not defined
def __init__(self):
print "A"... | 5 | 2009-05-25T10:08:29Z | [
"python"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.