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
Cannot import file in Python/Django
1,419,224
<p>I'm not sure what's going on, but on my own laptop, everything works okay. When I upload to my host with Python 2.3.5, my views.py can't find anything in my models.py. I have:</p> <pre><code>from dtms.models import User from dtms.item_list import * </code></pre> <p>where my models, item_list, and views files are i...
0
2009-09-14T00:34:57Z
1,419,747
<p>To check your sys.path you can do what Alex said, but instead of using print you can use the logging module:</p> <pre><code> import logging LOG_FILENAME = '/tmp/logging_example.out' logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,) logging.debug('This message should go to the log file') </code></pre>...
2
2009-09-14T05:02:11Z
[ "python", "django" ]
appengine select based on timestamp
1,419,354
<p>I can't seem to select something based on timestamp. The behavior is a bit weird and the &lt; and = symbols don't seem to mean what I expect them to.</p> <pre> """ A site message """ class Message( db.Model ) : # from/to/ a few other fields subject = db.StringProperty() body = db.Text() # this is the fiel...
2
2009-09-14T01:41:59Z
1,419,366
<p>Do <strong>NOT</strong> use strings to "stand in" for datetimes! It just won't work...</p> <p>See <a href="http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html">the docs</a>: <code>DateTimeProperty</code> corresponds to a <a href="http://code.google.com/appengine/docs/python/datastor...
5
2009-09-14T01:47:20Z
[ "python", "google-app-engine" ]
How to install distutils packages using distutils api or setuptools api
1,419,379
<p>I'm working on a buildout script that needs to install a distutils package on remote server.</p> <p>On PyPi there are 2 recipes for doing this <a href="http://pypi.python.org/pypi?%3Aaction=search&amp;term=recipe.distutils&amp;submit=search" rel="nofollow">collective.recipe.distutils 0.1 and zerokspot.recipe.distut...
2
2009-09-14T01:53:28Z
1,419,477
<p>Are you sure you don't want to just generate a <a href="http://docs.python.org/distutils/builtdist.html" rel="nofollow">bdist</a>?</p>
0
2009-09-14T02:45:42Z
[ "python", "distutils", "buildout" ]
How to install distutils packages using distutils api or setuptools api
1,419,379
<p>I'm working on a buildout script that needs to install a distutils package on remote server.</p> <p>On PyPi there are 2 recipes for doing this <a href="http://pypi.python.org/pypi?%3Aaction=search&amp;term=recipe.distutils&amp;submit=search" rel="nofollow">collective.recipe.distutils 0.1 and zerokspot.recipe.distut...
2
2009-09-14T01:53:28Z
1,419,644
<p>You can call a command line program within your Python program using the <a href="http://docs.python.org/library/subprocess.html#module-subprocess" rel="nofollow">subprocess</a> module:</p> <pre><code>import subprocess subprocess.call('python setup.py install') </code></pre> <p>However, how much control do you hav...
1
2009-09-14T04:12:12Z
[ "python", "distutils", "buildout" ]
How to install distutils packages using distutils api or setuptools api
1,419,379
<p>I'm working on a buildout script that needs to install a distutils package on remote server.</p> <p>On PyPi there are 2 recipes for doing this <a href="http://pypi.python.org/pypi?%3Aaction=search&amp;term=recipe.distutils&amp;submit=search" rel="nofollow">collective.recipe.distutils 0.1 and zerokspot.recipe.distut...
2
2009-09-14T01:53:28Z
1,420,372
<p>zerokspot.recipe.distutils is fundamentally broken in that it adds a dependency on zc.buildout in it's setup.py, as follows:</p> <ol> <li><code>setup.py</code> imports <code>get_version</code> from <code>zerokspot.recipe.distutils</code></li> <li>All of <code>zerokspot.recipe.distutils</code> is defined in it's <co...
1
2009-09-14T08:40:23Z
[ "python", "distutils", "buildout" ]
How to Model a Foreign Key in a Reusable Django App?
1,419,442
<p>In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the l...
11
2009-09-14T02:24:10Z
1,419,548
<p>Probably you need to use the content types app to link to a model. You might then arrange for your app to check the settings to do some additional checking to limit which content types it will accept or suggest.</p>
0
2009-09-14T03:19:40Z
[ "python", "django", "django-models" ]
How to Model a Foreign Key in a Reusable Django App?
1,419,442
<p>In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the l...
11
2009-09-14T02:24:10Z
1,419,617
<p>I think TokenMacGuy is on the right track. I would look at how <a href="http://code.google.com/p/django-tagging/" rel="nofollow">django-tagging</a> handles a similar generic relationship using the content type, generic object_id, <a href="http://code.google.com/p/django-tagging/source/browse/trunk/tagging/generic.p...
1
2009-09-14T04:00:17Z
[ "python", "django", "django-models" ]
How to Model a Foreign Key in a Reusable Django App?
1,419,442
<p>In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the l...
11
2009-09-14T02:24:10Z
1,419,704
<p>If you think the link app will always point to a single app then one approach would be to pass the name of the foreign model as a string containing the application label instead of a class reference (<a href="http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey">Django docs explanation</a>).</p> <p>In...
21
2009-09-14T04:39:11Z
[ "python", "django", "django-models" ]
How to Model a Foreign Key in a Reusable Django App?
1,419,442
<p>In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the l...
11
2009-09-14T02:24:10Z
1,423,477
<p>I'd go with generic relations. You can do something like select_related, it just require some extra work. But I think it's worth it. </p> <p>One possible solution for generic select_related-like functionality: </p> <p><a href="http://bitbucket.org/kmike/django-generic-images/src/tip/generic%5Futils/managers.py" re...
0
2009-09-14T19:36:25Z
[ "python", "django", "django-models" ]
How to Model a Foreign Key in a Reusable Django App?
1,419,442
<p>In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the l...
11
2009-09-14T02:24:10Z
1,424,850
<p>This question and Van Gale's <a href="http://stackoverflow.com/questions/1419442/how-to-model-a-foreign-key-in-a-reusable-django-app/1419704#1419704">answer</a> lead me to the question, how it could be possible, to limit contenttypes for GFK without the need of defining it via Q objects in the model, so it could be ...
0
2009-09-15T02:33:14Z
[ "python", "django", "django-models" ]
How to Model a Foreign Key in a Reusable Django App?
1,419,442
<p>In my django site I have two apps, blog and links. blog has a model blogpost, and links has a model link. There should be a one to many relationship between these two things. There are many links per blogpost, but each link has one and only one blog post. The simple answer is to put a ForeignKey to blogpost in the l...
11
2009-09-14T02:24:10Z
7,248,794
<p>Anoher way to solve this is how <a href="http://django-mptt.github.com/django-mptt/models.html" rel="nofollow">django-mptt</a> does this: define only an abstract model in a reusable app(MPTTModel), and require to inherit it with defining some fields (parent=ForeignKey to self, or whatever your app usecase will requi...
1
2011-08-30T19:36:52Z
[ "python", "django", "django-models" ]
Python __init__ setattr on arguments?
1,419,470
<p>It seems that often <code>__init__</code> methods are similar to this:</p> <pre><code>def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 </code></pre> <p>Is there someway to turn the arguments into a list (without resorting to <code>*args</code> or <code>*...
5
2009-09-14T02:41:58Z
1,419,490
<p>There is no good way to get the arguments as a list if they are specified individually in the function signature. You can probably do something with inspect or frame hacks, but that will be uglier than simply spelling it out as you have done.</p>
4
2009-09-14T02:51:23Z
[ "python", "list", "parameters", "initialization", "setattr" ]
Python __init__ setattr on arguments?
1,419,470
<p>It seems that often <code>__init__</code> methods are similar to this:</p> <pre><code>def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 </code></pre> <p>Is there someway to turn the arguments into a list (without resorting to <code>*args</code> or <code>*...
5
2009-09-14T02:41:58Z
1,419,494
<p>See if the new namedtuple (new in Python 2.6) from the collections module might work for you.</p>
2
2009-09-14T02:52:25Z
[ "python", "list", "parameters", "initialization", "setattr" ]
Python __init__ setattr on arguments?
1,419,470
<p>It seems that often <code>__init__</code> methods are similar to this:</p> <pre><code>def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 </code></pre> <p>Is there someway to turn the arguments into a list (without resorting to <code>*args</code> or <code>*...
5
2009-09-14T02:41:58Z
1,419,497
<p>Here you go. Yes this is an ugly evil hack. Yes the object needs a __dict__ variable. But hey, its a neat little one liner!</p> <pre><code>def __init__(self): self.__dict__.update(locals()) </code></pre> <p>The constructor can take any type of arguments.</p> <pre><code>class test(object): def __init__(sel...
7
2009-09-14T02:55:37Z
[ "python", "list", "parameters", "initialization", "setattr" ]
Python __init__ setattr on arguments?
1,419,470
<p>It seems that often <code>__init__</code> methods are similar to this:</p> <pre><code>def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 </code></pre> <p>Is there someway to turn the arguments into a list (without resorting to <code>*args</code> or <code>*...
5
2009-09-14T02:41:58Z
1,419,520
<p>Try <a href="http://docs.python.org/library/inspect.html#inspect.getargspec" rel="nofollow">inspect.getargspec</a>:</p> <pre><code>In [31]: inspect.getargspec(C.__init__) Out[31]: ArgSpec(args=['self', 'ivar1', 'ivar2', 'ivar3', 'optional'], varargs=None, keywords=None, defaults=(False,)) </code>...
3
2009-09-14T03:09:28Z
[ "python", "list", "parameters", "initialization", "setattr" ]
Python __init__ setattr on arguments?
1,419,470
<p>It seems that often <code>__init__</code> methods are similar to this:</p> <pre><code>def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 </code></pre> <p>Is there someway to turn the arguments into a list (without resorting to <code>*args</code> or <code>*...
5
2009-09-14T02:41:58Z
1,419,950
<p>You could use inspect.getargspec and encapsulate it as a decorator. The lookup of optional and keyword arguments is a bit tricky, but this should do it:</p> <pre><code>def inits_args(func): """Initializes object attributes by the initializer signature""" argspec = inspect.getargspec(func) argnames = arg...
6
2009-09-14T06:24:38Z
[ "python", "list", "parameters", "initialization", "setattr" ]
Python __init__ setattr on arguments?
1,419,470
<p>It seems that often <code>__init__</code> methods are similar to this:</p> <pre><code>def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 </code></pre> <p>Is there someway to turn the arguments into a list (without resorting to <code>*args</code> or <code>*...
5
2009-09-14T02:41:58Z
1,419,995
<p>You can do it using introspection of the arguments, but the code is going to be longer than the code you try to replace. Especially if you are handling kw, which you may have to do.</p> <p>This short code works in most cases (improved from Unknowns example):</p> <pre><code>&gt;&gt;&gt; class Foo: ... def __init_...
2
2009-09-14T06:38:39Z
[ "python", "list", "parameters", "initialization", "setattr" ]
Python __init__ setattr on arguments?
1,419,470
<p>It seems that often <code>__init__</code> methods are similar to this:</p> <pre><code>def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 </code></pre> <p>Is there someway to turn the arguments into a list (without resorting to <code>*args</code> or <code>*...
5
2009-09-14T02:41:58Z
1,420,325
<p>How about deriving from a special class? I think it's <strong>more explicit and more flexible</strong> this way:</p> <pre><code>class InitMe: def __init__(self, data): if 'self' in data: data = data.copy() del data['self'] self.__dict__.update(data) class MyClassA(Ini...
0
2009-09-14T08:28:50Z
[ "python", "list", "parameters", "initialization", "setattr" ]
Python __init__ setattr on arguments?
1,419,470
<p>It seems that often <code>__init__</code> methods are similar to this:</p> <pre><code>def __init__(self, ivar1, ivar2, ivar3): self.ivar1 = ivar1 self.ivar2 = ivar2 self.ivar3 = ivar3 </code></pre> <p>Is there someway to turn the arguments into a list (without resorting to <code>*args</code> or <code>*...
5
2009-09-14T02:41:58Z
1,727,051
<p>I like that form the most, not too long and both copy-pasteable and sub-classable:</p> <pre><code>class DynamicInitClass(object): __init_defargs=('x',) def __init__(self,*args,**attrs): for idx,val in enumerate(args): attrs[self.__init_defargs[idx]]=val for key,val in attrs.iteritems(): ...
1
2009-11-13T03:58:20Z
[ "python", "list", "parameters", "initialization", "setattr" ]
Selecting based on __key__ (a unique identifier) in google appengine
1,419,522
<p>Again i have</p> <pre> """ A site message """ class Message( db.Model ) : # from/to/ a few other fields subject = db.StringProperty() body = db.Text() sent = db.DateTimeProperty( auto_now_add=True ) </pre> <p>Now I'm trying to pick out a Message by its KEY. I saved off the key earlier and planted it in ...
1
2009-09-14T03:10:29Z
1,419,579
<p>Don't bother with GQL for key-based retrieval -- make a key object from the string:</p> <pre><code>k = db.Key('aght52oobW1hZHIOCxIHTWVzc2FnZRiyAQw') </code></pre> <p>and just <code>db.get(k)</code>. If you insist on GQL, btw, that <code>k</code> -- a suitably constructed instance of <code>db.Key</code>, <strong>N...
6
2009-09-14T03:37:32Z
[ "python", "google-app-engine" ]
Selecting based on __key__ (a unique identifier) in google appengine
1,419,522
<p>Again i have</p> <pre> """ A site message """ class Message( db.Model ) : # from/to/ a few other fields subject = db.StringProperty() body = db.Text() sent = db.DateTimeProperty( auto_now_add=True ) </pre> <p>Now I'm trying to pick out a Message by its KEY. I saved off the key earlier and planted it in ...
1
2009-09-14T03:10:29Z
8,303,679
<p>You can also construct a query by hand by constructing "<a href="http://code.google.com/appengine/docs/python/datastore/gqlreference.html" rel="nofollow">an entity key literal, with...a complete path of kinds and key names/IDs</a>".</p> <pre><code>SELECT * FROM Message WHERE __key__ = KEY('Message', 'message_key') ...
1
2011-11-28T23:07:09Z
[ "python", "google-app-engine" ]
Django LEFT JOIN?
1,419,537
<p>I have models, more or less like this:</p> <pre><code>class ModelA(models.Model): field = models.CharField(..) class ModelB(models.Model): name = models.CharField(.., unique=True) modela = models.ForeignKey(ModelA, blank=True, related_name='modelbs') class Meta: unique_together = ('name','...
9
2009-09-14T03:15:57Z
1,419,596
<p>Use Q to combine the two conditions:</p> <pre><code>from django.db.models import Q qs = ModelA.objects.exclude(field=condition) qs = qs.filter(Q(modelbs__name=condition) | Q(modelbs__isnull=True)) </code></pre> <p>To examine the resulting SQL query:</p> <pre><code>print qs.query.as_sql() </code></pre> <p>On a si...
11
2009-09-14T03:51:31Z
[ "python", "django" ]
Django LEFT JOIN?
1,419,537
<p>I have models, more or less like this:</p> <pre><code>class ModelA(models.Model): field = models.CharField(..) class ModelB(models.Model): name = models.CharField(.., unique=True) modela = models.ForeignKey(ModelA, blank=True, related_name='modelbs') class Meta: unique_together = ('name','...
9
2009-09-14T03:15:57Z
1,421,015
<p>LEFT JOIN is a union of two queries. Sometimes it's optimized to one query. Sometimes, it is not actually optimized by the underlying SQL engine and is done as two separate queries.</p> <p>Do this.</p> <pre><code>for a in ModelA.objects.all(): related = a.model_b.set().all() if related.count() == 0: ...
-3
2009-09-14T11:33:31Z
[ "python", "django" ]
Django LEFT JOIN?
1,419,537
<p>I have models, more or less like this:</p> <pre><code>class ModelA(models.Model): field = models.CharField(..) class ModelB(models.Model): name = models.CharField(.., unique=True) modela = models.ForeignKey(ModelA, blank=True, related_name='modelbs') class Meta: unique_together = ('name','...
9
2009-09-14T03:15:57Z
1,433,401
<p>It looks like you are coming up against the 80% barrier. Why not just use <a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none" rel="nofollow"><code>.extra(select={'has_x_or_none':'(EXISTS (SELECT ...))'})</code></a>...
1
2009-09-16T14:39:11Z
[ "python", "django" ]
Django LEFT JOIN?
1,419,537
<p>I have models, more or less like this:</p> <pre><code>class ModelA(models.Model): field = models.CharField(..) class ModelB(models.Model): name = models.CharField(.., unique=True) modela = models.ForeignKey(ModelA, blank=True, related_name='modelbs') class Meta: unique_together = ('name','...
9
2009-09-14T03:15:57Z
9,735,655
<p>Try this patch for custom joins: <a href="https://code.djangoproject.com/ticket/7231" rel="nofollow">https://code.djangoproject.com/ticket/7231</a></p>
1
2012-03-16T10:32:43Z
[ "python", "django" ]
How to forward port to router using python
1,419,590
<p>I am building python p2p application like p2p instant messenger. I am communicating with other peers using TCP/IP connection. I do not want client to do port forwarding. When application starts it should check whether port is forwarded to router if not it should forward it to router. Is it possible to programatical...
3
2009-09-14T03:46:07Z
1,419,639
<p>You may find the post and files listed here helpful. This person implemented a Nat PMP library in Python.</p> <p><a href="http://blog.yimingliu.com/2008/01/07/nat-pmp-client-library-for-python/" rel="nofollow">http://blog.yimingliu.com/2008/01/07/nat-pmp-client-library-for-python/</a></p> <p>If you want to use por...
1
2009-09-14T04:09:54Z
[ "python", "p2p", "portforwarding" ]
How to extract and then refer to variables defined in a python module?
1,419,620
<p>I'm trying to build a simple environment check script for my firm's test environment. My goal is to be able to ping each of the hosts defined for a given test environment instance. The hosts are defined in a file like this:</p> <pre><code>#!/usr/bin/env python host_ip = '192.168.100.10' router_ip = '192.168.100.2...
2
2009-09-14T04:00:43Z
1,419,622
<p>You need to do vars().iteritems(). (or .items())</p> <p>Looping over a dictionary like vars() will only extract the keys in the dictionary.</p> <p>Example.</p> <pre><code>&gt;&gt;&gt; for key in vars(): print key ... __builtins__ __name__ __doc__ key __package__ &gt;&gt;&gt; for key, value in vars().items(): pr...
2
2009-09-14T04:02:45Z
[ "python", "variables", "import" ]
How to extract and then refer to variables defined in a python module?
1,419,620
<p>I'm trying to build a simple environment check script for my firm's test environment. My goal is to be able to ping each of the hosts defined for a given test environment instance. The hosts are defined in a file like this:</p> <pre><code>#!/usr/bin/env python host_ip = '192.168.100.10' router_ip = '192.168.100.2...
2
2009-09-14T04:00:43Z
1,419,642
<p>First off, I strongly recommend not doing it that way. Instead, do:</p> <pre><code>hosts = { "host_ip": '192.168.100.10', "router_ip": '192.168.100.254', "fs_ip": '192.168.200.10', } </code></pre> <p>Then you can simply import the module and reference it normally--this gives an ordinary, standard way ...
8
2009-09-14T04:11:15Z
[ "python", "variables", "import" ]
How to extract and then refer to variables defined in a python module?
1,419,620
<p>I'm trying to build a simple environment check script for my firm's test environment. My goal is to be able to ping each of the hosts defined for a given test environment instance. The hosts are defined in a file like this:</p> <pre><code>#!/usr/bin/env python host_ip = '192.168.100.10' router_ip = '192.168.100.2...
2
2009-09-14T04:00:43Z
1,419,649
<p>Here's a hack I use all the time. You got really close when you returned the list of string names, but you have to use the eval() function to return the actual object that bears the name represented by the string:</p> <pre><code>hosts = [eval('modulename.' + x) for x in dir(local_variables) if '_ip' in x] </code></...
-1
2009-09-14T04:14:11Z
[ "python", "variables", "import" ]
How to extract and then refer to variables defined in a python module?
1,419,620
<p>I'm trying to build a simple environment check script for my firm's test environment. My goal is to be able to ping each of the hosts defined for a given test environment instance. The hosts are defined in a file like this:</p> <pre><code>#!/usr/bin/env python host_ip = '192.168.100.10' router_ip = '192.168.100.2...
2
2009-09-14T04:00:43Z
1,419,661
<p>If this really is all that your imported file contains, you could also read it as just a text file, and then parse the input lines using basic string methods.</p> <pre><code>iplistfile = open("iplist.py") host_addr_map = {} for line in iplistfile: if not line or line[0] == '#': continue host, ipad...
0
2009-09-14T04:18:53Z
[ "python", "variables", "import" ]
How to extract and then refer to variables defined in a python module?
1,419,620
<p>I'm trying to build a simple environment check script for my firm's test environment. My goal is to be able to ping each of the hosts defined for a given test environment instance. The hosts are defined in a file like this:</p> <pre><code>#!/usr/bin/env python host_ip = '192.168.100.10' router_ip = '192.168.100.2...
2
2009-09-14T04:00:43Z
1,419,724
<p>Glenn Maynard makes a good point, using a dictionary is simpler and more standard. That being said, here are a couple of tricks I've used sometimes:</p> <p>In the file <code>hosts.py</code>:</p> <pre><code>#!/usr/bin/env python host_ip = '192.168.100.10' router_ip = '192.168.100.254' fs_ip = '192.168.200.10' </cod...
0
2009-09-14T04:51:16Z
[ "python", "variables", "import" ]
Atlassian Bamboo with Django & Python - Possible?
1,419,629
<p>At my company, we currently use <a href="http://www.atlassian.com/software/bamboo/">Atlassian Bamboo</a> for our continuous integration tool. We currently use Java for all of our projects, so it works great.</p> <p>However, we are considering using a Django + Python for one of our new applications. I was wonderin...
27
2009-09-14T04:04:31Z
1,419,723
<p>Bamboo essentially just runs a shell script, so this could just as easily be:</p> <pre><code>./manage.py test </code></pre> <p>as it typically is:</p> <pre><code>mvn clean install </code></pre> <p>or:</p> <pre><code>ant compile </code></pre> <p>You may have to massage to output of the Django test runner into t...
23
2009-09-14T04:51:13Z
[ "python", "django", "deployment", "continuous-integration", "bamboo" ]
Atlassian Bamboo with Django & Python - Possible?
1,419,629
<p>At my company, we currently use <a href="http://www.atlassian.com/software/bamboo/">Atlassian Bamboo</a> for our continuous integration tool. We currently use Java for all of our projects, so it works great.</p> <p>However, we are considering using a Django + Python for one of our new applications. I was wonderin...
27
2009-09-14T04:04:31Z
25,667,201
<p>You can even add a bootstrap for pip and virtualenv on a clean environment quite easily, which is cool:</p> <pre><code>wget https://bootstrap.pypa.io/get-pip.py python get-pip.py --root=${bamboo.build.working.directory}/tmp --ignore-installed export PATH=${bamboo.build.working.directory}/tmp/usr/local/bin:$PATH exp...
9
2014-09-04T13:49:23Z
[ "python", "django", "deployment", "continuous-integration", "bamboo" ]
Atlassian Bamboo with Django & Python - Possible?
1,419,629
<p>At my company, we currently use <a href="http://www.atlassian.com/software/bamboo/">Atlassian Bamboo</a> for our continuous integration tool. We currently use Java for all of our projects, so it works great.</p> <p>However, we are considering using a Django + Python for one of our new applications. I was wonderin...
27
2009-09-14T04:04:31Z
31,393,864
<p>If you use pytest you can simply use <code>py.test --junitxml=/path/to/results/xml/file.xml</code></p>
0
2015-07-13T21:31:24Z
[ "python", "django", "deployment", "continuous-integration", "bamboo" ]
Atlassian Bamboo with Django & Python - Possible?
1,419,629
<p>At my company, we currently use <a href="http://www.atlassian.com/software/bamboo/">Atlassian Bamboo</a> for our continuous integration tool. We currently use Java for all of our projects, so it works great.</p> <p>However, we are considering using a Django + Python for one of our new applications. I was wonderin...
27
2009-09-14T04:04:31Z
39,509,301
<p>It turns out it is possible. There are two major integration tasks: test runner results and code coverage results. I assume normal Python 3 codebase and standard <code>unittest</code> test suite.</p> <h1>Test runner</h1> <p>Bamboo expects test runner results in <a href="https://confluence.atlassian.com/bamboo/jun...
0
2016-09-15T10:54:43Z
[ "python", "django", "deployment", "continuous-integration", "bamboo" ]
Just installed QtOpenGL but cannot import it (from Python)
1,419,650
<p>I just installed it with apt-get on debian linux with</p> <pre><code>apt-get install libqt4-opengl </code></pre> <p>the rest of PyQt4 is available, but I cant get to this new module.</p> <pre><code>from PyQt4 import QtOpenGL </code></pre> <p>raises ImportError. any idea what to do? </p>
10
2009-09-14T04:15:01Z
1,419,673
<p>Did you forget to install the Python bindings?</p> <pre><code>apt-get install python-qt4-gl </code></pre>
24
2009-09-14T04:25:35Z
[ "python", "opengl", "pyqt", "apt-get", "pyopengl" ]
Parsing unstructured text in Python
1,419,653
<p>I wanted to parse a text file that contains unstructured text. I need to get the address, date of birth, name, sex, and ID.</p> <pre><code>. 55 MORILLO ZONE VIII, BARANGAY ZONE VIII (POB.), LUISIANA, LAGROS F 01/16/1952 ALOMO, TERESITA CABALLES 3412-00000-A1652TCA2 12 . 22 FABRICANTE ST. ZONE VIII LUISIANA LAGR...
3
2009-09-14T04:15:31Z
1,419,671
<p>you have to exploit whatever regularity and structure the text does have.</p> <p>I suggest you read one line at a time and match it to a regular expression to determine its type, fill in the appropriate field in a person object. writing out that object and starting a new one whenever you get a field that you alread...
3
2009-09-14T04:24:12Z
[ "python", "parsing", "text" ]
Parsing unstructured text in Python
1,419,653
<p>I wanted to parse a text file that contains unstructured text. I need to get the address, date of birth, name, sex, and ID.</p> <pre><code>. 55 MORILLO ZONE VIII, BARANGAY ZONE VIII (POB.), LUISIANA, LAGROS F 01/16/1952 ALOMO, TERESITA CABALLES 3412-00000-A1652TCA2 12 . 22 FABRICANTE ST. ZONE VIII LUISIANA LAGR...
3
2009-09-14T04:15:31Z
1,419,684
<p>You can probably do this with regular expressions without too much difficulty. If you have never used them before, check out the python documentation, then fire up redemo.py (on my computer, it's in c:\python26\Tools\scripts).</p> <p>The first task is to split the flat file into a list of entities (one chunk of tex...
2
2009-09-14T04:32:13Z
[ "python", "parsing", "text" ]
Parsing unstructured text in Python
1,419,653
<p>I wanted to parse a text file that contains unstructured text. I need to get the address, date of birth, name, sex, and ID.</p> <pre><code>. 55 MORILLO ZONE VIII, BARANGAY ZONE VIII (POB.), LUISIANA, LAGROS F 01/16/1952 ALOMO, TERESITA CABALLES 3412-00000-A1652TCA2 12 . 22 FABRICANTE ST. ZONE VIII LUISIANA LAGR...
3
2009-09-14T04:15:31Z
1,419,692
<p>Here's a quick hack job.</p> <pre><code>f = open('data.txt') def process(file): address = "" for line in file: if line == '': raise StopIteration line = line.rstrip() # to ignore \n if line in ('M','F'): sex = line break else: address += ...
1
2009-09-14T04:34:08Z
[ "python", "parsing", "text" ]
Parsing unstructured text in Python
1,419,653
<p>I wanted to parse a text file that contains unstructured text. I need to get the address, date of birth, name, sex, and ID.</p> <pre><code>. 55 MORILLO ZONE VIII, BARANGAY ZONE VIII (POB.), LUISIANA, LAGROS F 01/16/1952 ALOMO, TERESITA CABALLES 3412-00000-A1652TCA2 12 . 22 FABRICANTE ST. ZONE VIII LUISIANA LAGR...
3
2009-09-14T04:15:31Z
1,419,711
<p>It may be overkill, but the leading edge machine learning algorithms for this type of problem are based on <a href="http://en.wikipedia.org/wiki/Conditional%5Frandom%5Ffield" rel="nofollow">conditional random fields</a>. For example, <a href="http://www.aclweb.org/anthology/N/N04/N04-1042.pdf" rel="nofollow">Accura...
2
2009-09-14T04:46:00Z
[ "python", "parsing", "text" ]
Parsing unstructured text in Python
1,419,653
<p>I wanted to parse a text file that contains unstructured text. I need to get the address, date of birth, name, sex, and ID.</p> <pre><code>. 55 MORILLO ZONE VIII, BARANGAY ZONE VIII (POB.), LUISIANA, LAGROS F 01/16/1952 ALOMO, TERESITA CABALLES 3412-00000-A1652TCA2 12 . 22 FABRICANTE ST. ZONE VIII LUISIANA LAGR...
3
2009-09-14T04:15:31Z
1,419,730
<p>Here is a first stab at a pyparsing solution (<a href="http://pyparsing.pastebin.com/f45acc301">easy-to-copy code at the pyparsing pastebin</a>). Walk through the separate parts, according to the interleaved comments.</p> <pre><code>data = """\ . 55 MORILLO ZONE VIII, BARANGAY ZONE VIII (POB.), LUISIANA, LAGROS F ...
11
2009-09-14T04:53:47Z
[ "python", "parsing", "text" ]
convert the key in MIME encoded form in python
1,419,686
<p>this is the code :</p> <pre><code>f = urllib.urlopen('http://pool.sks-keyservers.net:11371/pks/lookup?op=get&amp;search= 0x58e9390daf8c5bf3') #Retrieve the public key from PKS data = f.read() decoded_bytes = base64.b64decode(data) print decoded_bytes </code></pre> <p>i need to convert the key in MIME encoded form...
0
2009-09-14T04:32:34Z
1,419,721
<p>By adding a <code>print data</code> statement, I see...:</p> <blockquote> <p>'Error handling request\r\n<h1>Error handling request</h1>Error handling request: No keys found\r\n'</p> </blockquote> <p>Kind of hard to make ANYthing out of THAT string, wouldn't you say...?-)</p> <p>What do YOU see when you ad...
0
2009-09-14T04:49:30Z
[ "python", "encoding" ]
convert the key in MIME encoded form in python
1,419,686
<p>this is the code :</p> <pre><code>f = urllib.urlopen('http://pool.sks-keyservers.net:11371/pks/lookup?op=get&amp;search= 0x58e9390daf8c5bf3') #Retrieve the public key from PKS data = f.read() decoded_bytes = base64.b64decode(data) print decoded_bytes </code></pre> <p>i need to convert the key in MIME encoded form...
0
2009-09-14T04:32:34Z
1,419,886
<p>For the encoding in the URL you give, see <a href="http://superuser.com/questions/34826/the-encoding-mechanism">the-encoding-mechanism</a>. It is a public PGP key encoded using Radix64 (OpenPGP's variant of Base64) -- "armored".</p> <p>For a few ideas on dealing with PGP, see <a href="http://stackoverflow.com/quest...
0
2009-09-14T05:56:18Z
[ "python", "encoding" ]
convert the key in MIME encoded form in python
1,419,686
<p>this is the code :</p> <pre><code>f = urllib.urlopen('http://pool.sks-keyservers.net:11371/pks/lookup?op=get&amp;search= 0x58e9390daf8c5bf3') #Retrieve the public key from PKS data = f.read() decoded_bytes = base64.b64decode(data) print decoded_bytes </code></pre> <p>i need to convert the key in MIME encoded form...
0
2009-09-14T04:32:34Z
1,419,895
<p>For a start, when you do use a valid <code>search</code> value ("jay" returns an error stating "too many values"), you will receive an HTML page from which you need to extract the actual key. Trying a search value of "jaysh" I get the following response:</p> <pre><code>&gt;&gt;&gt; print urllib.urlopen('http://pool...
0
2009-09-14T06:02:19Z
[ "python", "encoding" ]
How can I generate a complete histogram with numpy?
1,420,235
<p>I have a very long list in a <code>numpy.array</code>. I want to generate a histogram for it. However, Numpy's <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html" rel="nofollow" title="numpy.histogram reference">built in histogram</a> requires a pre-defined number of bins. What's th...
1
2009-09-14T08:02:22Z
1,420,297
<p>A bin for every value sounds a bit strange but wouldn't</p> <pre><code>bins=a.max()-a.min() </code></pre> <p>give a similar result?</p>
0
2009-09-14T08:21:54Z
[ "python", "numpy", "histogram" ]
How can I generate a complete histogram with numpy?
1,420,235
<p>I have a very long list in a <code>numpy.array</code>. I want to generate a histogram for it. However, Numpy's <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html" rel="nofollow" title="numpy.histogram reference">built in histogram</a> requires a pre-defined number of bins. What's th...
1
2009-09-14T08:02:22Z
1,420,316
<p>If you have an array of integers and the max value isn't too large you can use numpy.bincount:</p> <pre><code>hist = dict((key,val) for key, val in enumerate(numpy.bincount(data)) if val) </code></pre> <p>Edit: If you have float data, or data spread over a huge range you can convert it to integers by doing:</p> <...
7
2009-09-14T08:26:48Z
[ "python", "numpy", "histogram" ]
How can I add a decorator to an existing object method?
1,420,484
<p>If I'm using a module/class I have no control over, how would I decorate one of the methods? </p> <p>I understand I can: <code>my_decorate_method(target_method)()</code> but I'm looking to have this happen wherever <code>target_method</code> is called without having to do a search/replace.</p> <p>Is it even possib...
7
2009-09-14T09:16:12Z
1,420,634
<p>Yes it's possible, but there are several problems. First whet you get method from class in obvious way you get a warper object but not the function itself.</p> <pre><code>class X(object): def m(self,x): print x print X.m #&gt;&gt;&gt; &lt;unbound method X.m&gt; print vars(X)['m'] #&gt;&gt;&g...
3
2009-09-14T09:57:09Z
[ "python", "decorator" ]
How can I add a decorator to an existing object method?
1,420,484
<p>If I'm using a module/class I have no control over, how would I decorate one of the methods? </p> <p>I understand I can: <code>my_decorate_method(target_method)()</code> but I'm looking to have this happen wherever <code>target_method</code> is called without having to do a search/replace.</p> <p>Is it even possib...
7
2009-09-14T09:16:12Z
1,420,994
<p>Don't do this.</p> <p>Use inheritance.</p> <pre><code>import some_module class MyVersionOfAClass( some_module.AClass ): def someMethod( self, *args, **kwargs ): # do your "decoration" here. super( MyVersionOfAClass, self ). someMethod( *args, **kwargs ) # you can also do "decoration" h...
6
2009-09-14T11:26:40Z
[ "python", "decorator" ]
How do I loop through relationships in a list only once?
1,420,705
<p>I have a list of users:</p> <pre><code>users = [1,2,3,4,5] </code></pre> <p>I want to compute a relationship between them:</p> <pre><code>score = compatibility( user[0], user[1] ) </code></pre> <p>How do I loop over users so that a relationship between users are computed only once?</p>
1
2009-09-14T10:19:00Z
1,420,737
<p>use for loops, or list comprehension.</p> <p>here is for loop example:</p> <pre><code>for u in users: for su in users: if su == u: pass else: score = compatibility(u, su) # do score whatever you want </code></pre> <p>list comprehension:</p> <pre><code>score...
0
2009-09-14T10:25:07Z
[ "python" ]
How do I loop through relationships in a list only once?
1,420,705
<p>I have a list of users:</p> <pre><code>users = [1,2,3,4,5] </code></pre> <p>I want to compute a relationship between them:</p> <pre><code>score = compatibility( user[0], user[1] ) </code></pre> <p>How do I loop over users so that a relationship between users are computed only once?</p>
1
2009-09-14T10:19:00Z
1,420,748
<p>If you care only about ordered relationship, you could do the following:</p> <pre><code>&gt;&gt;&gt; for i, u in enumerate(users[1:]): print(users[i], u) # or do something else 1 2 2 3 3 4 4 5 </code></pre> <p>if you need all combinations you should use <a href="http://docs.python.org/library/itert...
11
2009-09-14T10:28:46Z
[ "python" ]
How do I loop through relationships in a list only once?
1,420,705
<p>I have a list of users:</p> <pre><code>users = [1,2,3,4,5] </code></pre> <p>I want to compute a relationship between them:</p> <pre><code>score = compatibility( user[0], user[1] ) </code></pre> <p>How do I loop over users so that a relationship between users are computed only once?</p>
1
2009-09-14T10:19:00Z
1,420,750
<p>Something like the following should work (not tested):</p> <pre><code>users_range = range(len(users)) # Initialize a 2-dimensional array scores = [None for j in users_range for i in users_range] # Assign a compatibility to each pair of users. for i in users_range: for j in users_range: scores[i][j] = ...
0
2009-09-14T10:30:08Z
[ "python" ]
How do I loop through relationships in a list only once?
1,420,705
<p>I have a list of users:</p> <pre><code>users = [1,2,3,4,5] </code></pre> <p>I want to compute a relationship between them:</p> <pre><code>score = compatibility( user[0], user[1] ) </code></pre> <p>How do I loop over users so that a relationship between users are computed only once?</p>
1
2009-09-14T10:19:00Z
1,420,753
<p>I managed to do what I wanted with this:</p> <pre><code>i = 0 for user1 in users: i += 1 for user2 in users[i:]: print compatibility( user1, user2 ) </code></pre>
0
2009-09-14T10:31:39Z
[ "python" ]
How do I loop through relationships in a list only once?
1,420,705
<p>I have a list of users:</p> <pre><code>users = [1,2,3,4,5] </code></pre> <p>I want to compute a relationship between them:</p> <pre><code>score = compatibility( user[0], user[1] ) </code></pre> <p>How do I loop over users so that a relationship between users are computed only once?</p>
1
2009-09-14T10:19:00Z
1,420,790
<p>If you mean that:</p> <pre><code>compatibility(user[0], user[1]) == compatibility(user[1], user[0]) </code></pre> <p>you could use:</p> <pre><code>for i, user1 in enumerate(users): for user2 in users[i:]: score = compatibility(user1, user2) </code></pre> <p>this will also calculate the compatibility ...
0
2009-09-14T10:39:25Z
[ "python" ]
How do I loop through relationships in a list only once?
1,420,705
<p>I have a list of users:</p> <pre><code>users = [1,2,3,4,5] </code></pre> <p>I want to compute a relationship between them:</p> <pre><code>score = compatibility( user[0], user[1] ) </code></pre> <p>How do I loop over users so that a relationship between users are computed only once?</p>
1
2009-09-14T10:19:00Z
1,420,795
<pre><code>import itertools def compatibility(u1, u2): "just a stub for demonstration purposes" return abs(u1 - u2) def compatibility_map(users): return dict(((u1, u2), compatibility(u1, u2)) for u1, u2 in itertools.combinations(users, 2)) &gt; compat.compatiblity_map([1,2,3,4,5]) {(1, 2): 1, (1...
0
2009-09-14T10:40:21Z
[ "python" ]
Change keyboard layout with python?
1,420,925
<p>I'm working on a college system (windows XP) and want to set the keyboard to Dvorak when I log on. I currently have a python script that changes the desktop image.</p> <p>Can I use python to change the layout as well? Or are there other ways?</p>
2
2009-09-14T11:11:02Z
1,420,959
<p>answer can be found at <a href="http://stackoverflow.com/questions/167031/programatically-change-keyboard-to-dvorak">http://stackoverflow.com/questions/167031/programatically-change-keyboard-to-dvorak</a></p>
1
2009-09-14T11:19:24Z
[ "python", "keyboard", "registry" ]
Change keyboard layout with python?
1,420,925
<p>I'm working on a college system (windows XP) and want to set the keyboard to Dvorak when I log on. I currently have a python script that changes the desktop image.</p> <p>Can I use python to change the layout as well? Or are there other ways?</p>
2
2009-09-14T11:11:02Z
4,946,652
<p>I would use <a href="http://www.autohotkey.com/" rel="nofollow">AutoHotKey</a> to change the layout. You could write a script remapping the keys and compile it as an executable file.</p> <p>For example</p> <pre><code>q::' +q::" w::, +w::&lt; e::. +e::&gt; r::p </code></pre> <p>etc.</p>
1
2011-02-09T15:06:13Z
[ "python", "keyboard", "registry" ]
Change keyboard layout with python?
1,420,925
<p>I'm working on a college system (windows XP) and want to set the keyboard to Dvorak when I log on. I currently have a python script that changes the desktop image.</p> <p>Can I use python to change the layout as well? Or are there other ways?</p>
2
2009-09-14T11:11:02Z
15,770,148
<p>to Change keyboard layout </p> <pre><code>import win32api win32api.LoadKeyboardLayout('00000409',1) # to switch to english win32api.LoadKeyboardLayout('00000401',1) # to switch to arabic </code></pre> <p>and for Dvorak :</p> <pre><code>win32api.LoadKeyboardLayout("00010409",1) </code></pre> <p>or </p> <pre><cod...
3
2013-04-02T17:12:09Z
[ "python", "keyboard", "registry" ]
Stopping embedded Python
1,420,957
<p>I'm embedding Python interpreter to a C program. However, it might happen that while running some python script via <code>PyRun_SimpleString()</code> will run into infinite loop or execute for too long. Consider <code>PyRun_SimpleString("while 1: pass");</code> In preventing the main program to block I thought I cou...
16
2009-09-14T11:19:15Z
1,421,044
<p>Well the python interpreter would have to be running in a separate thread from the embedding program or you will simply never get a chance to interrupt the interpreter.</p> <p>When you have that, perhaps you can use one of the Python API exception calls to trigger an exception in the interpreter? See <a href="http...
1
2009-09-14T11:40:22Z
[ "python", "process", "multithreading", "embedded-language", "python-c-api" ]
Stopping embedded Python
1,420,957
<p>I'm embedding Python interpreter to a C program. However, it might happen that while running some python script via <code>PyRun_SimpleString()</code> will run into infinite loop or execute for too long. Consider <code>PyRun_SimpleString("while 1: pass");</code> In preventing the main program to block I thought I cou...
16
2009-09-14T11:19:15Z
1,427,498
<p>You can use <code>Py_AddPendingCall()</code> to add a function raising exception to be called on next check interval (see docs on <code>sys.setcheckinterval()</code> for more info). Here is an example with <code>Py_Exit()</code> call (which does works for me, but probably is not what you need), replace it with <code...
8
2009-09-15T14:21:33Z
[ "python", "process", "multithreading", "embedded-language", "python-c-api" ]
Yahoo BOSS Python Library, ExpatError
1,421,099
<p>I tried to install the Yahoo BOSS mashup framework, but am having trouble running the examples provided. Examples 1, 2, 5, and 6 work, but 3 &amp; 4 give Expat errors. Here is the output from ex3.py:</p> <pre><code>gpython examples/ex3.py examples/ex3.py:33: Warning: 'as' will become a reserved keyword in Pyth...
0
2009-09-14T11:54:27Z
1,422,100
<p>I believe that must be an error in the example: it's getting a JSON result (indeed if you copy and paste that URL in your browser, you'll download a file names search.json which starts with </p> <pre><code>{"results":[{"profile_image_url": "http://a3.twimg.com/profile_images/255524395/KEN_OMALLEY_REVISED_normal.jpg...
0
2009-09-14T14:58:04Z
[ "python", "expat-parser", "yahoo-boss-api" ]
Yahoo BOSS Python Library, ExpatError
1,421,099
<p>I tried to install the Yahoo BOSS mashup framework, but am having trouble running the examples provided. Examples 1, 2, 5, and 6 work, but 3 &amp; 4 give Expat errors. Here is the output from ex3.py:</p> <pre><code>gpython examples/ex3.py examples/ex3.py:33: Warning: 'as' will become a reserved keyword in Pyth...
0
2009-09-14T11:54:27Z
2,505,220
<p>The problem is the digg search string. It should be "s=". Not "search="</p>
1
2010-03-24T03:49:50Z
[ "python", "expat-parser", "yahoo-boss-api" ]
Python 3-compatibe HTML to text converter preserving basic structure under permissive licence?
1,421,238
<p>I am looking for a relatively simple HTML to text converter which displays links and works on strings.</p> <p>So far I have tried</p> <ul> <li>lynx but performance is too bad,</li> <li>html2text which gives weird and verbose markdown output and is under GPLv3 which is too restrictive for my (BSD-licensed) project,...
1
2009-09-14T12:23:52Z
1,421,388
<p>Pyparsing's examples include an <a href="http://pyparsing.wikispaces.com/file/view/htmlStripper.py" rel="nofollow">html stripper</a> and a <a href="http://pyparsing.wikispaces.com/file/view/urlExtractorNew.py" rel="nofollow">URL extractor</a>.</p> <p>Unlike BeautifulSoup and most HTML parsers, Pyparsing does not tr...
0
2009-09-14T12:56:50Z
[ "python" ]
Nested While loop in Python
1,421,323
<p>I am a beginner in python programming. I wrote the following program but it doesn't execute as I want it to. Here is the code:</p> <pre><code>b=0 x=0 while b&lt;=10: print 'here is the outer loop\n',b, while x&lt;=15: k=p[x] print'here is the inner loop\n',x, x=x+1 b=b+1 </code><...
0
2009-09-14T12:43:21Z
1,421,351
<p>Not sure what your problem is, maybe you want to put that <code>x=0</code> right before the inner loop ?</p> <p>Your whole code doesn't look remotely like Python code ... loops like that are better done like this:</p> <pre><code>for b in range(0,11): print 'here is the outer loop',b for x in range(0, 16): ...
23
2009-09-14T12:48:49Z
[ "python", "while-loop" ]
Nested While loop in Python
1,421,323
<p>I am a beginner in python programming. I wrote the following program but it doesn't execute as I want it to. Here is the code:</p> <pre><code>b=0 x=0 while b&lt;=10: print 'here is the outer loop\n',b, while x&lt;=15: k=p[x] print'here is the inner loop\n',x, x=x+1 b=b+1 </code><...
0
2009-09-14T12:43:21Z
1,421,383
<p>Running your code I'm get an error if "'p' is not defind" which means you are trying to use the the array p before anything is in it.</p> <p>Removing that that line lets the code run with output of</p> <pre><code>here is the outer loop 0 here is the inner loop 0 here is the inner loop 1 here is the inner loop 2 he...
0
2009-09-14T12:55:44Z
[ "python", "while-loop" ]
Nested While loop in Python
1,421,323
<p>I am a beginner in python programming. I wrote the following program but it doesn't execute as I want it to. Here is the code:</p> <pre><code>b=0 x=0 while b&lt;=10: print 'here is the outer loop\n',b, while x&lt;=15: k=p[x] print'here is the inner loop\n',x, x=x+1 b=b+1 </code><...
0
2009-09-14T12:43:21Z
1,421,390
<p>Because you defined the x outside of the outer while loop its scope is also outside of the outer loop and it does not get reset after each outer loop.</p> <p>To fix this move the defixition of x inside the outer loop:</p> <pre><code>b = 0 while b &lt;= 10: x = 0 print b while x &lt;= 15: print x x +=...
10
2009-09-14T12:57:00Z
[ "python", "while-loop" ]
Nested While loop in Python
1,421,323
<p>I am a beginner in python programming. I wrote the following program but it doesn't execute as I want it to. Here is the code:</p> <pre><code>b=0 x=0 while b&lt;=10: print 'here is the outer loop\n',b, while x&lt;=15: k=p[x] print'here is the inner loop\n',x, x=x+1 b=b+1 </code><...
0
2009-09-14T12:43:21Z
38,857,471
<p>You need to reset your x variable after processing the inner loop. Otherwise your outerloop will run through without firing the inner loop.</p> <pre><code>b=0 x=0 while b&lt;=10: print 'here is the outer loop\n',b, while x&lt;=15: k=p[x] #&lt;--not sure what "p" is here print'here is the in...
0
2016-08-09T17:56:48Z
[ "python", "while-loop" ]
How do I get the operating system name in a friendly manner using Python 2.5?
1,421,357
<p>I tried:</p> <pre><code>print os.name </code></pre> <p>And the output I got was:</p> <pre><code>:nt </code></pre> <p>However, I want output more like "Windows 98", or "Linux".</p> <p>After suggestions in this question, I also tried:</p> <pre><code>import os print os.name import platform print platform.system()...
7
2009-09-14T12:50:23Z
1,421,365
<p>Try:</p> <pre><code>import platform print platform.system(), platform.release() </code></pre> <p>I tried this on my computer with Python 2.6 and I got this as the output:</p> <pre><code>Windows XP </code></pre> <p>After your latest edits, I see that you called your script platform.py. This is causing a naming pr...
36
2009-09-14T12:52:34Z
[ "python" ]
How do I get the operating system name in a friendly manner using Python 2.5?
1,421,357
<p>I tried:</p> <pre><code>print os.name </code></pre> <p>And the output I got was:</p> <pre><code>:nt </code></pre> <p>However, I want output more like "Windows 98", or "Linux".</p> <p>After suggestions in this question, I also tried:</p> <pre><code>import os print os.name import platform print platform.system()...
7
2009-09-14T12:50:23Z
1,421,623
<p>it is because you named your program "platform". Hence when importing the module "platform", your program is imported instead in a circular import.</p> <p>Try renaming the file to test_platform.py, and it will work.</p>
14
2009-09-14T13:43:16Z
[ "python" ]
How do I get the operating system name in a friendly manner using Python 2.5?
1,421,357
<p>I tried:</p> <pre><code>print os.name </code></pre> <p>And the output I got was:</p> <pre><code>:nt </code></pre> <p>However, I want output more like "Windows 98", or "Linux".</p> <p>After suggestions in this question, I also tried:</p> <pre><code>import os print os.name import platform print platform.system()...
7
2009-09-14T12:50:23Z
3,060,944
<pre><code>import platform platform.dist() </code></pre>
4
2010-06-17T10:47:53Z
[ "python" ]
How do I get the operating system name in a friendly manner using Python 2.5?
1,421,357
<p>I tried:</p> <pre><code>print os.name </code></pre> <p>And the output I got was:</p> <pre><code>:nt </code></pre> <p>However, I want output more like "Windows 98", or "Linux".</p> <p>After suggestions in this question, I also tried:</p> <pre><code>import os print os.name import platform print platform.system()...
7
2009-09-14T12:50:23Z
25,814,896
<p>well it depends on the OS: for example I had tested </p> <pre><code> platform.system() - in linux works, AIX works platform.release()- in linux works, AIX gives a weird '1' with non other info platform.dist() - in linux works, AIX gives a nothing '','','' os.name - resolves 'posix' i...
1
2014-09-12T18:51:11Z
[ "python" ]
SQLAlchemy session management in long-running process
1,421,502
<p>Scenario:</p> <ul> <li>A .NET-based application server (<a href="http://global.wonderware.com/EN/Pages/WonderwareSystemPlatform.aspx" rel="nofollow">Wonderware IAS/System Platform</a>) hosts automation objects that communicate with various equipment on the factory floor.</li> <li>CPython is hosted inside this appli...
2
2009-09-14T13:18:43Z
1,422,367
<p>The described decorator is suitable for long running applications, but you can run into trouble if you accidentally share objects between requests. To make the errors appear earlier and not corrupt anything it is better to discard the session with session.remove().</p> <pre><code>try: try: retval = func...
3
2009-09-14T15:42:47Z
[ "python", "sqlalchemy", "wonderware" ]
SQLAlchemy session management in long-running process
1,421,502
<p>Scenario:</p> <ul> <li>A .NET-based application server (<a href="http://global.wonderware.com/EN/Pages/WonderwareSystemPlatform.aspx" rel="nofollow">Wonderware IAS/System Platform</a>) hosts automation objects that communicate with various equipment on the factory floor.</li> <li>CPython is hosted inside this appli...
2
2009-09-14T13:18:43Z
3,050,770
<p>Ask your WonderWare administrator to give you access to the Wonderware Historian, you can track the values of the tags pretty easily via MSSQL calls over sqlalchemy that you can poll every so often.</p> <p>Another option is to use the archestra toolkit to listen for the internal tag updates and have a server deploy...
1
2010-06-16T04:44:49Z
[ "python", "sqlalchemy", "wonderware" ]
How to trigger post-build using setuptools/distutils
1,421,709
<p>I am building an application using py2app/setuptools, so once it creates application bundle I want to take some action on dist folder e.g. create a installer/upload it.</p> <p>Is there a way? I have found some post-install solution but no post-build</p> <p>Alternatively I can call 'python setup.py py2app' from my ...
6
2009-09-14T13:57:33Z
1,421,744
<p>There are probably ways to do this using setuptools or distutils, but they're likely to be pretty hackish. I'd strongly recommend using one of the following tools if you want to do something like this:</p> <ul> <li><a href="http://www.blueskyonmars.com/projects/paver/" rel="nofollow">paver</a></li> <li><a href="ht...
0
2009-09-14T14:02:15Z
[ "python", "setuptools", "distutils", "py2app" ]
How to trigger post-build using setuptools/distutils
1,421,709
<p>I am building an application using py2app/setuptools, so once it creates application bundle I want to take some action on dist folder e.g. create a installer/upload it.</p> <p>Is there a way? I have found some post-install solution but no post-build</p> <p>Alternatively I can call 'python setup.py py2app' from my ...
6
2009-09-14T13:57:33Z
1,472,629
<p>Can you please clarify what you're trying to do?</p> <blockquote> <p>take some action on dist folder e.g. create a installer/upload it.</p> </blockquote> <p>When you say create a installer, do you mean build a distribution for the package? And when you say upload, do you mean upload to pypi? or somewhere else?</...
0
2009-09-24T15:59:03Z
[ "python", "setuptools", "distutils", "py2app" ]
How to trigger post-build using setuptools/distutils
1,421,709
<p>I am building an application using py2app/setuptools, so once it creates application bundle I want to take some action on dist folder e.g. create a installer/upload it.</p> <p>Is there a way? I have found some post-install solution but no post-build</p> <p>Alternatively I can call 'python setup.py py2app' from my ...
6
2009-09-14T13:57:33Z
1,719,797
<p>I <a href="http://stackoverflow.com/questions/1710839/custom-distutils-commands/1712544#1712544">responded to a similar question yesterday</a> about subclassing <strong>distutils.core.Command</strong>.</p> <p>The core of it is that by doing this you are able to precisely control the behavior of each stage of the pr...
4
2009-11-12T03:59:39Z
[ "python", "setuptools", "distutils", "py2app" ]
Set files to ownership of current directory in Python
1,421,807
<p>I'm working on a Python script that creates text files containing size/space information about the directories that the script is run on. The script needs to be run as root, and as a result, it sets the text files that it creates to root's ownership.</p> <p>I know I can change the ownership with os.fchown, but how ...
0
2009-09-14T14:11:37Z
1,421,900
<p>Use</p> <pre><code>import os, stat info = os.stat(dirpath) uid, gid = info[stat.ST_UID], info[stat.ST_GID] </code></pre>
0
2009-09-14T14:25:15Z
[ "python", "permissions" ]
Which python mpi library to use?
1,422,260
<p>I'm starting work on some simulations using MPI and want to do the programming in Python/scipy. The scipy <a href="http://www.scipy.org/Topical%5FSoftware#head-cf472934357fda4558aafdf558a977c4d59baecb">site</a> lists a number of mpi libraries, but I was hoping to get feedback on quality, ease of use, etc from anyone...
15
2009-09-14T15:26:04Z
1,422,871
<p>I have heard good things about <a href="http://mpi4py.scipy.org/">mpi4py</a> (but I have never used it myself). That's what a colleague recommended who looked at all the alternatives. He mentioned the completeness as one advantage.</p>
15
2009-09-14T17:20:57Z
[ "python", "mpi" ]
Which python mpi library to use?
1,422,260
<p>I'm starting work on some simulations using MPI and want to do the programming in Python/scipy. The scipy <a href="http://www.scipy.org/Topical%5FSoftware#head-cf472934357fda4558aafdf558a977c4d59baecb">site</a> lists a number of mpi libraries, but I was hoping to get feedback on quality, ease of use, etc from anyone...
15
2009-09-14T15:26:04Z
2,623,758
<p>Also check whether <a href="http://pymw.sourceforge.net/" rel="nofollow">pymw</a> (master/worker framework) might help you. It supports various backends (MPI via pympi, Boinc, ..)</p>
4
2010-04-12T16:49:18Z
[ "python", "mpi" ]
Which python mpi library to use?
1,422,260
<p>I'm starting work on some simulations using MPI and want to do the programming in Python/scipy. The scipy <a href="http://www.scipy.org/Topical%5FSoftware#head-cf472934357fda4558aafdf558a977c4d59baecb">site</a> lists a number of mpi libraries, but I was hoping to get feedback on quality, ease of use, etc from anyone...
15
2009-09-14T15:26:04Z
6,897,595
<p>I've used pypar on 64 bit windows server with MPICH2. It is easy to use, requires no special structures or constants and you can send almost any python object, list or dictionary about with no effort. The developer is also available to ask questions about.</p>
2
2011-08-01T11:14:57Z
[ "python", "mpi" ]
GAE load data into datastore without using CSV
1,422,270
<p>I've used bulkloader.Loader to load stuff into the GAE dev and live datastore, but my next thing to to create objects from non-CSV data and push it into the datastore.</p> <p>So say my object is something like:</p> <pre><code>class CainEvent(db.Model): name =db.StringProperty(required=True) birthdate ...
1
2009-09-14T15:29:12Z
1,422,712
<p>Here's an extremely simplified example of what we're doing to use the bulkloader to load JSON data instead of CSV data:</p> <pre><code>class JSONLoader(bulkloader.Loader): def generate_records(self, filename): for item in json.load(open(filename)): yield item['fields'] </code></pre> <p>In t...
2
2009-09-14T16:52:21Z
[ "python", "google-app-engine" ]
GAE load data into datastore without using CSV
1,422,270
<p>I've used bulkloader.Loader to load stuff into the GAE dev and live datastore, but my next thing to to create objects from non-CSV data and push it into the datastore.</p> <p>So say my object is something like:</p> <pre><code>class CainEvent(db.Model): name =db.StringProperty(required=True) birthdate ...
1
2009-09-14T15:29:12Z
1,575,564
<p>You may find <a href="http://blog.notdot.net/2009/9/Advanced-Bulk-Loading-part-3-Alternate-datasources" rel="nofollow">this post</a> useful - it details how to load data direct from an RDBMS, but applies equally to loading from any other source.</p>
0
2009-10-15T22:52:09Z
[ "python", "google-app-engine" ]
fcntl substitute on Windows
1,422,368
<p>I received a Python project (which happens to be a Django project, if that matters,) that uses the <code>fcntl</code> module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an <code>ImportError</code>, because this module does not exist ...
41
2009-09-14T15:43:11Z
1,422,436
<p>The substitute of <code>fcntl</code> on windows are <code>win32api</code> calls. The usage is completely different. It is not some switch you can just flip.</p> <p>In other words, porting a <code>fcntl</code>-heavy-user module to windows is not trivial. It requires you to analyze what exactly each <code>fcntl</code...
49
2009-09-14T15:54:35Z
[ "python", "windows", "linux" ]
fcntl substitute on Windows
1,422,368
<p>I received a Python project (which happens to be a Django project, if that matters,) that uses the <code>fcntl</code> module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an <code>ImportError</code>, because this module does not exist ...
41
2009-09-14T15:43:11Z
9,993,103
<p>Although this does not help you right away, there is an alternative that can work with both Unix (fcntl) and Windows (win32 api calls), called: <strong>portalocker</strong></p> <p>It describes itself as a cross-platform (posix/nt) API for flock-style file locking for Python. It basically maps fcntl to win32 api cal...
14
2012-04-03T12:18:58Z
[ "python", "windows", "linux" ]
fcntl substitute on Windows
1,422,368
<p>I received a Python project (which happens to be a Django project, if that matters,) that uses the <code>fcntl</code> module from the standard library, which seems to be available only on Linux. When I try to run it on my Windows machine, it stops with an <code>ImportError</code>, because this module does not exist ...
41
2009-09-14T15:43:11Z
25,471,508
<p>The fcntl module is just used for locking the pinning file, so assuming you don't try multiple access, this can be an acceptable workaround. Place this module in your PYTHONPATH, and it should just work as the official fcntl module.</p> <p>Try using <a href="https://communities.cisco.com/servlet/JiveServlet/downlo...
16
2014-08-24T12:05:33Z
[ "python", "windows", "linux" ]
Django Form Validation Framework on AppEngine: How to strip out HTML etc.?
1,422,674
<p>I'm using the Django Form Validation Framework on AppEngine (<a href="http://code.google.com/appengine/articles/djangoforms.html" rel="nofollow">http://code.google.com/appengine/articles/djangoforms.html</a>), like this:</p> <pre><code>data = MyForm(data=self.request.POST) if data.is_valid(): entity = data.sa...
1
2009-09-14T16:43:44Z
1,423,194
<p>Yes, of course. Have you tried reading the forms documentation?</p> <p><a href="http://docs.djangoproject.com/en/dev/ref/forms/validation/" rel="nofollow">http://docs.djangoproject.com/en/dev/ref/forms/validation/</a></p>
0
2009-09-14T18:31:06Z
[ "python", "django", "google-app-engine" ]
Django Form Validation Framework on AppEngine: How to strip out HTML etc.?
1,422,674
<p>I'm using the Django Form Validation Framework on AppEngine (<a href="http://code.google.com/appengine/articles/djangoforms.html" rel="nofollow">http://code.google.com/appengine/articles/djangoforms.html</a>), like this:</p> <pre><code>data = MyForm(data=self.request.POST) if data.is_valid(): entity = data.sa...
1
2009-09-14T16:43:44Z
1,423,936
<p>Short answer:</p> <p><code>forms.is_valid()</code> auto populates a dictionary <code>forms.cleaned_data</code> by calling a method called clean(). If you want to do any custom validation define your own 'clean_filed_name' that returns the cleaned field value or raises <code>forms.ValidationError()</code>. On error,...
2
2009-09-14T21:06:25Z
[ "python", "django", "google-app-engine" ]
Django Form Validation Framework on AppEngine: How to strip out HTML etc.?
1,422,674
<p>I'm using the Django Form Validation Framework on AppEngine (<a href="http://code.google.com/appengine/articles/djangoforms.html" rel="nofollow">http://code.google.com/appengine/articles/djangoforms.html</a>), like this:</p> <pre><code>data = MyForm(data=self.request.POST) if data.is_valid(): entity = data.sa...
1
2009-09-14T16:43:44Z
1,642,676
<p>In addition to the answers above, a different perspective: Don't. Store the user input with as little processing as is practical, and sanitize the data on output. Django templates provide filters for this - 'escape' is one that escapes all HTML tags.</p> <p>The advantage of this approach over sanitizing the data at...
1
2009-10-29T10:09:13Z
[ "python", "django", "google-app-engine" ]
How does AMF communication work?
1,422,724
<p>How does Flash communicate with services / scripts on servers via <a href="http://en.wikipedia.org/wiki/Action%5FMessage%5FFormat" rel="nofollow">AMF</a>?</p> <p>Regarding the <a href="http://en.wikipedia.org/wiki/Action%5FMessage%5FFormat#Support%5Ffor%5FAMF" rel="nofollow">AMF libraries</a> for Python / Perl / PH...
3
2009-09-14T16:53:44Z
1,422,867
<p>The only AMF library I'm familiar with is <a href="http://pyamf.org/">PyAMF</a>, which has been great to work with so far. Here are the answers to your questions for PyAMF:</p> <ul> <li><p>I'd imagine you can run it as a script (do you mean like CGI?), but the easiest IMO is to set up an app server specifically for...
7
2009-09-14T17:19:40Z
[ "python", "flash", "perl", "actionscript-2", "amf" ]
How does AMF communication work?
1,422,724
<p>How does Flash communicate with services / scripts on servers via <a href="http://en.wikipedia.org/wiki/Action%5FMessage%5FFormat" rel="nofollow">AMF</a>?</p> <p>Regarding the <a href="http://en.wikipedia.org/wiki/Action%5FMessage%5FFormat#Support%5Ffor%5FAMF" rel="nofollow">AMF libraries</a> for Python / Perl / PH...
3
2009-09-14T16:53:44Z
1,557,230
<blockquote> <p>How does Flash communicate with services / scripts on servers via AMF?</p> </blockquote> <p>Data is transferred over a TCP/IP connection. Sometimes an existing HTTP connection is used, and in other cases a new TCP/IP connection is opened for the AMF data. When the HTTP or additional TCP connections...
4
2009-10-12T22:13:36Z
[ "python", "flash", "perl", "actionscript-2", "amf" ]
pytz: Why is normalize needed when converting between timezones?
1,422,880
<p>I'm reading the not so complete <a href="http://pytz.sourceforge.net/">pytz documentation</a> and I'm stuck on understand one part of it.</p> <blockquote> <p>Converting between timezones also needs special attention. This also needs to use the normalize method to ensure the conversion is correct.</p> </blockquote...
14
2009-09-14T17:22:31Z
1,422,900
<p>From the pytz documentation:</p> <blockquote> <p>In addition, if you perform date arithmetic on local times that cross DST boundaries, the results may be in an incorrect timezone (ie. subtract 1 minute from 2002-10-27 1:00 EST and you get 2002-10-27 0:59 EST instead of the correct 2002-10-27 1:59 EDT). A normaliz...
8
2009-09-14T17:26:38Z
[ "python", "timezone", "pytz" ]
pytz: Why is normalize needed when converting between timezones?
1,422,880
<p>I'm reading the not so complete <a href="http://pytz.sourceforge.net/">pytz documentation</a> and I'm stuck on understand one part of it.</p> <blockquote> <p>Converting between timezones also needs special attention. This also needs to use the normalize method to ensure the conversion is correct.</p> </blockquote...
14
2009-09-14T17:22:31Z
1,422,904
<p>The docs say that normalize is used as a workaround for DST issues:</p> <blockquote> <p>In addition, if you perform date arithmetic on local times that cross DST boundaries, the results may be in an incorrect timezone (ie. subtract 1 minute from 2002-10-27 1:00 EST and you get 2002-10-27 0:59 EST instead of the c...
5
2009-09-14T17:27:59Z
[ "python", "timezone", "pytz" ]
Python and the built-in heap
1,422,969
<p>At the moment, I am trying to write a priority queue in Python using the built in heapq library. However, I am stuck trying to get a handle on what Python does with the tie-breaking, I want to have a specific condition where I can dictate what happens with the tie-breaking instead of the heapq library that seems to ...
2
2009-09-14T17:45:13Z
1,423,016
<p><code>heapq</code> uses the intrinsic comparisons on queue items (<code>__le__</code> and friends). The general way to work around this limit is the good old approach known as "decorate/undecorate" -- that's what we used to do in sorting, before the <code>key=</code> parameter was introduced there.</p> <p>To put it...
9
2009-09-14T17:59:03Z
[ "python" ]
web framework compatible with python 3.1 and py-postgresql
1,423,000
<p>I have started learning Python by writing a small application using Python 3.1 and py-postgresql. Now I want to turn it into a web application.</p> <p>But it seems that most frameworks such as web-py, django, zope are still based on Python 2.x. Unfortunately py-postgresql is incompatible with Python 2.x.</p> <p>Do...
1
2009-09-14T17:56:30Z
1,440,125
<p>Update: this answer is out of date in 2011.</p> <p>Unless you are interested in blazing a new trail while trying to learn Python at all, I'd recommend converting your project to Python 2.x. Hopefully your code doesn't use too many <code>py-postgresql</code> features not found in the widely supported DB-API interfac...
3
2009-09-17T17:08:02Z
[ "python", "web-applications", "python-3.x", "wsgi" ]
web framework compatible with python 3.1 and py-postgresql
1,423,000
<p>I have started learning Python by writing a small application using Python 3.1 and py-postgresql. Now I want to turn it into a web application.</p> <p>But it seems that most frameworks such as web-py, django, zope are still based on Python 2.x. Unfortunately py-postgresql is incompatible with Python 2.x.</p> <p>Do...
1
2009-09-14T17:56:30Z
1,443,094
<p>I have just found out about WSGI: a WSGI compatible app can also be written in Python 3.1. The following code runs just fine in Python 3.1:</p> <pre><code>def webapp(environment, start_response): start_response('200 OK', [('content-type', 'text/html')]) return ['Hello, World!'] if __name__ == '__main__': ...
1
2009-09-18T07:48:22Z
[ "python", "web-applications", "python-3.x", "wsgi" ]
web framework compatible with python 3.1 and py-postgresql
1,423,000
<p>I have started learning Python by writing a small application using Python 3.1 and py-postgresql. Now I want to turn it into a web application.</p> <p>But it seems that most frameworks such as web-py, django, zope are still based on Python 2.x. Unfortunately py-postgresql is incompatible with Python 2.x.</p> <p>Do...
1
2009-09-14T17:56:30Z
1,448,545
<p>Here's a simplified version of tornado's WSGI server implemented in python 3.</p> <p><a href="http://code.activestate.com/recipes/576906/" rel="nofollow">http://code.activestate.com/recipes/576906/</a></p> <p>probably has some bugs, but can get you started</p>
0
2009-09-19T13:15:46Z
[ "python", "web-applications", "python-3.x", "wsgi" ]
web framework compatible with python 3.1 and py-postgresql
1,423,000
<p>I have started learning Python by writing a small application using Python 3.1 and py-postgresql. Now I want to turn it into a web application.</p> <p>But it seems that most frameworks such as web-py, django, zope are still based on Python 2.x. Unfortunately py-postgresql is incompatible with Python 2.x.</p> <p>Do...
1
2009-09-14T17:56:30Z
1,934,744
<p>Even though it's not officially released yet, I am currently 'playing around' with CherryPy 3.2.0rc1 with Python 3.1.1 and have had no problems yet. Haven't used it with py-postgresql, but I don't see why it shouldn't work.</p> <p>Hope this helps, Alan</p>
0
2009-12-20T03:27:16Z
[ "python", "web-applications", "python-3.x", "wsgi" ]
What python web frameworks work well with CGI (e.g. on nearlyfreespeech.net)?
1,423,041
<p>From nearlyfreespeech's website, they state that the following don't work well:</p> <ul> <li>mod_python Web application</li> <li>frameworks that depend on persistent processes, including: Ruby On Rails, Django, Zope, and others (some of these will run under CGI, but will run slowly and are suitable only for develo...
5
2009-09-14T18:03:36Z
1,423,084
<p>By the things they reject. I think that twisted.web is still an option there, but I don't have any experience with nearlyfreespeech.net</p>
0
2009-09-14T18:11:23Z
[ "python", "frameworks", "cgi", "nearlyfreespeech" ]
What python web frameworks work well with CGI (e.g. on nearlyfreespeech.net)?
1,423,041
<p>From nearlyfreespeech's website, they state that the following don't work well:</p> <ul> <li>mod_python Web application</li> <li>frameworks that depend on persistent processes, including: Ruby On Rails, Django, Zope, and others (some of these will run under CGI, but will run slowly and are suitable only for develo...
5
2009-09-14T18:03:36Z
1,423,182
<p>WSGI can run on top of CGI, and popular frameworks typically run on top of WSGI, <strong>but</strong> performance is quite another issue -- since a CGI service starts afresh on each hit, any framework you may be using will need to reload from scratch each and every time, and that (in addition to opening a new connec...
5
2009-09-14T18:27:41Z
[ "python", "frameworks", "cgi", "nearlyfreespeech" ]
What python web frameworks work well with CGI (e.g. on nearlyfreespeech.net)?
1,423,041
<p>From nearlyfreespeech's website, they state that the following don't work well:</p> <ul> <li>mod_python Web application</li> <li>frameworks that depend on persistent processes, including: Ruby On Rails, Django, Zope, and others (some of these will run under CGI, but will run slowly and are suitable only for develo...
5
2009-09-14T18:03:36Z
1,423,207
<p>I got web.py to work on nearly free speech a few years ago by fooling with its WSGI stuff to run on CGI. It was just slightly too slow to be usable though.</p> <p>I've made a few Python web applications hosted on nearly free speech just using the CGI module, and they are actually plenty fast even with high traffic...
2
2009-09-14T18:34:18Z
[ "python", "frameworks", "cgi", "nearlyfreespeech" ]
What python web frameworks work well with CGI (e.g. on nearlyfreespeech.net)?
1,423,041
<p>From nearlyfreespeech's website, they state that the following don't work well:</p> <ul> <li>mod_python Web application</li> <li>frameworks that depend on persistent processes, including: Ruby On Rails, Django, Zope, and others (some of these will run under CGI, but will run slowly and are suitable only for develo...
5
2009-09-14T18:03:36Z
1,424,853
<p>Well, if what you really need is just free hosting for a Python web app, <a href="http://code.google.com/appengine/" rel="nofollow">Google AppEngine</a> is a nice alternative and you won't be as limited on choice of frameworks.</p>
-2
2009-09-15T02:34:39Z
[ "python", "frameworks", "cgi", "nearlyfreespeech" ]