title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags listlengths 1 5 |
|---|---|---|---|---|---|---|---|---|---|
Making a string the name of an instance/object | 1,479,490 | <p>I've been struggling for a couple of days now with the following... </p>
<p>I'm trying to find a way to instantiate a number of objects which I can name via a raw_input call, and then, when I need to, look at its attributes via the 'print VARIABLE NAME' command in conjunction with the <strong>str</strong>() method.... | 0 | 2009-09-25T20:45:18Z | 1,479,552 | <p>If you just want to introduce new named variables in a module namespace, then <code>setattr</code> may well be the easiest way to go:</p>
<pre><code>import sys
class Species:
def __init__(self, name, legs, stomachs):
self.name = name
self.legs = legs
self.stomachs = stomachs
def create... | 6 | 2009-09-25T20:59:25Z | [
"python",
"string",
"variables",
"object"
] |
Making a string the name of an instance/object | 1,479,490 | <p>I've been struggling for a couple of days now with the following... </p>
<p>I'm trying to find a way to instantiate a number of objects which I can name via a raw_input call, and then, when I need to, look at its attributes via the 'print VARIABLE NAME' command in conjunction with the <strong>str</strong>() method.... | 0 | 2009-09-25T20:45:18Z | 1,479,656 | <pre><code>class Zoo(object):
def __init__(self, name):
self.name = name
self.animals = []
def __str__(self):
return ("The %s Zoo houses:\n" % self.name) + "\n".join(str(an) for an in self.animals)
class Animal( object ):
species = None
def __init__(self, legs, stomach):
... | 0 | 2009-09-25T21:23:36Z | [
"python",
"string",
"variables",
"object"
] |
Making a string the name of an instance/object | 1,479,490 | <p>I've been struggling for a couple of days now with the following... </p>
<p>I'm trying to find a way to instantiate a number of objects which I can name via a raw_input call, and then, when I need to, look at its attributes via the 'print VARIABLE NAME' command in conjunction with the <strong>str</strong>() method.... | 0 | 2009-09-25T20:45:18Z | 1,480,247 | <p>It's really, truly, SERIOUSLY a bad idea to create barenamed variables on the fly -- I <strong>earnestly</strong> implore you to give up the requirement to be able to just <code>print FOOBAR</code> for a FOOBAR barename that never existed in the code, much as I'd implore a fellow human being who's keen to commit sui... | 1 | 2009-09-26T02:16:01Z | [
"python",
"string",
"variables",
"object"
] |
Making a string the name of an instance/object | 1,479,490 | <p>I've been struggling for a couple of days now with the following... </p>
<p>I'm trying to find a way to instantiate a number of objects which I can name via a raw_input call, and then, when I need to, look at its attributes via the 'print VARIABLE NAME' command in conjunction with the <strong>str</strong>() method.... | 0 | 2009-09-25T20:45:18Z | 1,481,690 | <pre><code>>>> class Bear():
... pass
...
>>> class Dog():
... pass
...
>>>
>>> types = {'bear': Bear, 'dog': Dog}
>>>
>>> types['dog']()
<__main__.Dog instance at 0x75c10>
</code></pre>
| 0 | 2009-09-26T17:25:36Z | [
"python",
"string",
"variables",
"object"
] |
What is Python's Fabric equivalent in other languages? | 1,479,632 | <p>Can someone tell me what's the equivalent of Python's <a href="http://docs.fabfile.org/0.9/">Fabric</a> in Python itself, other languages or third party tools? I am still a bit fuzzy on what it is trying to accomplish and it's usage.</p>
| 5 | 2009-09-25T21:17:16Z | 1,479,645 | <p>It helps you to run commands on a lot of remote machines via SSH from your box. So you don't have to login on each one and copypaste the output of some machine back to your desktop.</p>
| 1 | 2009-09-25T21:21:13Z | [
"python"
] |
What is Python's Fabric equivalent in other languages? | 1,479,632 | <p>Can someone tell me what's the equivalent of Python's <a href="http://docs.fabfile.org/0.9/">Fabric</a> in Python itself, other languages or third party tools? I am still a bit fuzzy on what it is trying to accomplish and it's usage.</p>
| 5 | 2009-09-25T21:17:16Z | 1,479,653 | <p>The Ruby community uses a tool called <a href="http://capistranorb.com" rel="nofollow">Capistrano</a> for the same purpose.</p>
| 1 | 2009-09-25T21:22:46Z | [
"python"
] |
What is Python's Fabric equivalent in other languages? | 1,479,632 | <p>Can someone tell me what's the equivalent of Python's <a href="http://docs.fabfile.org/0.9/">Fabric</a> in Python itself, other languages or third party tools? I am still a bit fuzzy on what it is trying to accomplish and it's usage.</p>
| 5 | 2009-09-25T21:17:16Z | 1,479,654 | <p>These tools are for performing common remote administration tasks usually as part of automated builds - a Ruby equivalent might be Capistrano, JSch in Java.</p>
| 5 | 2009-09-25T21:22:48Z | [
"python"
] |
What is Python's Fabric equivalent in other languages? | 1,479,632 | <p>Can someone tell me what's the equivalent of Python's <a href="http://docs.fabfile.org/0.9/">Fabric</a> in Python itself, other languages or third party tools? I am still a bit fuzzy on what it is trying to accomplish and it's usage.</p>
| 5 | 2009-09-25T21:17:16Z | 1,480,519 | <p>Looking at the fabric example the first thing I thought about was mpiexec. Given right coding, I believe fabric can be used to run bot-nets or parallel processing clusters depending on your inclination.</p>
| 0 | 2009-09-26T05:44:47Z | [
"python"
] |
Readably print out a python dict() sorted by key | 1,479,649 | <p>I would like to print a python dictionary to a file using PrettyPrinter (for human readability) but have the dictionary be sorted by key in the output file to further improve readability. So:</p>
<pre><code>mydict = {'a':1, 'b':2, 'c':3}
pprint(mydict)
</code></pre>
<p>currently prints to</p>
<pre><code>{'b':2,
... | 46 | 2009-09-25T21:22:11Z | 1,479,676 | <p>You could transform this dict a little to ensure that (as dicts aren't kept sorted internally), e.g.</p>
<pre><code>pprint([(key, mydict[key]) for key in sorted(mydict.keys())])
</code></pre>
| 3 | 2009-09-25T21:28:23Z | [
"python"
] |
Readably print out a python dict() sorted by key | 1,479,649 | <p>I would like to print a python dictionary to a file using PrettyPrinter (for human readability) but have the dictionary be sorted by key in the output file to further improve readability. So:</p>
<pre><code>mydict = {'a':1, 'b':2, 'c':3}
pprint(mydict)
</code></pre>
<p>currently prints to</p>
<pre><code>{'b':2,
... | 46 | 2009-09-25T21:22:11Z | 1,479,691 | <p>The Python <code>pprint</code> module actually <em>already</em> sorts dictionaries by key. In versions prior to Python 2.5, the sorting was only triggered on dictionaries whose pretty-printed representation spanned multiple lines, but in 2.5.X and 2.6.X, <em>all</em> dictionaries are sorted.</p>
<p>Generally, thoug... | 12 | 2009-09-25T21:31:31Z | [
"python"
] |
Readably print out a python dict() sorted by key | 1,479,649 | <p>I would like to print a python dictionary to a file using PrettyPrinter (for human readability) but have the dictionary be sorted by key in the output file to further improve readability. So:</p>
<pre><code>mydict = {'a':1, 'b':2, 'c':3}
pprint(mydict)
</code></pre>
<p>currently prints to</p>
<pre><code>{'b':2,
... | 46 | 2009-09-25T21:22:11Z | 1,479,748 | <p>Actually pprint seems to sort the keys for you under python2.5</p>
<pre><code>>>> from pprint import pprint
>>> mydict = {'a':1, 'b':2, 'c':3}
>>> pprint(mydict)
{'a': 1, 'b': 2, 'c': 3}
>>> mydict = {'a':1, 'b':2, 'c':3, 'd':4, 'e':5}
>>> pprint(mydict)
{'a': 1, 'b': 2,... | 53 | 2009-09-25T21:55:27Z | [
"python"
] |
Readably print out a python dict() sorted by key | 1,479,649 | <p>I would like to print a python dictionary to a file using PrettyPrinter (for human readability) but have the dictionary be sorted by key in the output file to further improve readability. So:</p>
<pre><code>mydict = {'a':1, 'b':2, 'c':3}
pprint(mydict)
</code></pre>
<p>currently prints to</p>
<pre><code>{'b':2,
... | 46 | 2009-09-25T21:22:11Z | 11,789,032 | <p>I wrote the following function to print dicts, lists, and tuples in a more readable format:</p>
<pre><code>def printplus(obj):
"""
Pretty-prints the object passed in.
"""
# Dict
if isinstance(obj, dict):
for k, v in sorted(obj.items()):
print u'{0}: {1}'.format(k, v)
# ... | 11 | 2012-08-03T03:51:19Z | [
"python"
] |
Readably print out a python dict() sorted by key | 1,479,649 | <p>I would like to print a python dictionary to a file using PrettyPrinter (for human readability) but have the dictionary be sorted by key in the output file to further improve readability. So:</p>
<pre><code>mydict = {'a':1, 'b':2, 'c':3}
pprint(mydict)
</code></pre>
<p>currently prints to</p>
<pre><code>{'b':2,
... | 46 | 2009-09-25T21:22:11Z | 15,060,724 | <p>I had the same problem you had. I used a for loop with the sorted function passing in the dictionary like so:</p>
<pre><code>for item in sorted(mydict):
print(item)
</code></pre>
| 3 | 2013-02-25T05:31:03Z | [
"python"
] |
Readably print out a python dict() sorted by key | 1,479,649 | <p>I would like to print a python dictionary to a file using PrettyPrinter (for human readability) but have the dictionary be sorted by key in the output file to further improve readability. So:</p>
<pre><code>mydict = {'a':1, 'b':2, 'c':3}
pprint(mydict)
</code></pre>
<p>currently prints to</p>
<pre><code>{'b':2,
... | 46 | 2009-09-25T21:22:11Z | 18,219,242 | <p>An easy way to print the sorted contents of the dictionary, in Python 3:</p>
<pre><code>>>> dict_example = {'c': 1, 'b': 2, 'a': 3}
>>> for key, value in sorted(dict_example.items()):
... print("{} : {}".format(key, value))
...
a : 3
b : 2
c : 1
</code></pre>
<p>The expression <code>dict_examp... | 8 | 2013-08-13T21:07:44Z | [
"python"
] |
Readably print out a python dict() sorted by key | 1,479,649 | <p>I would like to print a python dictionary to a file using PrettyPrinter (for human readability) but have the dictionary be sorted by key in the output file to further improve readability. So:</p>
<pre><code>mydict = {'a':1, 'b':2, 'c':3}
pprint(mydict)
</code></pre>
<p>currently prints to</p>
<pre><code>{'b':2,
... | 46 | 2009-09-25T21:22:11Z | 36,336,386 | <p>Another alternative :</p>
<pre><code>>>> mydict = {'a':1, 'b':2, 'c':3}
>>> import json
>>> print json.dumps(mydict, indent=4, sort_keys=True)
{
"a": 1,
"b": 2,
"c": 3
}
</code></pre>
| 0 | 2016-03-31T14:32:36Z | [
"python"
] |
How to bind a TextField to an IBOutlet()? | 1,479,709 | <p>I'm trying to figure out how to update an NSTextField programatically.</p>
<p>I've figured out how to get the current value of the Text Field from Python:</p>
<pre><code>myVar = objc.IBOutlet()
....
self.myVar.stringValue()
</code></pre>
<p>How do I set the value of myVar from the Python side and have the GUI upd... | 1 | 2009-09-25T21:38:01Z | 1,479,843 | <blockquote>
<p>How do I set the value of myVar from the Python side and have the GUI update?</p>
</blockquote>
<p>Why would you want to? The nib loader set it to a control; if you set the variable, you would lose the control.</p>
<p>To set the value of the control, send it a <code>setStringValue_</code> (or simila... | 1 | 2009-09-25T22:32:25Z | [
"python",
"cocoa",
"binding",
"pyobjc"
] |
"Too many values to unpack" Exception | 1,479,776 | <p>I'm working on a project in Django and I've just started trying to extend the User model in order to make user profiles. </p>
<p>Unfortunately, I've run into a problem: Every time I try to get the user's profile inside of a template (<code>user.get_template.lastIP</code>, for example), I get the following error:</p... | 52 | 2009-09-25T22:04:27Z | 1,479,795 | <p>Most likely there is an error somewhere in the get_profile() call. In your view, before you return the request object, put this line:</p>
<pre><code>request.user.get_profile()
</code></pre>
<p>It should raise the error, and give you a more detailed traceback, which you can then use to further debug.</p>
| 0 | 2009-09-25T22:12:03Z | [
"python",
"django"
] |
"Too many values to unpack" Exception | 1,479,776 | <p>I'm working on a project in Django and I've just started trying to extend the User model in order to make user profiles. </p>
<p>Unfortunately, I've run into a problem: Every time I try to get the user's profile inside of a template (<code>user.get_template.lastIP</code>, for example), I get the following error:</p... | 52 | 2009-09-25T22:04:27Z | 1,479,796 | <p>That exception means that you are trying to unpack a tuple, but the tuple has too many values with respect to the number of target variables. For example: this work, and prints 1, then 2, then 3</p>
<pre><code>def returnATupleWithThreeValues():
return (1,2,3)
a,b,c = returnATupleWithThreeValues()
print a
print ... | 116 | 2009-09-25T22:13:22Z | [
"python",
"django"
] |
"Too many values to unpack" Exception | 1,479,776 | <p>I'm working on a project in Django and I've just started trying to extend the User model in order to make user profiles. </p>
<p>Unfortunately, I've run into a problem: Every time I try to get the user's profile inside of a template (<code>user.get_template.lastIP</code>, for example), I get the following error:</p... | 52 | 2009-09-25T22:04:27Z | 1,479,907 | <p>This happens to me when I'm using Jinja2 for templates. The problem can be solved by running the development server using the <a href="http://code.google.com/p/django-command-extensions/wiki/RunServerPlus" rel="nofollow"><code>runserver_plus</code></a> command from <a href="http://code.google.com/p/django-command-ex... | 0 | 2009-09-25T23:03:52Z | [
"python",
"django"
] |
"Too many values to unpack" Exception | 1,479,776 | <p>I'm working on a project in Django and I've just started trying to extend the User model in order to make user profiles. </p>
<p>Unfortunately, I've run into a problem: Every time I try to get the user's profile inside of a template (<code>user.get_template.lastIP</code>, for example), I get the following error:</p... | 52 | 2009-09-25T22:04:27Z | 1,481,134 | <p>This problem looked familiar so I thought I'd see if I could replicate from the limited amount of information.</p>
<p>A quick search turned up an entry in James Bennett's blog <a href="http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/">here</a> which mentions that when working with the User... | 8 | 2009-09-26T12:43:50Z | [
"python",
"django"
] |
"Too many values to unpack" Exception | 1,479,776 | <p>I'm working on a project in Django and I've just started trying to extend the User model in order to make user profiles. </p>
<p>Unfortunately, I've run into a problem: Every time I try to get the user's profile inside of a template (<code>user.get_template.lastIP</code>, for example), I get the following error:</p... | 52 | 2009-09-25T22:04:27Z | 1,899,737 | <p>try unpacking in one variable,</p>
<p>python will handle it as a list,</p>
<p>then unpack from the list</p>
| 11 | 2009-12-14T08:51:12Z | [
"python",
"django"
] |
Case-insensitive comparison of sets in Python | 1,479,979 | <p>I have two sets (although I can do lists, or whatever):</p>
<pre><code>a = frozenset(('Today','I','am','fine'))
b = frozenset(('hello','how','are','you','today'))
</code></pre>
<p>I want to get:</p>
<pre><code>frozenset(['Today'])
</code></pre>
<p>or at least:</p>
<pre><code>frozenset(['today'])
</code></pre>
... | 4 | 2009-09-25T23:35:12Z | 1,480,000 | <p>First, don't you mean <code>a.intersection(b)</code>? The intersection (if case insensitive) would be <code>set(['today'])</code>. The difference would be <code>set(['i', 'am', 'fine'])</code></p>
<p>Here are two ideas:</p>
<p>1.) Write a function to convert the elements of both sets to lowercase and then do the i... | 3 | 2009-09-25T23:44:36Z | [
"python",
"django",
"compare"
] |
Case-insensitive comparison of sets in Python | 1,479,979 | <p>I have two sets (although I can do lists, or whatever):</p>
<pre><code>a = frozenset(('Today','I','am','fine'))
b = frozenset(('hello','how','are','you','today'))
</code></pre>
<p>I want to get:</p>
<pre><code>frozenset(['Today'])
</code></pre>
<p>or at least:</p>
<pre><code>frozenset(['today'])
</code></pre>
... | 4 | 2009-09-25T23:35:12Z | 1,480,230 | <p>Unfortunately, even if you COULD "change on the fly" the comparison-related special methods of the sets' items (<code>__lt__</code> and friends -- actually, only <code>__eq__</code> needed the way sets are currently implemented, but that's an implementatio detail) -- and you can't, because they belong to a built-in ... | 6 | 2009-09-26T02:03:24Z | [
"python",
"django",
"compare"
] |
Case-insensitive comparison of sets in Python | 1,479,979 | <p>I have two sets (although I can do lists, or whatever):</p>
<pre><code>a = frozenset(('Today','I','am','fine'))
b = frozenset(('hello','how','are','you','today'))
</code></pre>
<p>I want to get:</p>
<pre><code>frozenset(['Today'])
</code></pre>
<p>or at least:</p>
<pre><code>frozenset(['today'])
</code></pre>
... | 4 | 2009-09-25T23:35:12Z | 1,480,291 | <p>Here's version that works for any pair of iterables:</p>
<pre><code>def intersection(iterableA, iterableB, key=lambda x: x):
"""Return the intersection of two iterables with respect to `key` function.
"""
def unify(iterable):
d = {}
for item in iterable:
d.setdefault(key(ite... | 8 | 2009-09-26T02:46:07Z | [
"python",
"django",
"compare"
] |
Case-insensitive comparison of sets in Python | 1,479,979 | <p>I have two sets (although I can do lists, or whatever):</p>
<pre><code>a = frozenset(('Today','I','am','fine'))
b = frozenset(('hello','how','are','you','today'))
</code></pre>
<p>I want to get:</p>
<pre><code>frozenset(['Today'])
</code></pre>
<p>or at least:</p>
<pre><code>frozenset(['today'])
</code></pre>
... | 4 | 2009-09-25T23:35:12Z | 1,487,698 | <pre><code>>>> a_, b_ = map(set, [map(str.lower, a), map(str.lower, b)])
>>> a_ & b_
set(['today'])
</code></pre>
<p>Or... with less maps,</p>
<pre><code>>>> a_ = set(map(str.lower, a))
>>> b_ = set(map(str.lower, b))
>>> a_ & b_
set(['today'])
</code></pre>
| 1 | 2009-09-28T15:27:51Z | [
"python",
"django",
"compare"
] |
How to get _sqlite3.so file? | 1,480,024 | <p>I have installed Python 2.6.2.. I did it "locally" since I do not have root permissions. With this version of Python I wanted to use module called "sqlite3" (it is called "pysqlite" in earlier versions). In theory I had to be able to use this module without any problems since it is supposed to be included by defaul... | 3 | 2009-09-25T23:55:45Z | 1,480,027 | <p>Your <code>sys.path</code> is likely not pointing to your locally installed copy, or you're not running the Python 2.6.2 you think you are.</p>
<p>If none of that is the case, you need the SQLite development headers (sqlite-dev or whatever), and then recompile Python. You need to pay attention at the end of the co... | 1 | 2009-09-25T23:58:45Z | [
"python",
"sqlite",
"sqlite3",
"pysqlite"
] |
How to get _sqlite3.so file? | 1,480,024 | <p>I have installed Python 2.6.2.. I did it "locally" since I do not have root permissions. With this version of Python I wanted to use module called "sqlite3" (it is called "pysqlite" in earlier versions). In theory I had to be able to use this module without any problems since it is supposed to be included by defaul... | 3 | 2009-09-25T23:55:45Z | 14,545,666 | <p>Although you might have found your solution, I just wrote mine down for someone who are stuck in the same problem. </p>
<p>My OS is <strong>CentOS 6.3(Final) with python2.6</strong>.</p>
<p>I install python2.7.3 in my system, but the problem's still there. (_sqlite3.so should be in <code>/path/to/python2.7.3/lib/p... | 0 | 2013-01-27T08:23:07Z | [
"python",
"sqlite",
"sqlite3",
"pysqlite"
] |
Is there anyway to use TestCase.assertEqual() outside of a TestCase? | 1,480,144 | <p>I have a utility class that stores methods that are useful for some unit test cases. I want these helper methods to be able to do asserts/fails/etc., but it seems I can't use those methods because they expect TestCase as their first argument...</p>
<p>I want to be able to store the common methods outside of the tes... | 2 | 2009-09-26T01:05:08Z | 1,480,150 | <p>Sounds like you want this, from the error at least ...</p>
<h3>unittest_foo.py:</h3>
<pre><code>import unittest
from common_methods import *
class TestPayments(unittest.TestCase):
def test_0(self):
common_method1(self, "foo")
</code></pre>
<h3>common_methods.py:</h3>
<pre><code>def common_method1( s... | 1 | 2009-09-26T01:08:51Z | [
"python",
"unit-testing"
] |
Is there anyway to use TestCase.assertEqual() outside of a TestCase? | 1,480,144 | <p>I have a utility class that stores methods that are useful for some unit test cases. I want these helper methods to be able to do asserts/fails/etc., but it seems I can't use those methods because they expect TestCase as their first argument...</p>
<p>I want to be able to store the common methods outside of the tes... | 2 | 2009-09-26T01:05:08Z | 1,480,296 | <p>This is often accomplished with multiple inheritance:</p>
<p><strong>common_methods.py:</strong> </p>
<pre><code>class CommonMethods:
def common_method1(self, stuff):
blah=stuff
self.failUnless(len(blah) > 5)
...
...
</code></pre>
<p><strong>unittest_foo.py:</strong></p>
<pre><code... | 3 | 2009-09-26T02:48:11Z | [
"python",
"unit-testing"
] |
Python: Grab the A record of any URI? | 1,480,183 | <p>I basically want to implement something where you can type in any URI ( I probably will only deal with http ) and I want to return the A record of the domain in the URI, I want the server's IP address. </p>
<p>I know there's the ping command which most people use to look an ip address up, but I also know there's 'h... | 0 | 2009-09-26T01:25:55Z | 1,480,191 | <pre><code>py> import urlparse,socket
py> p = urlparse.urlparse("http://stackoverflow.com/questions/1480183")
py> p
('http', 'stackoverflow.com', '/questions/1480183', '', '', '')
py> host=p[1]
py> ai=socket.gethostbyname(host)
py> socket.gethostbyname(host)
'69.59.196.211'
</code></pre>
| 5 | 2009-09-26T01:31:43Z | [
"python",
"url",
"dns",
"ip",
"host"
] |
how to submit query to .aspx page in python | 1,480,356 | <p>I need to scrape query results from an .aspx web page. </p>
<p><a href="http://legistar.council.nyc.gov/Legislation.aspx">http://legistar.council.nyc.gov/Legislation.aspx</a></p>
<p>The url is static, so how do I submit a query to this page and get the results? Assume we need to select "all years" and "all types" ... | 16 | 2009-09-26T03:27:22Z | 1,480,367 | <p>"Assume we need to select "all years" and "all types" from the respective dropdown menus."</p>
<p>What do these options do to the URL that is ultimately submitted.</p>
<p>After all, it amounts to an HTTP request sent via <code>urllib2</code>. </p>
<p>Do know how to do '"all years" and "all types" from the respec... | 0 | 2009-09-26T03:33:17Z | [
"asp.net",
"python",
"asp.net-ajax"
] |
how to submit query to .aspx page in python | 1,480,356 | <p>I need to scrape query results from an .aspx web page. </p>
<p><a href="http://legistar.council.nyc.gov/Legislation.aspx">http://legistar.council.nyc.gov/Legislation.aspx</a></p>
<p>The url is static, so how do I submit a query to this page and get the results? Assume we need to select "all years" and "all types" ... | 16 | 2009-09-26T03:27:22Z | 1,480,376 | <p>Most ASP.NET sites (the one you referenced included) will actually post their queries back to themselves using the HTTP POST verb, not the GET verb. That is why the URL is not changing as you noted.</p>
<p>What you will need to do is look at the generated HTML and capture all their form values. Be sure to capture a... | 3 | 2009-09-26T03:39:38Z | [
"asp.net",
"python",
"asp.net-ajax"
] |
how to submit query to .aspx page in python | 1,480,356 | <p>I need to scrape query results from an .aspx web page. </p>
<p><a href="http://legistar.council.nyc.gov/Legislation.aspx">http://legistar.council.nyc.gov/Legislation.aspx</a></p>
<p>The url is static, so how do I submit a query to this page and get the results? Assume we need to select "all years" and "all types" ... | 16 | 2009-09-26T03:27:22Z | 1,480,696 | <p>As an overview, you will need to perform four main tasks:</p>
<ul>
<li>to submit request(s) to the web site, </li>
<li>to retrieve the response(s) from the site </li>
<li>to parse these responses</li>
<li>to have some logic to iterate in the tasks above, with parameters associated with the navigation (to "next" pag... | 19 | 2009-09-26T07:37:23Z | [
"asp.net",
"python",
"asp.net-ajax"
] |
how to submit query to .aspx page in python | 1,480,356 | <p>I need to scrape query results from an .aspx web page. </p>
<p><a href="http://legistar.council.nyc.gov/Legislation.aspx">http://legistar.council.nyc.gov/Legislation.aspx</a></p>
<p>The url is static, so how do I submit a query to this page and get the results? Assume we need to select "all years" and "all types" ... | 16 | 2009-09-26T03:27:22Z | 6,311,712 | <p><a href="http://seleniumhq.org/" rel="nofollow">Selenium</a> is a great tool to use for this kind of task. You can specify the form values that you want to enter and retrieve the html of the response page as a string in a couple of lines of python code.
Using Selenium you might not have to do the manual work of simu... | 4 | 2011-06-10T20:26:41Z | [
"asp.net",
"python",
"asp.net-ajax"
] |
how to submit query to .aspx page in python | 1,480,356 | <p>I need to scrape query results from an .aspx web page. </p>
<p><a href="http://legistar.council.nyc.gov/Legislation.aspx">http://legistar.council.nyc.gov/Legislation.aspx</a></p>
<p>The url is static, so how do I submit a query to this page and get the results? Assume we need to select "all years" and "all types" ... | 16 | 2009-09-26T03:27:22Z | 8,864,259 | <p>The code in the other answers was useful; I never would have been able to write my crawler without it.</p>
<p>One problem I did come across was cookies. The site I was crawling was using cookies to log session id/security stuff, so I had to add code to get my crawler to work:</p>
<p>Add this import:</p>
<pre><cod... | 3 | 2012-01-14T18:12:44Z | [
"asp.net",
"python",
"asp.net-ajax"
] |
Efficient method to determine location on a grid(array) | 1,480,406 | <p>I am representing a grid with a 2D list in python. I would like to pick a point (x,y) in the list and determine it's location...right edge, top left corner, somewhere in the middle...</p>
<p>Currently I am checking like so:</p>
<pre><code> # left column, not a corner
if x == 0 and y != 0 and y !=... | 2 | 2009-09-26T03:58:50Z | 1,480,422 | <pre><code># initially:
method_list = [
bottom_left, bottom, bottom_right,
left, middle, right,
top_left, top, top_right,
]
# each time:
keyx = 0 if not x else (2 if x == self.dim_x - 1 else 1)
keyy = 0 if not y else (2 if y == self.dim_y - 1 else 1)
key = keyy * 3 + keyx
method_list[key](self, x, y, o... | 3 | 2009-09-26T04:16:57Z | [
"python",
"arrays",
"list",
"performance"
] |
Efficient method to determine location on a grid(array) | 1,480,406 | <p>I am representing a grid with a 2D list in python. I would like to pick a point (x,y) in the list and determine it's location...right edge, top left corner, somewhere in the middle...</p>
<p>Currently I am checking like so:</p>
<pre><code> # left column, not a corner
if x == 0 and y != 0 and y !=... | 2 | 2009-09-26T03:58:50Z | 1,480,437 | <p>If I understand correctly, you have a collection of coordinates (x,y) living in a grid, and you would like to know, given any coordinate, whether it is inside the grid or on an edge.</p>
<p>The approach I would take is to normalize the grid before making the comparison, so that its origin is (0,0) and its top right... | 1 | 2009-09-26T04:31:11Z | [
"python",
"arrays",
"list",
"performance"
] |
Efficient method to determine location on a grid(array) | 1,480,406 | <p>I am representing a grid with a 2D list in python. I would like to pick a point (x,y) in the list and determine it's location...right edge, top left corner, somewhere in the middle...</p>
<p>Currently I am checking like so:</p>
<pre><code> # left column, not a corner
if x == 0 and y != 0 and y !=... | 2 | 2009-09-26T03:58:50Z | 1,480,473 | <pre><code>def location(x,y,dim_x,dim_y):
index = 1*(y==0) + 2*(y==dim_y-1) + 3*(x==0) + 6*(x==dim_x-1)
return ["interior","top","bottom","left","top-left",
"bottom-left","right","top-right","bottom-right"][index]
</code></pre>
| 7 | 2009-09-26T05:11:18Z | [
"python",
"arrays",
"list",
"performance"
] |
Efficient method to determine location on a grid(array) | 1,480,406 | <p>I am representing a grid with a 2D list in python. I would like to pick a point (x,y) in the list and determine it's location...right edge, top left corner, somewhere in the middle...</p>
<p>Currently I am checking like so:</p>
<pre><code> # left column, not a corner
if x == 0 and y != 0 and y !=... | 2 | 2009-09-26T03:58:50Z | 1,480,746 | <p>I guess if you really want to treat all these cases completely differently, your solution is okay, as it is very explicit. A compact solution might look more elegant, but will probably be harder to maintain. It really depends on what happens inside the if-blocks.</p>
<p>As soon as there is a common handling of, say... | 0 | 2009-09-26T08:11:39Z | [
"python",
"arrays",
"list",
"performance"
] |
Efficient method to determine location on a grid(array) | 1,480,406 | <p>I am representing a grid with a 2D list in python. I would like to pick a point (x,y) in the list and determine it's location...right edge, top left corner, somewhere in the middle...</p>
<p>Currently I am checking like so:</p>
<pre><code> # left column, not a corner
if x == 0 and y != 0 and y !=... | 2 | 2009-09-26T03:58:50Z | 1,480,880 | <p>Something like this might be more readable / maintainable. It will probably be a lot faster than your nested if statements since it only tests each condition once and dispatches through a dictionary which is nice and fast.</p>
<pre><code>class LocationThing:
def __init__(self, x, y):
self.dim_x = x
... | 0 | 2009-09-26T09:50:47Z | [
"python",
"arrays",
"list",
"performance"
] |
Efficient method to determine location on a grid(array) | 1,480,406 | <p>I am representing a grid with a 2D list in python. I would like to pick a point (x,y) in the list and determine it's location...right edge, top left corner, somewhere in the middle...</p>
<p>Currently I am checking like so:</p>
<pre><code> # left column, not a corner
if x == 0 and y != 0 and y !=... | 2 | 2009-09-26T03:58:50Z | 1,481,572 | <p>For a fast inner-loop function, you can just bite the bullet and do the ugly: nested if else statements with repeated terms, so that each comparison is only done once, and it runs about <strong>twice as fast</strong> as an example cleaner answer (by mobrule):</p>
<pre><code>import timeit
def f0(x, y, x_dim, y_dim)... | 0 | 2009-09-26T16:23:39Z | [
"python",
"arrays",
"list",
"performance"
] |
Most used Python module for video processing? | 1,480,431 | <p>I need to:</p>
<ol>
<li>Open a video file</li>
<li>Iterate over the frames of the file as images</li>
<li>Do some analysis in this image frame of the video</li>
<li>Draw in this image of the video</li>
<li>Create a new video with these changes</li>
</ol>
<p>OpenCV isn't working for my webcam, but python-gst is wor... | 12 | 2009-09-26T04:23:53Z | 1,480,450 | <p>Do you mean opencv can't connect to your webcam or can't read video files recorded by it?</p>
<p>Have you tried saving the video in an other format?</p>
<p>OpenCV is probably the best supported python image processing tool </p>
| 5 | 2009-09-26T04:47:50Z | [
"python",
"image-processing",
"video-processing"
] |
Most used Python module for video processing? | 1,480,431 | <p>I need to:</p>
<ol>
<li>Open a video file</li>
<li>Iterate over the frames of the file as images</li>
<li>Do some analysis in this image frame of the video</li>
<li>Draw in this image of the video</li>
<li>Create a new video with these changes</li>
</ol>
<p>OpenCV isn't working for my webcam, but python-gst is wor... | 12 | 2009-09-26T04:23:53Z | 1,497,418 | <p>Just build a C/C++ wrapper for your webcam and then use SWIG or SIP to access these functions from Python. Then use OpenCV in Python that's the best open sourced computer vision library in the wild.</p>
<p>If you worry for performance and you work under Linux, you could download free versions of Intel Performance P... | 0 | 2009-09-30T11:00:07Z | [
"python",
"image-processing",
"video-processing"
] |
Most used Python module for video processing? | 1,480,431 | <p>I need to:</p>
<ol>
<li>Open a video file</li>
<li>Iterate over the frames of the file as images</li>
<li>Do some analysis in this image frame of the video</li>
<li>Draw in this image of the video</li>
<li>Create a new video with these changes</li>
</ol>
<p>OpenCV isn't working for my webcam, but python-gst is wor... | 12 | 2009-09-26T04:23:53Z | 1,929,649 | <p>I'm going through this myself. It's only a couple of lines in MATLAB using mmreader, but I've already blown two work days trying to figure out how to pull frames from a video file into numpy. If you have enough disk space, and it doesn't have to be real time, you can use:</p>
<pre><code>mplayer -noconsolecontrols... | 3 | 2009-12-18T17:36:04Z | [
"python",
"image-processing",
"video-processing"
] |
Most used Python module for video processing? | 1,480,431 | <p>I need to:</p>
<ol>
<li>Open a video file</li>
<li>Iterate over the frames of the file as images</li>
<li>Do some analysis in this image frame of the video</li>
<li>Draw in this image of the video</li>
<li>Create a new video with these changes</li>
</ol>
<p>OpenCV isn't working for my webcam, but python-gst is wor... | 12 | 2009-09-26T04:23:53Z | 1,939,327 | <p>I used this script to convert a movie to a numpy array + binary store:</p>
<pre><code>"""
Takes a MPEG movie and produces a numpy record file with a numpy array.
"""
import os
filename = 'walking'
if not(os.path.isfile(filename + '.npy')): # do nothing if files exists
N_frame = 42 # number of frames we want t... | 3 | 2009-12-21T10:25:19Z | [
"python",
"image-processing",
"video-processing"
] |
phpMyAdmin equivalent in python? | 1,480,453 | <p>Is there a python equivalent of phpMyAdmin?</p>
<p>Here's why I'm looking for a python version of phpmyadmin: While I agree that phpmyadmin really rocks, I don't want to run php on my server. I'd like to move from apache2-prefork to apache2-mpm-worker. Worker blows the doors off of prefork for performance, but php5... | 27 | 2009-09-26T04:51:49Z | 1,480,549 | <p>You can use phpMyAdmin for python project, because phpMyAdmin is meant for MySQL databases. If you are using MySQL, then regardless of whether you are using PHP or python, you can use phpMyAdmin.</p>
| 9 | 2009-09-26T06:08:12Z | [
"python",
"phpmyadmin"
] |
phpMyAdmin equivalent in python? | 1,480,453 | <p>Is there a python equivalent of phpMyAdmin?</p>
<p>Here's why I'm looking for a python version of phpmyadmin: While I agree that phpmyadmin really rocks, I don't want to run php on my server. I'd like to move from apache2-prefork to apache2-mpm-worker. Worker blows the doors off of prefork for performance, but php5... | 27 | 2009-09-26T04:51:49Z | 13,483,043 | <p>I'm basing my answer off the last sentence of your question, "[the] extra memory and performance penalty for having php on this server", because it sounds like you don't want php on that server, even though "phpmyadmin rocks". From that, I would suggest using phpMyAdmin to manage the MySQL database remotely, which ... | 1 | 2012-11-20T22:08:14Z | [
"python",
"phpmyadmin"
] |
phpMyAdmin equivalent in python? | 1,480,453 | <p>Is there a python equivalent of phpMyAdmin?</p>
<p>Here's why I'm looking for a python version of phpmyadmin: While I agree that phpmyadmin really rocks, I don't want to run php on my server. I'd like to move from apache2-prefork to apache2-mpm-worker. Worker blows the doors off of prefork for performance, but php5... | 27 | 2009-09-26T04:51:49Z | 22,571,406 | <p>I don't think there is an alternative to phpMyAdmin. <a href="https://github.com/ChipaKraken/pythonMyAdmin" rel="nofollow">pythonMyAdmin</a> doesn't seems mature.</p>
<p>The philosophy in python is to create the databease with the ORM and after to manage it through the web framework admin page (like the one in Djan... | 2 | 2014-03-21T23:39:10Z | [
"python",
"phpmyadmin"
] |
Python interpreter as a c++ class | 1,480,490 | <p>I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.</p>
<p>Can I wrap Python interpreter in to a c++ class and get services from two or more class instances?</p>
| 7 | 2009-09-26T05:28:18Z | 1,480,578 | <p>You can, but I'd recommend you not to re-implement a Python interpreter when there is a standard implementation. Use <strong>boost::python</strong> to interface with Python.</p>
| 3 | 2009-09-26T06:28:08Z | [
"c++",
"python",
"multithreading",
"python-c-api",
"python-embedding"
] |
Python interpreter as a c++ class | 1,480,490 | <p>I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.</p>
<p>Can I wrap Python interpreter in to a c++ class and get services from two or more class instances?</p>
| 7 | 2009-09-26T05:28:18Z | 1,480,900 | <p>Callin <code>Py_Initialize()</code> twice won't work well, however <a href="http://docs.python.org/c-api/init.html#Py%5FNewInterpreter"><code>Py_NewInterpreter</code></a> can work, depending on what you're trying to do. Read the docs carefully, you have to hold the GIL when calling this.</p>
| 6 | 2009-09-26T10:01:10Z | [
"c++",
"python",
"multithreading",
"python-c-api",
"python-embedding"
] |
Python interpreter as a c++ class | 1,480,490 | <p>I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.</p>
<p>Can I wrap Python interpreter in to a c++ class and get services from two or more class instances?</p>
| 7 | 2009-09-26T05:28:18Z | 1,515,293 | <p>I don't think you are the first person to want to do this, unfortunately I believe it is not possible. Are you able to run the python interperters as separate processes and use RPC?</p>
| 1 | 2009-10-04T01:00:56Z | [
"c++",
"python",
"multithreading",
"python-c-api",
"python-embedding"
] |
Python interpreter as a c++ class | 1,480,490 | <p>I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.</p>
<p>Can I wrap Python interpreter in to a c++ class and get services from two or more class instances?</p>
| 7 | 2009-09-26T05:28:18Z | 1,518,878 | <ul>
<li>You can let the python interpreter live outside of your application memory space. Just embed the interpreter in a DLL.</li>
<li>You can set up & save python contexts to simulate two different interpreters.</li>
</ul>
| 0 | 2009-10-05T08:45:55Z | [
"c++",
"python",
"multithreading",
"python-c-api",
"python-embedding"
] |
Python interpreter as a c++ class | 1,480,490 | <p>I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.</p>
<p>Can I wrap Python interpreter in to a c++ class and get services from two or more class instances?</p>
| 7 | 2009-09-26T05:28:18Z | 8,849,082 | <p>I have used Py_NewInterpreter for different interpreters in different threads, but this should also work for several interpreters within one thread:</p>
<p>In the main thread:</p>
<pre><code>Py_Initialize();
PyEval_InitThreads();
mainThreadState = PyEval_SaveThread();
</code></pre>
<p>For each interpreter instanc... | 12 | 2012-01-13T10:28:54Z | [
"c++",
"python",
"multithreading",
"python-c-api",
"python-embedding"
] |
Python interpreter as a c++ class | 1,480,490 | <p>I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.</p>
<p>Can I wrap Python interpreter in to a c++ class and get services from two or more class instances?</p>
| 7 | 2009-09-26T05:28:18Z | 29,132,983 | <p>mosaik's answer did not work in my situation where my module is a plugin to a host application that already initializes python. I was able to get it to work with the following code.</p>
<pre><code>// initialize interpreter
::PyEval_InitThreads();
::PyThreadState *mainThread = ::PyThreadState_Get();
myState = ::Py_N... | 0 | 2015-03-18T21:24:31Z | [
"c++",
"python",
"multithreading",
"python-c-api",
"python-embedding"
] |
How can I, on some global keystroke, paste some text to current active application in linux with Python or C++ | 1,480,655 | <p>I want to write app, which will work like a daemon and on some global keystroke paste some text to current active application (text editor, browser, jabber client) I think i will need to use some low level xserver api. How i can do this with Python or C++ ?</p>
| 1 | 2009-09-26T07:18:01Z | 1,480,730 | <h3>Probably you want to hack <a href="http://sourceforge.net/projects/xmon/" rel="nofollow">xmon</a>...</h3>
<p><hr /></p>
<p>AFAIK there is no easy way to hook the X protocol. You will need to do "deep packet inspection", which would be fairly easy in the application event loop but not so easy, as you want, "like a... | 1 | 2009-09-26T08:03:14Z | [
"c++",
"python",
"linux",
"xserver"
] |
How can I, on some global keystroke, paste some text to current active application in linux with Python or C++ | 1,480,655 | <p>I want to write app, which will work like a daemon and on some global keystroke paste some text to current active application (text editor, browser, jabber client) I think i will need to use some low level xserver api. How i can do this with Python or C++ ?</p>
| 1 | 2009-09-26T07:18:01Z | 1,480,829 | <p>You can use the <a href="http://xmacro.sourceforge.net/" rel="nofollow">xmacroplay utility from xmacro</a> to do this under X windows I think. Either use it directly - send it commands to standard input using the subprocess module, or read the source code and find out how it does it! I don't think there are python... | 0 | 2009-09-26T09:16:02Z | [
"c++",
"python",
"linux",
"xserver"
] |
Socket program Python vs C++ (Winsock) | 1,481,103 | <p>I have python program which works perfectly for internet chatting. But program built on similar sockets in C++ do not work over internet.<br />
Python program</p>
<pre><code>import thread
import socket
class p2p:
def __init__(self):
socket.setdefaulttimeout(50)
self.port = 3000
#Destination IP... | 0 | 2009-09-26T12:17:37Z | 1,481,797 | <p>Per <a href="http://msdn.microsoft.com/en-us/library/ms740148%28VS.85%29.aspx" rel="nofollow">the docs</a>, <code>sendto</code> returns a number that's >0 (number of bytes sent) for success, <0 for failure, and in the latter case you use <a href="http://msdn.microsoft.com/en-us/library/ms741580%28VS.85%29.aspx" r... | 1 | 2009-09-26T18:13:42Z | [
"c++",
"python",
"sockets",
"winsock"
] |
pythonic format for indices | 1,481,192 | <p>I am after a string format to efficiently represent a set of indices.
For example "1-3,6,8-10,16" would produce [1,2,3,6,8,9,10,16]</p>
<p>Ideally I would also be able to represent infinite sequences. </p>
<p>Is there an existing standard way of doing this? Or a good library? Or can you propose your own format? <... | 6 | 2009-09-26T13:21:53Z | 1,481,262 | <p>If you're into something Pythonic, I think <code>1:3,6,8:10,16</code> would be a better choice, as <code>x:y</code> is a standard notation for index range and the syntax allows you to use this notation on objects. Note that the call</p>
<pre><code>z[1:3,6,8:10,16]
</code></pre>
<p>gets translated into</p>
<pre><c... | 3 | 2009-09-26T13:48:36Z | [
"python",
"indexing",
"set",
"sequence"
] |
pythonic format for indices | 1,481,192 | <p>I am after a string format to efficiently represent a set of indices.
For example "1-3,6,8-10,16" would produce [1,2,3,6,8,9,10,16]</p>
<p>Ideally I would also be able to represent infinite sequences. </p>
<p>Is there an existing standard way of doing this? Or a good library? Or can you propose your own format? <... | 6 | 2009-09-26T13:21:53Z | 1,481,263 | <p>This is probably about as lazily as it can be done, meaning it will be okay for even very large lists:</p>
<pre><code>def makerange(s):
for nums in s.split(","): # whole list comma-delimited
range_ = nums.split("-") # number might have a dash - if not, no big deal
start = int(range_[0])
... | 2 | 2009-09-26T13:48:38Z | [
"python",
"indexing",
"set",
"sequence"
] |
pythonic format for indices | 1,481,192 | <p>I am after a string format to efficiently represent a set of indices.
For example "1-3,6,8-10,16" would produce [1,2,3,6,8,9,10,16]</p>
<p>Ideally I would also be able to represent infinite sequences. </p>
<p>Is there an existing standard way of doing this? Or a good library? Or can you propose your own format? <... | 6 | 2009-09-26T13:21:53Z | 1,481,267 | <p>This looked like a fun puzzle to go with my coffee this morning. If you settle on your given syntax (which looks okay to me, with some notes at the end), here is a pyparsing converter that will take your input string and return a list of integers:</p>
<pre><code>from pyparsing import *
integer = Word(nums).setPar... | 1 | 2009-09-26T13:50:38Z | [
"python",
"indexing",
"set",
"sequence"
] |
pythonic format for indices | 1,481,192 | <p>I am after a string format to efficiently represent a set of indices.
For example "1-3,6,8-10,16" would produce [1,2,3,6,8,9,10,16]</p>
<p>Ideally I would also be able to represent infinite sequences. </p>
<p>Is there an existing standard way of doing this? Or a good library? Or can you propose your own format? <... | 6 | 2009-09-26T13:21:53Z | 1,481,281 | <p>You don't need a string for that, This is as simple as it can get:</p>
<pre><code>from types import SliceType
class sequence(object):
def __getitem__(self, item):
for a in item:
if isinstance(a, SliceType):
i = a.start
step = a.step if a.step else 1
... | 7 | 2009-09-26T14:00:28Z | [
"python",
"indexing",
"set",
"sequence"
] |
pythonic format for indices | 1,481,192 | <p>I am after a string format to efficiently represent a set of indices.
For example "1-3,6,8-10,16" would produce [1,2,3,6,8,9,10,16]</p>
<p>Ideally I would also be able to represent infinite sequences. </p>
<p>Is there an existing standard way of doing this? Or a good library? Or can you propose your own format? <... | 6 | 2009-09-26T13:21:53Z | 1,481,985 | <pre><code>import sys
class Sequencer(object):
def __getitem__(self, items):
if not isinstance(items, (tuple, list)):
items = [items]
for item in items:
if isinstance(item, slice):
for i in xrange(*item.indices(sys.maxint)):
yield i
... | 1 | 2009-09-26T19:28:50Z | [
"python",
"indexing",
"set",
"sequence"
] |
How can I make Python see sqlite? | 1,481,237 | <p>I cannot use sqlite3 (build python package), for the reason that <code>_sqlite3.so</code> file is missing. I found that people had the same problem and they resolved it <a href="http://www.linuxquestions.org/questions/slackware-14/no-sqlite3.so-in-usrlibpython2.5lib-dynload-599027/" rel="nofollow">here</a>. To solve... | 1 | 2009-09-26T13:39:23Z | 2,046,217 | <p>I don't have exact answer, but few hints here</p>
<ul>
<li><p>To install python from source, you don't need to be root, you can always install at <code>/home/USERNAME/usr</code>, for example when you do configure, do like <code>./configure --prefix=/home/USERNAME/usr</code></p></li>
<li><p>Installing sqlite binarie... | 0 | 2010-01-12T02:02:39Z | [
"python",
"sqlite",
"pysqlite"
] |
Python - Same line of code only works the second time it called? | 1,481,264 | <p>Sorry I couldn't really describe my problem much better in the title.</p>
<p>I am trying to learn Python, and came across this strange behavior and was hoping someone could explain this to me.</p>
<p>I am running Ubuntu 8.10 and python 2.5.2</p>
<p>First I import xml.dom<br />
Then I create an instance of a minid... | 3 | 2009-09-26T13:49:42Z | 1,481,273 | <p>minidom is a module so you should need</p>
<pre><code>import xml.dom.minidom
xml.dom.minidom.parseString("<xml><item/></xml>")
</code></pre>
<p>I don't know how you got the second parseString to work it fails on my python as in your other machine</p>
| 4 | 2009-09-26T13:54:35Z | [
"python"
] |
Python - Same line of code only works the second time it called? | 1,481,264 | <p>Sorry I couldn't really describe my problem much better in the title.</p>
<p>I am trying to learn Python, and came across this strange behavior and was hoping someone could explain this to me.</p>
<p>I am running Ubuntu 8.10 and python 2.5.2</p>
<p>First I import xml.dom<br />
Then I create an instance of a minid... | 3 | 2009-09-26T13:49:42Z | 1,481,280 | <p>I couldn't get your code to work even on the second try (using Python 2.6.1 on Snow Leopard). :-) However, here's one version that does work for me:</p>
<pre><code>>>> from xml.dom.minidom import parseString
>>> parseString("<xml><item/></xml>")
<xml.dom.minidom.Document ins... | 0 | 2009-09-26T13:59:38Z | [
"python"
] |
Python - Same line of code only works the second time it called? | 1,481,264 | <p>Sorry I couldn't really describe my problem much better in the title.</p>
<p>I am trying to learn Python, and came across this strange behavior and was hoping someone could explain this to me.</p>
<p>I am running Ubuntu 8.10 and python 2.5.2</p>
<p>First I import xml.dom<br />
Then I create an instance of a minid... | 3 | 2009-09-26T13:49:42Z | 1,481,322 | <p>I can replicate your behaviour on Ubuntu 9.04 (python 2.6.2). If you do <code>python -v</code> you can see the first error causes lots of extra imports. Since it doesn't happen for everybody, I can only assume the Ubuntu/Debian have added something to python to auto load modules.</p>
<p>Still the recommended action... | 0 | 2009-09-26T14:28:58Z | [
"python"
] |
Python - Same line of code only works the second time it called? | 1,481,264 | <p>Sorry I couldn't really describe my problem much better in the title.</p>
<p>I am trying to learn Python, and came across this strange behavior and was hoping someone could explain this to me.</p>
<p>I am running Ubuntu 8.10 and python 2.5.2</p>
<p>First I import xml.dom<br />
Then I create an instance of a minid... | 3 | 2009-09-26T13:49:42Z | 1,481,378 | <p>The problem is in <code>apport_python_hook.apport_excepthook()</code> as a side effect it imports <code>xml.dom.minidom</code>.</p>
<p>Without <code>apport_except_hook</code>:</p>
<pre><code>>>> import sys
>>> sys.excepthook = sys.__excepthook__
>>> import xml.dom
>>> xml.dom.mi... | 7 | 2009-09-26T14:56:27Z | [
"python"
] |
how to configure apache on XP for python 2.6.2 and what do you prefer, python with framework/without? | 1,481,309 | <p>I am starting python today. It will be my pleasure to have your help.</p>
| 2 | 2009-09-26T14:17:10Z | 1,481,329 | <p>If you are starting Python today, why tackle web development immediately? I'd start off with "hello world" in the console.</p>
| 0 | 2009-09-26T14:31:42Z | [
"python",
"apache",
"windows-xp"
] |
how to configure apache on XP for python 2.6.2 and what do you prefer, python with framework/without? | 1,481,309 | <p>I am starting python today. It will be my pleasure to have your help.</p>
| 2 | 2009-09-26T14:17:10Z | 1,481,362 | <p>About a framework - choose the one you'll like. You can find most of them on <a href="http://wiki.python.org/moin/WebFrameworks" rel="nofollow">Python wiki</a>.</p>
<p>About Apache - if you choose a framework, it'll probably have some kind of development web server built-in, with better debugging capabilities than ... | 1 | 2009-09-26T14:48:07Z | [
"python",
"apache",
"windows-xp"
] |
How to add header while making soap request using soappy | 1,481,313 | <p>I have WSDL file, using that i wanted to make soap request which will look exactly like this --</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap... | 0 | 2009-09-26T14:22:13Z | 1,481,829 | <p>Not tested, but I believe you can use the method <a href="https://svn.origo.ethz.ch/playmobil/trunk/contrib/pywebsvcs/SOAPpy/docs/UsingHeaders.txt" rel="nofollow">the docs</a> suggest to add soap headers, i.e., make and prep a <code>SOAPpy.Header</code> instance, then use <code>server = server._hd (hd)</code> to get... | 0 | 2009-09-26T18:23:32Z | [
"python",
"soap",
"soappy"
] |
set URL when enter site - pylons | 1,481,363 | <p>My problem is that when a user enter my website like: www.mywebsite.com</p>
<p>I use <a href="http://pylonshq.com" rel="nofollow">pylonshq</a> </p>
<p>I want the URL to be change to /#home if its possible via. map.connect. I have no idéa how to fix it via. python, so therefore a guide or maybe some samples would ... | 1 | 2009-09-26T14:48:15Z | 1,481,557 | <p>Simplest solution is to add js, something like this:
location.url += '#home'.</p>
<p>Or issue redirect with anchor included (but this won't work in IE).</p>
| 1 | 2009-09-26T16:14:28Z | [
"python",
"pylons"
] |
Python urllib2 HTTPS and proxy NTLM authentication | 1,481,398 | <p>urllib2 doesn't seem to support HTTPS with proxy authentication in general, even less with NTLM authentication. Anyone knows if there is a patch somewhere for HTTPS on proxy with NTLM authentication.</p>
<p>Regards,</p>
<p>Laurent</p>
| 5 | 2009-09-26T15:03:41Z | 1,481,487 | <p><a href="http://code.google.com/p/python-ntlm/" rel="nofollow">http://code.google.com/p/python-ntlm/</a></p>
<p>I never tried with HTTPS but I think it should work.</p>
<p>EDIT: If you are using SSL Tunneling, proxy authentication is a bad idea.</p>
<p>Proxy using Basic Auth over HTTPS is not secure when the SSL ... | 2 | 2009-09-26T15:49:47Z | [
"python",
"authentication",
"proxy",
"https",
"ntlm"
] |
Python urllib2 HTTPS and proxy NTLM authentication | 1,481,398 | <p>urllib2 doesn't seem to support HTTPS with proxy authentication in general, even less with NTLM authentication. Anyone knows if there is a patch somewhere for HTTPS on proxy with NTLM authentication.</p>
<p>Regards,</p>
<p>Laurent</p>
| 5 | 2009-09-26T15:03:41Z | 1,481,719 | <p>Good recipe (for HTTPS w/proxy) and discussion <a href="http://code.activestate.com/recipes/456195/" rel="nofollow">here</a>, it should be possible to meld that with the python-nltm code @ZZ has already suggested.</p>
| 1 | 2009-09-26T17:42:37Z | [
"python",
"authentication",
"proxy",
"https",
"ntlm"
] |
Python urllib2 HTTPS and proxy NTLM authentication | 1,481,398 | <p>urllib2 doesn't seem to support HTTPS with proxy authentication in general, even less with NTLM authentication. Anyone knows if there is a patch somewhere for HTTPS on proxy with NTLM authentication.</p>
<p>Regards,</p>
<p>Laurent</p>
| 5 | 2009-09-26T15:03:41Z | 1,793,206 | <p>Late reply. Urllib2 does not support NTLM proxying but <a href="http://pycurl.sourceforge.net/" rel="nofollow">pycurl</a> does. Excerpt:</p>
<pre><code>self._connection = pycurl.Curl()
self._connection.setopt(pycurl.PROXY, PROXY_HOST)
self._connection.setopt(pycurl.PROXYPORT, PROXY_PORT)
self._connection.setopt(pyc... | 6 | 2009-11-24T21:56:57Z | [
"python",
"authentication",
"proxy",
"https",
"ntlm"
] |
What is the __del__ method, How to call it? | 1,481,488 | <p>I am reading a code. There is a class in which <code>__del__</code> method is defined. I figured out that this method is used to destroy an instance of the class. However, I cannot find a place where this method is used. The main reason for that is that I do not know how this method is used, probably not like that: ... | 29 | 2009-09-26T15:49:52Z | 1,481,512 | <p><code>__del__</code> is a <strong>destructor</strong>. It is called when an object is <strong>garbage collected</strong> which happens after all references to the object have been deleted. </p>
<p>In a <strong>simple case</strong> this could be right after you say <code>del x</code> or, if <code>x</code> is a local... | 64 | 2009-09-26T15:58:53Z | [
"python",
"oop"
] |
What is the __del__ method, How to call it? | 1,481,488 | <p>I am reading a code. There is a class in which <code>__del__</code> method is defined. I figured out that this method is used to destroy an instance of the class. However, I cannot find a place where this method is used. The main reason for that is that I do not know how this method is used, probably not like that: ... | 29 | 2009-09-26T15:49:52Z | 1,481,523 | <p>The <code>__del__</code> method (note spelling!) is called when your object is finally destroyed. Technically speaking (in cPython) that is when there are no more references to your object, ie when it goes out of scope.</p>
<p>If you want to delete your object and thus call the <code>__del__</code> method use</p>
... | 5 | 2009-09-26T16:00:51Z | [
"python",
"oop"
] |
What is the __del__ method, How to call it? | 1,481,488 | <p>I am reading a code. There is a class in which <code>__del__</code> method is defined. I figured out that this method is used to destroy an instance of the class. However, I cannot find a place where this method is used. The main reason for that is that I do not know how this method is used, probably not like that: ... | 29 | 2009-09-26T15:49:52Z | 1,481,527 | <p>The <code>__del__</code> method, it will be called when the object is garbage collected. Note that it isn't necessarily guaranteed to be called though. The following code by itself won't necessarily do it:</p>
<pre><code>del obj
</code></pre>
<p>The reason being that <code>del</code> just decrements the referenc... | 3 | 2009-09-26T16:02:03Z | [
"python",
"oop"
] |
What is the __del__ method, How to call it? | 1,481,488 | <p>I am reading a code. There is a class in which <code>__del__</code> method is defined. I figured out that this method is used to destroy an instance of the class. However, I cannot find a place where this method is used. The main reason for that is that I do not know how this method is used, probably not like that: ... | 29 | 2009-09-26T15:49:52Z | 2,452,895 | <p>I wrote up the answer for another question, though this is a more accurate question for it. </p>
<p><a href="http://stackoverflow.com/questions/2433130/can-someone-here-explain-constructors-and-destructors-in-python-simple-explanat/2433847#2433847">Can someone here explain constructors and destructors in python - ... | 25 | 2010-03-16T08:21:02Z | [
"python",
"oop"
] |
Python: This should be impossible, shouldn't it? | 1,481,545 | <p>This is part of my Django application which is saving a user's profile in a special way.</p>
<pre><code>class SomeUser:
def __init__(self, request):
self.logged_in = True
self.profile = request.user.get_profile()
self.favorites = self.profile.favorites.all().values_list('pk', flat=True)... | 1 | 2009-09-26T16:10:06Z | 1,481,566 | <p>With <em>just</em> this snippet of code, it can't happen (assuming self.favorites and self.hello aren't properties). My guess would be that something somewhere else is mutating the value of self.favorites or self.hello. Is there another thread that could be doing this somewhere? Or could this perhaps be happening... | 0 | 2009-09-26T16:21:18Z | [
"python",
"django"
] |
Python: This should be impossible, shouldn't it? | 1,481,545 | <p>This is part of my Django application which is saving a user's profile in a special way.</p>
<pre><code>class SomeUser:
def __init__(self, request):
self.logged_in = True
self.profile = request.user.get_profile()
self.favorites = self.profile.favorites.all().values_list('pk', flat=True)... | 1 | 2009-09-26T16:10:06Z | 1,481,574 | <p>I'm guessing self.favorites is some kind of iterator, maybe a django QuerySet.</p>
<p>The first str() runs the iterator and empties it out</p>
<p>The second str() runs the iterator again and it is empty</p>
| 4 | 2009-09-26T16:24:27Z | [
"python",
"django"
] |
What is a difference between "sqlite" and "pysqlite2/sqlite3" modules? | 1,481,682 | <p>I gave up to make "sqlite3" working but I just found out (with help("modules")) that I have "sqlite" module. I tested it (create table, insert some values and so on) and it works fine. But before I start to use this module I would like to know if it has some significant limitations in comparison with sqlite3 module?... | 3 | 2009-09-26T17:22:53Z | 1,481,725 | <p>As per <a href="http://trac.edgewall.org/wiki/PySqlite">this wiki</a>, you can ask your module exactly what version it is, e.g.:</p>
<pre><code>>>> import sqlite
>>> sqlite.version
'1.0.1'
>>> sqlite._sqlite.sqlite_version()
'2.8.16'
</code></pre>
<p>So what versions numbers do you see w... | 6 | 2009-09-26T17:45:12Z | [
"python",
"sqlite",
"sqlite3",
"pysqlite"
] |
Django instance start under Google App Engine | 1,481,942 | <p>After thinking quite a while about how to make a fast and scalable web application, I am almost decided to go for a combination of Google App Engine, Python+Django, and app-engine-patch. But I came across a comment in the <a href="http://code.google.com/p/app-engine-patch/wiki/FAQ" rel="nofollow">app-engine-patch FA... | 2 | 2009-09-26T19:15:30Z | 1,482,005 | <p>I respect what you are trying to do, but this sounds a little like pre-mature optimization to me. The py+django patch you are discussing is recommended by Google until they upgrade to "real" django so I can't imagine it's all that bad. It's also not that hard to test the performance of what you are talking about, ... | 1 | 2009-09-26T19:38:33Z | [
"python",
"django",
"google-app-engine",
"app-engine-patch",
"google-app-engine-patch"
] |
Django instance start under Google App Engine | 1,481,942 | <p>After thinking quite a while about how to make a fast and scalable web application, I am almost decided to go for a combination of Google App Engine, Python+Django, and app-engine-patch. But I came across a comment in the <a href="http://code.google.com/p/app-engine-patch/wiki/FAQ" rel="nofollow">app-engine-patch FA... | 2 | 2009-09-26T19:15:30Z | 1,482,184 | <p>Yes, long startup times are a caveat of using a framework with a lot of code. There's no way around them, currently, other than using a framework that is lighter-weight (such as the built in webapp framework).</p>
<p>Polling your app isn't recommended: It'll use up quota, and doesn't actually guarantee that the rea... | 3 | 2009-09-26T21:06:48Z | [
"python",
"django",
"google-app-engine",
"app-engine-patch",
"google-app-engine-patch"
] |
Django instance start under Google App Engine | 1,481,942 | <p>After thinking quite a while about how to make a fast and scalable web application, I am almost decided to go for a combination of Google App Engine, Python+Django, and app-engine-patch. But I came across a comment in the <a href="http://code.google.com/p/app-engine-patch/wiki/FAQ" rel="nofollow">app-engine-patch FA... | 2 | 2009-09-26T19:15:30Z | 1,483,439 | <p>Also, it seems to me (but Nick can correct me here if I'm wrong) that if you use the built in Django (.97 or 1.0) the loading is less of a problem. Logically, I'd say they keep the built-in libs in memory for everyone, or share that cached code between instances. But I don't know for sure.</p>
| 0 | 2009-09-27T11:53:19Z | [
"python",
"django",
"google-app-engine",
"app-engine-patch",
"google-app-engine-patch"
] |
Django instance start under Google App Engine | 1,481,942 | <p>After thinking quite a while about how to make a fast and scalable web application, I am almost decided to go for a combination of Google App Engine, Python+Django, and app-engine-patch. But I came across a comment in the <a href="http://code.google.com/p/app-engine-patch/wiki/FAQ" rel="nofollow">app-engine-patch FA... | 2 | 2009-09-26T19:15:30Z | 1,985,669 | <p>See <a href="http://takashi-matsuo.blogspot.com/2009/10/minimum-cost-of-various-frameworks-cold.html" rel="nofollow">Takashi Matsuo's comparisons</a>. Basically, for simplest app-engine-patch that does almost nothing, he claims about ~1s versus ~350ms for webapp+Django templates.</p>
<p>It feels like longer than 1... | 0 | 2009-12-31T14:40:06Z | [
"python",
"django",
"google-app-engine",
"app-engine-patch",
"google-app-engine-patch"
] |
Django instance start under Google App Engine | 1,481,942 | <p>After thinking quite a while about how to make a fast and scalable web application, I am almost decided to go for a combination of Google App Engine, Python+Django, and app-engine-patch. But I came across a comment in the <a href="http://code.google.com/p/app-engine-patch/wiki/FAQ" rel="nofollow">app-engine-patch FA... | 2 | 2009-09-26T19:15:30Z | 2,039,666 | <p>They also mention in the FAQ that using a zipped version of Django will help the load time, although I'm guessing it might still be long. As for your original question, I'd agree with others that polling your app is probably not a good idea because it likely won't solve your problem because Google may distribute you... | 1 | 2010-01-11T02:54:04Z | [
"python",
"django",
"google-app-engine",
"app-engine-patch",
"google-app-engine-patch"
] |
Export QT Menu to text | 1,481,999 | <p>I was wondering if there is a way to convert my QT (version 4.50) menu and all its submenus into a text document in something similar to the following format:</p>
<ul>
<li>Menu 1
<ul>
<li>Sub Menu 2</li>
</ul></li>
<li>Menu 2
<ul>
<li>sub menu 3</li>
<li>sub menu 4
<ul>
<li>sub menu 1</li>
</ul></li>
</ul></li>
</u... | 0 | 2009-09-26T19:35:51Z | 1,483,655 | <p>You might want to look at <a href="http://doc.trolltech.com/4.5/qobject.html#findChildren" rel="nofollow">QObject::findChildren</a>, and use it like this:</p>
<pre><code>submenus = mainwindow.menuBar().findChildren(QAction)
</code></pre>
<p>Depending on how you construct your menus you might have to use QMenu as a... | 1 | 2009-09-27T14:14:18Z | [
"python",
"qt",
"pyqt"
] |
Why I get urllib2.HTTPError with urllib2 and no errors with urllib? | 1,482,028 | <p>I have the following simple code:</p>
<pre><code>import urllib2
import sys
sys.path.append('../BeautifulSoup/BeautifulSoup-3.1.0.1')
from BeautifulSoup import *
page='http://en.wikipedia.org/wiki/Main_Page'
c=urllib2.urlopen(page)
</code></pre>
<p>This code generates the following error messages:</p>
<pre><code> ... | 6 | 2009-09-26T19:46:36Z | 1,482,042 | <p>Wikipedia seems to be filtering out urllib2's default User-Agent. Just change it.</p>
| 4 | 2009-09-26T19:52:40Z | [
"python",
"urllib2",
"urllib"
] |
Why I get urllib2.HTTPError with urllib2 and no errors with urllib? | 1,482,028 | <p>I have the following simple code:</p>
<pre><code>import urllib2
import sys
sys.path.append('../BeautifulSoup/BeautifulSoup-3.1.0.1')
from BeautifulSoup import *
page='http://en.wikipedia.org/wiki/Main_Page'
c=urllib2.urlopen(page)
</code></pre>
<p>This code generates the following error messages:</p>
<pre><code> ... | 6 | 2009-09-26T19:46:36Z | 1,482,046 | <p>The original <code>urllib</code> simply does not raise an exception on a 403 code. If you add <code>print c.getcode()</code> to the last line of your program, <code>urllib</code> will reach it and still print out 403.</p>
<p>Then if you do <code>print c.read()</code> at the end, you will see that you did indeed ge... | 9 | 2009-09-26T19:55:21Z | [
"python",
"urllib2",
"urllib"
] |
Why I get urllib2.HTTPError with urllib2 and no errors with urllib? | 1,482,028 | <p>I have the following simple code:</p>
<pre><code>import urllib2
import sys
sys.path.append('../BeautifulSoup/BeautifulSoup-3.1.0.1')
from BeautifulSoup import *
page='http://en.wikipedia.org/wiki/Main_Page'
c=urllib2.urlopen(page)
</code></pre>
<p>This code generates the following error messages:</p>
<pre><code> ... | 6 | 2009-09-26T19:46:36Z | 5,125,803 | <p><a href="http://stackoverflow.com/questions/2233687/overriding-urllib2-httperror-and-reading-response-html-anyway">Overriding urllib2 HTTPError and reading response HTML anyway</a> this post shows some nice way to obtain detailed error message from server</p>
| 0 | 2011-02-26T08:08:56Z | [
"python",
"urllib2",
"urllib"
] |
Is there any way to programmatically generate Python bytecode? | 1,482,055 | <p>I want to hack around with the Python interpreter and try creating a small DSL . Is there any module where I can do something like this theoretical code (similar to LINQ expression trees)? </p>
<pre><code>expression_tree = Function(
Print(
String('Hello world!')
)
)
compile_to_bytecode(expression... | 9 | 2009-09-26T20:01:18Z | 1,482,059 | <p>Check out the disassembler module found here:</p>
<p><a href="http://docs.python.org/library/dis.html" rel="nofollow">http://docs.python.org/library/dis.html</a></p>
| 0 | 2009-09-26T20:02:45Z | [
"python",
"expression-trees",
"abstract-syntax-tree",
"dsl",
"bytecode"
] |
Is there any way to programmatically generate Python bytecode? | 1,482,055 | <p>I want to hack around with the Python interpreter and try creating a small DSL . Is there any module where I can do something like this theoretical code (similar to LINQ expression trees)? </p>
<pre><code>expression_tree = Function(
Print(
String('Hello world!')
)
)
compile_to_bytecode(expression... | 9 | 2009-09-26T20:01:18Z | 1,482,069 | <p>In Python 2.X, you would typically approach this with the <a href="http://docs.python.org/library/compiler.html" rel="nofollow"><code>compiler</code> module</a> and its <code>ast</code> sub-module. In Python 3.X, you would use just <a href="http://docs.python.org/3.1/library/ast.html" rel="nofollow"><code>ast</code... | 5 | 2009-09-26T20:07:24Z | [
"python",
"expression-trees",
"abstract-syntax-tree",
"dsl",
"bytecode"
] |
Is there any way to programmatically generate Python bytecode? | 1,482,055 | <p>I want to hack around with the Python interpreter and try creating a small DSL . Is there any module where I can do something like this theoretical code (similar to LINQ expression trees)? </p>
<pre><code>expression_tree = Function(
Print(
String('Hello world!')
)
)
compile_to_bytecode(expression... | 9 | 2009-09-26T20:01:18Z | 1,482,101 | <p><a href="http://blog.fmeyer.org/entry/writing%5Fa%5Fdomain%5Fspecific%5Flanguage%5Fdsl%5Fwith%5Fpython" rel="nofollow">Fernando Meyer recently wrote a blog post</a> explaining how to use the <code># coding</code> directive to specify your own extensions to Python. Example (the actual format definition is in <a href=... | 1 | 2009-09-26T20:25:00Z | [
"python",
"expression-trees",
"abstract-syntax-tree",
"dsl",
"bytecode"
] |
Is there any way to programmatically generate Python bytecode? | 1,482,055 | <p>I want to hack around with the Python interpreter and try creating a small DSL . Is there any module where I can do something like this theoretical code (similar to LINQ expression trees)? </p>
<pre><code>expression_tree = Function(
Print(
String('Hello world!')
)
)
compile_to_bytecode(expression... | 9 | 2009-09-26T20:01:18Z | 1,482,194 | <p>It's easier to generate Python code and run it. If you do that you can also debug it more easily since there is actual source for the debugger to display. See also Malte Borchs article in the July issue of Python magazine, where he talks about this amongst other things.</p>
| 2 | 2009-09-26T21:11:44Z | [
"python",
"expression-trees",
"abstract-syntax-tree",
"dsl",
"bytecode"
] |
Is there any way to programmatically generate Python bytecode? | 1,482,055 | <p>I want to hack around with the Python interpreter and try creating a small DSL . Is there any module where I can do something like this theoretical code (similar to LINQ expression trees)? </p>
<pre><code>expression_tree = Function(
Print(
String('Hello world!')
)
)
compile_to_bytecode(expression... | 9 | 2009-09-26T20:01:18Z | 1,482,491 | <p>Working via <code>ast</code> and compiling the tree into bytecode, as another answer suggests, is probably simplest; generating sources and compiling those, almost as good.</p>
<p>However, to explore lower-level approaches, check out the links from <a href="http://news.ycombinator.com/item?id=781461">this page</a>;... | 9 | 2009-09-27T00:35:35Z | [
"python",
"expression-trees",
"abstract-syntax-tree",
"dsl",
"bytecode"
] |
Is there any way to programmatically generate Python bytecode? | 1,482,055 | <p>I want to hack around with the Python interpreter and try creating a small DSL . Is there any module where I can do something like this theoretical code (similar to LINQ expression trees)? </p>
<pre><code>expression_tree = Function(
Print(
String('Hello world!')
)
)
compile_to_bytecode(expression... | 9 | 2009-09-26T20:01:18Z | 38,509,519 | <p>Updating for Python3 - there's also very interesting assembler <a href="https://github.com/zachariahreed/byteasm" rel="nofollow"><code>zachariahreed/byteasm</code></a>.</p>
<p>Actually the only one working for me in Py3. It has very nice & clean API:</p>
<pre><code>>>> import byteasm, dis
>>>... | 0 | 2016-07-21T16:23:55Z | [
"python",
"expression-trees",
"abstract-syntax-tree",
"dsl",
"bytecode"
] |
What does it mean "weakly-referenced object no longer exists"? | 1,482,141 | <p>I am running a Python code and I get the following error message:</p>
<pre><code>Exception exceptions.ReferenceError: 'weakly-referenced object no longer exists' in <bound method crawler.__del__ of <searchengine.crawler instance at 0x2b8c1f99ef80>> ignored
</code></pre>
<p>Does anybody know what can it... | 5 | 2009-09-26T20:42:08Z | 1,482,147 | <p>Weak references are a form of reference that does not prevent the garbage collector from disposing the referenced object. If you want to guarantee that the object will continue to exist, you should use a strong (normal) reference.</p>
<p>Otherwise, there is no guarantee that the object will or will not exist after... | 1 | 2009-09-26T20:44:27Z | [
"python"
] |
What does it mean "weakly-referenced object no longer exists"? | 1,482,141 | <p>I am running a Python code and I get the following error message:</p>
<pre><code>Exception exceptions.ReferenceError: 'weakly-referenced object no longer exists' in <bound method crawler.__del__ of <searchengine.crawler instance at 0x2b8c1f99ef80>> ignored
</code></pre>
<p>Does anybody know what can it... | 5 | 2009-09-26T20:42:08Z | 1,482,155 | <p>The code is referring to an instance which has already been garbage collected.
To avoid circular references you can use a weak reference which isn't enough to prevent garbage collection. In this case there is a weakref.proxy (<a href="http://docs.python.org/library/weakref.html#weakref.proxy" rel="nofollow">http://d... | 1 | 2009-09-26T20:49:57Z | [
"python"
] |
What does it mean "weakly-referenced object no longer exists"? | 1,482,141 | <p>I am running a Python code and I get the following error message:</p>
<pre><code>Exception exceptions.ReferenceError: 'weakly-referenced object no longer exists' in <bound method crawler.__del__ of <searchengine.crawler instance at 0x2b8c1f99ef80>> ignored
</code></pre>
<p>Does anybody know what can it... | 5 | 2009-09-26T20:42:08Z | 1,482,477 | <p>A normal AKA strong reference is one that keeps the referred-to object alive: in CPython, each object keeps the number of (normal) references to it that exists (known as its "reference count" or RC) and goes away as soon as the RC reaches zero (occasional generational mark and sweep passes also garbage-collect "refe... | 14 | 2009-09-27T00:27:08Z | [
"python"
] |
Why I cannot build a chain of methods? (method1.method2.method3) | 1,482,270 | <p>If I have the following code:</p>
<pre><code>import sqlite
sqlite.connect('tmp.db').cursor().close()
</code></pre>
<p>I get the following error message:</p>
<pre><code>Traceback (most recent call last):
File "searchengine2.py", line 13, in ?
sqlite.connect('tmp.db').cursor().close()
File "/usr/lib64/pytho... | 0 | 2009-09-26T21:46:49Z | 1,482,290 | <p>Apparently the <code>cursor</code> keeps a weak reference to the connection (<code>self.con</code>). Because you chain the functions, the connection you've instantiated is out of scope as soon as you instantiate the cursor -- nothing holds a <em>strong</em> reference to the connection anymore, and the connection is... | 3 | 2009-09-26T22:00:22Z | [
"python",
"sqlite",
"methods"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.