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:
Splitting up a list into parts of balanced lengths
I need an algorithm which given a list L and a number N, returns a list of N smaller lists where the sublists are "balanced". Examples:
algo(range(1, 8), 3) -> [[1,2,3], [4,5], [6,7]]
algo(range(1, 6), 4) -> [[1,2], [3], [4], [5]]
algo(range(1, 12), 5) -> [[1,2... | Splitting up a list into parts of balanced lengths | I need an algorithm which given a list L and a number N, returns a list of N smaller lists where the sublists are "balanced". Examples:
algo(range(1, 8), 3) -> [[1,2,3], [4,5], [6,7]]
algo(range(1, 6), 4) -> [[1,2], [3], [4], [5]]
algo(range(1, 12), 5) -> [[1,2,3], [4,5], [6,7], [8,9], [10, 11]]
As you can see, the... | [
"This is the code I came up with, without the sorting. Just slap on a lst.sort() if the input is not sorted.\nI think this came out nicely, using iterators and using islice to cut off the next piece.\nimport itertools\n\ndef partlst(lst, n):\n \"\"\"Partition @lst in @n balanced parts, in given order\"\"\"\n ... | [
5,
1,
0,
0,
0
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0001380162_algorithm_python.txt |
Q:
Dynamically decompose list into variables in Python
I have 2 dimensional list created at runtime (the number of entries in either dimension is unknown). For example:
long_list = [ [2, 3, 6], [3, 7, 9] ]
I want to iterate through it by getting the ith entry from each list inside the long_list:
for entry in long_li... | Dynamically decompose list into variables in Python | I have 2 dimensional list created at runtime (the number of entries in either dimension is unknown). For example:
long_list = [ [2, 3, 6], [3, 7, 9] ]
I want to iterate through it by getting the ith entry from each list inside the long_list:
for entry in long_list.iter():
#entry will be [2, 3] then [3, 7] then [6,... | [
">>> long_list = [ [2, 3, 6], [3, 7, 9] ]\n>>> import itertools\n>>> for i in itertools.izip_longest(*long_list): # called zip_longest in py3k\n print(i)\n\n\n(2, 3)\n(3, 7)\n(6, 9)\n\nBasically, you need to use unpacking feature here. It would work similarly for zip.\n"
] | [
4
] | [] | [] | [
"list",
"python",
"python_itertools",
"reflection"
] | stackoverflow_0001674621_list_python_python_itertools_reflection.txt |
Q:
How to store callback methods?
i am trying to store some method callbacks but referring to it will keep the bound object alive, so i tried to keep a weakref to method but that doesn't seems to be possible?
so
Why can't i keep a weak ref. to method (see example below)
What is the best way to keep method ref? any t... | How to store callback methods? | i am trying to store some method callbacks but referring to it will keep the bound object alive, so i tried to keep a weakref to method but that doesn't seems to be possible?
so
Why can't i keep a weak ref. to method (see example below)
What is the best way to keep method ref? any thing in standard lib? Or I will have... | [
"Since the method is bound to the object, what would you expect to do with it if the object doesnt exist? What would self contain?\nIf you dont need the object in the method, make it a classmethod. Then your object will be GC:d even if you have a normal reference to the method.\n",
"Recipe 6.10 in Python Cookbook... | [
3,
2,
0,
0
] | [] | [] | [
"methods",
"python",
"weak_references"
] | stackoverflow_0001673483_methods_python_weak_references.txt |
Q:
Dictionary Operations... Index / Iterate / Validate
I'd like to:
Check a key / value at position i
Check to see if key / value contains a string
delete / store in another variable either the key / value
The equivelant of this Java code:
//Some list...
ArrayList<String> example;
...
//Index into data structure
ex... | Dictionary Operations... Index / Iterate / Validate | I'd like to:
Check a key / value at position i
Check to see if key / value contains a string
delete / store in another variable either the key / value
The equivelant of this Java code:
//Some list...
ArrayList<String> example;
...
//Index into data structure
example.get(i);
//Check for some string...
if (example.get(... | [
"Python dictionaries are implemented as hash tables, so there is no intrinsic ordering; therefore, \"position i\" is a totally nonsensical concept for a dict -- it's like asking for the dict entry that's most yellow, or that least resembles a llama... those concepts just don't apply to dict entries, and \"position ... | [
5,
3,
1,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0001674683_dictionary_python.txt |
Q:
Can I add Runtime Properties to a Python App Engine App?
Coming from a java background I'm used to having a bunch of properties files I can swap round at runtime dependent on what server I'm running on e.g. dev/production.
Is there a method in python to do similar, specifically on Google's App Engine framework?
At... | Can I add Runtime Properties to a Python App Engine App? | Coming from a java background I'm used to having a bunch of properties files I can swap round at runtime dependent on what server I'm running on e.g. dev/production.
Is there a method in python to do similar, specifically on Google's App Engine framework?
At the minute I have them defined in .py files, obviously I'd li... | [
"You can:\n\nedit records in the datastore through the dashboard ( if you really have to )\nupload new scripts / files ( you can access files in READ-ONLY )\nexport a WEB Service API to configuration records in the datastore ( probably not what you had in mind )\naccess a page somewhere through an HTTP end-point\n... | [
1,
1
] | [] | [] | [
"google_app_engine",
"properties",
"python",
"runtime"
] | stackoverflow_0001674764_google_app_engine_properties_python_runtime.txt |
Q:
Delineating a Read File
Not really too sure how to word this question, therefore if you don't particularly understand it then I can try again.
I have a file called example.txt and I'd like to import this into my Python program. Here I will do some calculations with what it contains and other things that are irrele... | Delineating a Read File | Not really too sure how to word this question, therefore if you don't particularly understand it then I can try again.
I have a file called example.txt and I'd like to import this into my Python program. Here I will do some calculations with what it contains and other things that are irrelevant.
Instead of me importin... | [
"with open(\"example.txt\") as f:\n for line in f:\n key, value = line.strip().split(\"=\")\n do_something(key,value)\n\nlooks like a starting point if I understand you correctly. You need Python 2.6 or 3.x for this.\nAnother place to look is the csv module that can parse comma-separated value file... | [
4,
0,
0
] | [] | [] | [
"file_handling",
"python"
] | stackoverflow_0001673740_file_handling_python.txt |
Q:
Why does python -V write to the error stream?
I was writing a script to inspect python's version on my system and I've noticed that python -V writes to the error stream, while python -h, for instance, uses the standard output. Is there a good reason for this behavior?
A:
The -h option also used to print to stder... | Why does python -V write to the error stream? | I was writing a script to inspect python's version on my system and I've noticed that python -V writes to the error stream, while python -h, for instance, uses the standard output. Is there a good reason for this behavior?
| [
"The -h option also used to print to stderr because it is not part of the output of your program, i.e. the output is not produced by your Python script but by the Python interpreter itself. \nAs for why they changed the -h to use stdout? Try typing python -h with your terminal window set to the standard 24 lines. I... | [
3,
2,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0001672650_python.txt |
Q:
How to interpret status code in Python commands.getstatusoutput()
In a related question, I asked where to find the documentation for the C function "wait." This was an attempt to figure out return codes for the commands.getstatusoutput() module. Stackoverflow came through, but the documentation didn't help. Here's... | How to interpret status code in Python commands.getstatusoutput() | In a related question, I asked where to find the documentation for the C function "wait." This was an attempt to figure out return codes for the commands.getstatusoutput() module. Stackoverflow came through, but the documentation didn't help. Here's what puzzles me:
#!/usr/bin/python
import commands
goodcommand = 'ls /... | [
"There is a set of functions in os module (os.WIFCONTINUED, os.WIFSTOPPED, os.WTERMSIG, os.WCOREDUMP, os.WIFEXITED, os.WEXITSTATUS, os.WIFSIGNALED, os.WSTOPSIG), which correspond to macros from wait(2) manual. You should use them to interpret the status code.\nFor example, to get the exit code you should use os.WEX... | [
11,
4,
3,
0
] | [] | [] | [
"command",
"exit_code",
"python",
"subprocess"
] | stackoverflow_0001535672_command_exit_code_python_subprocess.txt |
Q:
Fastest Way To Remove Duplicates In Lists Python
I have two very large lists and to loop through it once takes at least a second and I need to do it 200,000 times. What's the fastest way to remove duplicates in two lists to form one?
A:
This is the fastest way I can think of:
import itertools
output_list = list(... | Fastest Way To Remove Duplicates In Lists Python | I have two very large lists and to loop through it once takes at least a second and I need to do it 200,000 times. What's the fastest way to remove duplicates in two lists to form one?
| [
"This is the fastest way I can think of:\nimport itertools\noutput_list = list(set(itertools.chain(first_list, second_list)))\n\nSlight update: As jcd points out, depending on your application, you probably don't need to convert the result back to a list. Since a set is iterable by itself, you might be able to jus... | [
23,
11,
8,
3
] | [] | [] | [
"list",
"python",
"sorting"
] | stackoverflow_0001675321_list_python_sorting.txt |
Q:
SMTP and XMPP deployment/workflow
I'm developing a website that incorporates an XMPP bot and a custom SMTP server (mainly these services process commands and reply). I'd like to set up a system where I can develop locally, push changes to a staging server, and finally to a production system. (Essentially I'm dev... | SMTP and XMPP deployment/workflow | I'm developing a website that incorporates an XMPP bot and a custom SMTP server (mainly these services process commands and reply). I'd like to set up a system where I can develop locally, push changes to a staging server, and finally to a production system. (Essentially I'm developing on the live server currently.)
... | [
"Partial answer: DNS has no way to tell you to connect to a non-standard SMTP port, even with SRV records. (XMPP does.)\nSo, for sending email, you'll have to do something like:\nimport smtplib\nserver = smtplib.SMTP('localhost:2525')\nserver.sendmail(fromaddr, toaddrs, msg)\nserver.quit()\n\n"
] | [
2
] | [] | [] | [
"deployment",
"python",
"smtp",
"xmpp"
] | stackoverflow_0001552417_deployment_python_smtp_xmpp.txt |
Q:
Using Google AppEngine as a "cache" for personal websites (wordpress blogs, wikis)
I read an article of an indie game developer who is using Google AppEngine to cache his main site and blog, to protect provide high-availability during traffic spikes (Digg, Slashdot effect).
Wolfire Blog - Google App Engine for Ind... | Using Google AppEngine as a "cache" for personal websites (wordpress blogs, wikis) | I read an article of an indie game developer who is using Google AppEngine to cache his main site and blog, to protect provide high-availability during traffic spikes (Digg, Slashdot effect).
Wolfire Blog - Google App Engine for Indie Developers
There's not a lot of detail on the exactly what they developed in Python o... | [
"You could start by taking the code for DryDrop, which mirrors static pages from a repository hosted on GitHub, and making it a more general reverse proxy. For example, you'd need to ensure that POST requests or logged-in users get passed through directly to the proxy.\n"
] | [
9
] | [] | [] | [
"caching",
"google_app_engine",
"java",
"python"
] | stackoverflow_0001675715_caching_google_app_engine_java_python.txt |
Q:
Computing article abstracts
I'm looking for a way to automatically produce an abstract, basically the first few sentances/paragraphs of a blog entry, to display in a list of articles (which are written in markdown). Currently, I'm doing something like this:
def abstract(article, paras=3):
return '\n'.join(art... | Computing article abstracts | I'm looking for a way to automatically produce an abstract, basically the first few sentances/paragraphs of a blog entry, to display in a list of articles (which are written in markdown). Currently, I'm doing something like this:
def abstract(article, paras=3):
return '\n'.join(article.split('\n')[0:paras])
to ju... | [
"EDIT:\nYou can do something like this:\nfrom textwrap import wrap\n\ndef getAbstract(text, lines=5, screenwidth=100):\n width = len(' '.join([\n line for block in text.splitlines()\n for line in wrap(block, width=screenwidth)\n ][:lines]))\n return text[:width] + '...'\... | [
7,
0
] | [] | [] | [
"markdown",
"python"
] | stackoverflow_0001675943_markdown_python.txt |
Q:
Network analysis and adjacency matrices
I want to try and create a network for several hundred shapefiles that consist of polylines. The polylines are snapped to each other and consistent. Then I want to create an adjacency matrix for this network.
What is the best way of doing this? I know how to do it on an indi... | Network analysis and adjacency matrices | I want to try and create a network for several hundred shapefiles that consist of polylines. The polylines are snapped to each other and consistent. Then I want to create an adjacency matrix for this network.
What is the best way of doing this? I know how to do it on an individual basis by clicking through options with... | [
"I don't know what exactly you want to achieve but when it comes to network analysis in python take a look at networkx. \n"
] | [
2
] | [] | [] | [
"arcgis",
"arcmap",
"esri",
"python",
"vba"
] | stackoverflow_0001675347_arcgis_arcmap_esri_python_vba.txt |
Q:
Feedparser - retrieve old messages from Google Reader
I'm using the feedparser library in python to retrieve news from a local newspaper (my intent is to do Natural Language Processing over this corpus) and would like to be able to retrieve many past entries from the RSS feed.
I'm not very acquainted with the tech... | Feedparser - retrieve old messages from Google Reader | I'm using the feedparser library in python to retrieve news from a local newspaper (my intent is to do Natural Language Processing over this corpus) and would like to be able to retrieve many past entries from the RSS feed.
I'm not very acquainted with the technical issues of RSS, but I think this should be possible (I... | [
"You're only getting a dozen entries or so because that's what the feed contains. If you want historic data you will have to find a feed/database of said data.\nCheck out this ReadWriteWeb article for some resources on finding open data on the web.\nNote that Feedparser has nothing to do with this as your title sug... | [
10,
3
] | [] | [] | [
"feedparser",
"google_reader",
"python",
"rss"
] | stackoverflow_0001676223_feedparser_google_reader_python_rss.txt |
Q:
How to pass flag to gcc in Python setup.py script?
I'm writing a Python extension in C that requires the CoreFoundation framework (among other things). This compiles fine with:
gcc -o foo foo.c -framework CoreFoundation -framework Python
("-framework" is an Apple-only gcc extension, but that's okay because I'm us... | How to pass flag to gcc in Python setup.py script? | I'm writing a Python extension in C that requires the CoreFoundation framework (among other things). This compiles fine with:
gcc -o foo foo.c -framework CoreFoundation -framework Python
("-framework" is an Apple-only gcc extension, but that's okay because I'm using their specific framework anyway)
How do I tell setup... | [
"Maybe you need to set extra_link_args, too? extra_compile_args is used when compiling the source code, extra_link_args when linking the result.\n"
] | [
19
] | [] | [] | [
"distutils",
"python",
"python_c_api"
] | stackoverflow_0001676384_distutils_python_python_c_api.txt |
Q:
Exporting keyframes in blender python
I'm trying to export animation from blender, here's what I've done so far:
--- This is just to give you an idea of what I'm doing and I've left out a lot to keep it short.
--- If it's too confusing or if it's needed I could post the whole source.
# Get the armature
arm = ob.... | Exporting keyframes in blender python | I'm trying to export animation from blender, here's what I've done so far:
--- This is just to give you an idea of what I'm doing and I've left out a lot to keep it short.
--- If it's too confusing or if it's needed I could post the whole source.
# Get the armature
arm = ob.getData()
# Start at the root bone
for ... | [
"The channel data should be applied on top of the bind pose matrix.\nThe complete formula is the following:\nMr = Ms * B0*P0 * B1*P1 ... Bn*Pn\nwhere:\nMr = result matrix for a bone 'n'\nMs = skeleton->world matrix\nBi = bind pose matrix for bone 'i'\nPi = pose actual matrix constructed from stored channels (that y... | [
2
] | [] | [] | [
"3d",
"blender",
"python"
] | stackoverflow_0001273588_3d_blender_python.txt |
Q:
Pyfacebook from buildout
What is the best way to install the latest version of pyfacebook with buildout? The package is hosted on github and is not on pypi. This system doesn't have git installed, so a git-based recipe isn't unfortunately not an option. The github URL is http://github.com/sciyoshi/pyfacebook. TIA!... | Pyfacebook from buildout | What is the best way to install the latest version of pyfacebook with buildout? The package is hosted on github and is not on pypi. This system doesn't have git installed, so a git-based recipe isn't unfortunately not an option. The github URL is http://github.com/sciyoshi/pyfacebook. TIA!
| [
"You can add any python package hosted on git-hub by adding a find-links url pointing to the project tarball URL plus a #egg=packagename postfix. For pyfacebook that is:\nhttp://github.com/sciyoshi/pyfacebook/tarball/master#egg=pyfacebook\n\nSo a simple buildout would be:\n[buildout]\nparts = whatever\nfind-links =... | [
5
] | [] | [] | [
"buildout",
"facebook",
"github",
"pypi",
"python"
] | stackoverflow_0001676520_buildout_facebook_github_pypi_python.txt |
Q:
Comparing elements in a list in Python's for -loop
What is wrong in the method end in the code?
The method end returns always 1 although it should return 0 with the current data.
# return 1 if the sum of four consecutive elements equal the sum over other sum of the other three sums
# else return 0
# Eg the current... | Comparing elements in a list in Python's for -loop | What is wrong in the method end in the code?
The method end returns always 1 although it should return 0 with the current data.
# return 1 if the sum of four consecutive elements equal the sum over other sum of the other three sums
# else return 0
# Eg the current sums "35 34 34 34" should return 0
data = "2|15|14... | [
"I can't really tell what you're trying to do here, but I can certainly say why end() returns 1 instead of 0. In your last for loop, you reset summat to [] at the start of the loop, so at the end, summat only contains a single value (the one you most recently appended on). So when you ask for summat[2:5] on a list ... | [
2,
2,
1,
1,
1
] | [] | [] | [
"list",
"python"
] | stackoverflow_0001675860_list_python.txt |
Q:
Does python optimize modules when they are imported multiple times?
If a large module is loaded by some submodule of your code, is there any benefit to referencing the module from that namespace instead of importing it again?
For example:
I have a module MyLib, which makes extensive use of ReallyBigLib. If I have ... | Does python optimize modules when they are imported multiple times? | If a large module is loaded by some submodule of your code, is there any benefit to referencing the module from that namespace instead of importing it again?
For example:
I have a module MyLib, which makes extensive use of ReallyBigLib. If I have code that imports MyLib, should I dig the module out like so
import MyLib... | [
"Python modules could be considered as singletons... no matter how many times you import them they get initialized only once, so it's better to do:\nimport MyLib\nimport ReallyBigLib\n\nRelevant documentation on the import statement:\nhttps://docs.python.org/2/reference/simple_stmts.html#the-import-statement\n\nOnc... | [
88,
42,
9,
8,
3,
2
] | [] | [] | [
"python",
"python_import"
] | stackoverflow_0000296036_python_python_import.txt |
Q:
Trying to upgrade Python to 3.0 on Mac OS 10.5.8
I'm having some problems upgrading Python on my Mac. For my first attempt, I downloaded and installed the 2.6.4 dmg MacPython installer from http://python.org/download/mac/. This did install 2.6.4, and when I ran 'python' from the terminal it says that version.
Howe... | Trying to upgrade Python to 3.0 on Mac OS 10.5.8 | I'm having some problems upgrading Python on my Mac. For my first attempt, I downloaded and installed the 2.6.4 dmg MacPython installer from http://python.org/download/mac/. This did install 2.6.4, and when I ran 'python' from the terminal it says that version.
However, I also had a test script where I am doing:
import... | [
"First, /usr/bin/python should always point to the Apple-supplied python and on 10.5 that means python2.5. Don't change this!\nWhen you installed the python.org python2.6, by default it installs symlinks in /usr/local/bin/ so one way to invoke it is /usr/local/bin/python2.6 or, most likely, just python2.6. Since ... | [
5
] | [] | [] | [
"macos",
"python"
] | stackoverflow_0001676831_macos_python.txt |
Q:
Pygtk StatusIcon not loading?
I'm currently working on a small script that needs to use gtk.StatusIcon(). For some reason, I'm getting some weird behavior with it. If I go into the python interactive shell and type:
>> import gtk
>> statusIcon = gtk.status_icon_new_from_file("img/lin_idle.png")
Pygtk does exactly... | Pygtk StatusIcon not loading? | I'm currently working on a small script that needs to use gtk.StatusIcon(). For some reason, I'm getting some weird behavior with it. If I go into the python interactive shell and type:
>> import gtk
>> statusIcon = gtk.status_icon_new_from_file("img/lin_idle.png")
Pygtk does exactly what it should do, and shows an ic... | [
"You need to call the gtk.main function like qba said, however the correct way to call a function every N milliseconds is to use the gobject.timeout_add function. In most cases you would want to have anything that could tie up the gui in a separate thread, however in your case where you just have an icon you don't ... | [
4,
1
] | [] | [] | [
"gtk",
"pygtk",
"python"
] | stackoverflow_0001659085_gtk_pygtk_python.txt |
Q:
algorithm for list identification and parsing
I have data which in theory is a list, but historically has been input by the user as a free form text field. Now I need to separate each item of the list so that each element can be analysed.
Simplified examples of my data as input by users:
one, two, three, four, fiv... | algorithm for list identification and parsing | I have data which in theory is a list, but historically has been input by the user as a free form text field. Now I need to separate each item of the list so that each element can be analysed.
Simplified examples of my data as input by users:
one, two, three, four, five
one. two. three, four. five.
"I start with one... | [
"The first step to solving this problem is to analyze, in detail, how it is that humans solve this problem. I'd break the problem down into two parts.\n\nHow do humans distinguish between lists and non-lists? For example, is it because non-lists are grammatical English sentences? If that's the case, you may be a... | [
3,
2,
1,
1,
0,
0,
0,
0,
0
] | [] | [] | [
"java",
"list",
"parsing",
"python"
] | stackoverflow_0001673729_java_list_parsing_python.txt |
Q:
How to enforce unicode arguments for methods?
I have a model class with getter and setter methods, and the occasional static methods. I would like to enforce the usage of unicode strings as arguments for specific methods and using decorators was the first idea I had. Now I have something like this:
import types
c... | How to enforce unicode arguments for methods? | I have a model class with getter and setter methods, and the occasional static methods. I would like to enforce the usage of unicode strings as arguments for specific methods and using decorators was the first idea I had. Now I have something like this:
import types
class require_unicode(object):
def __init__(sel... | [
"I think, your problem is with the @staticmethod decorator, not with your require_unicode decorator. Staticmethods, unlike classmethods don't receive the reference to the class as the first argument, so your argument signature is wrong.\nYou must either change do_another to be a @classmethod, or remove self from th... | [
1,
0,
0
] | [] | [] | [
"arguments",
"decorator",
"python",
"unicode"
] | stackoverflow_0001675154_arguments_decorator_python_unicode.txt |
Q:
How does a classmethod object work?
I'm having trouble to understand how a classmethod object works in Python, especially in the context of metaclasses and in __new__. In my special case I would like to get the name of a classmethod member, when I iterate through the members that were given to __new__.
For normal ... | How does a classmethod object work? | I'm having trouble to understand how a classmethod object works in Python, especially in the context of metaclasses and in __new__. In my special case I would like to get the name of a classmethod member, when I iterate through the members that were given to __new__.
For normal methods the name is simply stored in a __... | [
"A classmethod object is a descriptor. You need to understand how descriptors work.\nIn a nutshell, a descriptor is an object which has a method __get__, which takes three arguments: self, an instance, and an instance type.\nDuring normal attribute lookup, if a looked-up object A has a method __get__, that method g... | [
22
] | [] | [] | [
"class_method",
"metaclass",
"python"
] | stackoverflow_0001677468_class_method_metaclass_python.txt |
Q:
How to sign a document in python with M2Crypto using particular padding technique?
I need to digitally sign some text in python using a private key stored in a .pem file. It seems like M2Crypto is the preferred way to do that these days, so that's what I'm using. I think I get most of it, but I'm confused about ... | How to sign a document in python with M2Crypto using particular padding technique? | I need to digitally sign some text in python using a private key stored in a .pem file. It seems like M2Crypto is the preferred way to do that these days, so that's what I'm using. I think I get most of it, but I'm confused about how to configure padding. To be specific, I need to verify the signature in an iPhone ap... | [
"AFAIK M2Crypto adds padding where it's required. \nPKCS1 padding is the default.\nBut, (again only AFAIK), signatures don't have padding, padding is only added to encrypted data to prevent a possible attack.\nEDIT: user caf, in a comment says that a padding is essnetial to a good signature. I'm still recommending ... | [
2
] | [] | [] | [
"cryptography",
"digital_signature",
"m2crypto",
"python"
] | stackoverflow_0001677594_cryptography_digital_signature_m2crypto_python.txt |
Q:
Building python 2.6 w/ sqlite3 module if sqlite is installed in non-standard location
I am trying to build python2.6 with support for the sqlite3 module.
I have successfully built and installed the sqlite-amalgamation to a non standard path:
./configure --prefix=/my/non/standard/install/path/sqlite/3.6.20/
make
ma... | Building python 2.6 w/ sqlite3 module if sqlite is installed in non-standard location | I am trying to build python2.6 with support for the sqlite3 module.
I have successfully built and installed the sqlite-amalgamation to a non standard path:
./configure --prefix=/my/non/standard/install/path/sqlite/3.6.20/
make
make install
I would like the python2.6 build to use this path & build the sqlite3 module. I ... | [
"Rather than rebuilding python, the simplest way to get the most recent sqlite3 is to install the pysqlite package which is the more up-to-date version of the standard library's sqlite3 module. It includes support for more recent sqlite3 features and is upwards compatible. More details are here.\n"
] | [
7
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0001677666_python_sqlite.txt |
Q:
Python decorators on class members fail when decorator mechanism is a class
When creating decorators for use on class methods, I'm having trouble when the decorator mechanism is a class rather than a function/closure. When the class form is used, my decorator doesn't get treated as a bound method.
Generally I pre... | Python decorators on class members fail when decorator mechanism is a class | When creating decorators for use on class methods, I'm having trouble when the decorator mechanism is a class rather than a function/closure. When the class form is used, my decorator doesn't get treated as a bound method.
Generally I prefer to use the function form for decorators but in this case I have to use an exi... | [
"Your WrapperClass needs to be a descriptor (just like a function is!), i.e., supply appropriate special methods __get__ and __set__. This how-to guide teaches all you need to know about that!-)\n"
] | [
10
] | [] | [] | [
"decorator",
"python"
] | stackoverflow_0001677747_decorator_python.txt |
Q:
Can you only communicate once with a subprocess?
communicate's documentation says:
Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate.
What do you do if you need to send input to a process more than once ? For example, I spawn... | Can you only communicate once with a subprocess? | communicate's documentation says:
Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate.
What do you do if you need to send input to a process more than once ? For example, I spawn a process, send it some data, the process does someth... | [
"Then you can't use .communicate(). You can either poll the streams, use select or some other way that allows you to listen to FD changes (both gtk and Qt have tools for that, for example).\n",
"Take a look at Doug Hellman's Python Module of the Week writeup about subprocess. Search down until you see \"repeater.... | [
3,
3,
2,
1
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0001676340_python_subprocess.txt |
Q:
Convert int64 to uint64
I want to convert an int64 numpy array to a uint64 numpy array, adding 2**63 to the values in the process so that they are still within the valid range allowed by the arrays. So for example if I start from
a = np.array([-2**63,2**63-1], dtype=np.int64)
I want to end up with
np.array([0.,2*... | Convert int64 to uint64 | I want to convert an int64 numpy array to a uint64 numpy array, adding 2**63 to the values in the process so that they are still within the valid range allowed by the arrays. So for example if I start from
a = np.array([-2**63,2**63-1], dtype=np.int64)
I want to end up with
np.array([0.,2**64], dtype=np.uint64)
Sound... | [
"Use astype() to convert the values to another dtype:\nimport numpy as np\n(a+2**63).astype(np.uint64)\n# array([ 0, 18446744073709551615], dtype=uint64)\n\n",
"I'm not a real numpy expert, but this:\n>>> a = np.array([-2**63,2**63-1], dtype=np.int64)\n>>> b = np.array([x+2**63 for x in a], dtyp... | [
3,
1
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0001677639_numpy_python.txt |
Q:
Convert Python for -loop to PHP
How can you convert the following code to PHP?
summat = [sum(arra[i:i+4]) for i in range(0,len(arra),4)]
My attempt
$summat = array()
foreach ( range(0, $arra.length, 4) as $i) {
$summat = array ( array_sum( array_slice( $array, $i, $i+5) ) ) // don't know how to append t... | Convert Python for -loop to PHP | How can you convert the following code to PHP?
summat = [sum(arra[i:i+4]) for i in range(0,len(arra),4)]
My attempt
$summat = array()
foreach ( range(0, $arra.length, 4) as $i) {
$summat = array ( array_sum( array_slice( $array, $i, $i+5) ) ) // don't know how to append the sums the array
| [
"$sum = array();\nforeach(range(0, count($a), 4) as $i)\n $sum []= array_sum(array_slice($a, $i, 4));\n\n\"[]=\" is an append-to-array operator\nslice's second parameter is slice length, not the last index\nor even simpler\n$sum = array_map('array_sum', array_chunk($a, 4));\n\n",
"To append a value to an array,... | [
4,
1
] | [] | [] | [
"php",
"python"
] | stackoverflow_0001678342_php_python.txt |
Q:
Proper way of having a unique identifier in Python?
Basically, I have a list like: [START, 'foo', 'bar', 'spam', eggs', END] and the START/END identifiers are necessary for later so I can compare later on. Right now, I have it set up like this:
START = object()
END = object()
This works fine, but it suffers from ... | Proper way of having a unique identifier in Python? | Basically, I have a list like: [START, 'foo', 'bar', 'spam', eggs', END] and the START/END identifiers are necessary for later so I can compare later on. Right now, I have it set up like this:
START = object()
END = object()
This works fine, but it suffers from the problem of not working with pickling. I tried doing i... | [
"If you want an object that's guaranteed to be unique and can also be guaranteed to get restored to exactly the same identify if pickled and unpickled right back, top-level functions, classes, class instances, and if you care about is rather than == also lists (and other mutables), are all fine. I.e., any of:\n# w... | [
10,
2,
1,
1,
0
] | [] | [] | [
"identifier",
"python"
] | stackoverflow_0001677726_identifier_python.txt |
Q:
accessing memcached stats via cmemcache or django returns warning
My Django application uses memcached via cmemcache. An issue sprung up when I was trying to monitor its usage:
I tried to access stats memcached provides through both Django and cmemcache:
django:
from django.core.cache import cache
cache._cache.get... | accessing memcached stats via cmemcache or django returns warning | My Django application uses memcached via cmemcache. An issue sprung up when I was trying to monitor its usage:
I tried to access stats memcached provides through both Django and cmemcache:
django:
from django.core.cache import cache
cache._cache.get_stats()
[WARN@1257320533.841286] mcm_server_stats():3027: unknown stat... | [
"First, you should not run those versions of memcached. They have lots and lots of known bugs and are many years old.\nSecondly, we add stats to memcached quite frequently, so if these libraries are complaining when they encounter new stats, you should complain to their authors.\nAlso, I don't believe cmemcache is... | [
1
] | [] | [] | [
"django",
"memcached",
"python"
] | stackoverflow_0001678848_django_memcached_python.txt |
Q:
Is there a python library that implements both sides of the AWS authentication protocol?
I am writing a REST service in python and django and wanted to use Amazon's AWS authentication protocol. I was wondering if anyone knew of a python library that implemented formation of the header for sending and the validatio... | Is there a python library that implements both sides of the AWS authentication protocol? | I am writing a REST service in python and django and wanted to use Amazon's AWS authentication protocol. I was wondering if anyone knew of a python library that implemented formation of the header for sending and the validation of the header for recieving?
| [
"Try this Library. I think it is the library you are searching for..\nCalNet\nYou can find some Python Code Samples Here\n",
"boto is a Python library for AWS. I don't know however if it supports what you are asking for.\n",
"I think this code does exactly what you want :)\nI'll be happy to get comments for imp... | [
2,
1,
0
] | [] | [] | [
"amazon_web_services",
"python"
] | stackoverflow_0000701789_amazon_web_services_python.txt |
Q:
Selenium RC: how to capture/handle error?
My test uses Selenium to loop through a CSV list of URLs via an HTTP proxy (working script below). As I watch the script run I can see about 10% of the calls produce "Proxy error: 502" ("Bad_Gateway"); however, the errors are not captured by my catch-all "except Exception"... | Selenium RC: how to capture/handle error? | My test uses Selenium to loop through a CSV list of URLs via an HTTP proxy (working script below). As I watch the script run I can see about 10% of the calls produce "Proxy error: 502" ("Bad_Gateway"); however, the errors are not captured by my catch-all "except Exception" clause -- ie: instead of writing 'error' in th... | [
"I think that the alternative you propose is ok. rather than the get_html_source, You can use the captureNetworkTraffic function to get the HTTP header. That would be safer because the 502 page can change.\nBe careful, there is a bug in the captureNetworkTraffic of the selenium python wrapper that can be hacked. Se... | [
1
] | [] | [] | [
"csv",
"error_handling",
"loops",
"python",
"selenium"
] | stackoverflow_0001678195_csv_error_handling_loops_python_selenium.txt |
Q:
template fragment caching doesn't seem to work for some custom template tags
I've been implementing caching in my django application, and used per view caching via the cache API and template fragment caching.
On some of my pages I use a custom django template tag, this tag is provided via a third party developer, ... | template fragment caching doesn't seem to work for some custom template tags | I've been implementing caching in my django application, and used per view caching via the cache API and template fragment caching.
On some of my pages I use a custom django template tag, this tag is provided via a third party developer, it takes some arguments in its template tags, and then make a request to a remote ... | [
"If the template fragment you're trying to cache can't be pickled, memcached won't be able to store it and will raise an exception. From what I can gather, exceptions generated when rendering Django templates are suppressed. Since your custom tag is doing HTTP requests, maybe socket objects (which can't be pickled)... | [
3,
0,
0,
0
] | [] | [] | [
"django",
"fragment_caching",
"memcached",
"python"
] | stackoverflow_0001627131_django_fragment_caching_memcached_python.txt |
Q:
Overriding the newline generation behaviour of Python's print statement
I have a bunch of legacy code for encoding raw emails that contains a lot of print statements such as
print >>f, "Content-Type: text/plain"
This is all well and good for emails, but we're now leveraging the same code for outputting HTTP reque... | Overriding the newline generation behaviour of Python's print statement | I have a bunch of legacy code for encoding raw emails that contains a lot of print statements such as
print >>f, "Content-Type: text/plain"
This is all well and good for emails, but we're now leveraging the same code for outputting HTTP request. The problem is that the Python print statement outputs '\n' whilst HTTP r... | [
"You should solve your problem now and for forever by defining a new output function. Were print a function, this would have been much easier.\nI suggest writing a new output function, mimicing as much of the modern print function signature as possible (because reusing a good interface is good), for example:\ndef o... | [
10,
8,
4,
0,
0,
0
] | [] | [] | [
"cpython",
"printing",
"python"
] | stackoverflow_0001677424_cpython_printing_python.txt |
Q:
How do I make Python pick the correct module without manually modifying sys.path?
I have made some changes in a python module in my checked out copy of a repository, and need to test them. However, when I try to run a script that uses the module, it keeps importing the module from the trunk of the repository, whic... | How do I make Python pick the correct module without manually modifying sys.path? | I have made some changes in a python module in my checked out copy of a repository, and need to test them. However, when I try to run a script that uses the module, it keeps importing the module from the trunk of the repository, which is of no use to me.
I tried setting PYTHONPATH, which did nothing at all. After some... | [
"It sounds like you need to install virtualenv and use it to set up different environments for different purposes. In one environment, you would import modules from the trunk of the repository, but in another environment you would have a mixture of trunk modules and test modules. \nBy keeping everything separate li... | [
3,
2,
1,
0
] | [] | [] | [
"import",
"module",
"path",
"python"
] | stackoverflow_0001679673_import_module_path_python.txt |
Q:
Error while exiting cherrypy server
Guys, I am getting following error while exiting cherrypy server. What is this error about?
2009-11-04 09:32:35,015 WARNING Error in atexit._run_exitfuncs:
2009-11-04 09:32:35,015 WARNING
2009-11-04 09:32:35,015 WARNING Traceback (most recent call last):
2009-11-04 09:32:3... | Error while exiting cherrypy server | Guys, I am getting following error while exiting cherrypy server. What is this error about?
2009-11-04 09:32:35,015 WARNING Error in atexit._run_exitfuncs:
2009-11-04 09:32:35,015 WARNING
2009-11-04 09:32:35,015 WARNING Traceback (most recent call last):
2009-11-04 09:32:35,015 WARNING File "atexit.pyc", line ... | [
"You probably log to console and then close it.\n",
"You closed your log file before exiting. The logging shutdown code wants to flush the log file before exiting. What you see here looks like bug #3126 in Python's logging module. It was fixed with:\n\nr64338 | vinay.sajip | 2008-06-17\n 13:02:14 +0200 (Tue, 17 ... | [
0,
0
] | [] | [] | [
"cherrypy",
"logging",
"python"
] | stackoverflow_0001675441_cherrypy_logging_python.txt |
Q:
copy files from IIs6.0 server to client machine without showing file dialog window on click of button in ASP.NET 3.5
File.VBS file should be copied from IIS6.0(File.VBS file will be deployed in IIS along the ASP.NET3.5 application) server to Client “TEMP” folder with out opening the file download dialog box.
Thank... | copy files from IIs6.0 server to client machine without showing file dialog window on click of button in ASP.NET 3.5 | File.VBS file should be copied from IIS6.0(File.VBS file will be deployed in IIS along the ASP.NET3.5 application) server to Client “TEMP” folder with out opening the file download dialog box.
Thanks!
| [
"As indicated in the comment by Cheeso,\n this is not possible!\nThis would constitute a very dangerous security hole!\nAlthough brief on this topic, the RFC 2616 is none the less explicit on this point, in particular with regards to the User Agent's (read the \"Web Browser\") duties in that regard.\n\nThe receivin... | [
1
] | [] | [] | [
"c#",
"python",
"ruby"
] | stackoverflow_0001680233_c#_python_ruby.txt |
Q:
Python: How much space does each element of a list take?
I need a very large list, and am trying to figure out how big I can make it so that it still fits in 1-2GB of RAM. I am using the CPython implementation, on 64 bit (x86_64).
Edit: thanks to bua's answer, I have filled in some of the more concrete answers.
Wh... | Python: How much space does each element of a list take? | I need a very large list, and am trying to figure out how big I can make it so that it still fits in 1-2GB of RAM. I am using the CPython implementation, on 64 bit (x86_64).
Edit: thanks to bua's answer, I have filled in some of the more concrete answers.
What is the space (memory) usage of (in bytes):
the list itself... | [
"point to start: \n>>> import sys\n>>> a=list()\n>>> type(a)\n<type 'list'>\n>>> sys.getsizeof(a)\n36\n>>> b=1\n>>> type(b)\n<type 'int'>\n>>> sys.getsizeof(b)\n12\n\nand from python help:\n>>> help(sys.getsizeof)\nHelp on built-in function getsizeof in module sys:\n\ngetsizeof(...)\n getsizeof(object, default) ... | [
11,
7
] | [] | [] | [
"list",
"memory",
"performance",
"python"
] | stackoverflow_0001680436_list_memory_performance_python.txt |
Q:
Custom exception handling in Python
I have two modules, main and notmain. I declared my custom exception in main module and want to catch it. This exception is raised in notmain module. The problem is I can't catch my exception raised in notmain module.
main.py:
class MyException(Exception):
pass
m = __import... | Custom exception handling in Python | I have two modules, main and notmain. I declared my custom exception in main module and want to catch it. This exception is raised in notmain module. The problem is I can't catch my exception raised in notmain module.
main.py:
class MyException(Exception):
pass
m = __import__('notmain')
try:
m.func()
except My... | [
"Your module main is imported twice (as main and __main__), each having its own class MyException. You should consider redesigning your application to avoid circular imports.\n",
"The __main__ name, with underscores, is an automatic namespace for the program being called. A workaround would be to declare the exc... | [
8,
1
] | [] | [] | [
"exception",
"exception_handling",
"python"
] | stackoverflow_0001681036_exception_exception_handling_python.txt |
Q:
How can I replace a class with another class from another module in a lot of files without a lot of manual editing?
Basically, I have a lot of Python classes (representing our database schema) that look something like this:
from foo import xyz, b, c
class bar(object):
x = xyz()
y = b()
z = c()
...and... | How can I replace a class with another class from another module in a lot of files without a lot of manual editing? | Basically, I have a lot of Python classes (representing our database schema) that look something like this:
from foo import xyz, b, c
class bar(object):
x = xyz()
y = b()
z = c()
...and I want to change it to this:
from foo import b, c
from baz import foobar
class bar(object):
x = foobar()
y = b(... | [
"Monkey-patching would be the quick and dirty way to do it -- before you do any other import, perform the following preliminary:\nimport foo\nimport baz\nfoo.a = baz.m\n\nnow, every subsequent use of attribute a of module foo will actually be using class m of module baz, as required, rather than the original class ... | [
3,
1,
1,
0,
0
] | [] | [] | [
"automation",
"python",
"rope",
"sed"
] | stackoverflow_0001674791_automation_python_rope_sed.txt |
Q:
How can I change a list of strings into CSV in Python?
Example strings:
uji708
uhodih
utus29
agamu4
azi340
ekon62
I need to change them into CSV list like this:
uji708,uhodih,utus29,
agamu4,azi340,ekon62,
My code so far:
email = 'mail_list.txt'
handle = open(email)
for line in handle:
try:
email =... | How can I change a list of strings into CSV in Python? | Example strings:
uji708
uhodih
utus29
agamu4
azi340
ekon62
I need to change them into CSV list like this:
uji708,uhodih,utus29,
agamu4,azi340,ekon62,
My code so far:
email = 'mail_list.txt'
handle = open(email)
for line in handle:
try:
email = line.split()[0].replace('\n', '')
l = line.split()
... | [
"Use csv.writer:\nimport csv\nimport sys\n\nwriter = csv.csvwriter(sys.stdout)\nwriter.writerow(iterable_containing_my_strings)\n\n",
"Here is a very specific answer to a very specific question\nwhen you will clarify/generalize your question I may update my answer\ns = \"\"\"\nuji708\nuhodih\nutus29\nagamu4\nazi3... | [
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0001671786_python.txt |
Q:
Cross-Platform Programming Language with a decent gui toolkit?
For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming lan... | Cross-Platform Programming Language with a decent gui toolkit? | For the program idea I have, it requires that the software be written in one binary that is executeable by all major desktop platforms, meaning it needs an interpreted language or a language within a JVM. Either is fine with me, but the programming language has to balance power & simplicity (e.g. Python)
I know of wxPy... | [
"I used Python with wxPython for quite a while and found it very easy to use. I now use Java with both Swing and SWT.\nI prefer Java but that's just a personal preference so you shouldn't let that sway you.\nI didn't find the transition from Python to Java that difficult. In terms of GUI, they both have the layout ... | [
6,
5,
3,
3,
2,
1,
1,
0,
0,
0,
0
] | [] | [] | [
"cross_platform",
"java",
"multiplatform",
"python",
"wxpython"
] | stackoverflow_0001653419_cross_platform_java_multiplatform_python_wxpython.txt |
Q:
Nested Python C Extensions/Modules?
How do I compile a C-Python module such that it is local to another? E.g. if I have a module named "bar" and another module named "mymodule", how do I compile "bar" so that it imported via "import mymodule.bar"?
(Sorry if this is poorly phrased, I wasn't sure what the proper ter... | Nested Python C Extensions/Modules? | How do I compile a C-Python module such that it is local to another? E.g. if I have a module named "bar" and another module named "mymodule", how do I compile "bar" so that it imported via "import mymodule.bar"?
(Sorry if this is poorly phrased, I wasn't sure what the proper term for it was.)
I tried the following in s... | [
"The instructions are here:\n\nExtension('foo', ['src/foo1.c',\n'src/foo2.c'])\ndescribes an extension that lives in\nthe root package, while\nExtension('pkg.foo', ['src/foo1.c',\n'src/foo2.c'])\ndescribes the same extension in the\npkg package. The source files and\nresulting object code are identical in\nboth cas... | [
5
] | [] | [] | [
"distutils",
"python",
"python_c_api"
] | stackoverflow_0001681281_distutils_python_python_c_api.txt |
Q:
Detailed explanation about Python's "freeze"
Is there anywhere a detailed explanation about Python's "freeze" thing? I saw the PyPi page, but I don't think it's comprehensive enough.
A:
There is documentation about freeze on the wiki and the source docstring is pretty good.. There is an alternative, cx_Freeze. F... | Detailed explanation about Python's "freeze" | Is there anywhere a detailed explanation about Python's "freeze" thing? I saw the PyPi page, but I don't think it's comprehensive enough.
| [
"There is documentation about freeze on the wiki and the source docstring is pretty good.. There is an alternative, cx_Freeze. For windows there is py2exe. For Macs, py2app. \nUnless you are trying to make a single-download type program for windows, it is often easier to rely on eggs or source packages installed ... | [
6
] | [] | [] | [
"freeze",
"python"
] | stackoverflow_0001681021_freeze_python.txt |
Q:
Komodo Python auto complete: type inference by variable metadata?
I'm using Komodo Edit for Python development, and I want to get the best out of the auto complete.
If I do this:
a = A()
a.
I can see a list of members of A.
But if I do this:
a = [A()]
b = a[0]
b.
It does not work. I want to be able to do this:
... | Komodo Python auto complete: type inference by variable metadata? | I'm using Komodo Edit for Python development, and I want to get the best out of the auto complete.
If I do this:
a = A()
a.
I can see a list of members of A.
But if I do this:
a = [A()]
b = a[0]
b.
It does not work. I want to be able to do this:
a = [A()]
b = a[0]
"""b
Type: A
"""
b.
So how can I tell the auto com... | [
"This doesn't really answer your question, but with Wing IDE you can give hints to the type analyzer with assert isinstance(b, A). See here. I haven't found a way to do it with Komodo, though apparently it's possible when writing PHP or JavaScript.\nUpdate:\nI've found a way to trick Komodo into doing this:\nif 0: ... | [
8,
3
] | [] | [] | [
"autocomplete",
"komodo",
"python"
] | stackoverflow_0001678953_autocomplete_komodo_python.txt |
Q:
How do I find out where an icon was clicked (relative to itself) using python?
Essentially, what I want to do is have an icon that has different symbols for various programs at the bottom of it (for example, a python file might have a symbol for command prompt, a text editor, and a debugger, all little squares at ... | How do I find out where an icon was clicked (relative to itself) using python? | Essentially, what I want to do is have an icon that has different symbols for various programs at the bottom of it (for example, a python file might have a symbol for command prompt, a text editor, and a debugger, all little squares at the bottom of the icon), and when the user double clicks on one of these, that progr... | [
"You use some GUI system, like GTK+ or wxPython or something.\n",
"Sounds like you want to write an extension to windows explorer. This would be a significant project and I'm not sure Python would be the best language (you'd be accessing the win32 api a lot).\n"
] | [
1,
1
] | [] | [] | [
"icons",
"python"
] | stackoverflow_0001681339_icons_python.txt |
Q:
How insecure is / replacement for tmpnam?
I considered using tmpnam to set the output file name of a QPrinter. But the Python documentation recommends against using it.
os.tmpnam()
Return a unique path name that is reasonable for creating a temporary
file. ... Applications are responsible
for properly creatin... | How insecure is / replacement for tmpnam? | I considered using tmpnam to set the output file name of a QPrinter. But the Python documentation recommends against using it.
os.tmpnam()
Return a unique path name that is reasonable for creating a temporary
file. ... Applications are responsible
for properly creating and managing
files created using paths retu... | [
"Please read http://docs.python.org/library/tempfile.html\nUse that instead.\n",
"Depending on how your QPrinter deals with a file that already exists, you could use QTemporaryFile to create a file, then close the file and keep the reference to the QTemporaryFile object around until you are done with it. (This w... | [
7,
0
] | [] | [] | [
"pyqt",
"python",
"qt",
"security"
] | stackoverflow_0001679844_pyqt_python_qt_security.txt |
Q:
Cross-platform way to terminate a process in python
When I try to kill a process in windows with the subprocess.Popen.terminate() or kill() commands, I get an access denied error. I really need a cross-platform way to terminate the process if the file no longer exists (Yes, I know it's not the most elegant way of... | Cross-platform way to terminate a process in python | When I try to kill a process in windows with the subprocess.Popen.terminate() or kill() commands, I get an access denied error. I really need a cross-platform way to terminate the process if the file no longer exists (Yes, I know it's not the most elegant way of doing what I'm doing), I don't want to have to use platf... | [
"You can easily make a platform independent call by doing something trivial like:\ntry:\n import win32\n def kill(param):\n # the code from S.Lotts link\nexcept ImportError:\n def kill(param):\n # the unix way\n\nWhy this doesn't exist in python by default I don't know, but there are very sim... | [
2
] | [] | [] | [
"python",
"terminate"
] | stackoverflow_0001682447_python_terminate.txt |
Q:
How to write a stub for a classmethod in Python
I have a method which calls for a classmethod of another class
def get_interface_params_by_mac(self, host, mac_unified):
lines = RemoteCommand.remote_command(host, cls.IFCONFIG)
...
class RemoteCommand(object):
@classmethod
def remote_command(cls, h... | How to write a stub for a classmethod in Python | I have a method which calls for a classmethod of another class
def get_interface_params_by_mac(self, host, mac_unified):
lines = RemoteCommand.remote_command(host, cls.IFCONFIG)
...
class RemoteCommand(object):
@classmethod
def remote_command(cls, host, cmd, sh = None):
...
I'm going to write a u... | [
"Your unit-test code (maybe in its setUp method, if this is needed across several test methods and thus qualifies as a fixture) should do:\ndef fake_command(cls, host, cmd, sh=None):\n pass # whatever you want in here\nself.save_remote_command = somemodule.RemoteCommand.remote_command\nsomemodule.RemoteCommand.re... | [
7
] | [] | [] | [
"python",
"unit_testing"
] | stackoverflow_0001682504_python_unit_testing.txt |
Q:
What are cycles ? in relation to python
im using the fantastic eric4 ide to code python, it's got a tool built in called 'cyclops', which is apparently looking for cycles. After running it, it gives me a bunch of big bold red letters declaring there to be a multitude of cycles in my code. The problem is the output... | What are cycles ? in relation to python | im using the fantastic eric4 ide to code python, it's got a tool built in called 'cyclops', which is apparently looking for cycles. After running it, it gives me a bunch of big bold red letters declaring there to be a multitude of cycles in my code. The problem is the output is nearly indecipherable, there's no way im ... | [
"A cycle (or \"references loop\") is two or more objects referring to each other, e.g.:\nalist = []\nanoth = [alist]\nalist.append(anoth)\n\nor\nclass Child(object): pass\n\nclass Parent(object): pass\n\nc = Child()\np = Parent()\nc.parent = p\np.child = c\n\nOf course, these are extremely simple examples with cycl... | [
4,
1
] | [] | [] | [
"cycle",
"python"
] | stackoverflow_0001682657_cycle_python.txt |
Q:
Getting Easting & Northing Values from geopy
I have a table full of longitude/ latitude pairs in decimal format (e.g., -41.547, 23.456). I want to display the values in "Easting and Northing"/ UTM format. Does geopy provide a way to convert from decimal to UTM? I see in the code that it will parse UTM values, but ... | Getting Easting & Northing Values from geopy | I have a table full of longitude/ latitude pairs in decimal format (e.g., -41.547, 23.456). I want to display the values in "Easting and Northing"/ UTM format. Does geopy provide a way to convert from decimal to UTM? I see in the code that it will parse UTM values, but I don't see how to get them back out and the geopy... | [
"Nope. You need to reproject your points, and geopy isn't going to do that for you.\nWhat you need is libgdal and some Python bindings. I always use the bindings in GeoDjango, but there are other alternatives.\nEDIT: It is just a mathematical formula, but it's non-trivial. There are thousands of different ways to r... | [
2,
0
] | [] | [] | [
"formats",
"geocoding",
"geopy",
"python"
] | stackoverflow_0001647408_formats_geocoding_geopy_python.txt |
Q:
Embedding Python Design
There are lots of tutorials/instructions on how to embed python in an application, but nothing (that I've seen) on overall design for how the embedded interpreter should be used and interact with the application.
The only idea I could think of would be to simply give the user a method (menu... | Embedding Python Design | There are lots of tutorials/instructions on how to embed python in an application, but nothing (that I've seen) on overall design for how the embedded interpreter should be used and interact with the application.
The only idea I could think of would be to simply give the user a method (menu option, etc) of executing sc... | [
"The only idea I could think of would be to simply give the user a method (menu option, etc) of executing scripts in the program.\nCorrect.\nSo certain classes, functions, objects, etc. would be exported to python, some script would do something, then said script could be run from the program.\nCorrect.\nWould such... | [
1
] | [] | [] | [
"embedding",
"python"
] | stackoverflow_0001682831_embedding_python.txt |
Q:
Django: Blank Choices in Many To Many Fields
When making forms in Django, the IntegerField comes with a blank choice (a bunch of dashes "------") if called with blank=True and null=True. Is there any way to get ManyToManyField to include such an explicit blank choice?
I've tried subclassing ManyToManyField with n... | Django: Blank Choices in Many To Many Fields | When making forms in Django, the IntegerField comes with a blank choice (a bunch of dashes "------") if called with blank=True and null=True. Is there any way to get ManyToManyField to include such an explicit blank choice?
I've tried subclassing ManyToManyField with no success:
class ManyFieldWithBlank(ManyToManyFiel... | [
"That is not really an improvement on the interface, IMO.\nWhy not have a button in your template saying \"none of these\" or \"reset choices\"? Better yet - if your field is called \"Blah\" make the button say \"Unselect all Blah\".\nThe button would just have some javascript to clear out any selection in the sele... | [
4
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001682537_django_python.txt |
Q:
Sorting Lists of List of Dictionaries
I've just read in a file that is something like:
name: john, jane
car: db9, m5
food: pizza, lasagne
Each of these rows (names, car, food) are in order of who owns what. Therefore John owns the car 'DB9' and his favourite food is 'Pizza'. Likewise with Jane, her car is an 'M5'... | Sorting Lists of List of Dictionaries | I've just read in a file that is something like:
name: john, jane
car: db9, m5
food: pizza, lasagne
Each of these rows (names, car, food) are in order of who owns what. Therefore John owns the car 'DB9' and his favourite food is 'Pizza'. Likewise with Jane, her car is an 'M5' and her favourite food is 'Lasagne'.
I ef... | [
"Looks like you want something like:\nimport collections\n\ndata = '''name: john, jane\ncar: db9, m5\nfood: pizza, lasagne\n'''\n\npersonal_list = collections.defaultdict(dict)\n\nfor line in data.splitlines():\n key, _, info = line.partition(':')\n infos = info.split(',')\n key = key.strip().title()\n for i, i... | [
3,
1,
1,
1
] | [] | [] | [
"dictionary",
"list",
"python",
"sorting"
] | stackoverflow_0001682506_dictionary_list_python_sorting.txt |
Q:
Google Apps Engine mail fetch
How can I fetch mails from gmail account in Google Apps Engine Django application?
A:
Configure your app to receive email, then, if it really has to be a gmail address, set up the gmail address to forward everything to your appspot address.
A:
You could cronjob rss feed to gmail ... | Google Apps Engine mail fetch | How can I fetch mails from gmail account in Google Apps Engine Django application?
| [
"Configure your app to receive email, then, if it really has to be a gmail address, set up the gmail address to forward everything to your appspot address.\n",
"You could cronjob rss feed to gmail messages?\ngmail rss\npython cron\n",
"I would use libgmail -- seems to be the most popular pure-Python way to do i... | [
3,
0,
0
] | [
"Just use the Python's standard POP or IMAP client. Google does not provide a GMail API.\n"
] | [
-1
] | [
"gmail",
"google_app_engine",
"python"
] | stackoverflow_0001680856_gmail_google_app_engine_python.txt |
Q:
Can I use Django's Generic Views with google-app-engine-django?
Put simply, is there a way to get generic views to work?
If I try the following in urls.py:
publisher_info = {
'queryset': Publisher.objects.all(),
}
urlpatterns = patterns('',
(r'^publishers/$', list_detail.object_list, publisher_info)
)
I ge... | Can I use Django's Generic Views with google-app-engine-django? | Put simply, is there a way to get generic views to work?
If I try the following in urls.py:
publisher_info = {
'queryset': Publisher.objects.all(),
}
urlpatterns = patterns('',
(r'^publishers/$', list_detail.object_list, publisher_info)
)
I get the following error:
AttributeError at /publishers 'Query'
object ... | [
"It looks like this project should provide that functionality as a core feature.\nhttp://code.google.com/p/app-engine-patch/\n",
"The answer seems to be No.\n"
] | [
1,
1
] | [] | [] | [
"django",
"django_generic_views",
"django_models",
"google_app_engine",
"python"
] | stackoverflow_0001572255_django_django_generic_views_django_models_google_app_engine_python.txt |
Q:
website load testing Python script
I am after a Python script to help me load test my Google App Engine website. I want to give it a set of URLs and a request rate (would need to use threads) and then measure the response times of my website.
I have had a look at a few solutions but they don't let you set an upper... | website load testing Python script | I am after a Python script to help me load test my Google App Engine website. I want to give it a set of URLs and a request rate (would need to use threads) and then measure the response times of my website.
I have had a look at a few solutions but they don't let you set an upper limit for the request rate.
Any ideas?
... | [
"You don't need a python script for this, you want to use the apache tool ab.\nhttp://httpd.apache.org/docs/2.0/programs/ab.html\nIt is the canonical load testing solution, and will get you great metrics for performance. You can set the request rate, but should really look at the concurrency level which is a far mo... | [
3,
3
] | [] | [] | [
"google_app_engine",
"load_testing",
"python",
"web"
] | stackoverflow_0001683342_google_app_engine_load_testing_python_web.txt |
Q:
'getattr(): attribute name must be string' error in admin panel for a model with an ImageField
I have the following model set up:
class UserProfile(models.Model):
"Additional attributes for users."
url = models.URLField()
location = models.CharField(max_length=100)
user = models.ForeignKey(User, un... | 'getattr(): attribute name must be string' error in admin panel for a model with an ImageField | I have the following model set up:
class UserProfile(models.Model):
"Additional attributes for users."
url = models.URLField()
location = models.CharField(max_length=100)
user = models.ForeignKey(User, unique=True)
avatar = models.ImageField(upload_to='/home/something/www/avatars', height_field=80, ... | [
"Your problem is with height_field=80 and width_field=80 these should not contain the height and width you require but rather the names of fields in your model that can have the values for height and width save in them.\nAs explained in the Django documentation for the ImagedField these are attributes on your model... | [
23,
9
] | [] | [] | [
"django",
"django_admin",
"django_models",
"python"
] | stackoverflow_0001683362_django_django_admin_django_models_python.txt |
Q:
How to defer a Django DB operation from within Twisted?
I have a normal Django site running. In addition, there is another twisted process, which listens for Jabber presence notifications and updates the Django DB using Django's ORM.
So far it works as I just call the corresponding Django models (after having set ... | How to defer a Django DB operation from within Twisted? | I have a normal Django site running. In addition, there is another twisted process, which listens for Jabber presence notifications and updates the Django DB using Django's ORM.
So far it works as I just call the corresponding Django models (after having set up the settings environment correctly). This, however, blocks... | [
"\"I have a normal Django site running.\"\nPresumably under Apache using mod_wsgi or similar.\nIf you're using mod_wsgi embedded in Apache, note that Apache is multi-threaded and your Python threads are mashed into Apache's threading. Analysis of what's blocking could get icky.\nIf you're using mod_wsgi in daemon ... | [
1,
1,
0
] | [] | [] | [
"deferred_execution",
"django",
"python",
"twisted"
] | stackoverflow_0001642392_deferred_execution_django_python_twisted.txt |
Q:
What does the ** maths operator do in Python?
What does this mean in Python:
sock.recvfrom(2**16)
I know what sock is, and I get the gist of the recvfrom function, but what the heck is 2**16? Specifically, the two asterisk/double asterisk operator?
(english keywords, because it's hard to search for this: times-t... | What does the ** maths operator do in Python? | What does this mean in Python:
sock.recvfrom(2**16)
I know what sock is, and I get the gist of the recvfrom function, but what the heck is 2**16? Specifically, the two asterisk/double asterisk operator?
(english keywords, because it's hard to search for this: times-times star-star asterisk-asterisk double-times doubl... | [
"It is the power operator.\nFrom the Python 3 docs: \n\nThe power operator has the same semantics as the built-in pow() function, when called with two arguments: it yields its left argument raised to the power of its right argument. The numeric arguments are first converted to a common type, and the result is of th... | [
55,
14,
6,
4,
1
] | [] | [] | [
"operators",
"python",
"syntax"
] | stackoverflow_0001683008_operators_python_syntax.txt |
Q:
Sort a multidimensional list by a variable number of keys
I've read this post and is hasn't ended up working for me.
Edit: the functionality I'm describing is just like the sorting function in Excel... if that makes it any clearer
Here's my situation, I have a tab-delimited text document. There are about 125,000 l... | Sort a multidimensional list by a variable number of keys | I've read this post and is hasn't ended up working for me.
Edit: the functionality I'm describing is just like the sorting function in Excel... if that makes it any clearer
Here's my situation, I have a tab-delimited text document. There are about 125,000 lines and 6 columns per line (columns are separated by a tab cha... | [
"import operator:\ndef sortByColumn(bigList, *args)\n bigList.sort(key=operator.itemgetter(*args)) # sorts the list in place\n\n",
"This will sort by columns 2 and 3:\na.sort(key=operator.itemgetter(2,3))\n\n",
"The key idea here (pun intended) is to use a key function that returns a tuple.\nBelow, the key f... | [
11,
8,
2,
1
] | [] | [] | [
"python",
"sorting"
] | stackoverflow_0001683775_python_sorting.txt |
Q:
Limitations of TEMP directory in Windows?
I have an application written in Python that's writing large amounts of data to the %TEMP% folder. Oddly, every once and awhile, it dies, returning IOError: [Errno 28] No space left on device. The drive has plenty of free space, %TEMP% is not its own partition, I'm an ad... | Limitations of TEMP directory in Windows? | I have an application written in Python that's writing large amounts of data to the %TEMP% folder. Oddly, every once and awhile, it dies, returning IOError: [Errno 28] No space left on device. The drive has plenty of free space, %TEMP% is not its own partition, I'm an administrator, and the system has no quotas.
Does... | [
"What is the exact error you encounter?\nAre you creating too many temp files?\n\nThe GetTempFileName method will raise\n an IOException if it is used to\n create more than 65535 files without \n deleting previous temporary files.\nThe GetTempFileName method will raise\n an IOException if no unique temporary\... | [
11,
2,
1,
0
] | [] | [] | [
"python",
"temporary_files",
"windows"
] | stackoverflow_0001683831_python_temporary_files_windows.txt |
Q:
Django: Streaming dynamically generated XML output through an HttpResponse
recently I wanted to return through a Django view a dynamically generated XML tree. The module I use for XML manipulation is the usual cElementTree.
I think I tackled what I wanted by doing the following:
def view1(request):
resp = Http... | Django: Streaming dynamically generated XML output through an HttpResponse | recently I wanted to return through a Django view a dynamically generated XML tree. The module I use for XML manipulation is the usual cElementTree.
I think I tackled what I wanted by doing the following:
def view1(request):
resp = HttpResponse(g())
return resp
def g():
root = Element("ist")
list_sta... | [
"About middlewares \"breaking\" streaming:\nCommonMiddleware will try to consume the whole iterator if you set USE_ETAGS = True in settings. But in modern Django (1.1) there's a better way to do conditional get than CommonMiddleware + ConditionalGetMiddleware -- condition decorator. Use that and your streaming will... | [
11,
2,
2,
2
] | [] | [] | [
"django",
"python",
"xml"
] | stackoverflow_0001683144_django_python_xml.txt |
Q:
Acessing other py file's class
I have two files:
a.py
b.py
How can I access my ABC123 class defined in a.py from b.py?
A:
import a
x = a.ABC123()
or
from a import ABC123
x = ABC123()
will do the job, as long as a.py and b.py are in the same directory, or if a.py is in a directory in sys.path or in a directory ... | Acessing other py file's class | I have two files:
a.py
b.py
How can I access my ABC123 class defined in a.py from b.py?
| [
"import a\nx = a.ABC123()\n\nor\nfrom a import ABC123\nx = ABC123()\n\nwill do the job, as long as a.py and b.py are in the same directory, or if a.py is in a directory in sys.path or in a directory in your environment's $PYTHONPATH. If neither of those is the case, you might want to read up on relative imports in... | [
10,
2
] | [] | [] | [
"python"
] | stackoverflow_0001684274_python.txt |
Q:
org.apache.commons.lang.StringEscapeUtils in python
is there any python module or code that implements the org.apache.commons.lang.StringEscapeUtils.escapeHtml ?
exactly the same as in http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String)
i googled around bu... | org.apache.commons.lang.StringEscapeUtils in python | is there any python module or code that implements the org.apache.commons.lang.StringEscapeUtils.escapeHtml ?
exactly the same as in http://commons.apache.org/lang/api/org/apache/commons/lang/StringEscapeUtils.html#escapeHtml(java.lang.String)
i googled around but could only find the cgi.escape function that doesn't do... | [
"This is for XML and not for HTML, but it might fit your needs: Escaping XML\n>>> from xml.sax.saxutils import escape\n>>>\n>>> escape(\"< & >\")\n'< & >'\n\n"
] | [
1
] | [] | [] | [
"apache",
"apache_commons",
"java",
"python"
] | stackoverflow_0001683965_apache_apache_commons_java_python.txt |
Q:
Uploading to the cheeseshop different versions of a package for different versions of Python
I have an open-source Python project (called GarlicSim), and I maintain 4 different versions of it for Python versions 2.4, 2.5, 2.6 and 3.1. Yes, maybe it's unusual, but I like using as much features as possible. I keep t... | Uploading to the cheeseshop different versions of a package for different versions of Python | I have an open-source Python project (called GarlicSim), and I maintain 4 different versions of it for Python versions 2.4, 2.5, 2.6 and 3.1. Yes, maybe it's unusual, but I like using as much features as possible. I keep them in 4 different forks of the repository.
Now I want to upload my project to the cheeseshop. Wha... | [
"python2.4 setup.py bdist_egg upload\npython2.5 setup.py bdist_egg upload\npython2.6 setup.py bdist_egg upload\npython3.1 setup.py bdist_egg upload\n\n"
] | [
3
] | [] | [] | [
"distribution",
"distutils",
"pypi",
"python",
"python_3.x"
] | stackoverflow_0001684173_distribution_distutils_pypi_python_python_3.x.txt |
Q:
Python .pyc files removal in django app
i have a following solution structure in python:
main_app
main_app/template_processor/
main_app/template_processor/models
main_app/template_processor/views
everything works just fine on my local machine. as soon as code gets to server (it stopped working after i removed all... | Python .pyc files removal in django app | i have a following solution structure in python:
main_app
main_app/template_processor/
main_app/template_processor/models
main_app/template_processor/views
everything works just fine on my local machine. as soon as code gets to server (it stopped working after i removed all .pyc files from svn), it doesn't see the ass... | [
"Sounds like Django isn't seeing that module (folder, in this case) for some reason. Make sure all the folders have a file called __init__.py (notice the two underscores before and after). Once that's done, make sure it's listed in your installed apps.\nMaybe you made some change to it that's causing it to stop loa... | [
1,
1,
1,
0
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0001683695_django_django_models_python.txt |
Q:
How to set attributes using property decorators?
This code returns an error: AttributeError: can't set attribute
This is really a pity because I would like to use properties instead of calling the methods. Does anyone know why this simple example is not working?
#!/usr/bin/python2.6
class Bar( object ):
"""
... | How to set attributes using property decorators? | This code returns an error: AttributeError: can't set attribute
This is really a pity because I would like to use properties instead of calling the methods. Does anyone know why this simple example is not working?
#!/usr/bin/python2.6
class Bar( object ):
"""
...
"""
@property
def value():
... | [
"Is this what you want?\nclass C(object):\n def __init__(self):\n self._x = None\n\n @property\n def x(self):\n \"\"\"I'm the 'x' property.\"\"\"\n return self._x\n\n @x.setter\n def x(self, value):\n self._x = value\n\nTaken from http://docs.python.org/library/functions.h... | [
155
] | [] | [] | [
"python"
] | stackoverflow_0001684828_python.txt |
Q:
Call Ruby or Python API in C# .NET
I have a lot of APIs/Classes that I have developed in Ruby and Python that I would like to use in my .NET apps. Is it possible to instantiate a Ruby or Python Object in C# and call its methods?
It seems that libraries like IronPython do the opposite of this. Meaning, they allow P... | Call Ruby or Python API in C# .NET | I have a lot of APIs/Classes that I have developed in Ruby and Python that I would like to use in my .NET apps. Is it possible to instantiate a Ruby or Python Object in C# and call its methods?
It seems that libraries like IronPython do the opposite of this. Meaning, they allow Python to utilize .NET objects, but not t... | [
"This is one of the two things that the Dynamic Language Runtime is supposed to do: everybody thinks that the DLR is only for language implementors to make it easier to implement dynamic languages on the CLI. But, it is also for application writers, to make it easier to host dynamic languages in their applications.... | [
9,
3,
1
] | [
"I have seen ways to call into Ruby / Python from c#. But it's easier the other way around.\n"
] | [
-1
] | [
".net",
"c#",
"python",
"ruby"
] | stackoverflow_0001684145_.net_c#_python_ruby.txt |
Q:
Transactions behaviour when request times out. [google app engine]
Google app engine has this useful little function in its db class,
db.run_in_transaction()
Which is suppose to garentee that your method will be rolled back if an exception is raised. "If the function raises an exception, the transaction is rolle... | Transactions behaviour when request times out. [google app engine] | Google app engine has this useful little function in its db class,
db.run_in_transaction()
Which is suppose to garentee that your method will be rolled back if an exception is raised. "If the function raises an exception, the transaction is rolled back."
What happens if my request times out in the middle of its execu... | [
"Yes, the timeout raises an exception, so that also will mean a rollback.\n"
] | [
2
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0001685329_google_app_engine_python.txt |
Q:
how to write regex for below format using python
I want to validate below data using regex and python.
Below is the dump of the data which Can be stored in string variable
Start 0 .......... group=..... name=...... number=.... end=(digits)
Start 1 .......... group=..... name=...... number=.... end=(digits)
Star... | how to write regex for below format using python | I want to validate below data using regex and python.
Below is the dump of the data which Can be stored in string variable
Start 0 .......... group=..... name=...... number=.... end=(digits)
Start 1 .......... group=..... name=...... number=.... end=(digits)
Start 2 .......... group=..... name=...... number=.... en... | [
"You could use r'(Start \\d+.*?group=.*?name=.*?number=.*?end=\\d+)*'.\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0001685558_python.txt |
Q:
Python mechanize - two buttons of type 'submit'
I have a mechanize script written in python that fills out a web form and is supposed to click on the 'create' button. But there's a problem, the form has two buttons. One for 'add attached file' and one for 'create'. Both are of type 'submit', and the attach button ... | Python mechanize - two buttons of type 'submit' | I have a mechanize script written in python that fills out a web form and is supposed to click on the 'create' button. But there's a problem, the form has two buttons. One for 'add attached file' and one for 'create'. Both are of type 'submit', and the attach button is the first one listed. So when I select the forum a... | [
"I tried using the nr parameter, without any luck.\nI was able to get it to work with a combination of the name and label parameters, where \"label\" seems to correspond to the \"value\" in the HTML:\nHere are my two submit buttons:\n<input type=\"submit\" name=\"Preview\" value=\"Preview\" />\n<input type=\"submit... | [
22,
7,
5,
2
] | [] | [] | [
"mechanize",
"python"
] | stackoverflow_0000734893_mechanize_python.txt |
Q:
Debugging the reading of output of a Windows console app using Python
This question is very similar to this one. I want to read output from a console app of mine. The app does not terminate, nor does it take input from stdin.
When I modify rix0rrr's solution to execute my app and then run his solution, Python hang... | Debugging the reading of output of a Windows console app using Python | This question is very similar to this one. I want to read output from a console app of mine. The app does not terminate, nor does it take input from stdin.
When I modify rix0rrr's solution to execute my app and then run his solution, Python hangs because read(1) does not return. The initial output of the app is "Starti... | [
"The very first thing I would check is the buffering in app.exe. If \"Starting the server.\\n\" is being buffered and doesn't make it to the pipe, there is nothing you can do on the reader's side.\nSo, try adding fflush(stdout) after printf(\"Starting the server.\\n\").\n"
] | [
1
] | [] | [] | [
"popen",
"process",
"python",
"windows"
] | stackoverflow_0001684995_popen_process_python_windows.txt |
Q:
How to execute os.* methods as root?
Is it possible to ask for a root pw without storing in in my script memory and to run some of os.* commands as root?
My script
scans some folders and files to check if it can do the job
makes some changes in /etc/...
creates a folder and files that should be owned by the user ... | How to execute os.* methods as root? | Is it possible to ask for a root pw without storing in in my script memory and to run some of os.* commands as root?
My script
scans some folders and files to check if it can do the job
makes some changes in /etc/...
creates a folder and files that should be owned by the user who ran the script
(1) can be done as a n... | [
"Maybe you can put (2) in a separate script, say script2.py, and in the main script you call sudo script2.py with a popen ? \nThis way only (2) will be executed as root.\n",
"yourscript.py:\nrun_part_1()\nsubprocess.call(['sudo', sys.executable, 'part2.py'])\nrun_part_3()\n\npart2.py:\nrun_part_2()\n\n",
"Would... | [
2,
2,
1,
1,
1
] | [] | [] | [
"python",
"root",
"sudo"
] | stackoverflow_0001636136_python_root_sudo.txt |
Q:
Auto run unit test cases in Python
We have a python based web application along with its unit test cases. Our need is to automate the process of running unit test cases. They should run either after every checking OR after every fixed time interval. With minimal effort and time what is best tool that we can use to... | Auto run unit test cases in Python | We have a python based web application along with its unit test cases. Our need is to automate the process of running unit test cases. They should run either after every checking OR after every fixed time interval. With minimal effort and time what is best tool that we can use to automate this process. We are using Lin... | [
"You're basically looking for continuous integration tools and processes (I mention the term of art because it helps you research the subject in more depth). buildbot is the most popular Python system for the purpose and I would recommend it -- see here for more.\n",
"Hudson is a good choice for this - I've used... | [
3,
2,
1
] | [] | [] | [
"automation",
"python",
"unit_testing"
] | stackoverflow_0001685885_automation_python_unit_testing.txt |
Q:
Is this possible?
I've got a class Foo that's a running thread, what I'd like to do is limit how much class Bar can access of Foo while still having access to Foo's internals, is that possible?
A:
Python is a strongly, dynamically typed language. What this means is:
Objects are strongly typed which means an int... | Is this possible? | I've got a class Foo that's a running thread, what I'd like to do is limit how much class Bar can access of Foo while still having access to Foo's internals, is that possible?
| [
"Python is a strongly, dynamically typed language. What this means is:\n\nObjects are strongly typed which means an integer is an integer and can't be treated as anything else unless you say so. Objects have a specific type and stay that way.\nYou can use a name (a variable) to refer to an object, but the name does... | [
2,
0
] | [] | [] | [
"python"
] | stackoverflow_0001686194_python.txt |
Q:
Matrix data structure
A simple 2 dimensional array allows swapping rows (or columns) in a matrix in O(1) time. Is there an efficient data structure that would allow swapping both rows and columns of a matrix in O(1) time?
A:
You have to store your matrix either as a list of rows or list of columns. Which gives e... | Matrix data structure | A simple 2 dimensional array allows swapping rows (or columns) in a matrix in O(1) time. Is there an efficient data structure that would allow swapping both rows and columns of a matrix in O(1) time?
| [
"You have to store your matrix either as a list of rows or list of columns. Which gives either swapping of rows or swapping of columns in O(1).\nHowever, you can add another layer on top of it to handle column order so that you can reorder columns in O(1).\nSo for every access you need to do:\nx = data[row][colorde... | [
4,
0
] | [] | [] | [
"matrix",
"python"
] | stackoverflow_0001686162_matrix_python.txt |
Q:
Python ClientForm Error
import ClientForm
from urllib2 import urlopen
page = urlopen('http://garciainteractive.com/blog/topic_view/topics/content/')
form = ClientForm.ParseResponse(page, backwards_compat=False)
print form[0]
The problem is that ClientForm parses the first html form the following way:
<POST ht... | Python ClientForm Error | import ClientForm
from urllib2 import urlopen
page = urlopen('http://garciainteractive.com/blog/topic_view/topics/content/')
form = ClientForm.ParseResponse(page, backwards_compat=False)
print form[0]
The problem is that ClientForm parses the first html form the following way:
<POST http://garciainteractive.com/bl... | [
"The problem is likely that the HTML itself is invalid - for example it re-uses the id=\"comment_form\" over and over again, while there is only supposed to be one id of a given name per document.\nYour best solution would probably be to use BeautifulSoup to parse your urlopen page result first, then pretty-print i... | [
1,
1
] | [] | [] | [
"clientform",
"python"
] | stackoverflow_0001681150_clientform_python.txt |
Q:
Django Forms not rendering ModelChoiceField's query set
I have the following ModelForm:
class AttendanceForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
operation_id = kwargs['operation_id']
del kwargs['operation_id']
super(AttendanceForm, self).__init__(*args, **kwargs)
... | Django Forms not rendering ModelChoiceField's query set | I have the following ModelForm:
class AttendanceForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
operation_id = kwargs['operation_id']
del kwargs['operation_id']
super(AttendanceForm, self).__init__(*args, **kwargs)
self.fields['deployment'].query_set = \
Deplo... | [
"The parameter is queryset, not query_set. See the documentation.\n"
] | [
4
] | [] | [] | [
"django",
"django_forms",
"python"
] | stackoverflow_0001686292_django_django_forms_python.txt |
Q:
How to remove extended ascii using python?
In trying to fix up a PML (Palm Markup Language) file, it appears as if my test file has non-ASCII characters which is causing MakeBook to complain. The solution would be to strip out all the non-ASCII chars in the PML.
So in attempting to fix this in python, I have
impor... | How to remove extended ascii using python? | In trying to fix up a PML (Palm Markup Language) file, it appears as if my test file has non-ASCII characters which is causing MakeBook to complain. The solution would be to strip out all the non-ASCII chars in the PML.
So in attempting to fix this in python, I have
import unicodedata, fileinput
for line in fileinput.... | [
"Try print line.decode('iso-8859-1').encode('ascii', 'ignore') -- that should be much closer to what you want.\n",
"You would like to treat line as ASCII-encoded data, so the answer is to decode it to text using the ascii codec:\nline.decode('ascii')\nThis will raise errors for data that is not in fact ASCII-enco... | [
5,
4,
2,
0
] | [] | [] | [
"ascii",
"extended_ascii",
"python"
] | stackoverflow_0001685681_ascii_extended_ascii_python.txt |
Q:
Weighted average of angles
I want to calculate the weighted mean of a set of angles.
In this Question, there's an answer how to calculate the mean
as shown in this page.
Now I'm trying to figure out how to calculate the weighted average.
That is, for each angle there is a weight (the weights sum up to 1)
0.25, 0 d... | Weighted average of angles | I want to calculate the weighted mean of a set of angles.
In this Question, there's an answer how to calculate the mean
as shown in this page.
Now I'm trying to figure out how to calculate the weighted average.
That is, for each angle there is a weight (the weights sum up to 1)
0.25, 0 degrees
0.5, 20 degrees
0.25, 90... | [
"OK, my attemp was to just multiply the values with the weights:\ndef circular_mean(weights, angles):\n x = y = 0.\n for angle, weight in zip(angles, weights):\n x += math.cos(math.radians(angle)) * weight\n y += math.sin(math.radians(angle)) * weight\n\n mean = math.degrees(math.atan2(y, x))... | [
6,
1
] | [] | [] | [
"algorithm",
"mean",
"python"
] | stackoverflow_0001686994_algorithm_mean_python.txt |
Q:
How can I tell if a given method is a classmethod or instancemethod in Python?
Checking to see if m.im_self is the class works some of the time but doesn't seem to be 100% reliable (ex. if you use multiple decorators on a method.)
A:
If it's a bound method on the class then it's a classmethod.
from inspect impo... | How can I tell if a given method is a classmethod or instancemethod in Python? | Checking to see if m.im_self is the class works some of the time but doesn't seem to be 100% reliable (ex. if you use multiple decorators on a method.)
| [
"If it's a bound method on the class then it's a classmethod. \nfrom inspect import ismethod, isclass\ndef isclassmethod( m ):\n return ismethod(m) and isclass(m.__self__)\n\n"
] | [
2
] | [] | [] | [
"class",
"python"
] | stackoverflow_0001687531_class_python.txt |
Q:
Why does an assignment for double-sliced numpy arrays not work?
why do the following lines not work as I expect?
import numpy as np
a = np.array([0,1,2,1,1])
a[a==1][1:] = 3
print a
>>> [0 1 2 1 1]
# I would expect [0 1 2 3 3]
Is this a 'bug' or is there another recommended way to this?
On the other hand, the fol... | Why does an assignment for double-sliced numpy arrays not work? | why do the following lines not work as I expect?
import numpy as np
a = np.array([0,1,2,1,1])
a[a==1][1:] = 3
print a
>>> [0 1 2 1 1]
# I would expect [0 1 2 3 3]
Is this a 'bug' or is there another recommended way to this?
On the other hand, the following works:
a[a==1] = 3
print a
>>> [0 3 2 3 3]
Cheers, Philipp
| [
"It's related to how fancy indexing works. There is a thorough explanation here. It is done this way to allow inplace modification with fancy indexing (ie a[x>3] *= 2). A consequence of this is that you can't assign to a double index as you have found. Fancy indexing always returns a copy rather than a view.\n",
... | [
10,
9,
3,
0
] | [] | [] | [
"numpy",
"python",
"slice",
"variable_assignment"
] | stackoverflow_0001687566_numpy_python_slice_variable_assignment.txt |
Q:
Django Formsets - form.is_valid() is False preventing formset validation
I'm am utilizing a formset to enable users subscribe to multiple feeds. I require a) Users chose a subscription by selecting a boolean field, and are also required to tag the subscription and b) a user must subscribe to an specified number of... | Django Formsets - form.is_valid() is False preventing formset validation | I'm am utilizing a formset to enable users subscribe to multiple feeds. I require a) Users chose a subscription by selecting a boolean field, and are also required to tag the subscription and b) a user must subscribe to an specified number of subscriptions.
Currently the below code is capable of a) ensuring the users t... | [
"Solved. Below is a quick run through of the solution.\nReporting the error required manipulating and formating a special error message. In the source code for formsets I found the errors that apply to a whole form are known as non_form_errors and produced a custom error based on this. [note: I couldn't find any au... | [
3,
0
] | [] | [] | [
"django",
"django_forms",
"python"
] | stackoverflow_0001682069_django_django_forms_python.txt |
Q:
Python app distribution cross-platform
I want to distribute my app on OSX (using py2app) and as a Debian package.
The structure of my app is like:
app/
debian/
<lots of debian related stuff>
scripts/
app
app/
__init__.py
app.py
mod1/
... | Python app distribution cross-platform | I want to distribute my app on OSX (using py2app) and as a Debian package.
The structure of my app is like:
app/
debian/
<lots of debian related stuff>
scripts/
app
app/
__init__.py
app.py
mod1/
__init__.py
a.py
mod2... | [
"I'm not sure if this is the 'best practice' or not (I've not put much python software into proper distribution), but I would just make sure that the top-level app package was in sys.path. Something like putting the following into the top-level __init__.py:\ntry:\n import myapp\nexcept ImportError:\n import ... | [
5
] | [] | [] | [
"cross_platform",
"py2app",
"python",
"setuptools"
] | stackoverflow_0001688105_cross_platform_py2app_python_setuptools.txt |
Q:
Why am I getting a little-endian error when importing .so file in python
Im attempting to use a C++ extension for Python called PySndObj. and getting an error I have never seen and cannot find anything about on the web :(
ImportError: /home/nhnifong/SndObj-2.6.6/python/_sndobj.so: ELF file data encoding not little... | Why am I getting a little-endian error when importing .so file in python | Im attempting to use a C++ extension for Python called PySndObj. and getting an error I have never seen and cannot find anything about on the web :(
ImportError: /home/nhnifong/SndObj-2.6.6/python/_sndobj.so: ELF file data encoding not little-endian
I know that probably means the byte order is backwards, So I tried wri... | [
"You have to build the extension from source yourself.\nIt was valiant of you to try and \"reverse the bytes\", but only certain sections of the ELF file have word-oriented (as opposed to byte-oriented) data.\nFurthermore, it's unlikely that the dll in question was compiled for your system's CPU architecture.\n"
] | [
4
] | [] | [] | [
"import",
"python"
] | stackoverflow_0001688845_import_python.txt |
Q:
How do you call PyObjC code from Objective-C?
Possible Duplicate:
Calling Python from Objective-C
I'm a long-time Python programmer and short-time Cocoa programmer. I'm just getting started with PyObjC and it's really amazing how easy it it is to get stuff done. That said, I wanted to try using pure ObjC for my ... | How do you call PyObjC code from Objective-C? |
Possible Duplicate:
Calling Python from Objective-C
I'm a long-time Python programmer and short-time Cocoa programmer. I'm just getting started with PyObjC and it's really amazing how easy it it is to get stuff done. That said, I wanted to try using pure ObjC for my controller with PyObjC models. I might be enjoy le... | [
"There are several possible approaches. The most tempting is to use py2app to compile a loadable bundle from your python code from which you can access the principal class using NSBundle. Unfortunately, this use case hasn't gotten much love from the py2app developers, and I've found several bugs in 10.5 and 10.6, i... | [
3,
0
] | [] | [] | [
"cocoa",
"objective_c",
"pyobjc",
"python"
] | stackoverflow_0001689012_cocoa_objective_c_pyobjc_python.txt |
Q:
python image recognition
what I want to do is a image recognition for a simple app:
given image (500 x 500) pxs ( 1 color background )
the image will have only 1 geometric figure (triangle or square or smaleyface :) ) of (50x50) pxs.
python will do the recognition of the figure and display what geometric figure i... | python image recognition | what I want to do is a image recognition for a simple app:
given image (500 x 500) pxs ( 1 color background )
the image will have only 1 geometric figure (triangle or square or smaleyface :) ) of (50x50) pxs.
python will do the recognition of the figure and display what geometric figure is.
any links? any hints? any ... | [
"A typical python tool chain would be:\n\nread your images with with PIL \ntransform them into Numpy arrays\nuse Scipy's image filters (linear and rank, morphological) to implement your solution\n\nAs far differentiating the shapes, I would obtain its silhouette by looking at the shape of the background. I would th... | [
32,
10,
3,
2
] | [] | [] | [
"algorithm",
"image",
"image_processing",
"python",
"python_imaging_library"
] | stackoverflow_0001603688_algorithm_image_image_processing_python_python_imaging_library.txt |
Q:
What can cause select to block in Python?
Here's a snippet of code I'm using in a loop:
while True:
print 'loop'
rlist, wlist, xlist = select.select(readers, [], [], TIMEOUT)
print 'selected'
# do stuff
At a certain point, select will block and "selected" is never getting printed. What can cause ... | What can cause select to block in Python? | Here's a snippet of code I'm using in a loop:
while True:
print 'loop'
rlist, wlist, xlist = select.select(readers, [], [], TIMEOUT)
print 'selected'
# do stuff
At a certain point, select will block and "selected" is never getting printed. What can cause this behavior? Is it possible there's some kin... | [
"Yes, depending on the OS in question, it is indeed possible for a certain file descriptor to block at OS level in a non-interruptible way even though you've explicitly demanded for it to be non-blocking. Depending on your OS, there may be workarounds to these OS-level bugs (or \"misfeatures\"), but to offer any f... | [
2,
1
] | [] | [] | [
"asynchronous",
"python",
"select",
"sockets"
] | stackoverflow_0001689182_asynchronous_python_select_sockets.txt |
Q:
What's the easiest way of finding a child instance from a parent instance in Django?
My application uses class inheritance to minimize repetition across my models. My models.py looks kind of like this:
class BaseModel(models.Model):
title = models.CharField(max_length=100)
pub_date = models.DateField()
cla... | What's the easiest way of finding a child instance from a parent instance in Django? | My application uses class inheritance to minimize repetition across my models. My models.py looks kind of like this:
class BaseModel(models.Model):
title = models.CharField(max_length=100)
pub_date = models.DateField()
class Child(BaseModel):
foo = models.CharField(max_length=20)
class SecondChild(BaseModel... | [
"I haven't tested this, but it might be worth tinkering with:\ndef get_absolute_url(self):\n subclasses = ('child', 'secondchild', )\n\n for subclass in subclasses:\n if hasattr(self, subclass):\n return getattr(self, subclass).get_absolute_url()\n\n return '/base/%i' % self.id\n\n",
"I... | [
0,
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001683711_django_python.txt |
Q:
Is there a more succinct / pythonic way to do this? (counting longest seq of heads, tails in coin flips)
Count the longest sequence of heads and tails in 200 coin flips.
I did this - is there a niftier way to do it in python? (without being too obfuscated)
import random
def toss(n):
count = [0,0]
longest... | Is there a more succinct / pythonic way to do this? (counting longest seq of heads, tails in coin flips) | Count the longest sequence of heads and tails in 200 coin flips.
I did this - is there a niftier way to do it in python? (without being too obfuscated)
import random
def toss(n):
count = [0,0]
longest = [0,0]
for i in xrange(n):
coinface = random.randrange(2)
count[coinface] += 1
c... | [
"def coins(num):\n lst = [random.randrange(2) for i in range(num)]\n lst = [(i, len(list(j))) for i, j in itertools.groupby(lst)]\n tails = max(j for i, j in lst if i)\n heads = max(j for i, j in lst if not i)\n return {1: tails, 0: heads}\n\n",
"import collections, itertools, random\n\ndef makeseq... | [
11,
11,
7,
3,
2,
2,
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0001689032_python.txt |
Q:
Embedding Gnash into PyGame?
Is there a way to display flash applications using Gnash renderer (I'm not averse to Adobe's renderer but would prefer not to use it) in a PyGame application?
A:
Does Gnash allow drawing to an SDL_Surface? If so, Pygame has a C API that would make gluing these together easy. If not y... | Embedding Gnash into PyGame? | Is there a way to display flash applications using Gnash renderer (I'm not averse to Adobe's renderer but would prefer not to use it) in a PyGame application?
| [
"Does Gnash allow drawing to an SDL_Surface? If so, Pygame has a C API that would make gluing these together easy. If not your best bet will be Pygame's frombuffer command. This will interepret a raw block of data as an image. You'll still need some way of getting that pointer from Gnash to your Python code. \n"
] | [
0
] | [] | [] | [
"flash",
"gnash",
"pygame",
"python"
] | stackoverflow_0001685969_flash_gnash_pygame_python.txt |
Q:
Overhead of a Round-trip to MySql?
So I've been building django applications for a while now, and drinking the cool-aid and all: only using the ORM and never writing custom SQL.
The main page of the site (the primary interface where users will spend 80% - 90% of their time) was getting slow once you have a large a... | Overhead of a Round-trip to MySql? | So I've been building django applications for a while now, and drinking the cool-aid and all: only using the ORM and never writing custom SQL.
The main page of the site (the primary interface where users will spend 80% - 90% of their time) was getting slow once you have a large amount of user specific content (ie photo... | [
"Just because you are using an ORM doesn't mean that you shouldn't do performance tuning. \nI had - like you - a home page of one of my applications that had low performance. I saw that I was doing hundreds of queries to display that page. I went looking at my code and realized that with some careful use of select_... | [
4,
3,
2,
1
] | [] | [] | [
"django",
"mysql",
"overhead",
"python"
] | stackoverflow_0001689031_django_mysql_overhead_python.txt |
Q:
handling multiple returned objects
I have a contact/address app that allows users to search the database for contact entries. The current view will return an object (Entry()) and display its fields. The code is as follows:
def search_page(request):
form = SearchForm()
entrylinks = []
show_results = ... | handling multiple returned objects | I have a contact/address app that allows users to search the database for contact entries. The current view will return an object (Entry()) and display its fields. The code is as follows:
def search_page(request):
form = SearchForm()
entrylinks = []
show_results = True
if request.GET.has_key('query'... | [
"The object returned by Entry.objects.filter (a QuerySet) has a length, meaning you can call len(entrylinks) to get the number of records returned. Thus, you can do something like this:\nif len(entrylinks) == 1:\n tpl = \"search.html\"\nelse:\n tpl = \"select.html\"\nvariables = RequestContext(request, {\n ... | [
2,
1
] | [] | [] | [
"django",
"django_views",
"python"
] | stackoverflow_0001689122_django_django_views_python.txt |
Q:
In Python 2.6.4, why do I get a syntax error for a function call, of which the function is defined and works perfectly on its own?
This happens in IDLE and Windows 7 RC1 (if that helps). Here is the module:
from math import *
from TurtleWorld import *
world = TurtleWorld()
bob = Turtle()
bob.delay = 0.1
def ... | In Python 2.6.4, why do I get a syntax error for a function call, of which the function is defined and works perfectly on its own? | This happens in IDLE and Windows 7 RC1 (if that helps). Here is the module:
from math import *
from TurtleWorld import *
world = TurtleWorld()
bob = Turtle()
bob.delay = 0.1
def polyline(turtle, length, n, angle):
for i in range(n):
fd(turtle, length)
rt(turtle, angle)
def polygon(turtle, len... | [
"At quick glance are you missing a closing parenthesis at the end of the line before you call spokes()?\nlength_of_spoke = length_of_side/(2*sin(pi/180*angle/2))\n\ninstead of\nlength_of_spoke = length_of_side/(2*sin(pi/180*angle/2)\n\n",
"The previous line is missing a closing parenthesis. It should read like t... | [
3,
2,
2,
2
] | [] | [] | [
"python",
"python_idle",
"syntax"
] | stackoverflow_0001689594_python_python_idle_syntax.txt |
Q:
Tool like 2to3, except for merges
I maintain a fork of my project for Python 3.1. When I initially made the port from 2.6, I used 2to3, but now I constantly have to merge new code from the 2.6 fork into the 3.1 fork. How can I perform the 2to3 operation on these merges automatically? (I use git, if it matters.)
A... | Tool like 2to3, except for merges | I maintain a fork of my project for Python 3.1. When I initially made the port from 2.6, I used 2to3, but now I constantly have to merge new code from the 2.6 fork into the 3.1 fork. How can I perform the 2to3 operation on these merges automatically? (I use git, if it matters.)
| [
"Hmmm, you are in a tough position. Perhaps you could run 2to3 on the 2.6 fork, then merge the results of that into your 3.1 branch?\nAlternatively, perhaps this pain will make you reconsider your strategy of maintaining two distinct branches for the two Python versions? I've had good luck using a single codebase ... | [
7
] | [] | [] | [
"merge",
"python",
"python_2to3",
"python_3.x"
] | stackoverflow_0001689548_merge_python_python_2to3_python_3.x.txt |
Q:
Generating Separate Output files in Hadoop Streaming
Using only a mapper (a Python script) and no reducer, how can I output a separate file with the key as the filename, for each line of output, rather than having long files of output?
A:
The input and outputformat classes can be replaced by use of the -inputfor... | Generating Separate Output files in Hadoop Streaming | Using only a mapper (a Python script) and no reducer, how can I output a separate file with the key as the filename, for each line of output, rather than having long files of output?
| [
"The input and outputformat classes can be replaced by use of the -inputformat and -outputformat commandline parameters.\nOne example of how to do this can be found in the dumbo project, which is a python framework for writing streaming jobs. It has a feature for writing to multiple files, and internally it replace... | [
7,
1,
1
] | [] | [] | [
"hadoop",
"mapreduce",
"python",
"streaming"
] | stackoverflow_0001626786_hadoop_mapreduce_python_streaming.txt |
Q:
What technologies are good for sending encapsulated data, and later converting it, between Python and Objective-C?
I'm attempting to create a client/server web-app. The client software is written in Objective-C (Mac), and the server software is written in Python (Linux). I'd like to encapsulate object data on ei... | What technologies are good for sending encapsulated data, and later converting it, between Python and Objective-C? | I'm attempting to create a client/server web-app. The client software is written in Objective-C (Mac), and the server software is written in Python (Linux). I'd like to encapsulate object data on either side, and send it across the internet to the other side. This will include standard types such as strings, doubles... | [
"If you're talking about a traditional browser based web app, then I'd probably stick with JSON or XML serialization.\nFor anything else I'd suggest drum roll please...\nGoogle Protocol Buffers\nSmall, fast, and has a decent set of providers for different languages.\n",
"Might check out a piece of technology call... | [
2,
1,
1
] | [] | [] | [
"encapsulation",
"objective_c",
"python"
] | stackoverflow_0001690080_encapsulation_objective_c_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.