content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
Root priv can't be dropped in python even after seteuid. A bug?
Root priv can't be dropped in python even after seteuid. A bug?
EDIT Summary: I forgot to drop gid. The accepted answer may help you, though.
Hi. I can't drop the root privilege in python 3.2 on my linux. In fact, even after seteuid(1000), it can read... | Root priv can't be dropped in python even after seteuid. A bug? | Root priv can't be dropped in python even after seteuid. A bug?
EDIT Summary: I forgot to drop gid. The accepted answer may help you, though.
Hi. I can't drop the root privilege in python 3.2 on my linux. In fact, even after seteuid(1000), it can read root-owned 400-mode files. The euid is surely set to 1000!
I found a... | [
"Manipulating process credentials on Unix systems is tricky. I highly recommend gaining a thorough understanding of how the Real, Effective, and Saved-Set user ids are interrelated. It's very easy to screw up \"dropping privileges\".\nAs to your specific observations... I'm wondering if there's a simple cause you m... | [
7
] | [] | [] | [
"privilege",
"python"
] | stackoverflow_0006211599_privilege_python.txt |
Q:
How to provide X11 with a wm_name for a Qt4 window?
Background
I am about to resolve another issue, which consists in reserving screen-space for a Qt Window on X11. For this i use PyQt4 and Python-Xlib.
Situation
The application i want to save screen space for is a frameless Qt Window, 25px high and screen-wide, ... | How to provide X11 with a wm_name for a Qt4 window? | Background
I am about to resolve another issue, which consists in reserving screen-space for a Qt Window on X11. For this i use PyQt4 and Python-Xlib.
Situation
The application i want to save screen space for is a frameless Qt Window, 25px high and screen-wide, it's a panel in fact. The simplified code looks like this... | [
"Although i don't quite know what the unnamed window is (and it seems related to launching the QtPanel application, the Xlib script is not able to find the window on display because it is queried before the event loop QApplication._exec(). A thread may be required to do that outside of the main loop.\n"
] | [
0
] | [] | [] | [
"pyqt4",
"python",
"x11",
"xlib"
] | stackoverflow_0006207877_pyqt4_python_x11_xlib.txt |
Q:
WindowsError: [Error 5] Access is denied when trying to kill a subprocess (python)
So I have a python script that runs a loop in which it calls a program A through subprocess.Popen waits for its output, then saves the output and then calls it again and so on. (This keeps happening for a number of runs I set as an ... | WindowsError: [Error 5] Access is denied when trying to kill a subprocess (python) | So I have a python script that runs a loop in which it calls a program A through subprocess.Popen waits for its output, then saves the output and then calls it again and so on. (This keeps happening for a number of runs I set as an input)
The thing is that I have a timer so that whenever the program A takes more than a... | [
"You are seperating your p.poll() and your p.kill() by 20 seconds. By then the process could have finished. I would suggest moving the time.sleep(20) call around so that you poll and kill happen in the same time frame, to avoid killing a dead process. Below is an example run in iPython showing a similar error when ... | [
8
] | [] | [] | [
"popen",
"python",
"subprocess"
] | stackoverflow_0005573257_popen_python_subprocess.txt |
Q:
How to input parameters into Selenium RC TestSuite?
I have to test few sites which sales the same things, but they have an another template.
So I want to run each MainTestClass with giving some input parameter, let's say :
java -jar SeleniumServerStandalone-2.0b2.jar -port 5555 (template_id=5)
Is it possible?
clas... | How to input parameters into Selenium RC TestSuite? | I have to test few sites which sales the same things, but they have an another template.
So I want to run each MainTestClass with giving some input parameter, let's say :
java -jar SeleniumServerStandalone-2.0b2.jar -port 5555 (template_id=5)
Is it possible?
class MainTestCases(unittest.TestCase):
def setUp(self):
... | [
"Try adding an init method to MainTestCases, like so:\nclass MainTestCases(unittest.TestCase):\n\n def __init__(self, methodName, template_id):\n super(MainTestCases, self).__init__(self, methodName)\n self.template_id = templateId\n\n def setUp(self):\n ... and so on...\n\nDue to this cu... | [
1,
0
] | [] | [] | [
"python",
"selenium",
"selenium_rc",
"testcase"
] | stackoverflow_0005300872_python_selenium_selenium_rc_testcase.txt |
Q:
Calculate the total value of the Widgets sold each month for a particular year
If I have a Django Model that defines a Widget like this:
class Widget(models.Model):
type = models.CharField()
sold = models.DateTimeField()
price = models.DecimalField()
.
.
How would I go about getting the total ... | Calculate the total value of the Widgets sold each month for a particular year | If I have a Django Model that defines a Widget like this:
class Widget(models.Model):
type = models.CharField()
sold = models.DateTimeField()
price = models.DecimalField()
.
.
How would I go about getting the total value of the Widgets sold per month for a particular year?
I'd like to end up with ... | [
"based on this answer you could do. \nWidget.objects.extra(select={'year': \"EXTRACT(year FROM sold)\", 'month': \"EXTRACT(month from sold)\"}).values('year', 'month').annotate(Sum('price'))\n\nwould give you something like\n[{'price__sum': 1111, 'year': 2010L, 'month': 6L}...]\n\nEdit - without using EXTRACT\nprob... | [
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006214746_django_python.txt |
Q:
How to deploy pinax with virtualenv?
I developed one application with Pinax http://pinaxproject.com/. I created project by pinax-admin setup_project mysite -b social in my local virtualenv, i want to deploy my project to my Centos server, so how to setup the libraries ? you know i setup many libraries by pinax-ad... | How to deploy pinax with virtualenv? | I developed one application with Pinax http://pinaxproject.com/. I created project by pinax-admin setup_project mysite -b social in my local virtualenv, i want to deploy my project to my Centos server, so how to setup the libraries ? you know i setup many libraries by pinax-admin setup_project mysite -b social and all... | [
"Generally you create a new virtualenv on your server and install your dependencies into it. The documentation recommends zc.buildout: http://pinaxproject.com/docs/dev/buildout/.\n"
] | [
0
] | [] | [] | [
"django",
"pinax",
"python"
] | stackoverflow_0006215042_django_pinax_python.txt |
Q:
How to extract text from a web page that requires logging in using python and beautiful soup?
i have to retrieve some text from a website called morningstar.com . To access that data i have to log in. Once i log in and provide the url of the web page , i get the HTML text of a normal user (not logged in).As a r... | How to extract text from a web page that requires logging in using python and beautiful soup? | i have to retrieve some text from a website called morningstar.com . To access that data i have to log in. Once i log in and provide the url of the web page , i get the HTML text of a normal user (not logged in).As a result am not able to accees that information . ANy solutions ?
| [
"BeautifulSoup is for parsing html once you've already fetched it. You can fetch the html using any standard url fetching library. I prefer curl, as you tagged your post, python's built-in urllib2 also works well.\nIf you're saying that after logging in the response html is the same as for those who are not logge... | [
3
] | [] | [] | [
"beautifulsoup",
"python",
"urllib2"
] | stackoverflow_0006215808_beautifulsoup_python_urllib2.txt |
Q:
Import strings from .txt and searching for first numeric character - python
I am a total noob with python (programming in fact) but I hope you can help :)
I have a .txt file with a list of strings containing addresses.
I want to import it to Python and then search for the first numberic character and then create a... | Import strings from .txt and searching for first numeric character - python | I am a total noob with python (programming in fact) but I hope you can help :)
I have a .txt file with a list of strings containing addresses.
I want to import it to Python and then search for the first numberic character and then create a new column for it...like
input
'Elm Street 12'
'Baker Street 143'
and output
'... | [
"with open('file.txt') as inn:\n for line in inn:\n print \"%s %s\" % (line, [int(item) for item in line.split(' ') if item.isdigit()])\n\n",
"You probably want to use a dict. Loop through and use re to find your numeric characters, use that as a key in the dict to each string. If you expect to have dup... | [
0,
0,
0,
0
] | [] | [] | [
"export",
"import",
"python",
"text_files"
] | stackoverflow_0006215930_export_import_python_text_files.txt |
Q:
Optimize the code
I am new to python. I would like all the python gurus to suggest some ways to make the following code more pythonic and hence more efficient .
Its a simple code to find the edit distance between two words.
P.S. I would like improvements in code, not in the logic or algorithm optimization.
class t... | Optimize the code | I am new to python. I would like all the python gurus to suggest some ways to make the following code more pythonic and hence more efficient .
Its a simple code to find the edit distance between two words.
P.S. I would like improvements in code, not in the logic or algorithm optimization.
class test:
def __init__(s... | [
"Pythonic would be:\n\nWrite lots of unit tests.\nDon't reinvent the wheel: search online for previous solutions to the problem. See the comments.\nDon't optimise prematurely: profile your code to work out whether this really is\n a bottleneck and if it is improve the algorithm. \nMeaningful variable names\nDon't s... | [
3,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0006215885_python.txt |
Q:
Twitter streaming API with Python - controlling the process
I'm writing a script that uses Python to consume Twitter's streaming API. My issue is that I would like to collect tweets for only a specific time frame (i.e. 1 hr worth of tweets). I've used a Timer object to stop the process and attempt to close the con... | Twitter streaming API with Python - controlling the process | I'm writing a script that uses Python to consume Twitter's streaming API. My issue is that I would like to collect tweets for only a specific time frame (i.e. 1 hr worth of tweets). I've used a Timer object to stop the process and attempt to close the connection but this works half the time. I also tried to catch Keybo... | [
"urllib2 is a blocking API and includes buffering. There is little you can do to cleanly interrupt its read() at a given time.\nYou'll need a more flexible HTTP library. Here's a tutorial for Twitter with PyCurl.\n"
] | [
2
] | [] | [] | [
"process",
"python",
"twitter"
] | stackoverflow_0006215311_process_python_twitter.txt |
Q:
Most efficient way in Python to iterate over a large file (10GB+)
I'm working on a Python script to go through two files - one containing a list of UUIDs, the other containing a large amount of log entries - each line containing one of the UUIDs from the other file. The purpose of the program is to create a list o... | Most efficient way in Python to iterate over a large file (10GB+) | I'm working on a Python script to go through two files - one containing a list of UUIDs, the other containing a large amount of log entries - each line containing one of the UUIDs from the other file. The purpose of the program is to create a list of the UUIDS from file1, then for each time that UUID is found in the lo... | [
"Think functionally!\n\nWrite a function which will take a line of the log file and return the uuid. Call it uuid, say.\nApply this function to every line of the log file. If you are using Python 3 you can use the built-in function map; otherwise, you need to use itertools.imap.\nPass this iterator to a collections... | [
14,
3,
3,
3,
0
] | [] | [] | [
"design_patterns",
"file",
"matching",
"python"
] | stackoverflow_0006215523_design_patterns_file_matching_python.txt |
Q:
light up the mass storage's led
I have usb mass stroage with led
I am trying to light on and off the led
using usb packet sniffing tool USBlyzer,
I can get the raw data
55 53 42 43 58 66 93 88 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
whose Request info is Bulk or Interrupt Transfer and... | light up the mass storage's led | I have usb mass stroage with led
I am trying to light on and off the led
using usb packet sniffing tool USBlyzer,
I can get the raw data
55 53 42 43 58 66 93 88 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
whose Request info is Bulk or Interrupt Transfer and I/O is out
and in the USB properties... | [
"I don't know anything about pyusb, but my interpretation of the error message is that, contra others' opinions, cfg is not an integer, but that it requires a non-integral index. I say this because the exception is thrown in a __getitem__ function, which could only be cfg's __getitem__, because that's the only plac... | [
2
] | [] | [] | [
"io",
"python",
"pyusb",
"usb"
] | stackoverflow_0006216505_io_python_pyusb_usb.txt |
Q:
How to start ttk.Progressbar?
I am having trouble with getting the progressbar to start. I have scoured the internet for answers, and have tried multiple ways for hours, but have been rewarded with errors such as:
TypeError: unbound method start() must be called with Progressbar instance as first argument (got not... | How to start ttk.Progressbar? | I am having trouble with getting the progressbar to start. I have scoured the internet for answers, and have tried multiple ways for hours, but have been rewarded with errors such as:
TypeError: unbound method start() must be called with Progressbar instance as first argument (got nothing instead)
TypeError: unbound m... | [
"Your prog variable does not contain the progressbar because you call the grid method which does return None. That does explain the \nAttributeError: 'NoneType' object has no attribute 'stop'\n\nchange your code to\nprog = ttk.Progressbar(mainframe, mode='indeterminate')\nprog.grid(column=1, row=100, sticky=W)\n\na... | [
4
] | [] | [] | [
"debugging",
"progress_bar",
"python",
"ttk"
] | stackoverflow_0006212896_debugging_progress_bar_python_ttk.txt |
Q:
Python/matplotlib Show confidence levels in a histogram
here is my problem. I have some data I binned to obtain a "digitalised" pdf, and that's fine.
Now, I wanted to find a way to indicate different confidence intervals by coloring the bin groups differently.
In particular, starting with the bin containing the h... | Python/matplotlib Show confidence levels in a histogram | here is my problem. I have some data I binned to obtain a "digitalised" pdf, and that's fine.
Now, I wanted to find a way to indicate different confidence intervals by coloring the bin groups differently.
In particular, starting with the bin containing the highest count I wanted to find and colour, say red, all the hi... | [
"If I understand your question correctly, I think the code below will do what you are suggesting. It seems a little different than the approach you were considering, and I'm not sure it is more efficient. Regardless, it usually helps to see the way someone else would do something. It assumes an already generated ... | [
6
] | [] | [] | [
"confidence_interval",
"histogram",
"matplotlib",
"numpy",
"python"
] | stackoverflow_0006204181_confidence_interval_histogram_matplotlib_numpy_python.txt |
Q:
What is the best way to parse a tuple from a string in Python?
I tried this:
def string_to_value(self, old_value, distribution_type, new_value_str):
parameter_names = distribution_type.parameters # a list of string
try:
parameter_values = ast.literal_eval(new_value_str) # a tuple or basic type ho... | What is the best way to parse a tuple from a string in Python? | I tried this:
def string_to_value(self, old_value, distribution_type, new_value_str):
parameter_names = distribution_type.parameters # a list of string
try:
parameter_values = ast.literal_eval(new_value_str) # a tuple or basic type hopefully
except SyntaxError:
raise ValueError('Syntax err... | [
"Check this documentation and this PEP about evaluating inf. I guess they will help\n",
"Do you need to evaluate? e.g.\na = \"(1,2,3,4)\"\nb = tuple(a.strip('( )').split(','))\nassert ('1','2','3','4') == b\n\n",
"If all the elements have the same numeric type, then this works:\nnumpy.fromstring('1.3, 2.2, 5, i... | [
1,
0,
0
] | [] | [] | [
"abstract_syntax_tree",
"python",
"string_parsing"
] | stackoverflow_0006212366_abstract_syntax_tree_python_string_parsing.txt |
Q:
web2py: multiple tables: conditional insert/update/delete: from one form
I have written code for managing conditional insert/update/delete to
multiple tables from single form in 'web2py'.
I agree, the code is in very raw form & may not be ‘pythonic’.
There are code repeatitions.
But at least I have something t... | web2py: multiple tables: conditional insert/update/delete: from one form | I have written code for managing conditional insert/update/delete to
multiple tables from single form in 'web2py'.
I agree, the code is in very raw form & may not be ‘pythonic’.
There are code repeatitions.
But at least I have something to go ahead & build a refined
structure.
MODELS:
db.define_table('mdlmst', ... | [
"Your database design looks strange to me.\nIn each table you have a field of type 'id'. This will replace the id field automatically generated by web2py - a bad idea. From the web2py book: \"Do not declare a field called \"id\", because one is created by web2py anyway. Every table has a field called \"id\" by de... | [
2
] | [] | [] | [
"python",
"web2py"
] | stackoverflow_0006214531_python_web2py.txt |
Q:
Unicode error on response from web service using python suds
I've seen the other threads about this issue, but I haven't seen an answer that helps me.
My issue is very similar to the person using "CJ's horrible web services" in a previous post.
I'm using python 2.5 and the suds library (version 0.4.1). I request ... | Unicode error on response from web service using python suds | I've seen the other threads about this issue, but I haven't seen an answer that helps me.
My issue is very similar to the person using "CJ's horrible web services" in a previous post.
I'm using python 2.5 and the suds library (version 0.4.1). I request some records from a database through a web service. I then try to... | [
"It's just failing to print. If your terminal can handle utf-8 (Macs and most recent Linux), print sr.Title.encode(\"utf-8\") should work. On Windows, I think you can try encoding with your system code page (probably cp1252) - but it might not have the necessary characters.\nUpgrading to a newer version of Python m... | [
1
] | [] | [] | [
"python",
"suds",
"unicode",
"utf_8"
] | stackoverflow_0006217024_python_suds_unicode_utf_8.txt |
Q:
Python Prepared Statements. Problems with SELECT IN
I'm having an issue with a prepared statement in Python I can't solve so far.
The Query, which should be execute is e.g.:
SELECT md5 FROM software WHERE software_id IN (1, 2, 4)
So I tried to execute a Query like this:
software_id_string = "(2, 3, 4)"
cursor.ex... | Python Prepared Statements. Problems with SELECT IN | I'm having an issue with a prepared statement in Python I can't solve so far.
The Query, which should be execute is e.g.:
SELECT md5 FROM software WHERE software_id IN (1, 2, 4)
So I tried to execute a Query like this:
software_id_string = "(2, 3, 4)"
cursor.execute("SELECT md5 FROM software WHERE software_id IN %s",... | [
"You need one placeholder for each item in your parameter list.\nYou can use string operations to get that part done: \n\nCreate one %s for each parameter, and \nJoin those together with a comma.\n\nIn the next step you can pass your two arguments to execute() as recommended in the DB-API documentation.\nsoftware_i... | [
7,
2,
0
] | [] | [] | [
"mysql",
"prepared_statement",
"python",
"sql"
] | stackoverflow_0006216503_mysql_prepared_statement_python_sql.txt |
Q:
Python udp sockets in windows (can't send msg to server if ran it in command promt(in IDE send's fine) )
I have a ploblem with socket communication in my python app. I'm using python32. OS windows 7.
In my task i must use UDP sockets. If i ran my app from IDE(Eclipse) communication between client and server is fin... | Python udp sockets in windows (can't send msg to server if ran it in command promt(in IDE send's fine) ) | I have a ploblem with socket communication in my python app. I'm using python32. OS windows 7.
In my task i must use UDP sockets. If i ran my app from IDE(Eclipse) communication between client and server is fine.
BUT:
if i ran my app in Command Promtp and then i can't to communicate from client to server (get errno 1... | [
"can you print out the value of the addr variable when you get the exception? maybe something silly with the address (embedded line feed or something like that)\nProbably safest to add a addr.strip() call?\n"
] | [
1
] | [] | [] | [
"python",
"sockets",
"udp"
] | stackoverflow_0006218151_python_sockets_udp.txt |
Q:
gdb with Qt pretty printers
My goal is to allow pretty printing of Qt classes in gdb.
I.e if i have:
QString str("str");
in my code and execute
(gdb) print qwe
I want str content to be printed(not real QString structure).
gdb itself support pretty-printers to be defined using python, and it seems that Qt Creat... | gdb with Qt pretty printers | My goal is to allow pretty printing of Qt classes in gdb.
I.e if i have:
QString str("str");
in my code and execute
(gdb) print qwe
I want str content to be printed(not real QString structure).
gdb itself support pretty-printers to be defined using python, and it seems that Qt Creator partically use this feature.
T... | [
"I don't think Qt Creator uses pretty printers on the strict sense, they probably use the \nGDB/MI interface to directly access variables and their contents. If you want to use Pretty Printers to display QString contents, you could simple inspect where in the type is the real string and then show it. Here is an exa... | [
3,
3,
0
] | [] | [] | [
"gdb",
"pretty_print",
"python",
"qt"
] | stackoverflow_0004967354_gdb_pretty_print_python_qt.txt |
Q:
How to implement followers/following in Django
I want to implement the followers/following feature in my Django application.
I've an UserProfile class for every User (django.contrib.auth.User):
class UserProfile(models.Model):
user = models.ForeignKey(User, unique = True, related_name = 'user')
follows = m... | How to implement followers/following in Django | I want to implement the followers/following feature in my Django application.
I've an UserProfile class for every User (django.contrib.auth.User):
class UserProfile(models.Model):
user = models.ForeignKey(User, unique = True, related_name = 'user')
follows = models.ManyToManyField("self", related_name = 'follow... | [
"Set symmetrical to False in your Many2Many relation:\nfollows = models.ManyToManyField('self', related_name='follows', symmetrical=False)\n\n",
"In addition to mouad's answer, may I suggest choosing a different *related_name*: If Mark follows John, then Mark is one of John's followers, right?\n"
] | [
29,
17
] | [] | [] | [
"django",
"django_orm",
"python"
] | stackoverflow_0006218175_django_django_orm_python.txt |
Q:
Twistd TAP change log verbosity
I am currently writing an application that is meant to be started using Twisted's twistd script as a plugin.
However my code is currently very verbose logging quite a bit of information. When running my application a a twistd pluging is there any way that I can filter the log messag... | Twistd TAP change log verbosity | I am currently writing an application that is meant to be started using Twisted's twistd script as a plugin.
However my code is currently very verbose logging quite a bit of information. When running my application a a twistd pluging is there any way that I can filter the log messages and offer different levels of log ... | [
"If you want a factory to not tell you when it builds a new protocol, you can just set its noisy to False. See http://twistedmatrix.com/trac/browser/tags/releases/twisted-11.0.0/twisted/internet/protocol.py#L35 -- I am not sure if this is what you were asking.\n"
] | [
0
] | [] | [] | [
"python",
"twisted"
] | stackoverflow_0006190166_python_twisted.txt |
Q:
Python - how can I read stdin from shell, and send stdout to shell and file
I'd like to have a Python script read stdin from the shell (bash), and send stdout to shell as well a redirected file. I tried the following:
$ cat test.py
#!/usr/bin/python
val = raw_input("enter val: ")
print val
$ ./test.py | tee out... | Python - how can I read stdin from shell, and send stdout to shell and file | I'd like to have a Python script read stdin from the shell (bash), and send stdout to shell as well a redirected file. I tried the following:
$ cat test.py
#!/usr/bin/python
val = raw_input("enter val: ")
print val
$ ./test.py | tee out
testing
enter val: testing
$ cat out
enter val: testing
For some reason, the r... | [
"#!/usr/bin/python\nimport sys\n\nprint \"enter val: \",\nsys.stdout.flush()\nval = raw_input()\nprint val\n\nOr\n#!/usr/bin/python\nimport sys\n\nsys.stdout = sys.stderr\nval = raw_input(\"enter val: \")\nsys.stdout = sys.__stdout__\nprint val\n\n",
"See this bug, looks like raw_input writes its prompt to stderr... | [
2,
1
] | [] | [] | [
"bash",
"python"
] | stackoverflow_0006218890_bash_python.txt |
Q:
Repeating function over certain amount of time
I am writing a program that upload files from my nokia cell phone files to the web server which I am already done writing that. But, my program only does his job only one time and what I want is that I want to call that function for let's say every 5 mins again and ag... | Repeating function over certain amount of time | I am writing a program that upload files from my nokia cell phone files to the web server which I am already done writing that. But, my program only does his job only one time and what I want is that I want to call that function for let's say every 5 mins again and again which I do not know how to do it.
| [
"You can use the time module and the sleep function.\n",
"Just loop forever and sleep\n import time\n while True:\n doUpload()\n time.sleep(300) # sleep in seconds\n\n",
"Call your function inside a loop:\nIn [1]: import time\n\nIn [2]: while True:\n ...: print 'woke up'\n ...: time.sleep(2)... | [
2,
0,
0
] | [] | [] | [
"mobile",
"python"
] | stackoverflow_0006219063_mobile_python.txt |
Q:
Extracting projects to their own repository in svn using svndumpfilter2 (python assertion error)
I'm attempting to migrate a project out of one repository into its own repository to more easily handle authentication/authorization via ldap. However, in attempting the svnadmin dump | svndumpfilter --include ... I g... | Extracting projects to their own repository in svn using svndumpfilter2 (python assertion error) | I'm attempting to migrate a project out of one repository into its own repository to more easily handle authentication/authorization via ldap. However, in attempting the svnadmin dump | svndumpfilter --include ... I get the standard error that some files in the included path were moved or copied from somewhere NOT in ... | [
"This error may be occurring because Python-on-Windows is performing newline conversions (treating stdin as a text file).\nBecause \"svnadmin dump\" produces a dump file using Unix newline convention (even when run on Windows), you don't want python performing newline conversions. The solution is to invoke python w... | [
3
] | [] | [] | [
"python",
"svn"
] | stackoverflow_0003110545_python_svn.txt |
Q:
What platforms offer SystemRandom?
Python's random.SystemRandom provides cryptographic-quality pseudorandom numbers. What platforms is it supported on? Most importantly, are there any platforms that it is not supported on, and if so, which ones? Can anyone provide any information about how portable it is?
A:
... | What platforms offer SystemRandom? | Python's random.SystemRandom provides cryptographic-quality pseudorandom numbers. What platforms is it supported on? Most importantly, are there any platforms that it is not supported on, and if so, which ones? Can anyone provide any information about how portable it is?
| [
"From http://docs.python.org/library/random.html\n\nThe random module also provides the SystemRandom class which uses the system function os.urandom() to generate random numbers from sources provided by the operating system.\n\nFrom http://docs.python.org/library/os.html#os.urandom\n\nThis function returns random ... | [
4
] | [] | [] | [
"cryptography",
"portability",
"prng",
"python",
"random"
] | stackoverflow_0006219254_cryptography_portability_prng_python_random.txt |
Q:
Redefining Pythons builtin datatypes
Is it possible to redefine which object the brackets [] use?
I can subclass the list object, but how to I make the interpreter use my subclass in place of the buildin list object? Is it possible?
(I'm pretty sure I'm using the wrong terms for the question- feel free to edit)
>... | Redefining Pythons builtin datatypes | Is it possible to redefine which object the brackets [] use?
I can subclass the list object, but how to I make the interpreter use my subclass in place of the buildin list object? Is it possible?
(I'm pretty sure I'm using the wrong terms for the question- feel free to edit)
>>> class mlist(list):
... def __init__... | [
"The brackets are part of the language. They're used to create lists. It's not possible to redefine that (and not desirable either!).\n",
"Try running the code after you've run the code you posted\n>>> testlist = list()\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nTypeError: 'mlis... | [
7,
2,
0,
0
] | [] | [] | [
"built_in_types",
"list",
"object",
"python",
"subclass"
] | stackoverflow_0006217351_built_in_types_list_object_python_subclass.txt |
Q:
how do you obtain the address of an instance after overriding the __str__ method in python
class Bar:
pass
class Foo:
def __str__(self): return "Foo instance"
>> aBar = Bar()
>> print aBar
<__main__.Bar instance at 0x100572a28>
>> aFoo = Foo()
>> print aFoo
Foo instance
is there a way to print out the... | how do you obtain the address of an instance after overriding the __str__ method in python | class Bar:
pass
class Foo:
def __str__(self): return "Foo instance"
>> aBar = Bar()
>> print aBar
<__main__.Bar instance at 0x100572a28>
>> aFoo = Foo()
>> print aFoo
Foo instance
is there a way to print out the address of aFoo after overriding the str method?
using
>>repr(aFoo)
solved my problem
| [
"At least in cpython, id provides the address. But the output is in decimal; you have to convert that to hex:\n>>> f = (x for x in [1,2,3])\n>>> print f\n<generator object <genexpr> at 0x1004d22d0>\n>>> '%x' % id(f)\n'1004d22d0'\n\n\nActually, though, the __repr__ function isn't altered when __str__ is overridden. ... | [
6
] | [] | [] | [
"memory_address",
"python",
"string"
] | stackoverflow_0006219446_memory_address_python_string.txt |
Q:
How to execute a method automatically after entering Qt event loop?
I would like to execute a method which can only be called once my QApplication is displayed, i.e. when it has entered its main event loop exec_(). I'm new to Qt4 (using PyQt4): i was hoping to have a on_start()-like callback, but didn't find one.
... | How to execute a method automatically after entering Qt event loop? | I would like to execute a method which can only be called once my QApplication is displayed, i.e. when it has entered its main event loop exec_(). I'm new to Qt4 (using PyQt4): i was hoping to have a on_start()-like callback, but didn't find one.
Do i need to create a thread or a timer? Or is there some callback includ... | [
"You can use a single-shot timer for this, as in the following simple script:\nimport sys\nfrom PyQt4 import QtGui, QtCore\n\napp = QtGui.QApplication(sys.argv)\n\ndef on_start():\n print(' in event loop!')\n print(' telling app to exit ...')\n app.exit(123)\n\nQtCore.QTimer.singleShot(0, on_start)\nprint(... | [
6,
0,
0
] | [] | [] | [
"event_loop",
"multithreading",
"pyqt4",
"python",
"timer"
] | stackoverflow_0006215690_event_loop_multithreading_pyqt4_python_timer.txt |
Q:
In Sphinx documentation, is it possible to use the module name to specify a code sample to be included?
I'd like to include a code example in my sphinx documentation.
I don't, however, want to refer to the file by its path,
but would rather specify it by its module name.
That is, instead of doing it the way indi... | In Sphinx documentation, is it possible to use the module name to specify a code sample to be included? | I'd like to include a code example in my sphinx documentation.
I don't, however, want to refer to the file by its path,
but would rather specify it by its module name.
That is, instead of doing it the way indicated here Showing code examples
.. literalinclude example.py
or
.. literalinclude ../../example.py
I'd rat... | [
"You can reference other classes by using something like this:\n:class:`~module.submodule.Class`\n\nIf you add the examples as doctest to the class than you have examples which are guaranteed to work since they are directly runnable.\n"
] | [
0
] | [] | [] | [
"python",
"python_sphinx"
] | stackoverflow_0006219661_python_python_sphinx.txt |
Q:
Python Numpy Question and Python Version Question
I want to use Numpy with Python 3.2 and it won't work; it says I need 3.1. Does anyone know how to get around this issue, other than using 3.1? What do I have to import in order to make this work in a python program?
I want to represent a matrix in python, as well ... | Python Numpy Question and Python Version Question | I want to use Numpy with Python 3.2 and it won't work; it says I need 3.1. Does anyone know how to get around this issue, other than using 3.1? What do I have to import in order to make this work in a python program?
I want to represent a matrix in python, as well as get the norm of the matrix. How would I go about doi... | [
"NumPy 1.6.0 released on 5/14/2011 supports Python 3.2. The prior version (1.5.1) was released prior to Python 3.2. So what version of NumPy are you using? If it's 1.6.0 and it's not working on 3.2 it might be a bug with NumPy and you should report it to NumPy.\nRegarding basic use of numpy, use this tutorial. ... | [
2,
1
] | [] | [] | [
"matrix",
"matrix_multiplication",
"norm",
"numpy",
"python"
] | stackoverflow_0006219734_matrix_matrix_multiplication_norm_numpy_python.txt |
Q:
How do you enable block folding for Python comments in TextMate?
In TextMate 1.5.10 r1623, you get little arrows that allow you to fold method blocks:
Unfortunately, if you have a multi-lined Python comment, it doesn't recognize it, so you can't fold it:
def foo():
"""
How do
I fold
these comments?
"""
pri... | How do you enable block folding for Python comments in TextMate? | In TextMate 1.5.10 r1623, you get little arrows that allow you to fold method blocks:
Unfortunately, if you have a multi-lined Python comment, it doesn't recognize it, so you can't fold it:
def foo():
"""
How do
I fold
these comments?
"""
print "bar"
TextMate has this on their site on how to customize folding:... | [
"It appears that multi-line comment folding does work in TextMate, but your must line up your quotes exactly like so:\n\"\"\" Some sort of multi\n line comment, which needs quotes\n in just the right places to work. \"\"\"\n\nThat seems to do it:\n\n\n",
"According to this Textmate Mailing list thread, if y... | [
2,
1
] | [] | [] | [
"block",
"comments",
"folding",
"python",
"textmate"
] | stackoverflow_0004637378_block_comments_folding_python_textmate.txt |
Q:
Terminate importation of module non-fatally?
I'd like use if __name__ != '__main__': and then end the execution of a script at that point when it's being imported, rather than doing the usual if __name__ == '__main__': and indentation of all the rest of the code in the file.
However I have been unable to determin... | Terminate importation of module non-fatally? | I'd like use if __name__ != '__main__': and then end the execution of a script at that point when it's being imported, rather than doing the usual if __name__ == '__main__': and indentation of all the rest of the code in the file.
However I have been unable to determine what would cause only this to happen and not hav... | [
"Very similar to my original answer but slightly scarier\npartialimport.py\nclass PartialImport(Exception):\n def __init__(self, locals, msg = \"\"):\n self.module = locals\n\nmain.py\nfrom partialimport import PartialImport\ntry:\n import foo\nexcept PartialImport, e:\n #Note e.module and therefore ... | [
2,
2,
1,
1
] | [] | [] | [
"import",
"python"
] | stackoverflow_0006217505_import_python.txt |
Q:
pySQLite integration to pyGtk treeview
Is there some simple way or how to integrate sqlite database into gtk.TreeModel (TreeView)?
What I want is to display data from a db in treeview, and it would be nice when I change something in db to see the change in treeview and the other way round.
A:
Let's say you put ... | pySQLite integration to pyGtk treeview | Is there some simple way or how to integrate sqlite database into gtk.TreeModel (TreeView)?
What I want is to display data from a db in treeview, and it would be nice when I change something in db to see the change in treeview and the other way round.
| [
"Let's say you put all your data in itemlist:\ncur.execute('''select * from warehouse''')\nitemlist = cur.fetchall()\n\nTo get list of column properties, do:\ncur.execute('''PRAGMA table_info(warehouse)''')\n\nTo get only names of columns, you can then do:\ncolnames = [ i[1] for i in cur.fetchall() ]\n\nLater you m... | [
3
] | [] | [] | [
"gtk",
"python",
"sqlite"
] | stackoverflow_0003955051_gtk_python_sqlite.txt |
Q:
In Python, how do i check if 2 different links actually point to the same page?
For example, these 2 links point to the same location:
http://www.independent.co.uk/life-style/gadgets-and-tech/news/chinese-blamed-for-gmail-hacking-2292113.html
http://www.independent.co.uk/life-style/gadgets-and-tech/news/2292113.h... | In Python, how do i check if 2 different links actually point to the same page? | For example, these 2 links point to the same location:
http://www.independent.co.uk/life-style/gadgets-and-tech/news/chinese-blamed-for-gmail-hacking-2292113.html
http://www.independent.co.uk/life-style/gadgets-and-tech/news/2292113.html
How do i check this in python?
| [
"Call geturl() on the result of urllib2.urlopen(). geturl() \"returns the URL of the resource retrieved, commonly used to determine if a redirect was followed.\"\nFor example:\n#!/usr/bin/env python\n# coding: utf-8\n\nimport urllib2\n\nurl1 = 'http://www.independent.co.uk/life-style/gadgets-and-tech/news/chinese-b... | [
12,
2
] | [] | [] | [
"python",
"urllib2"
] | stackoverflow_0006220407_python_urllib2.txt |
Q:
bdist_rpm from Ubuntu to CentOs
We develop on Ubuntu/Macs and deploy RPMs to CentOS (this is the settings, can't be changed much).
The problem is that when installing from the rpm, the packages go to /usr/local/lib/python2.7/dist-packages (which is the right location for Ubuntu). However the default python path in... | bdist_rpm from Ubuntu to CentOs | We develop on Ubuntu/Macs and deploy RPMs to CentOS (this is the settings, can't be changed much).
The problem is that when installing from the rpm, the packages go to /usr/local/lib/python2.7/dist-packages (which is the right location for Ubuntu). However the default python path in CentOS is looking at /usr/local/lib/... | [
"You can use a setup.cfg file to override the Python lib install path:\nsetup.cfg:\n[install]\ninstall-lib=/usr/local/lib/python2.7/site-packages\n\nExample:\n% python setup.py bdist_rpm\n% rpm -qpl dist/foo-0.0.0-1.noarch.rpm | grep foo\n\n/usr/local/lib/python2.7/site-packages/foo/__init__.py\n/usr/local/lib/pyth... | [
10
] | [] | [] | [
"centos",
"python",
"rpm",
"ubuntu"
] | stackoverflow_0006220315_centos_python_rpm_ubuntu.txt |
Q:
Include Python Code In Excel?
I'd like to be able to include python code snippets in Excel (ideally, in a nice format -- all colors/formats should be kept the same).
What would be the best way to go about it?
EDIT: I just want to store python code in an Excel spreadsheet for an easy overview -- I am not going to r... | Include Python Code In Excel? | I'd like to be able to include python code snippets in Excel (ideally, in a nice format -- all colors/formats should be kept the same).
What would be the best way to go about it?
EDIT: I just want to store python code in an Excel spreadsheet for an easy overview -- I am not going to run it -- just want it to be nicely ... | [
"I think that gist (from github) is precisely what you are looking for. From the description:\n\nGist is a simple way to share snippets\n and pastes with others. All gists are\n git repositories, so they are\n automatically versioned, forkable and\n usable as a git repository.\n\n",
"While Excel itself does... | [
2,
1
] | [] | [] | [
"excel",
"python"
] | stackoverflow_0006216278_excel_python.txt |
Q:
Install python module to non default version of python on Mac
I have a couple different versions of Python installed on my Mac. The default version is 2.5, so when I install a module it gets installed to 2.5. I need to be able to install some modules to a different version of Python because I am working on project... | Install python module to non default version of python on Mac | I have a couple different versions of Python installed on my Mac. The default version is 2.5, so when I install a module it gets installed to 2.5. I need to be able to install some modules to a different version of Python because I am working on projects that use different versions. Any one know how to accomplish this?... | [
"If you're installing using setup.py, just run it via the appropriate version of Python, e.g.:\npython2.6 setup.py install\n\nIf you're using easy_install there should be a version for the corresponding Python version called easy_install-N.N, e.g.\neasy_install-2.6 some_module\n\nIf you're working on different proj... | [
5,
3,
2
] | [] | [] | [
"module",
"python"
] | stackoverflow_0006220274_module_python.txt |
Q:
How to do a forloop in a Django template?
I know how to do a forloop to get the objects from a list but here I'm talking about a forloop in order to repeat something a certain number of times. Like how in PHP I would do:
for (i=0; i < 10; i++) {
hello <br />
}
This would output hello 10 times. So how to do t... | How to do a forloop in a Django template? | I know how to do a forloop to get the objects from a list but here I'm talking about a forloop in order to repeat something a certain number of times. Like how in PHP I would do:
for (i=0; i < 10; i++) {
hello <br />
}
This would output hello 10 times. So how to do this in django template language?
| [
"The Django template language has For loops. See:\nhttps://docs.djangoproject.com/en/dev/ref/templates/builtins/#for\n....you might notice that there is no clear shot at the kind of \"repeat\" functionality you're after. You can, for example, define an int in your view (i in your case) and pass its range into the... | [
10,
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006219997_django_python.txt |
Q:
Searching for a string in a large text file - profiling various methods in python
This question has been asked many times. After spending some time reading the answers, I did some quick profiling to try out the various methods mentioned previously...
I have a 600 MB file with 6 million lines of strings (Category ... | Searching for a string in a large text file - profiling various methods in python | This question has been asked many times. After spending some time reading the answers, I did some quick profiling to try out the various methods mentioned previously...
I have a 600 MB file with 6 million lines of strings (Category paths from DMOZ project).
The entry on each line is unique.
I want to load the file o... | [
"Variant 1 is great if you need to launch many sequential searches. Since set is internally a hash table, it's rather good at search. It takes time to build, though, and only works well if your data fit into RAM.\nVariant 3 is good for very big files, because you have plenty of address space to map them and OS cach... | [
13,
10,
6,
3,
1,
1
] | [] | [] | [
"large_files",
"performance",
"profiling",
"python",
"search"
] | stackoverflow_0006219141_large_files_performance_profiling_python_search.txt |
Q:
How does subprocess.call differ from os.system
I have a python script to install/uninstall some regularly used programs for me and it also does some shortcut/folder clean up after uninstall. I used to use this code to delete a folder
os.system('rd /S /Q "{0}\\{1}"'.format(dirname, name))
which worked just fine. I... | How does subprocess.call differ from os.system | I have a python script to install/uninstall some regularly used programs for me and it also does some shortcut/folder clean up after uninstall. I used to use this code to delete a folder
os.system('rd /S /Q "{0}\\{1}"'.format(dirname, name))
which worked just fine. I am attempting to convert my usage of os.system to s... | [
"The difference is that os.system excutes in a subshell by default, whereas subprocess.call does not. Try using shell=True.\n"
] | [
2
] | [] | [] | [
"os.system",
"python",
"subprocess"
] | stackoverflow_0006220157_os.system_python_subprocess.txt |
Q:
Using Scrapy with Javascript and iFrames and alternatives
I'm trying to use Scrapy to scrape the U.S. government regulations website (www.regulations.gov). It's got a ton of information on it, but it's a terrible website, that is chock-full of javascript and iframes. I tried to run some simple Scrapy spiders, bu... | Using Scrapy with Javascript and iFrames and alternatives | I'm trying to use Scrapy to scrape the U.S. government regulations website (www.regulations.gov). It's got a ton of information on it, but it's a terrible website, that is chock-full of javascript and iframes. I tried to run some simple Scrapy spiders, but I can't parse anything out because everything loads through J... | [
"Alternatives :\ntry \n1) selenium\n2) imacros\n3) PhantomJS with CasperJS\n"
] | [
3
] | [] | [] | [
"python",
"scrapy",
"web_scraping"
] | stackoverflow_0006023226_python_scrapy_web_scraping.txt |
Q:
Reading files in parallel in python
I have a bunch of files (almost 100) which contain data of the format:
(number of people) \t (average age)
These files were generated from a random walk conducted on a population of a certain demographic. Each file has 100,000 lines, corresponding to the average age of populatio... | Reading files in parallel in python | I have a bunch of files (almost 100) which contain data of the format:
(number of people) \t (average age)
These files were generated from a random walk conducted on a population of a certain demographic. Each file has 100,000 lines, corresponding to the average age of populations of sizes from 1 to 100,000. Each file ... | [
"Actually, it would be possible to hold 10,000,000 lines in memory.\nMake a dictionary where the keys are number of people and values are lists of average age where each element of the list comes a different file. Therefore, if there are 100 files, each of your lists will have 100 elements.\nThis way, you don't nee... | [
3,
1,
0
] | [] | [] | [
"file",
"python"
] | stackoverflow_0006220490_file_python.txt |
Q:
How do I get the color depth and/or the resolution from a byte string in Python?
^ As above. Is this possible?
I'm using a library to get image data from an mp3 and it returns the data as a byte string but to display the image I need to get the resolution and color depth.
Ideally I would prefer a library written ... | How do I get the color depth and/or the resolution from a byte string in Python? | ^ As above. Is this possible?
I'm using a library to get image data from an mp3 and it returns the data as a byte string but to display the image I need to get the resolution and color depth.
Ideally I would prefer a library written in Python without dependencies so as to make my app as portable as possible.
If it's ... | [
"You can use PIL to work with images in Python. In your case you can do:\n>>> from StringIO import StringIO\n>>> from PIL import Image\n\n>>> im = Image.open(StringIO(image_string))\n\n>>> im.size, im.bits\n<<< ((1654, 1279), 8)\n\n",
"Either the image has headers (which you could read with something like exiftoo... | [
5,
0
] | [] | [] | [
"byte",
"data_structures",
"image",
"mp3",
"python"
] | stackoverflow_0006221196_byte_data_structures_image_mp3_python.txt |
Q:
How to read PRS / SKmapDat files?
I have these graphic files from Legend of Mana, that I would like to understand how works.
size file name
149968 TWR_I100.IMG
35500 TWR_RA00.IMG
148736 WAL_TMPL.PRS
214574 WAL_VLLG.PRS
63762 WM_D351.PIM
1208 WM_D352.DAT
63446 WM_D352.PIM
1208 WM_D353.DAT
The pro... | How to read PRS / SKmapDat files? | I have these graphic files from Legend of Mana, that I would like to understand how works.
size file name
149968 TWR_I100.IMG
35500 TWR_RA00.IMG
148736 WAL_TMPL.PRS
214574 WAL_VLLG.PRS
63762 WM_D351.PIM
1208 WM_D352.DAT
63446 WM_D352.PIM
1208 WM_D353.DAT
The problem is figuring out how the pixels are... | [
"Game consoles have limited library/runtime support. Most often the formats are chosen to perform well on their hardware or to optimize storage. Have a look at http://www.zophar.net/utilities/psxutil.html for some resources that might help you\n"
] | [
2
] | [] | [] | [
"c",
"c++",
"file_format",
"perl",
"python"
] | stackoverflow_0006221083_c_c++_file_format_perl_python.txt |
Q:
Web Api to extract information from website
I need kind of service that extracts title from web page and returns in from of json. I would not like to parse web page or waste any unnecessary CPU cycles.
ie call should be something like this:
curl http://api.someservice.com/fetch?url=google.com&element=title&out=jso... | Web Api to extract information from website | I need kind of service that extracts title from web page and returns in from of json. I would not like to parse web page or waste any unnecessary CPU cycles.
ie call should be something like this:
curl http://api.someservice.com/fetch?url=google.com&element=title&out=json
Response from api would be:
{
response: {
... | [
"You should have a look at YQL - it's a general-purpose service from Yahoo! that can do this kind of scraping really easily. Try this:\nselect * from html where url=\"google.com\" and xpath='//title'\n\nTest it here.\n",
"I suspect that Yahoo!'s YQL is probably pretty close to what you're looking for.\n(In fact I... | [
5,
1
] | [] | [] | [
"api",
"javascript",
"jquery",
"python"
] | stackoverflow_0006221235_api_javascript_jquery_python.txt |
Q:
How to interactively draw points onto a Pixmap that is on a QLabel in PyQT
I am building a small GUI interface and I have a QLabel that draws images from a directory onto itself by setting them as the pixmap. I want the user to be able to interactively click points on this pixmap and have a small green 'x' appear ... | How to interactively draw points onto a Pixmap that is on a QLabel in PyQT | I am building a small GUI interface and I have a QLabel that draws images from a directory onto itself by setting them as the pixmap. I want the user to be able to interactively click points on this pixmap and have a small green 'x' appear at the clicked locations. I have tried re-implementing the paintEvent method, bu... | [
"You actually do want to use a paintEvent() override. Even if you do want to only draw things over an image, the widget still needs to be able to redraw portions of the image if you remove or move things that are drawn over it and this happens in the paintEvent(). If you want to add things to the rendering, that's ... | [
3
] | [] | [] | [
"pyqt",
"python",
"qpixmap",
"qt"
] | stackoverflow_0006221135_pyqt_python_qpixmap_qt.txt |
Q:
PendingDeprecationWarning: cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead
warning message:
File "procesador.py", line 10, in <module>
from model import *
File "/Users/juque/Proyectos/est/patan/_patan/model.py", line 14, in <module>
b_engine = create_engine('mysql://root@localhost/intranet?ch... | PendingDeprecationWarning: cgi.parse_qsl is deprecated, use urlparse.parse_qsl instead | warning message:
File "procesador.py", line 10, in <module>
from model import *
File "/Users/juque/Proyectos/est/patan/_patan/model.py", line 14, in <module>
b_engine = create_engine('mysql://root@localhost/intranet?charset=utf8&use_unicode=0', pool_recycle=3600, echo=False)
File "/Library/Frameworks/Python... | [
"From the docs:\n\nSupported Platforms\nSQLAlchemy has been tested against the following platforms:\n\ncPython since version 2.4, through the 2.xx series\ncPython version 3, throughout all 3.xx series\nJython 2.5 or greater\nPypy 1.5 or greater\n\n\nNot all of those have urlparse.parse_qsl(). If you feel that this ... | [
1
] | [] | [] | [
"python",
"sqlalchemy",
"urlparse"
] | stackoverflow_0006220262_python_sqlalchemy_urlparse.txt |
Q:
python dynamic dictionary
im creating a function that will handle xml data, the data can vary but the structure is the same :
events ( list like )
event
info
additional info
the function needs to create a dictionary that contains a mapping in which if the data being looped is not 0 then the data... | python dynamic dictionary | im creating a function that will handle xml data, the data can vary but the structure is the same :
events ( list like )
event
info
additional info
the function needs to create a dictionary that contains a mapping in which if the data being looped is not 0 then the data needs to be mapped in a dictio... | [
"(Reposting as an answer, because the questioner intends to use the idea)\nIn the latest versions of Python, there are dict comprehensions as well as list comprehensions. Like this:\nsub_info = {i.tag: i.text for i in tag}\n\n"
] | [
3
] | [] | [] | [
"dictionary",
"for_loop",
"python"
] | stackoverflow_0006221453_dictionary_for_loop_python.txt |
Q:
What is the exact requirement for defining a python tp_call function?
I am binding C++ classes to Python and have come to an interesting solution to a previous problem, unfortunately this has lead to another question that there seems to be no easy answer too.
I am wrapping each function into a "callable" PyObjec... | What is the exact requirement for defining a python tp_call function? | I am binding C++ classes to Python and have come to an interesting solution to a previous problem, unfortunately this has lead to another question that there seems to be no easy answer too.
I am wrapping each function into a "callable" PyObject, what makes it callable is having the call function define (C side this i... | [
"The third PyObject* is the kwargs. Write a wrapper that just... doesn't pass them. Raising TypeError if it contains anything is optional.\n"
] | [
3
] | [] | [] | [
"callable",
"python"
] | stackoverflow_0006221533_callable_python.txt |
Q:
Is it possible to use Twisted with IPv6?
I'm trying to add IPv6 support to an application written with Twisted, which unfortunately does not support IPv6. There's a three-year-old ticket for this in Twisted's trac, but it seems to be stuck in debate with no indication of progress any time soon.
Ideally I'd like e... | Is it possible to use Twisted with IPv6? | I'm trying to add IPv6 support to an application written with Twisted, which unfortunately does not support IPv6. There's a three-year-old ticket for this in Twisted's trac, but it seems to be stuck in debate with no indication of progress any time soon.
Ideally I'd like existing reactor methods like listenTCP and con... | [
"Yes. Use HostnameEndpoint to connect to a remote host regardless of its address family.\n"
] | [
6
] | [] | [] | [
"ipv6",
"python",
"twisted"
] | stackoverflow_0006217312_ipv6_python_twisted.txt |
Q:
Installing setup tools for python
I'm trying to install setuptools on centos 5.6 for python 2.7.1. The system version is python 2.4
I found a similar question here but the solution still brings up the same error: setuptools-0.6c11-py2.7.egg: line 3: exec: python2.7: not found
Python is located in /usr/bin/python2.... | Installing setup tools for python | I'm trying to install setuptools on centos 5.6 for python 2.7.1. The system version is python 2.4
I found a similar question here but the solution still brings up the same error: setuptools-0.6c11-py2.7.egg: line 3: exec: python2.7: not found
Python is located in /usr/bin/python2.7.1
Any ideas?
| [
"Looks like the installer wants to execute python2.7, whereas your binary is called python2.7.1.\nTry making a symlink in your /usr/bin/ directory.\nsudo ln -s /usr/bin/python2.7.1 /usr/bin/python2.7\n"
] | [
6
] | [] | [] | [
"python"
] | stackoverflow_0006221696_python.txt |
Q:
WebHost runs Python 2.4 & I need Python 2.6+ to run my scripts that use SQLite3
I have a website that loads/displays by grabbing the HTML from an SQLite3 database & displaying that (so if the user is on a Smart phone it will grab different HTML from the database than for someone on IE). I use python scripts as the... | WebHost runs Python 2.4 & I need Python 2.6+ to run my scripts that use SQLite3 | I have a website that loads/displays by grabbing the HTML from an SQLite3 database & displaying that (so if the user is on a Smart phone it will grab different HTML from the database than for someone on IE). I use python scripts as the server side behaviour to interact with the SQLite3 database & post the HTML.
My prob... | [
"The sqlite3 module in python 2.5+ is based on the pysqlite package, which does work for python 2.4. You can instead install that package and swap the import, then you can use it with less work.\nOne option to support both methods is to use a conditional import, like this:\ntry:\n import sqlite3\nexcept ImportEr... | [
1
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0006221872_python_sqlite.txt |
Q:
Calling uname from libc with Pythons ctypes
tl;dr
this works with the GNU version of libc (haven't tried it with uclibc yet)
from ctypes import *
libc = CDLL('libc.so.6')
class uts_struct(Structure):
_fields_ = [ ('sysname', c_char * 65),
('nodename', c_char * 65),
('releas... | Calling uname from libc with Pythons ctypes | tl;dr
this works with the GNU version of libc (haven't tried it with uclibc yet)
from ctypes import *
libc = CDLL('libc.so.6')
class uts_struct(Structure):
_fields_ = [ ('sysname', c_char * 65),
('nodename', c_char * 65),
('release', c_char * 65),
('version', c_... | [
"The fields in a utsname structure are not pointers; they are \"arrays of unspecified size\".\nSo the strings are packed back-to-back in the structure and null-terminated.\nI do not know how to represent this in Python. But I would suggest starting with something other than uname() for your experiments. :-)\n[upd... | [
2,
2
] | [] | [] | [
"c",
"ctypes",
"libc",
"python",
"uname"
] | stackoverflow_0006221001_c_ctypes_libc_python_uname.txt |
Q:
Python: 'object in list' checks and '__cmp__' overflow
this is my first time at stack overflow so I'm sorry if the format doesn't fit quite right with the site.
I just recently started learning programming, almost 2 weeks have passed since. I'm learning python from http://openbookproject.net/thinkcs/python/englis... | Python: 'object in list' checks and '__cmp__' overflow | this is my first time at stack overflow so I'm sorry if the format doesn't fit quite right with the site.
I just recently started learning programming, almost 2 weeks have passed since. I'm learning python from http://openbookproject.net/thinkcs/python/english3e/index.html and everything had been quite nice until now... | [
"\"So I was wondering, maybe it is a problem with Python 3.2, or maybe the syntax has changed somewhere?\"\nOh, you're running Python 3.2? This'll never work in Python 3: python 3 doesn't use __cmp__! \nSee the data model (look for __eq__). Also read the what's new in Python 3 for some other things it's way too e... | [
6,
1,
0,
0,
0
] | [] | [] | [
"cmp",
"list",
"object",
"playing_cards",
"python"
] | stackoverflow_0006215549_cmp_list_object_playing_cards_python.txt |
Q:
Python and Boost - Trying to run vPython and getting __doc__ is read only error.
How to get vPython working?
I'm running on Mac OS X with Python 2.6 , and recently downloaded vPython. Upon installation it also installs the Boost libraries for Python. Now, when I try to import the vPython libraries ('visual'), the ... | Python and Boost - Trying to run vPython and getting __doc__ is read only error. | How to get vPython working?
I'm running on Mac OS X with Python 2.6 , and recently downloaded vPython. Upon installation it also installs the Boost libraries for Python. Now, when I try to import the vPython libraries ('visual'), the following occurs:
>>>import visual
Traceback (most recent call last):
File "<std... | [
"Have you tried using:\nfrom visual import *\n\nIf thats not working than possibly reinstall Python on your machine as well as vPython.\n"
] | [
0
] | [] | [] | [
"boost",
"macos",
"python",
"vpython"
] | stackoverflow_0002116323_boost_macos_python_vpython.txt |
Q:
target both android and iphone with Python
I want to develop an application targeting both android and iphone. I guess they use Java and Objective-C. Can I use single language like Python? Is it the best route? Will I lose performance, features, etc. by using Python. Are there any limitations that I will run into?... | target both android and iphone with Python | I want to develop an application targeting both android and iphone. I guess they use Java and Objective-C. Can I use single language like Python? Is it the best route? Will I lose performance, features, etc. by using Python. Are there any limitations that I will run into?
| [
"You cannot use Python on either of Android or iPhone platforms. This is clearly outruled by Apple SDK license, while with Android there actually is an Android scripting environment, but you will quickly realize that is not meant for the final user. In any case, the fact that Python is not supported on iPhone rules... | [
3,
0,
0,
0
] | [] | [] | [
"android",
"beeware",
"iphone",
"python"
] | stackoverflow_0006216890_android_beeware_iphone_python.txt |
Q:
Python - PyQT - How to detect mouse events when clicking text/points in a pixmap
Suppose I have drawn simple text (say just the letter 'x') with some font parameters (like size 20 font, etc.) onto an (x,y) location in a QLabel that holds a QPixmap. What are the relevant methods that I will need to override in orde... | Python - PyQT - How to detect mouse events when clicking text/points in a pixmap | Suppose I have drawn simple text (say just the letter 'x') with some font parameters (like size 20 font, etc.) onto an (x,y) location in a QLabel that holds a QPixmap. What are the relevant methods that I will need to override in order to detect a mouse event when a click occurs "precisely" over one of these drawn x's.... | [
"Although you alluded to your plans for user interaction in your previous question, it is now clear that the Graphics View Framework may be more appropriate for what you are trying to do.\nThis is distinctly different from drawing in a widget. With this framework, you create a scene composed of graphic items (QGrap... | [
0
] | [] | [] | [
"image_processing",
"pixmap",
"pyqt",
"python"
] | stackoverflow_0006222044_image_processing_pixmap_pyqt_python.txt |
Q:
Need to clear import/module path for python interpreter
I need a unix terminal command that will boot a python interpreter without giving it access to import anything. I am aware that you can import os, and then change that path, but this would be counter productive, so I need to do it either on Python startup, or... | Need to clear import/module path for python interpreter | I need a unix terminal command that will boot a python interpreter without giving it access to import anything. I am aware that you can import os, and then change that path, but this would be counter productive, so I need to do it either on Python startup, or without importing anything in the python interpreter.
| [
"Python does not have robust support for running untrusted code, but for a reasonable approximation, you can try this blog post. A more robust alternative would be to use Lua, JavaScript or TCL, all of which are carefully designed to run untrusted code in a crafted sandbox environment.\n"
] | [
1
] | [] | [] | [
"import",
"module",
"python",
"unix"
] | stackoverflow_0006221973_import_module_python_unix.txt |
Q:
Convert number to binary string
Is this the best way to convert a Python number to a hex string?
number = 123456789
hex(number)[2:-1].decode('hex')
Sometimes it doesn't work and complains about Odd-length string when you do 1234567890.
Clarification:
I am going from int to hex.
Also, I need it to be escaped.
IE:... | Convert number to binary string | Is this the best way to convert a Python number to a hex string?
number = 123456789
hex(number)[2:-1].decode('hex')
Sometimes it doesn't work and complains about Odd-length string when you do 1234567890.
Clarification:
I am going from int to hex.
Also, I need it to be escaped.
IE:
1234567890 -> '\x49\x96\x02\xd2' not... | [
"You can use string formatting:\n>>> number = 123456789\n>>> hex = \"%X\" % number\n>>> hex\n'75BCD15'\n\n",
"I'm not sure exactly what you want, but have you looked at the struct module?\nGiven\n>>> hex(123456789)\n'0x75bcd15'\n\nYou can do:\n>>> struct.pack('i', 123456789)\n'\\x15\\xcd[\\x07'\n\nNote that '\\x5... | [
6,
5,
1,
1,
0,
0,
0
] | [] | [] | [
"binary",
"hex",
"python"
] | stackoverflow_0000699285_binary_hex_python.txt |
Q:
CMS or Framework ground-up?
I just got done reading this thread...
https://stackoverflow.com/questions/588888/best-cms-for-a-corporate-web-presence
Which was the closest thing I could find on the web. I too am looking to redesign a website for a corporation. I am the marketing director, not a developer.
I have r... | CMS or Framework ground-up? | I just got done reading this thread...
https://stackoverflow.com/questions/588888/best-cms-for-a-corporate-web-presence
Which was the closest thing I could find on the web. I too am looking to redesign a website for a corporation. I am the marketing director, not a developer.
I have researched this subject in many pl... | [
"Before determining how to proceed, you need to as a few important questions -\n\nIs your company in business to make money?\nDo you ever expect potential customers to view your website?\nAre you a trained designer with experience in usability and best practices?\nCan you write maintainable, scalable, and standards... | [
4,
0,
0,
0,
0
] | [] | [] | [
"content_management_system",
"css",
"javascript",
"php",
"python"
] | stackoverflow_0006221452_content_management_system_css_javascript_php_python.txt |
Q:
Django view and separate processes
I would like to do something similar:
f(n) calculates n! , this obviously takes a long time to do, so the calculations need to run in a separate process from the django view. Additionally I would like the view to return a response immediately (ex. progress 0% ) and subsequent po... | Django view and separate processes | I would like to do something similar:
f(n) calculates n! , this obviously takes a long time to do, so the calculations need to run in a separate process from the django view. Additionally I would like the view to return a response immediately (ex. progress 0% ) and subsequent polling needs to update progress, so the v... | [
"Try django-celery\n",
"Andrey Fedoseev gave a great suggestion, but let me come up with a more general solution. You can create some WaitingTasks model into which where your view puts new tasks. Then, there can use any method to process those waiting tasks - cronjob, upstart daemon, whatever - writing back progr... | [
6,
0,
0
] | [] | [] | [
"django",
"multiprocessing",
"python"
] | stackoverflow_0006211868_django_multiprocessing_python.txt |
Q:
Verifying ctypes type precision in Python
If an API expects a 64 bit type, how can I check that a ctypes type has that many bits if sizeof returns the number of bytes?
How do I know how many bits are in each byte on the current platform?
Where is CHAR_BIT defined in Python?
A:
C/C++ function signatures are wri... | Verifying ctypes type precision in Python |
If an API expects a 64 bit type, how can I check that a ctypes type has that many bits if sizeof returns the number of bytes?
How do I know how many bits are in each byte on the current platform?
Where is CHAR_BIT defined in Python?
| [
"C/C++ function signatures are written with C/C++ types, like \"int\" or \"double\" or \"uint32_t\". All of these have corresponding ctypes equivalents, so normally you do not care about the number of bits.\nThat said...\nimport os\nprint os.sysconf('SC_CHAR_BIT')\n\n...is about as close as you will get, I think. ... | [
6
] | [] | [] | [
"ansi",
"c",
"limits",
"python"
] | stackoverflow_0006223137_ansi_c_limits_python.txt |
Q:
**kwargs vs 10 arguments in a python function?
I am starting out with python and trying to construct an XML request for an ebay web service:
Now, my question is:
Say, this is my function:
def findBestMatchItemDetailsAcrossStores():
request = """<?xml version="1.0" encoding="utf-8"?>
<findBestMatchItemDet... | **kwargs vs 10 arguments in a python function? | I am starting out with python and trying to construct an XML request for an ebay web service:
Now, my question is:
Say, this is my function:
def findBestMatchItemDetailsAcrossStores():
request = """<?xml version="1.0" encoding="utf-8"?>
<findBestMatchItemDetailsAcrossStoresRequest xmlns="http://www.ebay.com/m... | [
"A good idea is to put all the parameters with appropriate defaults (or just None defaults) in the function signature. Yeah, it will require a little more typing in the function itself, but the interface will be clean, self-documented and simple to use, as you won't have to look up possible parameters in ebay docs ... | [
7,
0,
0
] | [] | [] | [
"ebay_api",
"python",
"xml"
] | stackoverflow_0006223561_ebay_api_python_xml.txt |
Q:
ipython and fork()
I am planning a Python script that'll use os.fork() to create a bunch of child processes to perform some computations. The parent process will block until the children terminate.
The twist is that I need to be able to run the script both from the Unix shell using python and from ipython using %r... | ipython and fork() | I am planning a Python script that'll use os.fork() to create a bunch of child processes to perform some computations. The parent process will block until the children terminate.
The twist is that I need to be able to run the script both from the Unix shell using python and from ipython using %run.
In what manner shoul... | [
"The following seems to work:\nimport os, sys\n\nchild_pid = os.fork()\nif child_pid == 0:\n print 'in child'\n os._exit(os.EX_OK)\n print 'hm... wasn''t supposed to get here'\nelse:\n print 'in parent'\n\nThe trick is to use os._exit() instead of sys.exit(). The documentation contains the following passage:\n\... | [
9,
0
] | [] | [] | [
"fork",
"ipython",
"process",
"python"
] | stackoverflow_0006049741_fork_ipython_process_python.txt |
Q:
How to do reverse for get_absolute_url with many to many field?
I have a model with many-to-many fields and I need to get an ID selected from a many to many field. I decorated a get_absolute_url method with permaling decorator. And it doesn't work. So I understand that I need to reverse the relation, it is obvious... | How to do reverse for get_absolute_url with many to many field? | I have a model with many-to-many fields and I need to get an ID selected from a many to many field. I decorated a get_absolute_url method with permaling decorator. And it doesn't work. So I understand that I need to reverse the relation, it is obvious from the trace, but I do not really understand what should I do?
Mod... | [
"without seeing the url pattern. \nself.filter_ids does not return a list of ids, something like.\nself.filter_ids.all().values_list('id', flat=True)\nwould return [1,2,3]\n",
"You didn't post your url but something like this, should work\nurls\nurl(r'^/something/(?P<var>\\d+)/$', view_name, name=\"homepage_ids\"... | [
1,
0,
0
] | [] | [] | [
"django",
"django_models",
"django_urls",
"python"
] | stackoverflow_0006212457_django_django_models_django_urls_python.txt |
Q:
How to install Python 2.7 devel if I have Python 2.7 in a different directory
I have python 2.7 installed in /opt/python2.7.
Now i want to install the devel packages for it but could not find it.
How can i install it os that goes in python2.7 not for default python2.4
A:
Installing Python from source installs th... | How to install Python 2.7 devel if I have Python 2.7 in a different directory | I have python 2.7 installed in /opt/python2.7.
Now i want to install the devel packages for it but could not find it.
How can i install it os that goes in python2.7 not for default python2.4
| [
"Installing Python from source installs the development files in the same prefix.\n"
] | [
7
] | [] | [] | [
"dependencies",
"development_environment",
"python"
] | stackoverflow_0006224228_dependencies_development_environment_python.txt |
Q:
Remove invalid entry in SDK console
I have a playground on Windows 7 with the App Engine Console.
I get the following error message when accessing the SDK console.
Traceback (most recent call last):
File "C:\Program
Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py",
line 700... | Remove invalid entry in SDK console | I have a playground on Windows 7 with the App Engine Console.
I get the following error message when accessing the SDK console.
Traceback (most recent call last):
File "C:\Program
Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py",
line 700, in __call__
handler.get(*groups... | [
"It looks like a bug in the App Engine SDK -- it should at least fail gracefully. I would:\n\nFile a bug report against the App Engine SDK, and\nWrite a little App Engine web script which deletes the offending entry, and run it (sort of a hack way to delete something without using the admin console).\n\nAlternative... | [
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0006222878_google_app_engine_python.txt |
Q:
Pyramid logging
I have a pyramid application and I want the logs to got to stderr and stdout. stdout should be "INFO" level and below. stderr should be "WARN" and higher. How would I change my .ini file to do this?
Currently I am logging like this, is this considered the correct way?
log = logger.getLogger(__name... | Pyramid logging | I have a pyramid application and I want the logs to got to stderr and stdout. stdout should be "INFO" level and below. stderr should be "WARN" and higher. How would I change my .ini file to do this?
Currently I am logging like this, is this considered the correct way?
log = logger.getLogger(__name__)
log.info("update ... | [
"You can add multiple handlers to the root, comma-delimited. If you want to filter outside of the normal \"only accept messages above this logging level\" criterion (i.e. only debug messages) then you need to use something like a logging filter to accept/reject records based on their specific levels:\nhttp://docs.p... | [
11
] | [] | [] | [
"logging",
"pyramid",
"python",
"stderr",
"stdout"
] | stackoverflow_0006219073_logging_pyramid_python_stderr_stdout.txt |
Q:
Get enum definition from shared library
I am using ctypes to access a shared library written in C. The C source of the shared library contains an enum like
enum {
invalid = 0,
type1 = 1,
type2 = 2
} type_enum;
On the Python side I was intending to just define integer constants for the various enum ... | Get enum definition from shared library | I am using ctypes to access a shared library written in C. The C source of the shared library contains an enum like
enum {
invalid = 0,
type1 = 1,
type2 = 2
} type_enum;
On the Python side I was intending to just define integer constants for the various enum values, like:
INVALID = 0
TYPE1 = 1
TYPE2 =... | [
"Enum definitions are not exported so your current solution is the only one available.\nIn any case, C enum values are nothing much more than integer constants. There's no type safety on the C side, you can pass any integer values to an enum parameter. So it's not like the C compiler is doing much anyway.\n",
"Se... | [
5,
0
] | [] | [] | [
"c",
"ctypes",
"python"
] | stackoverflow_0006224523_c_ctypes_python.txt |
Q:
Is pyramid_who (repoze.who) the preferred way to do authentication for pyramid?
I am just starting to learn Pyramid Framework. Is pyramid_who (repoze.who) the preferred way to do authentication?
What other options do I have?
A:
pyramid_who is the best way to utilize repoze.who v2 for doing authentication. Wheth... | Is pyramid_who (repoze.who) the preferred way to do authentication for pyramid? | I am just starting to learn Pyramid Framework. Is pyramid_who (repoze.who) the preferred way to do authentication?
What other options do I have?
| [
"pyramid_who is the best way to utilize repoze.who v2 for doing authentication. Whether this is the best authentication solution for you or not is dependent on your needs.\nTypically repoze.who is the best solution for doing SSO (single sign-on) solutions where you need to connect to a service like LDAP.\nIf SSO is... | [
10,
4
] | [] | [] | [
"authentication",
"pyramid",
"python",
"repoze.who"
] | stackoverflow_0006211553_authentication_pyramid_python_repoze.who.txt |
Q:
How to generate Microsoft SQL Server DDL in a cross-platform way (preferably in Python)?
I'd like to have a cross-platform way to dump an SQL Server database's DDL to files, so I can keep them in version control. I currently use SQLDMO in VBScript on Windows to do this, but I am looking to be able to do this from... | How to generate Microsoft SQL Server DDL in a cross-platform way (preferably in Python)? | I'd like to have a cross-platform way to dump an SQL Server database's DDL to files, so I can keep them in version control. I currently use SQLDMO in VBScript on Windows to do this, but I am looking to be able to do this from a Linux system too, preferably in Python.
I currently have somewhat of a solution using SQLAl... | [
"Here is my stab at some code that does this:\nhttps://bitbucket.org/rsyring/mssqlddlwriter/\nIt writes basic details for tables, constraints, indexes, and triggers out to files.\n",
"This is not a complete solution (it's a script, originally by Tim Chapman, that I grabbed off the internet at some point, and has ... | [
0,
0
] | [] | [] | [
"python",
"sql_server"
] | stackoverflow_0006209512_python_sql_server.txt |
Q:
Generating evalable python code: all combinations of functions in disjunctive normal form
(A,B,C) = (100, 200, 300)
def f1(p): return p+50
def f2(p): return p*1.5
def f3(p): return p*p
vars_ = (A,B,C)
funcs_ = [f1, f2, f3]
logic_ = ["and","or"]
vol_lmt_ = [200, 300]
op_ = [">","<","="]
I want generate the a... | Generating evalable python code: all combinations of functions in disjunctive normal form | (A,B,C) = (100, 200, 300)
def f1(p): return p+50
def f2(p): return p*1.5
def f3(p): return p*p
vars_ = (A,B,C)
funcs_ = [f1, f2, f3]
logic_ = ["and","or"]
vol_lmt_ = [200, 300]
op_ = [">","<","="]
I want generate the assert code string for eval() to test the validity, take below one for example:
"f1(A)>200 and f... | [
"This is equivalent to taking the outer/cartesian product, \"summing\" across the \"var\" dimension, and interspersing those with the outer product of logic operators. You can use itertools.product or just the normal list comprehensions. The following will work for any number of variables, functions, comparators, l... | [
1,
0,
0
] | [] | [] | [
"eval",
"python"
] | stackoverflow_0006224474_eval_python.txt |
Q:
python - find occurrences of strings from a reference file within an input file
I have two files. Call one file as a reference file. This file contains a list of strings each on a separate line. The other file is an input file. It also has strings on on each line.
I want to find the occurrence of each string from... | python - find occurrences of strings from a reference file within an input file | I have two files. Call one file as a reference file. This file contains a list of strings each on a separate line. The other file is an input file. It also has strings on on each line.
I want to find the occurrence of each string from the reference file within the input file. This is my code
def count_line_occurrences... | [
"It sort of works for me. Calling your function like ...\nif __name__ == \"__main__\":\n x = count_line_occurrences([\"a\",\"b\",\"c\"],[\"c\",\"c\",\"b\",\"a\"])\n print x\n\nprints out ...\nfound a\nfound b\nfound c\nfound c\n{'a': 1, 'c': 2, 'b': 1}\n\n@Sumod ... isn't that the expected behavior ?\nEdition... | [
3
] | [] | [] | [
"python"
] | stackoverflow_0006225590_python.txt |
Q:
Can I create a single egg for multiple versions of python?
We have a local system which runs via a series of eggs. At the moment this means everyone must have a copy of Python 2.5 installed. Is it possible to create an egg which can be used by Python 2.5, 2.6, and 2.7 (ideally also any later versions)?
Obviously... | Can I create a single egg for multiple versions of python? | We have a local system which runs via a series of eggs. At the moment this means everyone must have a copy of Python 2.5 installed. Is it possible to create an egg which can be used by Python 2.5, 2.6, and 2.7 (ideally also any later versions)?
Obviously, the python code will have to run under all three versions. Eq... | [
"Distribute the source tarball only; easy-install (or pip or buildout, or whatever package dependency manager / installer you use) will create an egg for you for the python version used to install it.\nYou only ever need to create eggs for distribution only for packages with C-extensions, and then only for Windows ... | [
2
] | [] | [] | [
"egg",
"python"
] | stackoverflow_0006136930_egg_python.txt |
Q:
all threads hang when running a busy task in one thread
I have a multi-threaded python application where threads are spawned off to do various tasks. This application has been working great for months, but recently I've run into a problem.
One of the threads starts a python subprocess.Popen object which is runnin... | all threads hang when running a busy task in one thread | I have a multi-threaded python application where threads are spawned off to do various tasks. This application has been working great for months, but recently I've run into a problem.
One of the threads starts a python subprocess.Popen object which is running an intensive data copy command.
copy = subprocess.Popen(cmd... | [
"copy.wait() holding the GIL was my first suspicion too. However, this doesn't appear to be the case on my system (a wait() call isn't preventing other threads from progressing).\nYou are right that copy.wait() eventually ends up in os.waitpid(). The latter looks like this on my Linux system:\nPyDoc_STRVAR(posix_wa... | [
2
] | [] | [] | [
"gil",
"linux_kernel",
"multithreading",
"python",
"scheduler"
] | stackoverflow_0006225449_gil_linux_kernel_multithreading_python_scheduler.txt |
Q:
Default variable referencing own class in python
I'm trying to write something like:
class MyClass(object):
@staticmethod
def test(x, y, z=None):
if not z:
z = external_function(MyClass)
Is it possible in python to rewrite it to something like:
class MyClass(object):
@staticmethod
... | Default variable referencing own class in python | I'm trying to write something like:
class MyClass(object):
@staticmethod
def test(x, y, z=None):
if not z:
z = external_function(MyClass)
Is it possible in python to rewrite it to something like:
class MyClass(object):
@staticmethod
def test(x, y, z=external_function(MyClass)):
... | [
"It's not possible, since whatever is in the argument definition of any method, be it a static method or a normal method, is parsed and executed at class creation time, before the class object that you try to use has been created. Defaults are also evaluated at this time, as the code below demonstrates.\ndef say_hi... | [
3,
3
] | [] | [] | [
"default_value",
"python"
] | stackoverflow_0006225651_default_value_python.txt |
Q:
urllib2.urlopen('ur') gives error
I am new to python and trying to extract the contents of a page. When I do urlopen('http://www.google.com'), I get the following error :
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)... | urllib2.urlopen('ur') gives error | I am new to python and trying to extract the contents of a page. When I do urlopen('http://www.google.com'), I get the following error :
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py"... | [
"that error message occurs if your net is offline\n"
] | [
2
] | [] | [] | [
"python",
"urllib2"
] | stackoverflow_0006225746_python_urllib2.txt |
Q:
How to put the "build" module in python search path
After so much of hassle i build the libxml from source. I performed following steps
Downloaded the lxml.tar.gz and extracted its contents
Build it using
python2.7 setup.py build_ext -i -I /usr/include/libxml2 --with-xslt-config=/opt/xslt/bin/xslt-config
I tr... | How to put the "build" module in python search path | After so much of hassle i build the libxml from source. I performed following steps
Downloaded the lxml.tar.gz and extracted its contents
Build it using
python2.7 setup.py build_ext -i -I /usr/include/libxml2 --with-xslt-config=/opt/xslt/bin/xslt-config
I tried going in python shell and tried import lxml . it didn... | [
"You told it to build_ext, so it just compiled it and didn't install. If you told it to install, it would install it in system-wide directory (but you need write permissions for that) or whatever directory you specify (with --home (for installing as user) or --prefix (for installing as root to non-standard director... | [
1,
0
] | [] | [] | [
"linux",
"python"
] | stackoverflow_0006225843_linux_python.txt |
Q:
Why do Ruby and Python have the % for formatting instead of "format"
I mean what makes % look so much attractive compared to good old .format?!
I know this may be subjective, but I wonder if there is something about this.
A:
They inherit them from C. Specifically, sprintf.
A:
I'd assume they use % because tha... | Why do Ruby and Python have the % for formatting instead of "format" | I mean what makes % look so much attractive compared to good old .format?!
I know this may be subjective, but I wonder if there is something about this.
| [
"They inherit them from C. Specifically, sprintf.\n",
"I'd assume they use % because that's what the old C printf format strings looked like.\n",
"It's just a piece of syntactic sugar, meant to make a common operation more terse. If you don't like it, you can use str.format() instead. I enjoy it because it make... | [
5,
2,
0
] | [] | [] | [
"format",
"python",
"ruby"
] | stackoverflow_0006222605_format_python_ruby.txt |
Q:
hide scripts in msi installer
I am creating an python based msi installer.
by which I am executing some python scripts while the installer is running.
But I dont want to deliver/install these scripts with package just want to hide them in the msi and use while its running. I tried using binary table in the msi f... | hide scripts in msi installer | I am creating an python based msi installer.
by which I am executing some python scripts while the installer is running.
But I dont want to deliver/install these scripts with package just want to hide them in the msi and use while its running. I tried using binary table in the msi for the same but it didn't work. >H... | [
"A solution would be temporary files. You can store them in Binary table and use two custom actions:\n\none which extracts them before the installation starts\nanother one which removes them when installation is finished\n\nYou can extract them in a temporary location, for example the user Temp folder.\n"
] | [
0
] | [] | [] | [
"installation",
"python",
"windows_installer"
] | stackoverflow_0006225631_installation_python_windows_installer.txt |
Q:
using configobj to read a complete section one by one
I am using configobj to read a config file as below.
[default]
PROP1 = "12345"
PROP2 = "abcde"
[section1]
PROP1 = "56789"
PROP2 = ""
[section2]
PROP1 = ""
PROP2 = ""
I aim to read the list of sections first and then get each section on... | using configobj to read a complete section one by one | I am using configobj to read a config file as below.
[default]
PROP1 = "12345"
PROP2 = "abcde"
[section1]
PROP1 = "56789"
PROP2 = ""
[section2]
PROP1 = ""
PROP2 = ""
I aim to read the list of sections first and then get each section onto a dictionary. I have to replace with default values if ... | [
"When you read your config file, configobj will convert it into a dictionary for you.\n>>> from configobj import ConfigObj\n\n>>> config = ConfigObj('your_config_filename')\n\n>>> config.keys()\n<<< ['default', 'section1', 'section2']\n\n>>> config['default']\n<<< {'PROP1': '12345', 'PROP2': 'abcde'}\n\n"
] | [
2
] | [] | [] | [
"configobj",
"configuration_files",
"python"
] | stackoverflow_0006226312_configobj_configuration_files_python.txt |
Q:
Lazy loading of columns in sqlalchemy
Is it possible in sqlalchemy to lazy load a column? I have large BLOB column that I'm usually using but in some cases I don't want to load this specific column (while I'd like to have ORM object). Is it possible without adding separate table?
A:
class Book(Base):
__table... | Lazy loading of columns in sqlalchemy | Is it possible in sqlalchemy to lazy load a column? I have large BLOB column that I'm usually using but in some cases I don't want to load this specific column (while I'd like to have ORM object). Is it possible without adding separate table?
| [
"class Book(Base):\n __tablename__ = 'books'\n\n book_id = Column(Integer, primary_key=True)\n title = Column(String(200), nullable=False)\n summary = Column(String(2000))\n excerpt = deferred(Column(Text))\n photo = deferred(Column(Binary))\n\nDeferred Column Loading\n"
] | [
21
] | [] | [] | [
"lazy_evaluation",
"lazy_loading",
"orm",
"python",
"sqlalchemy"
] | stackoverflow_0006225901_lazy_evaluation_lazy_loading_orm_python_sqlalchemy.txt |
Q:
openCV: Sobel edge detection gives me assertion error
I am using python-openCV. When using the Sobel edge detection I get the following assertion error:
src.size() == dst.size() && src.channels() == dst.channels() && ((src.depth() == CV_8U && (dst.depth() == CV_16S || dst.depth() == CV_32F)) || (src.depth() == CV_... | openCV: Sobel edge detection gives me assertion error | I am using python-openCV. When using the Sobel edge detection I get the following assertion error:
src.size() == dst.size() && src.channels() == dst.channels() && ((src.depth() == CV_8U && (dst.depth() == CV_16S || dst.depth() == CV_32F)) || (src.depth() == CV_32F && dst.depth() == CV_32F))
I create the dest using Cre... | [
"I found the solution a bit tricky for novices to openCV:\nsrc = cv.LoadImageM('src.png', cv.CV_LOAD_IMAGE_GRAYSCALE)\ndest = cv.CreateMat(src.height, src.width, cv.CV_16S)\ncv.Sobel(src, dest, 1, 1)\n\nThe important thing to note is that the image formats required for operations are not clearly documented in API r... | [
5
] | [] | [] | [
"edge_detection",
"opencv",
"python"
] | stackoverflow_0006226032_edge_detection_opencv_python.txt |
Q:
i stuck how to create pyramid using python?
Possible Duplicate:
Pyramid of asterisks program in Python
I've written a program in C++ that displays a pyramid of asterisk (see below) and now I'd like to see how it's done in Python but it's not as easy as I'd thought it would be. :) Has anyone tried this and if so ... | i stuck how to create pyramid using python? |
Possible Duplicate:
Pyramid of asterisks program in Python
I've written a program in C++ that displays a pyramid of asterisk (see below) and now I'd like to see how it's done in Python but it's not as easy as I'd thought it would be. :) Has anyone tried this and if so could you show me code that would help out? 2) W... | [
"Disclaimer: This may not work in Python 3.x:\nPython 2.7.1 (r271:86832, May 27 2011, 21:41:45) \n[GCC 4.2.1 (Apple Inc. build 5664)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> print ''' * 1\n... *** 3\n... ***** 5'''\n * 1\n *** 3\n***** 5\n\n",
"It's ... | [
8,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0006226081_python.txt |
Q:
Troubles with python list and file saving
I really don't know why my code is not saving for me the readings from the adc and gps receiver to the file I already open it in the first line in the code. it save only one record from both adc and gps receiver.
this is my code:
import MDM
f = open("cord+adc.txt", 'w')
... | Troubles with python list and file saving | I really don't know why my code is not saving for me the readings from the adc and gps receiver to the file I already open it in the first line in the code. it save only one record from both adc and gps receiver.
this is my code:
import MDM
f = open("cord+adc.txt", 'w')
def getADC():
res = MDM.send('AT#ADC?\r', 0) ... | [
"You have two problems here, you are not closing you file. There is a bigger problem in your program though your while loop will go forever (or until something else goes wrong in your program) there is no terminating condition. You are looping while 1 but never explicitly breaking out of the loop. I assume that whe... | [
3,
1,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0001765394_python.txt |
Q:
PyQt4 Gui designing
I just started to lear the PyQt, but I got some problem. Here is my code:
class GUI( QtGui.QMainWindow ):
'''
classdocs
'''
"""**********************************************************************"""
""" Constructor """
"""**************... | PyQt4 Gui designing | I just started to lear the PyQt, but I got some problem. Here is my code:
class GUI( QtGui.QMainWindow ):
'''
classdocs
'''
"""**********************************************************************"""
""" Constructor """
"""***************************************... | [
"You can use: \nsendButton.setMinimumSize()\n\nand\nmainLayout.setRowMinimumHeight()\n\n"
] | [
1
] | [] | [] | [
"pyqt4",
"python"
] | stackoverflow_0006224716_pyqt4_python.txt |
Q:
How to block the main thread until all the other threads finish executing?
This is a newbie question. I start 10 threads from my main thread. How do I stop the main thread from continuing until all the other threads finish?
A:
Join all threads:
for t in threads:
t.join()
Here threads is the list of your thr... | How to block the main thread until all the other threads finish executing? | This is a newbie question. I start 10 threads from my main thread. How do I stop the main thread from continuing until all the other threads finish?
| [
"Join all threads:\nfor t in threads:\n t.join()\n\nHere threads is the list of your threads.\n"
] | [
7
] | [] | [] | [
"python"
] | stackoverflow_0006227219_python.txt |
Q:
Change svn node properties with Python raises a SubversionException
When changing a svn node property with python, using
svn.fs.change_node_prop(root, path, "thisisa:property", "andthisisavalue")
raises an exception with the message "svn.core.SubversionException: ('Root object must be a transaction root', 16002... | Change svn node properties with Python raises a SubversionException | When changing a svn node property with python, using
svn.fs.change_node_prop(root, path, "thisisa:property", "andthisisavalue")
raises an exception with the message "svn.core.SubversionException: ('Root object must be a transaction root', 160022)"
root is made with this:
canon_path = svn.core.svn_path_canonicalize(r... | [
"I was wrong using root as the head revision root.\nI needed to begin a transaction for commit and get it's transaction root.\nFor doing this I made,\ntxn = svn.repos.fs_begin_txn_for_commit(repos_ptr, headrev, SVN_COMMIT_USER, SVN_COMMIT_MESSAGE)\nroot = svn.fs.txn_root(txn)\n\nHope this helps to anyone.\n"
] | [
0
] | [] | [] | [
"python",
"svn",
"svn_propset"
] | stackoverflow_0006218111_python_svn_svn_propset.txt |
Q:
openCV vs GIMP, edge detection fails in openCV
I am doing Sobel edge detection in openCV using the with following parameters:
cv.Sobel(mat, edgemat, 1, 1)
# mat -> source image
# edgemat -> taget output image
# 1 -> xorder (int) – Order of the derivative x
# 1 -> yorder (int) – Order of the derivative y
# apertur... | openCV vs GIMP, edge detection fails in openCV | I am doing Sobel edge detection in openCV using the with following parameters:
cv.Sobel(mat, edgemat, 1, 1)
# mat -> source image
# edgemat -> taget output image
# 1 -> xorder (int) – Order of the derivative x
# 1 -> yorder (int) – Order of the derivative y
# apertureSize (int) – Size of the extended Sobel kernel -> i... | [
"Simple answer: You are doing it wrong. See the documentation - what you are doing is computing the d^2/(dx dy) derivative of the image - that means \"how do the horizontal edges change vertically\" (or, equivalently, \"how do the vertical edges change horizontally\"), that means, for a vertical or horizontal edge ... | [
9
] | [] | [] | [
"edge_detection",
"gimp",
"opencv",
"python"
] | stackoverflow_0006226597_edge_detection_gimp_opencv_python.txt |
Q:
How to get mechanize requests to look like they originate from a real browser
OK, here's the header(just an example) info I got from Live HTTP Header while logging into an account:
http://example.com/login.html
POST /login.html HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;... | How to get mechanize requests to look like they originate from a real browser | OK, here's the header(just an example) info I got from Live HTTP Header while logging into an account:
http://example.com/login.html
POST /login.html HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 GTB7.1 (.NET CLR 3.5.30729)
Accept: text/... | [
"It depends on what you're trying to 'fool'. You can try some online services that do simple User Agent sniffing to gauge your success:\nhttp://browserspy.dk/browser.php\nhttp://www.browserscope.org (look for 'We think you're using...')\nhttp://www.browserscope.org/ua\nhttp://panopticlick.eff.org/ -> will help you ... | [
7,
6,
0
] | [] | [] | [
"http_headers",
"http_post",
"mechanize",
"mechanize_python",
"python"
] | stackoverflow_0004622739_http_headers_http_post_mechanize_mechanize_python_python.txt |
Q:
ending the life of a thread in python?
I have the below code but it lives on after the queue is empty, any insights:
def processor():
while(1>0):
if queue.empty() == True:
print "the Queue is empty!"
break
source=queue.get()
page = urllib2.urlopen(source)
print page
def main:
for... | ending the life of a thread in python? | I have the below code but it lives on after the queue is empty, any insights:
def processor():
while(1>0):
if queue.empty() == True:
print "the Queue is empty!"
break
source=queue.get()
page = urllib2.urlopen(source)
print page
def main:
for i in range(threads):
th = Thread(targ... | [
"You need to call queue.task_done() after printing the page, otherwise join() will block. Each thread, after using get() must call task_done().\nSee documentation for queue\n",
"This part:\n while(1>0):\n if queue.empty() == True: \n print \"the Queue is empty!\" \n break\n\nAbove is just plain wrong... | [
5,
3,
1
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0006227058_multithreading_python.txt |
Q:
cd to user defined path
I was wondering if you could help me with my new python program. I recently added a browse button to the GUI to make things more "user-friendly." I told python to only accept *.pvt files when the user is asked to browse for a file... Now, I am left wondering how to tell python to take the p... | cd to user defined path | I was wondering if you could help me with my new python program. I recently added a browse button to the GUI to make things more "user-friendly." I told python to only accept *.pvt files when the user is asked to browse for a file... Now, I am left wondering how to tell python to take the path the user browsed to and o... | [
"Did you try this:\nsubprocess.Popen('cmd.exe', cwd=path)\n\nThis is based on the assumption, that you don't really want to cd, but instead want the current working directory to be set - which is the post condition of cd...\nCheck the subprocess module for more awesome parameters and examples!\n"
] | [
4
] | [] | [] | [
"cmd",
"python"
] | stackoverflow_0006227821_cmd_python.txt |
Q:
How to use the expanduser and exists modules together
Here's the code first
user = os.path.expanduser('~\AppData\Local\Temp')
os.path.exists(user,'\whatever.txt')
Now the problem is, when I run it it says:
Traceback (most recent call last):
File "pyshell#7", line 1, in module
os.path.exists(user,'\what... | How to use the expanduser and exists modules together | Here's the code first
user = os.path.expanduser('~\AppData\Local\Temp')
os.path.exists(user,'\whatever.txt')
Now the problem is, when I run it it says:
Traceback (most recent call last):
File "pyshell#7", line 1, in module
os.path.exists(user,'\whatever.txt')
TypeError: exists() takes exactly 1
argument (... | [
"Use os.path.join to join two path fragments together:\nos.path.exists(os.path.join(user,'whatever.txt'))\n\nNote that r'\\whatever.txt' is an absolute path, so \nos.path.join(user,r'\\whatever.txt') would return r'\\whatever.txt', ignoring the value of user. \nIf you want to look for whatever.txt inside the user d... | [
4
] | [] | [] | [
"module",
"python"
] | stackoverflow_0006227972_module_python.txt |
Q:
cd to user defined path in python
I was wondering if you could help me with my new python program. I recently added a browse button to the GUI to make things more "user-friendly." I told python to only accept *.pvt files when the user is asked to browse for a file... Now, I am left wondering how to tell python to ... | cd to user defined path in python | I was wondering if you could help me with my new python program. I recently added a browse button to the GUI to make things more "user-friendly." I told python to only accept *.pvt files when the user is asked to browse for a file... Now, I am left wondering how to tell python to take the path the user browsed to and o... | [
"subprocess.Popen() accepts a cwd argument:\nPopen([\"cmd.exe\"], cwd=mypath)\n\n"
] | [
2
] | [] | [] | [
"command_line",
"python"
] | stackoverflow_0006228165_command_line_python.txt |
Q:
Decorator design: executing a method only if it has been overridden
I've stumbled in a tricky python question. Given (updated):
class A(object):
def run(self):
# This makes possible to determine if 'run' was overridden
if self.run.im_func != A.run.im_func:
print('Running in {0}'.for... | Decorator design: executing a method only if it has been overridden | I've stumbled in a tricky python question. Given (updated):
class A(object):
def run(self):
# This makes possible to determine if 'run' was overridden
if self.run.im_func != A.run.im_func:
print('Running in {0}'.format(self.__class__.__name__))
class B(A):
def run(self):
sup... | [
"If I understand what you want:\nimport functools\ndef runoverridden(f):\n @functools.wraps(f)\n def wrapper(self, *args, **kw):\n if getattr(self, f.__name__).im_func != wrapper:\n return f(self, *args, **kw)\n return wrapper\n\nclass A(object):\n @runoverridden\n def run(self):\n ... | [
3,
0
] | [] | [] | [
"decorator",
"inheritance",
"python"
] | stackoverflow_0006228492_decorator_inheritance_python.txt |
Q:
Django, South and the --freeze command
I'm trying to get started with South data migrations. I found this SO question: South data migration 'instance' error when using south freeze orm, and tried the commands listed there but it does not seem to help.
I have 2 apps A and B in my project, here are their models:
# /... | Django, South and the --freeze command | I'm trying to get started with South data migrations. I found this SO question: South data migration 'instance' error when using south freeze orm, and tried the commands listed there but it does not seem to help.
I have 2 apps A and B in my project, here are their models:
# /app_A/models.py
from django.db import models... | [
"The line:\norm['hr_manager.Employee']\n\nAccesses the Model, not an instance. You need to access an instance via the usual:\norm['hr_manager.Employee'].objects.all()\norm['hr_manager.Employee'].objects.get(...)\n...\n\nmethods.\n"
] | [
2
] | [] | [] | [
"django",
"django_south",
"freeze",
"orm",
"python"
] | stackoverflow_0006228644_django_django_south_freeze_orm_python.txt |
Q:
Django url validation
HI,
I want to validate my urls whether they are post or get with caring the proper data.So i want to validate these urls before they call to respective views.So i am willing to write the some kind of middleware between view and urls so that i can keep safe the system.I am not aware how do i p... | Django url validation | HI,
I want to validate my urls whether they are post or get with caring the proper data.So i want to validate these urls before they call to respective views.So i am willing to write the some kind of middleware between view and urls so that i can keep safe the system.I am not aware how do i pass the data through middle... | [
"You should really be checking for request type in your views, and not in a middleware. As I mentioned in the comments above, you can't tell whether a request is a POST message from the URL alone, let alone determine what POST data it carries.\nChecking the request type within a view is very straight-forward -- sim... | [
5,
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006228102_django_python.txt |
Q:
How to get iPython to use Updated Egg/Module
I've updated a Python egg that is only being used locally. The update proceeded correctly and installed into /usr/lib/python2.5/site-packages/eggName-UpdatedVersionNumber-py2.5.egg
However, when I open iPython and try to import the egg, I still get the old version.
Run... | How to get iPython to use Updated Egg/Module | I've updated a Python egg that is only being used locally. The update proceeded correctly and installed into /usr/lib/python2.5/site-packages/eggName-UpdatedVersionNumber-py2.5.egg
However, when I open iPython and try to import the egg, I still get the old version.
Running egg_name.__file__ gives me:
/usr/local/FOLDE... | [
"Note that you have 2 different site-packages locations; one is /usr/lib/python2.5/site-packages and the other is /usr/local/FOLDER/lib/python2.5/site-packages.\nThe egg in the latter location is being preferred over the egg in the first location when the latter location comes first in your PYTHON_PATH. In iPython,... | [
1
] | [] | [] | [
"egg",
"module",
"python"
] | stackoverflow_0004834533_egg_module_python.txt |
Q:
Sorting and counting matching fields from a model django
I have a class of the form:
class data:
person.models.foreignKey("people.person")
place.models.foreignKey("places.place")
and I'm trying to create a dict containing places that have the same person associated with how many connections they have. I... | Sorting and counting matching fields from a model django | I have a class of the form:
class data:
person.models.foreignKey("people.person")
place.models.foreignKey("places.place")
and I'm trying to create a dict containing places that have the same person associated with how many connections they have. IE:
dict={[place1:place2]:count}
so the dict might look like t... | [
"Do not use predefined names like dict for your variables. Think that your problem is that you try to increase count variable while you have to increase dict[key] - e.g. dict[key] += 1 \ndct = {}\ndatas = data.objects.all()\n\nfor data1 in datas:\n for data2 in datas:\n # if dict is empty\n if not ... | [
3,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0006228869_django_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.