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 |
|---|---|---|---|---|---|---|---|---|---|
questions re: current state of GUI programming with Python | 707,491 | <p>I recently did some work modifying a Python gui app that was using wxPython widgets. I've experimented with Python in fits and starts over last six or seven years, but this was the first time I did any work with a gui. I was pretty disappointed at what seems to be the current state of gui programming with Python. ... | 20 | 2009-04-01T21:53:15Z | 714,201 | <p><a href="http://dabodev.com/" rel="nofollow">dabo</a> puts wxPython programming at a higher level like what you're looking for.</p>
| 3 | 2009-04-03T14:38:58Z | [
"python",
"user-interface"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 707,683 | <p>You're very close! <code>string</code> is a module, not a type. You probably want to compare the type of <code>obj</code> against the type object for strings, namely <code>str</code>:</p>
<pre><code>type(obj) == str # this works because str is already a type
</code></pre>
<p>Alternatively:</p>
<pre><code>type(ob... | 3 | 2009-04-01T23:06:36Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 707,685 | <pre><code>isinstance()
</code></pre>
<p>In your case, <code>isinstance("this is a string", str)</code> will return <code>True</code>.</p>
<p>You may also want to read this: <a href="http://www.canonical.org/~kragen/isinstance/">http://www.canonical.org/~kragen/isinstance/</a></p>
| 106 | 2009-04-01T23:07:02Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 707,687 | <p>i think this should do it</p>
<pre><code>if isinstance(obj, str)
</code></pre>
| 2 | 2009-04-01T23:07:49Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 707,716 | <p>For other types, check out the <a href="http://docs.python.org/library/types.html">types</a> module:</p>
<pre><code>>>> import types
>>> x = "mystring"
>>> isinstance(x, types.StringType)
True
>>> x = 5
>>> isinstance(x, types.IntType)
True
>>> x = None
>>... | 20 | 2009-04-01T23:19:36Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 707,732 | <p><code>isinstance</code> works:</p>
<pre><code>if isinstance(obj, MyClass): do_foo(obj)
</code></pre>
<p><strong>but</strong>, keep in mind: if it looks like a duck, and if it sounds like a duck, it is a duck.</p>
<p>EDIT: For the None type, you can simply do:</p>
<pre><code>if obj is None: obj = MyClass()
</cod... | 30 | 2009-04-01T23:26:47Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 707,812 | <p>You can always use the <code>type(x) == type(y)</code> trick, where <code>y</code> is something with known type.</p>
<pre><code># check if x is a regular string
type(x) == type('')
# check if x is an integer
type(x) == type(1)
# check if x is a NoneType
type(x) == type(None)
</code></pre>
<p>Often there are better... | 8 | 2009-04-02T00:01:28Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 707,836 | <p>I use <code>type(x) == type(y)</code></p>
<p>For instance, if I want to check something is an array:</p>
<pre><code>type( x ) == type( [] )
</code></pre>
<p>string check:</p>
<pre><code>type( x ) == type( '' ) or type( x ) == type( u'' )
</code></pre>
<p>If you want to check against None, use is</p>
<pre><code... | 2 | 2009-04-02T00:10:13Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 707,878 | <p>First, avoid all type comparisons. They're very, very rarely necessary. Sometimes, they help to check parameter types in a function -- even that's rare. Wrong type data will raise an exception, and that's all you'll ever need.</p>
<p>All of the basic conversion functions will map as equal to the type function.</... | 26 | 2009-04-02T00:34:18Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 712,116 | <p>It is because you have to write</p>
<pre><code>s="hello"
type(s) == type("")
</code></pre>
<p>type accepts an instance and returns its type. In this case you have to compare two instances' types.</p>
<p>If you need to do preemptive checking, it is better if you check for a supported interface than the type. </p>
... | 5 | 2009-04-03T00:14:45Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 10,049,518 | <p>Type doesn't work on certain classes. If you're not sure of the object's type use the <code>__class__</code> method, as so:</p>
<pre><code>>>>obj = 'a string'
>>>obj.__class__ == str
True
</code></pre>
<p>Also see this article - <a href="http://www.siafoo.net/article/56" rel="nofollow">http://www... | 1 | 2012-04-06T21:34:25Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 14,640,097 | <p>To get the type, use the <code>__class__</code> member, as in <code>unknown_thing.__class__</code></p>
<p>Talk of duck-typing is useless here because it doesn't answer a perfectly good question. In my application code I never need to know the type of something, but it's still useful to have a way to learn an object... | 0 | 2013-02-01T05:07:22Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 14,787,321 | <p>Use str instead of string </p>
<pre><code>type ( obj ) == str
</code></pre>
<p>Explanation </p>
<pre><code>>>> a = "Hello"
>>> type(a)==str
True
>>> type(a)
<type 'str'>
>>>
</code></pre>
| 2 | 2013-02-09T10:48:30Z | [
"python",
"types",
"compare"
] |
How to compare type of an object in Python? | 707,674 | <p>Basically I want to do this:</p>
<pre><code>obj = 'str'
type ( obj ) == string
</code></pre>
<p>I tried:</p>
<pre><code>type ( obj ) == type ( string )
</code></pre>
<p>and it didn't work.</p>
<p>Also, what about the other types? For example, I couldn't replicate <code>NoneType</code>.</p>
| 85 | 2009-04-01T23:03:05Z | 37,044,845 | <p>You can compare classes for check level.</p>
<pre><code>#!/usr/bin/env python
#coding:utf8
class A(object):
def t(self):
print 'A'
def r(self):
print 'rA',
self.t()
class B(A):
def t(self):
print 'B'
class C(A):
def t(self):
print 'C'
class D(B, C):
de... | 0 | 2016-05-05T07:25:19Z | [
"python",
"types",
"compare"
] |
web.py: passing initialization / global variables to handler classes? | 707,841 | <p>I'm attempting to use web.py with Tokyo Cabinet / pytc and need to pass the db handle (the connection to tokyo cabinet) to my handler classes so they can talk to tokyo cabinet. </p>
<p>Is there a way to pass the handler to the handler class's <strong>init</strong> function? Or should I be putting the handle in glob... | 1 | 2009-04-02T00:12:58Z | 709,243 | <p>The best way would be to add a load hook (described <a href="http://webpy.org/cookbook/sqlalchemy" rel="nofollow">here</a> for sqlalchemy). Define a function that connects to Tokyo Cabinet and adds the resulting db object as an .orm attribute to web.ctx, which is always available inside the controller.</p>
| 2 | 2009-04-02T10:47:49Z | [
"python",
"web.py"
] |
Which Python Bayesian text classification modules are similar to dbacl? | 707,879 | <p>A quick Google search reveals that there are a good number of Bayesian classifiers implemented as Python modules. If I want wrapped, high-level functionality similar to <a href="http://dbacl.sourceforge.net/" rel="nofollow">dbacl</a>, which of those modules is right for me?</p>
<p>Training</p>
<pre><code>% dbacl -... | 11 | 2009-04-02T00:34:26Z | 707,901 | <p>I think you'll find the <a href="http://www.nltk.org">nltk</a> helpful. Specifically, the <a href="http://nltk.googlecode.com/svn/trunk/doc/api/nltk.classify-module.html">classify module</a>.</p>
| 9 | 2009-04-02T00:49:04Z | [
"python",
"text",
"classification",
"bayesian"
] |
Which Python Bayesian text classification modules are similar to dbacl? | 707,879 | <p>A quick Google search reveals that there are a good number of Bayesian classifiers implemented as Python modules. If I want wrapped, high-level functionality similar to <a href="http://dbacl.sourceforge.net/" rel="nofollow">dbacl</a>, which of those modules is right for me?</p>
<p>Training</p>
<pre><code>% dbacl -... | 11 | 2009-04-02T00:34:26Z | 708,236 | <p>If you're trying to detect language
<a href="http://cogscicoder.blogspot.com/2009/03/automatic-language-identification-using.html" rel="nofollow">this</a> works fine even with pretty short texts.</p>
<p>The api is pretty close to yours but
I don't know if it is called a Bayesian classifier. </p>
| 0 | 2009-04-02T03:57:28Z | [
"python",
"text",
"classification",
"bayesian"
] |
Which Python Bayesian text classification modules are similar to dbacl? | 707,879 | <p>A quick Google search reveals that there are a good number of Bayesian classifiers implemented as Python modules. If I want wrapped, high-level functionality similar to <a href="http://dbacl.sourceforge.net/" rel="nofollow">dbacl</a>, which of those modules is right for me?</p>
<p>Training</p>
<pre><code>% dbacl -... | 11 | 2009-04-02T00:34:26Z | 1,041,350 | <p>It maybe this can be useful: <a href="http://www.divmod.org/trac/wiki/DivmodReverend" rel="nofollow">http://www.divmod.org/trac/wiki/DivmodReverend</a></p>
| 2 | 2009-06-24T22:29:57Z | [
"python",
"text",
"classification",
"bayesian"
] |
Which Python Bayesian text classification modules are similar to dbacl? | 707,879 | <p>A quick Google search reveals that there are a good number of Bayesian classifiers implemented as Python modules. If I want wrapped, high-level functionality similar to <a href="http://dbacl.sourceforge.net/" rel="nofollow">dbacl</a>, which of those modules is right for me?</p>
<p>Training</p>
<pre><code>% dbacl -... | 11 | 2009-04-02T00:34:26Z | 10,737,824 | <p>Noticing this question.
I put my implementation of a naive Bayesian classifier on gitHub.</p>
<p><a href="https://github.com/milkmeat/beiyesi" rel="nofollow">Here it is - beiyesi</a></p>
<p>It still needs a lot of improvement. Any help is appreciated.</p>
| 1 | 2012-05-24T12:48:28Z | [
"python",
"text",
"classification",
"bayesian"
] |
Which Python Bayesian text classification modules are similar to dbacl? | 707,879 | <p>A quick Google search reveals that there are a good number of Bayesian classifiers implemented as Python modules. If I want wrapped, high-level functionality similar to <a href="http://dbacl.sourceforge.net/" rel="nofollow">dbacl</a>, which of those modules is right for me?</p>
<p>Training</p>
<pre><code>% dbacl -... | 11 | 2009-04-02T00:34:26Z | 15,790,667 | <p>Try <a href="http://mallet.cs.umass.edu" rel="nofollow">Mallet</a> and <a href="http://alias-i.com/lingpipe/" rel="nofollow">LingPipe</a>. they provide more models for the classifier.</p>
| -1 | 2013-04-03T14:50:11Z | [
"python",
"text",
"classification",
"bayesian"
] |
Debugging a running python process | 707,999 | <p>Is there a way to see a stacktrace of what various threads are doing inside a python process? </p>
<p>Let's suppose I have a thread which allows me some sort of remote access to the process.</p>
| 14 | 2009-04-02T01:45:03Z | 708,031 | <p>About 4 years ago, when I was using twisted, manhole was a great way to do what you're asking.</p>
<p><a href="http://twistedmatrix.com/projects/core/documentation/howto/telnet.html" rel="nofollow">http://twistedmatrix.com/projects/core/documentation/howto/telnet.html</a></p>
<p>Right now most of my projects don't... | 2 | 2009-04-02T02:04:49Z | [
"python",
"remote-debugging"
] |
Debugging a running python process | 707,999 | <p>Is there a way to see a stacktrace of what various threads are doing inside a python process? </p>
<p>Let's suppose I have a thread which allows me some sort of remote access to the process.</p>
| 14 | 2009-04-02T01:45:03Z | 708,201 | <p><a href="http://winpdb.org/">Winpdb</a> is a <strong>platform independent</strong> graphical GPL Python debugger with support for remote debugging over a network, multiple threads, namespace modification, embedded debugging, encrypted communication and is up to 20 times faster than pdb.</p>
<p>Features:</p>
<ul>
<... | 6 | 2009-04-02T03:44:35Z | [
"python",
"remote-debugging"
] |
Python SAX parser says XML file is not well-formed | 708,531 | <p>I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how ... | 0 | 2009-04-02T06:35:38Z | 708,537 | <p>Does the sax parser not give you details about <em>where</em> it thinks it's not well-formed?</p>
<p>Have you tried loading the file into an XML editor and checking it there? Do other XML parsers accept it?</p>
<p>The schema shouldn't change whether or not the XML is well-formed or not; it may well change whether ... | 1 | 2009-04-02T06:38:48Z | [
"python",
"xml",
"sax"
] |
Python SAX parser says XML file is not well-formed | 708,531 | <p>I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how ... | 0 | 2009-04-02T06:35:38Z | 708,546 | <p>I would suggest putting those tags back in and making sure it still works. Then, if you want to take them out, do it one at a time until it breaks.</p>
<p>However, I question the wisdom of taking them out. If it's your XML file, you should understand it better. If it's a third-party XML file, you really shouldn't b... | 2 | 2009-04-02T06:42:50Z | [
"python",
"xml",
"sax"
] |
Python SAX parser says XML file is not well-formed | 708,531 | <p>I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how ... | 0 | 2009-04-02T06:35:38Z | 711,033 | <p>I would second recommendation to try to parse it using another XML parser. That should give an indication as to whether it's the document that's wrong, or parser.</p>
<p>Also, the actual error message might be useful. One fairly common problem for example is that the xml declaration (if one is used, it's optional) ... | 0 | 2009-04-02T18:32:53Z | [
"python",
"xml",
"sax"
] |
Python SAX parser says XML file is not well-formed | 708,531 | <p>I stripped some tags that I thought were unnecessary from an XML file. Now when I try to parse it, my SAX parser throws an error and says my file is not well-formed. However, I know every start tag has an end tag. The file's opening tag has a link to an XML schema. Could this be causing the trouble? If so, then how ... | 0 | 2009-04-02T06:35:38Z | 715,813 | <p>You could load it into Firefox, if you don't have an XML editor. Firefox shows you the error.</p>
| 0 | 2009-04-03T21:31:39Z | [
"python",
"xml",
"sax"
] |
Python comments: # vs strings | 708,649 | <p>I have a question regarding the "standard" way to put comments inside Python source code:</p>
<pre><code>def func():
"Func doc"
... <code>
'TODO: fix this'
#badFunc()
... <more code>
def func():
"Func doc"
... <code>
#TODO: fix this
#badFunc()
... <more ... | 19 | 2009-04-02T07:24:59Z | 708,655 | <p>I think that only the first string literal in a definition (or class) is "special", i.e. gets stored by the interpreter into the defined object's (or class') <a href="http://www.python.org/dev/peps/pep-0257/" rel="nofollow">docstring</a>.</p>
<p>Any other string literals you place in the code will, at the worst, me... | 4 | 2009-04-02T07:28:17Z | [
"python"
] |
Python comments: # vs strings | 708,649 | <p>I have a question regarding the "standard" way to put comments inside Python source code:</p>
<pre><code>def func():
"Func doc"
... <code>
'TODO: fix this'
#badFunc()
... <more code>
def func():
"Func doc"
... <code>
#TODO: fix this
#badFunc()
... <more ... | 19 | 2009-04-02T07:24:59Z | 708,668 | <p>The disadvantage, of course, is that someone else reading it will find that the code strings and comment strings are interleaved, which could be confusing.</p>
| 5 | 2009-04-02T07:32:53Z | [
"python"
] |
Python comments: # vs strings | 708,649 | <p>I have a question regarding the "standard" way to put comments inside Python source code:</p>
<pre><code>def func():
"Func doc"
... <code>
'TODO: fix this'
#badFunc()
... <more code>
def func():
"Func doc"
... <code>
#TODO: fix this
#badFunc()
... <more ... | 19 | 2009-04-02T07:24:59Z | 708,674 | <p>Don't misuse strings (no-op statements) as comments. Docstrings, e.g. the first string in a module, class or function, are special and definitely recommended.</p>
<p>Note that <strong>docstrings are documentation</strong>, and documentation and comments are two different things!</p>
<ul>
<li>Documentation is impor... | 53 | 2009-04-02T07:36:08Z | [
"python"
] |
SQLAlchemy - INSERT OR REPLACE equivalent | 708,762 | <p>does anybody know what is the equivalent to SQL "INSERT OR REPLACE" clause in SQLAlchemy and its SQL expression language?</p>
<p>Many thanks -- honzas</p>
| 9 | 2009-04-02T08:05:37Z | 708,769 | <pre><code>Session.save_or_update(model)
</code></pre>
| 6 | 2009-04-02T08:11:02Z | [
"python",
"sqlalchemy"
] |
SQLAlchemy - INSERT OR REPLACE equivalent | 708,762 | <p>does anybody know what is the equivalent to SQL "INSERT OR REPLACE" clause in SQLAlchemy and its SQL expression language?</p>
<p>Many thanks -- honzas</p>
| 9 | 2009-04-02T08:05:37Z | 709,452 | <p>I don't think (correct me if I'm wrong) INSERT OR REPLACE is in any of the SQL standards; it's an SQLite-specific thing. There is MERGE, but that isn't supported by all dialects either. So it's not available in SQLAlchemy's general dialect.</p>
<p>The cleanest solution is to use Session, as suggested by M. Utku. ... | 3 | 2009-04-02T12:10:45Z | [
"python",
"sqlalchemy"
] |
SQLAlchemy - INSERT OR REPLACE equivalent | 708,762 | <p>does anybody know what is the equivalent to SQL "INSERT OR REPLACE" clause in SQLAlchemy and its SQL expression language?</p>
<p>Many thanks -- honzas</p>
| 9 | 2009-04-02T08:05:37Z | 2,602,292 | <p>What about <code>Session.merge</code>?</p>
<pre><code>Session.merge(instance, load=True, **kw)
</code></pre>
<p>Copy the state an instance onto the persistent instance with the same identifier.</p>
<p>If there is no persistent instance currently associated with the session, it will be loaded. Return the persisten... | 5 | 2010-04-08T17:58:19Z | [
"python",
"sqlalchemy"
] |
SQLAlchemy - INSERT OR REPLACE equivalent | 708,762 | <p>does anybody know what is the equivalent to SQL "INSERT OR REPLACE" clause in SQLAlchemy and its SQL expression language?</p>
<p>Many thanks -- honzas</p>
| 9 | 2009-04-02T08:05:37Z | 5,745,573 | <p>You can use <code>OR REPLACE</code> as a so-called <code>prefix</code> in your SQLAlchemy <code>Insert</code> -- the documentation for how to place <code>OR REPLACE</code> between <code>INSERT</code> and <code>INTO</code> in your SQL statement is <a href="http://www.sqlalchemy.org/docs/core/expression_api.html?highl... | 1 | 2011-04-21T14:35:43Z | [
"python",
"sqlalchemy"
] |
How Much Traffic Can Shared Web Hosting (for a Python Django site) support? | 708,799 | <p>Someone in this thread</p>
<p><a href="http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take">http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take</a></p>
<p>stated that a $5/mo shared hosting account on Reliablesite.net can support 10,000 - 20,000... | 4 | 2009-04-02T08:27:42Z | 708,805 | <p>If your application is optimized, you shared hosting account can handle 10k unique visitors per day.</p>
<p>You can find a great hosting for your needs at WFT (<a href="http://www.webhostingtalk.com" rel="nofollow">WebHostingTalk</a>)</p>
<p>One of the biggest hosting provider is GoDaddy (I RECOMMEND IT). Their sh... | 0 | 2009-04-02T08:29:29Z | [
"python",
"hosting",
"web-hosting",
"shared-hosting"
] |
How Much Traffic Can Shared Web Hosting (for a Python Django site) support? | 708,799 | <p>Someone in this thread</p>
<p><a href="http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take">http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take</a></p>
<p>stated that a $5/mo shared hosting account on Reliablesite.net can support 10,000 - 20,000... | 4 | 2009-04-02T08:27:42Z | 708,848 | <p>100,000 - 200,000 pageviews/day is on average 2 pageviews/s, at most you'll get 10-20 pageviews/s during busy hours. That's not a lot to handle, especially if you have caching.</p>
<p>Anyways, I'd go for VPS. The problem with shared server is that you can never know the pattern of use the other ppl have.</p>
| 3 | 2009-04-02T08:47:46Z | [
"python",
"hosting",
"web-hosting",
"shared-hosting"
] |
How Much Traffic Can Shared Web Hosting (for a Python Django site) support? | 708,799 | <p>Someone in this thread</p>
<p><a href="http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take">http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take</a></p>
<p>stated that a $5/mo shared hosting account on Reliablesite.net can support 10,000 - 20,000... | 4 | 2009-04-02T08:27:42Z | 709,020 | <p>Webfaction hosting hosts nearly 10 sites of ours handling over 10k users each day, easily. I am also told that Slicehost is just as good.</p>
<p>Webfaction and Slicehost are often looked upto for mod_wsgi python hosting, which is fast becoming the preferred way to host django apps.</p>
<p>These hosts seem to be on... | 2 | 2009-04-02T09:41:07Z | [
"python",
"hosting",
"web-hosting",
"shared-hosting"
] |
How Much Traffic Can Shared Web Hosting (for a Python Django site) support? | 708,799 | <p>Someone in this thread</p>
<p><a href="http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take">http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take</a></p>
<p>stated that a $5/mo shared hosting account on Reliablesite.net can support 10,000 - 20,000... | 4 | 2009-04-02T08:27:42Z | 779,328 | <p>I have been using mysql on shared hosting for a while mainly on informational websites that have gotten at most 300 visits per day. What I have found is that the hosting was barely sufficient to support more than 3 or 4 people on the website at one time without it almost crashing.</p>
<p>Theoretically i think shar... | 1 | 2009-04-22T21:33:21Z | [
"python",
"hosting",
"web-hosting",
"shared-hosting"
] |
How Much Traffic Can Shared Web Hosting (for a Python Django site) support? | 708,799 | <p>Someone in this thread</p>
<p><a href="http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take">http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take</a></p>
<p>stated that a $5/mo shared hosting account on Reliablesite.net can support 10,000 - 20,000... | 4 | 2009-04-02T08:27:42Z | 840,005 | <p>I'm with GoDaddy.com and it's true that you can have an unlimited number of sites on the same hosting plan but you are limited to 100 unique users.
This means that it doesn't matter if you have 1 website or 1000 websites on your hosting plan, you can only have 100 visitors at the same time throughout all of your si... | 1 | 2009-05-08T14:20:09Z | [
"python",
"hosting",
"web-hosting",
"shared-hosting"
] |
How Much Traffic Can Shared Web Hosting (for a Python Django site) support? | 708,799 | <p>Someone in this thread</p>
<p><a href="http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take">http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take</a></p>
<p>stated that a $5/mo shared hosting account on Reliablesite.net can support 10,000 - 20,000... | 4 | 2009-04-02T08:27:42Z | 974,025 | <p>I am hosting with Godaddy. But I am not aware of this 100 users at the same time thing.</p>
| 0 | 2009-06-10T06:42:51Z | [
"python",
"hosting",
"web-hosting",
"shared-hosting"
] |
How Much Traffic Can Shared Web Hosting (for a Python Django site) support? | 708,799 | <p>Someone in this thread</p>
<p><a href="http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take">http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take</a></p>
<p>stated that a $5/mo shared hosting account on Reliablesite.net can support 10,000 - 20,000... | 4 | 2009-04-02T08:27:42Z | 979,305 | <p>Most hosts support multiple sites without extra charge. Don't pick GoDaddy because of that. I never used GoDaddy hosting, but use them for domain registration, and they are absolutely terrible. Terrible UI, terrible performance. I would never trust them to host a website. The only reason I use them for domain regist... | 2 | 2009-06-11T04:17:48Z | [
"python",
"hosting",
"web-hosting",
"shared-hosting"
] |
How Much Traffic Can Shared Web Hosting (for a Python Django site) support? | 708,799 | <p>Someone in this thread</p>
<p><a href="http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take">http://stackoverflow.com/questions/685162/how-much-traffic-can-shared-web-hosting-take</a></p>
<p>stated that a $5/mo shared hosting account on Reliablesite.net can support 10,000 - 20,000... | 4 | 2009-04-02T08:27:42Z | 994,295 | <p>That sounds like a stretch for a $5/month shared hosting service. I'd suggest looking in to MediaTemple Grid-Service which is a bit more expensive at $20/month but is more likely to be able to handle your volume and grow with you.</p>
| 0 | 2009-06-15T02:17:14Z | [
"python",
"hosting",
"web-hosting",
"shared-hosting"
] |
Why do languages like Java use hierarchical package names, while Python does not? | 709,036 | <p>I haven't done enterprise work in Java, but I often see the <a href="http://stackoverflow.com/questions/420945/java-package-name-convention-failure">reverse-domain-name package naming convention</a>. For example, for a Stack Overflow Java package you'd put your code underneath package <code>com.stackoverflow</code>.... | 13 | 2009-04-02T09:45:13Z | 709,040 | <p>The idea is to keep name spaces conflict free. Instead of unreadable UUIDs or the like, the reverse domain name is unlikely to get in someone else's way.
Very simple, but pragmatic.
Moreover when using 3rd party libs it might give you a clue as to where they came from (for updates, support etc.)</p>
| 5 | 2009-04-02T09:47:13Z | [
"java",
"python",
"packages"
] |
Why do languages like Java use hierarchical package names, while Python does not? | 709,036 | <p>I haven't done enterprise work in Java, but I often see the <a href="http://stackoverflow.com/questions/420945/java-package-name-convention-failure">reverse-domain-name package naming convention</a>. For example, for a Stack Overflow Java package you'd put your code underneath package <code>com.stackoverflow</code>.... | 13 | 2009-04-02T09:45:13Z | 709,100 | <p>It's a great way of preventing name collisions, and takes full advantage of the existing domain name system, so it requires no additional bureaucracy or registration. It is simple and brilliant.</p>
<p>By reversing the domain name it also gives it a hierarchical structure, which is handy. So you can have sub-pack... | 10 | 2009-04-02T10:02:10Z | [
"java",
"python",
"packages"
] |
Why do languages like Java use hierarchical package names, while Python does not? | 709,036 | <p>I haven't done enterprise work in Java, but I often see the <a href="http://stackoverflow.com/questions/420945/java-package-name-convention-failure">reverse-domain-name package naming convention</a>. For example, for a Stack Overflow Java package you'd put your code underneath package <code>com.stackoverflow</code>.... | 13 | 2009-04-02T09:45:13Z | 709,105 | <p>Java is able to do it like this, since it is a recommended Java standard practice, and pretty much universally accepted by the Java community. Python dos not have this convention.</p>
| 0 | 2009-04-02T10:04:05Z | [
"java",
"python",
"packages"
] |
Why do languages like Java use hierarchical package names, while Python does not? | 709,036 | <p>I haven't done enterprise work in Java, but I often see the <a href="http://stackoverflow.com/questions/420945/java-package-name-convention-failure">reverse-domain-name package naming convention</a>. For example, for a Stack Overflow Java package you'd put your code underneath package <code>com.stackoverflow</code>.... | 13 | 2009-04-02T09:45:13Z | 709,150 | <p>"What are the reasons you'd prefer one over the other?"</p>
<p>Python's style is simpler. Java's style allows same-name products from different organizations.</p>
<p>"Do those reasons apply across the languages?"</p>
<p>Yes. You can easily have top level Python packages named "com", "org", "mil", "net", "edu" a... | 12 | 2009-04-02T10:18:03Z | [
"java",
"python",
"packages"
] |
Why do languages like Java use hierarchical package names, while Python does not? | 709,036 | <p>I haven't done enterprise work in Java, but I often see the <a href="http://stackoverflow.com/questions/420945/java-package-name-convention-failure">reverse-domain-name package naming convention</a>. For example, for a Stack Overflow Java package you'd put your code underneath package <code>com.stackoverflow</code>.... | 13 | 2009-04-02T09:45:13Z | 709,160 | <p>Python <em>does</em> have it, it's just a much flatter hierarchy. Look at <code>os.path</code>, for example. And there's nothing stopping library designers making much deeper ones, e.g. Django.</p>
<p>Fundamentally, I think Python is designed on the idea that you want to get stuff done without having to specify o... | 2 | 2009-04-02T10:23:29Z | [
"java",
"python",
"packages"
] |
Why do languages like Java use hierarchical package names, while Python does not? | 709,036 | <p>I haven't done enterprise work in Java, but I often see the <a href="http://stackoverflow.com/questions/420945/java-package-name-convention-failure">reverse-domain-name package naming convention</a>. For example, for a Stack Overflow Java package you'd put your code underneath package <code>com.stackoverflow</code>.... | 13 | 2009-04-02T09:45:13Z | 709,188 | <p>Python doesn't do this because you end up with a problem -- who owns the "com" package that almost everything else is a subpackage of? Python's method of establishing package heirarchy (through the filesystem heirarchy) does not play well with this convention at all. Java can get away with it because package heira... | 18 | 2009-04-02T10:32:12Z | [
"java",
"python",
"packages"
] |
Why do languages like Java use hierarchical package names, while Python does not? | 709,036 | <p>I haven't done enterprise work in Java, but I often see the <a href="http://stackoverflow.com/questions/420945/java-package-name-convention-failure">reverse-domain-name package naming convention</a>. For example, for a Stack Overflow Java package you'd put your code underneath package <code>com.stackoverflow</code>.... | 13 | 2009-04-02T09:45:13Z | 711,380 | <p>If Guido himself announced that the reverse domain convention ought to be followed, it wouldn't be adopted, unless there were significant changes to the implementation of <code>import</code> in python.</p>
<p>Consider: python searches an import path at run-time with a fail-fast algorithm; java searches a path with ... | 12 | 2009-04-02T20:05:02Z | [
"java",
"python",
"packages"
] |
Why do languages like Java use hierarchical package names, while Python does not? | 709,036 | <p>I haven't done enterprise work in Java, but I often see the <a href="http://stackoverflow.com/questions/420945/java-package-name-convention-failure">reverse-domain-name package naming convention</a>. For example, for a Stack Overflow Java package you'd put your code underneath package <code>com.stackoverflow</code>.... | 13 | 2009-04-02T09:45:13Z | 711,452 | <p>Somewhere on Joel on Software, Joel has a comparison between two methods of growing a company: the Ben & Jerry's method, which starts small and grows organically, and the Amazon method of raising a whole lot of money and staking very wide claims from the start.</p>
<p>When Sun introduced Java, it was with fanf... | 10 | 2009-04-02T20:24:06Z | [
"java",
"python",
"packages"
] |
How to tell the difference between an iterator and an iterable? | 709,084 | <p>In Python the interface of an iterable is a subset of the <a href="http://docs.python.org/library/stdtypes.html#iterator-types">iterator interface</a>. This has the advantage that in many cases they can be treated in the same way. However, there is an important semantic difference between the two, since for an itera... | 10 | 2009-04-02T09:56:55Z | 709,123 | <blockquote>
<p>However, there is an important semantic difference between the two...</p>
</blockquote>
<p>Not really semantic or important. They're both iterable -- they both work with a for statement.</p>
<blockquote>
<p>The difference is for example important when one wants to loop multiple times.</p>
</block... | 3 | 2009-04-02T10:09:59Z | [
"python",
"iterator"
] |
How to tell the difference between an iterator and an iterable? | 709,084 | <p>In Python the interface of an iterable is a subset of the <a href="http://docs.python.org/library/stdtypes.html#iterator-types">iterator interface</a>. This has the advantage that in many cases they can be treated in the same way. However, there is an important semantic difference between the two, since for an itera... | 10 | 2009-04-02T09:56:55Z | 709,132 | <pre><code>'iterator' if obj is iter(obj) else 'iterable'
</code></pre>
| 14 | 2009-04-02T10:11:29Z | [
"python",
"iterator"
] |
How to tell the difference between an iterator and an iterable? | 709,084 | <p>In Python the interface of an iterable is a subset of the <a href="http://docs.python.org/library/stdtypes.html#iterator-types">iterator interface</a>. This has the advantage that in many cases they can be treated in the same way. However, there is an important semantic difference between the two, since for an itera... | 10 | 2009-04-02T09:56:55Z | 709,386 | <p>Because of Python's duck typing, </p>
<p>Any object is iterable if it defines the <code>next()</code> and <code>__iter__()</code> method returns itself.</p>
<p>If the object itself doesnt have the <code>next()</code> method, the <code>__iter__()</code> can return any object, that has a <code>next()</code> method</... | 0 | 2009-04-02T11:50:17Z | [
"python",
"iterator"
] |
How to tell the difference between an iterator and an iterable? | 709,084 | <p>In Python the interface of an iterable is a subset of the <a href="http://docs.python.org/library/stdtypes.html#iterator-types">iterator interface</a>. This has the advantage that in many cases they can be treated in the same way. However, there is an important semantic difference between the two, since for an itera... | 10 | 2009-04-02T09:56:55Z | 712,013 | <pre><code>import itertools
def process(iterable):
work_iter, backup_iter= itertools.tee(iterable)
for item in work_iter:
# bla bla
if need_to_startover():
for another_item in backup_iter:
</code></pre>
<p>That damn time machine that Raymond borrowed from Guidoâ¦</p>
| 2 | 2009-04-02T23:24:19Z | [
"python",
"iterator"
] |
What is the best way to toggle python prints? | 709,385 | <p>I'm running Python 2.4 in a game engine and I want to be able to turn off all prints if needed. For example I'd like to have the prints on for a debug build, and then turned off for a release build.
It's also imperative that it's as transparent as possible.</p>
<p>My solution to this in the C code of the engine is ... | 8 | 2009-04-02T11:49:09Z | 709,389 | <p>yes, you can assign <code>sys.stdout</code> to whatever you want. Create a little class with a <code>write</code> method that does nothing:</p>
<pre><code>class DevNull(object):
def write(self, arg):
pass
import sys
sys.stdout = DevNull()
print "this goes to nirvana!"
</code></pre>
<p>With the sam... | 12 | 2009-04-02T11:50:52Z | [
"python",
"printing"
] |
What is the best way to toggle python prints? | 709,385 | <p>I'm running Python 2.4 in a game engine and I want to be able to turn off all prints if needed. For example I'd like to have the prints on for a debug build, and then turned off for a release build.
It's also imperative that it's as transparent as possible.</p>
<p>My solution to this in the C code of the engine is ... | 8 | 2009-04-02T11:49:09Z | 709,393 | <p>Don't use print, but make a console class which handles all printing. Simply make calls to the console and the console can decide whether or not to actually print them. A console class is also useful for things like error and warning messages or redirecting where the output goes.</p>
| 3 | 2009-04-02T11:52:12Z | [
"python",
"printing"
] |
What is the best way to toggle python prints? | 709,385 | <p>I'm running Python 2.4 in a game engine and I want to be able to turn off all prints if needed. For example I'd like to have the prints on for a debug build, and then turned off for a release build.
It's also imperative that it's as transparent as possible.</p>
<p>My solution to this in the C code of the engine is ... | 8 | 2009-04-02T11:49:09Z | 709,417 | <p>The <a href="http://docs.python.org/library/logging.html" rel="nofollow">logging module</a> is the "best" way.. although I quite often just use something simple like..</p>
<pre><code>class MyLogger:
def _displayMessage(self, message, level = None):
# This can be modified easily
if level is not N... | 8 | 2009-04-02T12:00:43Z | [
"python",
"printing"
] |
What is the best way to toggle python prints? | 709,385 | <p>I'm running Python 2.4 in a game engine and I want to be able to turn off all prints if needed. For example I'd like to have the prints on for a debug build, and then turned off for a release build.
It's also imperative that it's as transparent as possible.</p>
<p>My solution to this in the C code of the engine is ... | 8 | 2009-04-02T11:49:09Z | 709,897 | <p>I know an answer has already been marked as correct, but Python has a debug flag that provides a cleaner solution. You use it like this:</p>
<pre><code>if __debug__:
print "whoa"
</code></pre>
<p>If you invoke Python with -O or -OO (as you normally would for a release build), <code>__debug__</code> is set to ... | 10 | 2009-04-02T14:17:17Z | [
"python",
"printing"
] |
What is the best way to toggle python prints? | 709,385 | <p>I'm running Python 2.4 in a game engine and I want to be able to turn off all prints if needed. For example I'd like to have the prints on for a debug build, and then turned off for a release build.
It's also imperative that it's as transparent as possible.</p>
<p>My solution to this in the C code of the engine is ... | 8 | 2009-04-02T11:49:09Z | 32,488,369 | <p>I've answered this question on a <a href="http://stackoverflow.com/questions/32487941/efficient-way-of-toggling-on-off-print-statements-in-python/32488016#32488016">different post</a> but was the question was marked duplicate:</p>
<p>anyhow, here's what I would do:</p>
<pre><code>from __future__ import print_funct... | 0 | 2015-09-09T20:14:24Z | [
"python",
"printing"
] |
What is the best way to toggle python prints? | 709,385 | <p>I'm running Python 2.4 in a game engine and I want to be able to turn off all prints if needed. For example I'd like to have the prints on for a debug build, and then turned off for a release build.
It's also imperative that it's as transparent as possible.</p>
<p>My solution to this in the C code of the engine is ... | 8 | 2009-04-02T11:49:09Z | 32,489,099 | <p>If you really want to toggle printing:</p>
<pre><code>>>> import sys
>>> import os
>>> print 'foo'
foo
>>> origstdout = sys.stdout
>>> sys.stdout = open(os.devnull, 'w')
>>> print 'foo'
>>> sys.stdout = origstdout
>>> print 'foo'
foo
</code></p... | 1 | 2015-09-09T21:01:21Z | [
"python",
"printing"
] |
What's a more elegant rephrasing of this cropping algorithm? (in Python) | 709,388 | <p>I want to crop a thumbnail image in my Django application, so that I get a quadratic image that shows the center of the image. This is not very hard, I agree. </p>
<p>I have already written some code that does exactly this, but somehow it lacks a certain ... elegance. I don't want to play code golf, but there must ... | 4 | 2009-04-02T11:50:49Z | 709,401 | <pre><code>width, height = image.size
if width > height:
crop_box = # something 1
else:
crop_box = # something 2
image = image.crop(crop_box)
image.thumbnail([x, x], Image.ANTIALIAS) # explicitly show "square" thumbnail
</code></pre>
| 1 | 2009-04-02T11:56:26Z | [
"image",
"python-imaging-library",
"python",
"crop"
] |
What's a more elegant rephrasing of this cropping algorithm? (in Python) | 709,388 | <p>I want to crop a thumbnail image in my Django application, so that I get a quadratic image that shows the center of the image. This is not very hard, I agree. </p>
<p>I have already written some code that does exactly this, but somehow it lacks a certain ... elegance. I don't want to play code golf, but there must ... | 4 | 2009-04-02T11:50:49Z | 709,437 | <p>The <code>fit()</code> function in the PIL <a href="http://www.pythonware.com/library/pil/handbook/imageops.htm" rel="nofollow">ImageOps</a> module does what you want:</p>
<pre><code>ImageOps.fit(image, (min(*image.size),) * 2, Image.ANTIALIAS, 0, (.5, .5))
</code></pre>
| 6 | 2009-04-02T12:05:43Z | [
"image",
"python-imaging-library",
"python",
"crop"
] |
What's a more elegant rephrasing of this cropping algorithm? (in Python) | 709,388 | <p>I want to crop a thumbnail image in my Django application, so that I get a quadratic image that shows the center of the image. This is not very hard, I agree. </p>
<p>I have already written some code that does exactly this, but somehow it lacks a certain ... elegance. I don't want to play code golf, but there must ... | 4 | 2009-04-02T11:50:49Z | 709,442 | <p>I think this should do.</p>
<pre><code>size = min(image.Size)
originX = image.Size[0] / 2 - size / 2
originY = image.Size[1] / 2 - size / 2
cropBox = (originX, originY, originX + size, originY + size)
</code></pre>
| 9 | 2009-04-02T12:06:23Z | [
"image",
"python-imaging-library",
"python",
"crop"
] |
What's a more elegant rephrasing of this cropping algorithm? (in Python) | 709,388 | <p>I want to crop a thumbnail image in my Django application, so that I get a quadratic image that shows the center of the image. This is not very hard, I agree. </p>
<p>I have already written some code that does exactly this, but somehow it lacks a certain ... elegance. I don't want to play code golf, but there must ... | 4 | 2009-04-02T11:50:49Z | 1,320,073 | <p>I want to a content analysis of a jepg image. I wish to take a jpeg imafe say 251 x 261 and pass it through an algorithm to crop it to say 96 x 87. Can this program do that like t write an intelligent cropping algorithm, with a prompt to rezie the image.</p>
| 0 | 2009-08-24T01:14:21Z | [
"image",
"python-imaging-library",
"python",
"crop"
] |
Import an existing python project to XCode | 709,397 | <p>I've got a python project I've been making in terminal with vim etc.. I've read that XCode supports Python development at that it supports SVN (which I am using) but I can't find documentation on how to start a new XCode project from an existing code repository.</p>
<p>Other developers are working on the project no... | 6 | 2009-04-02T11:54:59Z | 710,629 | <p>I don't think it's worth using Xcode for a pure python project. Although the Xcode editor does syntax-highlight Python code, Xcode does not give you any other benefit for writing a pure-python app. On OS X, I would recommend <a href="http://macromates.com/" rel="nofollow">TextMate</a> as a text editor or Eclipse wit... | 7 | 2009-04-02T16:57:19Z | [
"python",
"xcode",
"osx"
] |
Import an existing python project to XCode | 709,397 | <p>I've got a python project I've been making in terminal with vim etc.. I've read that XCode supports Python development at that it supports SVN (which I am using) but I can't find documentation on how to start a new XCode project from an existing code repository.</p>
<p>Other developers are working on the project no... | 6 | 2009-04-02T11:54:59Z | 851,810 | <p>There are no special facilities for working with non-Cocoa Python projects with Xcode. Therefore, you probably just want to create a project with the "Empty Project" template (under "Other") and just drag in your source code.</p>
<p>For convenience, you may want to set up an executable in the project. You can do th... | 1 | 2009-05-12T08:50:30Z | [
"python",
"xcode",
"osx"
] |
Import an existing python project to XCode | 709,397 | <p>I've got a python project I've been making in terminal with vim etc.. I've read that XCode supports Python development at that it supports SVN (which I am using) but I can't find documentation on how to start a new XCode project from an existing code repository.</p>
<p>Other developers are working on the project no... | 6 | 2009-04-02T11:54:59Z | 851,861 | <p>I recommend against doing so. Creating groups (which look like folders) in Xcode doesn't actually create folders in the filesystem. This wreaks havoc on the module hierarchy.</p>
<p>Also, the SCM integration in Xcode is very clunky. After becoming accustomed to using Subversion with Eclipse, the Subversion support ... | 2 | 2009-05-12T09:02:38Z | [
"python",
"xcode",
"osx"
] |
Import an existing python project to XCode | 709,397 | <p>I've got a python project I've been making in terminal with vim etc.. I've read that XCode supports Python development at that it supports SVN (which I am using) but I can't find documentation on how to start a new XCode project from an existing code repository.</p>
<p>Other developers are working on the project no... | 6 | 2009-04-02T11:54:59Z | 4,152,716 | <p>Also see:</p>
<p><a href="http://lethain.com/entry/2008/aug/22/an-epic-introduction-to-pyobjc-and-cocoa/" rel="nofollow">http://lethain.com/entry/2008/aug/22/an-epic-introduction-to-pyobjc-and-cocoa/</a></p>
| 1 | 2010-11-11T08:56:55Z | [
"python",
"xcode",
"osx"
] |
python code convention using pylint | 709,490 | <p>I'm trying out pylint to check my source code for conventions. Somehow some variable names are matched with the regex for constants (<code>const-rgx</code>) instead of the variable name regex (<code>variable-rgx</code>). How to match the variable name with <code>variable-rgx</code>? Or should I extend <code>const-rg... | 9 | 2009-04-02T12:21:31Z | 709,515 | <p>I just disable that warning because I don't follow those naming conventions.</p>
<p>To do that, add this line to the top of you module:</p>
<pre><code># pylint: disable-msg=C0103
</code></pre>
<p>If you want to disable that globally, then add it to the pylint command:</p>
<pre><code>python lint.py --disable-msg=... | 9 | 2009-04-02T12:29:00Z | [
"python",
"conventions",
"pylint"
] |
python code convention using pylint | 709,490 | <p>I'm trying out pylint to check my source code for conventions. Somehow some variable names are matched with the regex for constants (<code>const-rgx</code>) instead of the variable name regex (<code>variable-rgx</code>). How to match the variable name with <code>variable-rgx</code>? Or should I extend <code>const-rg... | 9 | 2009-04-02T12:21:31Z | 709,666 | <pre><code>
(should match (([A-Z_][A-Z1-9_]*)|(__.*__))$)
</code></pre>
<p>like you said that is the const-rgx that is only matching UPPERCASE names, or names surrounded by double underscores.</p>
<p>the variables-rgx is </p>
<pre><code>([a-z_][a-z0-9_]{2,30}$)</code></pre>
<p>if your variable is called 'settings' ... | 0 | 2009-04-02T13:18:58Z | [
"python",
"conventions",
"pylint"
] |
python code convention using pylint | 709,490 | <p>I'm trying out pylint to check my source code for conventions. Somehow some variable names are matched with the regex for constants (<code>const-rgx</code>) instead of the variable name regex (<code>variable-rgx</code>). How to match the variable name with <code>variable-rgx</code>? Or should I extend <code>const-rg... | 9 | 2009-04-02T12:21:31Z | 709,709 | <blockquote>
<p>Somehow some variable names are matched with the regex for constants (const-rgx) instead of the variable name regex (variable-rgx).</p>
</blockquote>
<p>Are those variables declared on module level? Maybe that's why they are treated as constants (at least that's how they should be declared, according... | 24 | 2009-04-02T13:27:59Z | [
"python",
"conventions",
"pylint"
] |
Python server side AJAX library? | 709,868 | <p>I want to have a browser page that updates some information on a timer or events. I'd like to use Python on the server side. It's quite simple, I don't need anything massively complex.</p>
<p>I can spend some time figuring out how to do all this the "AJAX way", but I'm sure someone has written a nice Python library... | 5 | 2009-04-02T14:09:01Z | 709,871 | <p>AJAX stands for Asynchronous JavaScript and XML. You don't need any special library, other than the Javascript installed on the browser to do AJAX calls. The AJAX requests comes from the client side Javascript code, and goes to the server side which in your case would be handled in python.</p>
<p>You probably wan... | 5 | 2009-04-02T14:10:03Z | [
"python",
"ajax"
] |
Python server side AJAX library? | 709,868 | <p>I want to have a browser page that updates some information on a timer or events. I'd like to use Python on the server side. It's quite simple, I don't need anything massively complex.</p>
<p>I can spend some time figuring out how to do all this the "AJAX way", but I'm sure someone has written a nice Python library... | 5 | 2009-04-02T14:09:01Z | 709,918 | <p>You <em>can</em> also write both the client and server side of the ajax code using python with pyjamas:</p>
<p>Here's an RPC style server and simple example:</p>
<p><a href="http://www.machine-envy.com/blog/2006/12/10/howto-pyjamas-pylons-json/" rel="nofollow">http://www.machine-envy.com/blog/2006/12/10/howto-pyja... | 5 | 2009-04-02T14:23:17Z | [
"python",
"ajax"
] |
Python server side AJAX library? | 709,868 | <p>I want to have a browser page that updates some information on a timer or events. I'd like to use Python on the server side. It's quite simple, I don't need anything massively complex.</p>
<p>I can spend some time figuring out how to do all this the "AJAX way", but I'm sure someone has written a nice Python library... | 5 | 2009-04-02T14:09:01Z | 710,259 | <p>I suggest you to implement the server part in Django, which is in my opinion a fantastic toolkit. Through Django, you produce your XML responses (although I suggest you to use JSON, which is easier to handle on the web browser side).</p>
<p>Once you have something that generates your reply on server side, you have ... | 1 | 2009-04-02T15:36:57Z | [
"python",
"ajax"
] |
Backslashes being added into my cookie in Python | 709,937 | <p>Hey,
I am working with Python's SimpleCookie and I ran into this problem and I am not sure if it is something with my syntax or what. Also, this is classwork for my Python class so it is meant to teach about Python so this is far from the way I would do this in the real world. </p>
<p>Anyway, so basically I am ke... | 7 | 2009-04-02T14:29:22Z | 709,980 | <p>I'm not sure, but it looks like regular Python string escaping. If you have a string containing a backslash or a double quote, for instance, Python will often print it in escaped form, to make the printed string a valid string literal.</p>
<p>The following snippet illustrates:</p>
<pre><code>>>> a='hell\'... | 2 | 2009-04-02T14:41:25Z | [
"python"
] |
Backslashes being added into my cookie in Python | 709,937 | <p>Hey,
I am working with Python's SimpleCookie and I ran into this problem and I am not sure if it is something with my syntax or what. Also, this is classwork for my Python class so it is meant to teach about Python so this is far from the way I would do this in the real world. </p>
<p>Anyway, so basically I am ke... | 7 | 2009-04-02T14:29:22Z | 709,985 | <p>The slashes result from escaping the double quotes. Apparently, the first time through, your code is seeing the double quote, and escaping it by adding a back-slash. Then it reads the escaped backslash, and escapes the backslash by prepending it with -- a backslash. Then it reads....</p>
<p>The problem is happening... | 2 | 2009-04-02T14:41:57Z | [
"python"
] |
Backslashes being added into my cookie in Python | 709,937 | <p>Hey,
I am working with Python's SimpleCookie and I ran into this problem and I am not sure if it is something with my syntax or what. Also, this is classwork for my Python class so it is meant to teach about Python so this is far from the way I would do this in the real world. </p>
<p>Anyway, so basically I am ke... | 7 | 2009-04-02T14:29:22Z | 709,986 | <p>Backslashes are used for "escaping" characters in strings that would otherwise have special meaning, in effect depriving them of their special meaning. The classic case is the way you can include quotes in quoted strings, such as:</p>
<pre><code>Bob said "Hey!"
</code></pre>
<p>which can be written as a string th... | 1 | 2009-04-02T14:42:08Z | [
"python"
] |
Backslashes being added into my cookie in Python | 709,937 | <p>Hey,
I am working with Python's SimpleCookie and I ran into this problem and I am not sure if it is something with my syntax or what. Also, this is classwork for my Python class so it is meant to teach about Python so this is far from the way I would do this in the real world. </p>
<p>Anyway, so basically I am ke... | 7 | 2009-04-02T14:29:22Z | 710,500 | <p>As explained by others, the backslashes are escaping double quote characters you insert into the cookie value. The (hidden) mechanism in action here is the <a href="http://docs.python.org/library/cookie.html#Cookie.SimpleCookie" rel="nofollow"><code>SimpleCookie</code></a> class. The <a href="http://docs.python.org/... | 3 | 2009-04-02T16:28:43Z | [
"python"
] |
Backslashes being added into my cookie in Python | 709,937 | <p>Hey,
I am working with Python's SimpleCookie and I ran into this problem and I am not sure if it is something with my syntax or what. Also, this is classwork for my Python class so it is meant to teach about Python so this is far from the way I would do this in the real world. </p>
<p>Anyway, so basically I am ke... | 7 | 2009-04-02T14:29:22Z | 711,392 | <p>As others have already said, you are experiencing string escaping issues as soon as you add "and more" onto the end of the cookie.</p>
<p>Until that point, the cookie header is being returned from the SimpleCookie without enclosing quotes. (If there are no spaces in the cookie value, then enclosing quotes are not n... | 2 | 2009-04-02T20:07:49Z | [
"python"
] |
Backslashes being added into my cookie in Python | 709,937 | <p>Hey,
I am working with Python's SimpleCookie and I ran into this problem and I am not sure if it is something with my syntax or what. Also, this is classwork for my Python class so it is meant to teach about Python so this is far from the way I would do this in the real world. </p>
<p>Anyway, so basically I am ke... | 7 | 2009-04-02T14:29:22Z | 712,178 | <p>Others have already pointed out that this is a result of backslash-escapes of quotes and backslashes. I just wanted to point out that if you look carefully at the structure of the output you cite, you can see how the structure is being built here.</p>
<p>The cookie value that you're getting from <code>SimpleCookie... | 1 | 2009-04-03T00:47:27Z | [
"python"
] |
'for' loop through form fields and excluding one of the fields with 'if' | 710,100 | <p>The problem I'm struggling with is as follows:</p>
<p>I have:</p>
<pre><code>{% for field in form %}
{{Â field }}
{% end for %}
</code></pre>
<p>What I want is to put an 'if' statement to exclude a field which .label or whatever is provided. Like:</p>
<pre><code>{% for field in form%}
{% if field == titl... | 3 | 2009-04-02T15:05:31Z | 710,146 | <p>Yes, this should be possible:</p>
<pre><code>{% for field in form %}
{% ifnotequal field.label title %}
{{ field }}
{% endifnotequal %}
{% endfor %}
</code></pre>
<p>Django's <a href="http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ref-templates-builtins">template tags</a> offer <code>... | 7 | 2009-04-02T15:14:10Z | [
"python",
"django-templates"
] |
'for' loop through form fields and excluding one of the fields with 'if' | 710,100 | <p>The problem I'm struggling with is as follows:</p>
<p>I have:</p>
<pre><code>{% for field in form %}
{{Â field }}
{% end for %}
</code></pre>
<p>What I want is to put an 'if' statement to exclude a field which .label or whatever is provided. Like:</p>
<pre><code>{% for field in form%}
{% if field == titl... | 3 | 2009-04-02T15:05:31Z | 710,350 | <p>You might be a lot happier creating a subclass of the form, excluding the offending field.
See <a href="http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#form-inheritance">http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#form-inheritance</a></p>
<pre><code>class SmallerForm( MyForm ):
c... | 6 | 2009-04-02T15:52:51Z | [
"python",
"django-templates"
] |
case-insensitive alphabetical sorting of nested lists | 710,262 | <p>i'm trying to sort this nested list by inner's list first element:</p>
<pre><code>ak = [ ['a',1],['E',2],['C',13],['A',11],['b',9] ]
ak.sort(cmp=lambda x, y: cmp(x[0], y[0]))
for i in ak: {
print i
}
</code></pre>
<p>by default python considers A > a, hence the output i get is:</p>
<pre><code>['A', 11] ['C', 13]... | 1 | 2009-04-02T15:37:15Z | 710,274 | <p>Try:</p>
<pre><code>ak.sort(key=lambda x:x[0].lower())
</code></pre>
<p>I would recommend that you avoid using <code>cmp</code> as this has been deprecated in Python 2.6, and removed in 3.0. I know you're using 2.4, but the reason <code>cmp</code> has fallen into disfavour is that it is a very slow way to sort.</p... | 9 | 2009-04-02T15:39:06Z | [
"python"
] |
case-insensitive alphabetical sorting of nested lists | 710,262 | <p>i'm trying to sort this nested list by inner's list first element:</p>
<pre><code>ak = [ ['a',1],['E',2],['C',13],['A',11],['b',9] ]
ak.sort(cmp=lambda x, y: cmp(x[0], y[0]))
for i in ak: {
print i
}
</code></pre>
<p>by default python considers A > a, hence the output i get is:</p>
<pre><code>['A', 11] ['C', 13]... | 1 | 2009-04-02T15:37:15Z | 710,301 | <pre><code>ak.sort(cmp=lambda x, y: cmp(x[0].lower(), y[0].lower()))
</code></pre>
<p>Did you forget the parens in <code>x[0].lower()</code>?</p>
| 3 | 2009-04-02T15:42:26Z | [
"python"
] |
Python 3.0 Windows/COM | 710,278 | <p>How to access a COM object from a python file using python 3.0. </p>
<p>And, yes, I know that not a lot of people are using Python 3.0. Switching back to 2.6 is a <em>huge</em> hassle for me, so I don't want to unless I absolutely have to. </p>
<p>I appreciate your time, and any assistance!</p>
| 1 | 2009-04-02T15:39:19Z | 710,305 | <p>Install <a href="http://python.net/crew/mhammond/win32/Downloads.html" rel="nofollow">pywin32</a> and then create the object using it's progid:</p>
<pre><code>import win32com.client
object = win32com.client.Dispatch("Outlook.Application")
</code></pre>
<p>See also the <a href="http://www.boddie.org.uk/python/COM.h... | 4 | 2009-04-02T15:42:49Z | [
"python",
"com",
"python-3.x"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 710,598 | <p>Both ways are supported for a reason: there are times when one is more appropriate than the other.</p>
<p>import module: nice when you are using many bits from the module. drawback is that you'll need to qualify each reference with the module name.</p>
<p>from module import ...: nice that imported items are usable... | 27 | 2009-04-02T16:50:35Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 710,603 | <p>The difference between <code>import module</code> and <code>from module import foo</code> is mainly subjective. Pick the one you like best and be consistent in your use of it. Here are some points to help you decide.</p>
<p><code>import module</code></p>
<ul>
<li><strong>Pros:</strong>
<ul>
<li>Less maintenance ... | 181 | 2009-04-02T16:52:11Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 710,606 | <pre><code>import module
</code></pre>
<p>Is best when you will use many functions from the module.</p>
<pre><code>from module import function
</code></pre>
<p>Is best when you want to avoid polluting the global namespace with all the functions and types from a module when you only need <code>function</code>.</p>
| 9 | 2009-04-02T16:52:49Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 710,656 | <p>I personally always use </p>
<pre><code>from package.subpackage.subsubpackage import module
</code></pre>
<p>and then access everything as</p>
<pre><code>module.function
module.modulevar
</code></pre>
<p>etc. The reason is that at the same time you have short invocation, and you clearly define the module namespa... | 24 | 2009-04-02T17:03:54Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 710,831 | <p>To add to what people have said about <code>from x import *</code>: besides making it more difficult to tell where names came from, this throws off code checkers like Pylint. They will report those names as undefined variables.</p>
| 4 | 2009-04-02T17:46:08Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 710,861 | <p>My own answer to this depends mostly on first, how many different modules I'll be using. If i'm only going to use one or two, I'll often use <strong><code>from</code></strong> ... <strong><code>import</code></strong> since it makes for fewer keystrokes in the rest of the file, but if I'm going to make use of many d... | 2 | 2009-04-02T17:53:14Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 16,688,845 | <p>I've just discovered one more subtle difference between these two methods.</p>
<p>If module <code>foo</code> uses a following import:</p>
<pre><code>from itertools import count
</code></pre>
<p>Then module <code>bar</code> can by mistake use <code>count</code> as though it was defined in <code>foo</code>, not in ... | 3 | 2013-05-22T09:56:25Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 19,185,936 | <p>There's another detail here, not mentioned, related to writing to a module. Granted this may not be very common, but I've needed it from time to time.</p>
<p>Due to the way references and name binding works in Python, if you want to update some symbol in a module, say foo.bar, from outside that module, and have oth... | 11 | 2013-10-04T16:10:12Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 21,170,625 | <p>Here is another difference not mentioned. This is copied verbatim from <a href="http://docs.python.org/2/tutorial/modules.html" rel="nofollow">http://docs.python.org/2/tutorial/modules.html</a></p>
<p>Note that when using </p>
<pre><code>from package import item
</code></pre>
<p>the item can be either a submodul... | 3 | 2014-01-16T19:05:39Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 21,547,583 | <p>Already many people explained about <code>import</code> vs <code>from</code>, even I want to try to explain a bit more under the hood, where are all the places it got changes:</p>
<p><strong>First of all let me explain:</strong></p>
<p><strong>import X :</strong></p>
<pre><code>imports the module X, and creates a... | 11 | 2014-02-04T08:40:54Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 28,654,914 | <pre><code>import package
import module
</code></pre>
<p>With <code>import</code>, the token must be a package (a file containing Python commands) or a module (a folder in the <code>sys.path</code> containing a file <code>__init__.py</code>.)</p>
<p>When there are subpackages:</p>
<pre><code>import package1.package2... | 1 | 2015-02-22T05:37:51Z | [
"python",
"python-import"
] |
'import module' or 'from module import' | 710,551 | <p>I've tried to find a comprehensive guide on whether it is best to use <code>import module</code> or <code>from module import</code>. I've just started with Python, with the intention for developing web applications with Django and I'm trying to start off with best practices in mind.</p>
<p>Basically, I was hoping i... | 138 | 2009-04-02T16:40:49Z | 34,892,472 | <p>Import Module - You don't need additional efforts to fetch another thing from module. It has disadvantages such as redundant typing </p>
<p>Module Import From - Less typing &More control over which items of a module can be accessed.To use a new item from the module you have to update your import statement.</p>
| 0 | 2016-01-20T05:51:40Z | [
"python",
"python-import"
] |
Checking a Python module version at runtime | 710,609 | <p>Many third-party Python modules have an attribute which holds the version information for the module (usually something like <code>module.VERSION</code> or <code>module.__version__</code>), however some do not.</p>
<p>Particular examples of such modules are libxslt and libxml2.</p>
<p>I need to check that the corr... | 94 | 2009-04-02T16:53:08Z | 710,642 | <p>Some ideas:</p>
<ol>
<li>Try checking for functions that exist or don't exist in your needed versions.</li>
<li>If there are no function differences, inspect function arguments and signatures.</li>
<li>If you can't figure it out from function signatures, set up some stub calls at import time and check their behavio... | 5 | 2009-04-02T16:58:33Z | [
"python",
"module",
"version"
] |
Checking a Python module version at runtime | 710,609 | <p>Many third-party Python modules have an attribute which holds the version information for the module (usually something like <code>module.VERSION</code> or <code>module.__version__</code>), however some do not.</p>
<p>Particular examples of such modules are libxslt and libxml2.</p>
<p>I need to check that the corr... | 94 | 2009-04-02T16:53:08Z | 710,653 | <p>I'd stay away from hashing. The version of libxslt being used might contain some type of patch that doesn't effect your use of it. </p>
<p>As an alternative, I'd like to suggest that you don't check at run time (don't know if that's a hard requirement or not). For the python stuff I write that has external depen... | 5 | 2009-04-02T17:02:16Z | [
"python",
"module",
"version"
] |
Checking a Python module version at runtime | 710,609 | <p>Many third-party Python modules have an attribute which holds the version information for the module (usually something like <code>module.VERSION</code> or <code>module.__version__</code>), however some do not.</p>
<p>Particular examples of such modules are libxslt and libxml2.</p>
<p>I need to check that the corr... | 94 | 2009-04-02T16:53:08Z | 4,939,465 | <p>Use <a href="https://pythonhosted.org/setuptools/pkg_resources.html">pkg_resources</a>. Anything installed from PyPI at least should have a version number.</p>
<pre><code>>>> import pkg_resources
>>> pkg_resources.get_distribution("blogofile").version
'0.7.1'
</code></pre>
| 203 | 2011-02-08T22:54:17Z | [
"python",
"module",
"version"
] |
Checking a Python module version at runtime | 710,609 | <p>Many third-party Python modules have an attribute which holds the version information for the module (usually something like <code>module.VERSION</code> or <code>module.__version__</code>), however some do not.</p>
<p>Particular examples of such modules are libxslt and libxml2.</p>
<p>I need to check that the corr... | 94 | 2009-04-02T16:53:08Z | 39,652,019 | <p>You can use </p>
<pre><code>pip freeze
</code></pre>
<p>to see the installed packages in requirements format.</p>
| 0 | 2016-09-23T03:18:03Z | [
"python",
"module",
"version"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.