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:
IPC between python app and injected DLL
Hello stack overflow: Sometimes reader, first time poster.
Background:
Windows box running XP SP3, soon to be upgraded to Windows Seven (MSDNAA <3)
I have an injected DLL which gets cycles by hooking a function that is called thousands of times a second.
I would like to co... | IPC between python app and injected DLL | Hello stack overflow: Sometimes reader, first time poster.
Background:
Windows box running XP SP3, soon to be upgraded to Windows Seven (MSDNAA <3)
I have an injected DLL which gets cycles by hooking a function that is called thousands of times a second.
I would like to communicate/control this DLL via a python app. ... | [
"Try sockets. Your demands are essentially a requirement of asynchronous operating; Python has asyncore module for asynchronous IO on sockets. At the same time, it doesn't look like Python's stdlib can asynchronously handle other IPC things, so I'd not recommend using them.\n",
"If you don't care about realtime, ... | [
2,
1
] | [] | [] | [
"code_injection",
"dll",
"ipc",
"python"
] | stackoverflow_0002049467_code_injection_dll_ipc_python.txt |
Q:
Django and root processes
In my Django project I need to be able to check whether a host on the LAN is up using an ICMP ping. I found this SO question which answers how to ping something in Python and this SO question which links to resources explaining how to use the sodoers file.
The Setting
A Device model store... | Django and root processes | In my Django project I need to be able to check whether a host on the LAN is up using an ICMP ping. I found this SO question which answers how to ping something in Python and this SO question which links to resources explaining how to use the sodoers file.
The Setting
A Device model stores an IP address for a host on t... | [
"Absolutely no way, do not run the Django code as root! \nI would run a daemon as root (written in Python, why not) and then IPC between the Django instance and your daemon. As long as you're sure to validate the content and properly handle it (e.g. use subprocess.call with an array etc) and only pass in data (not... | [
7,
2,
1
] | [] | [] | [
"django",
"django_views",
"ping",
"python",
"root"
] | stackoverflow_0004748971_django_django_views_ping_python_root.txt |
Q:
Calling a def as a function in a Mako template
I'd like to use a def as a function, and call it from an if block:
<%def name="check(foo)">
% if len(foo.things) == 0:
return False
% else:
% for thing in foo.things:
% if thing.status == 'active':
return True
... | Calling a def as a function in a Mako template | I'd like to use a def as a function, and call it from an if block:
<%def name="check(foo)">
% if len(foo.things) == 0:
return False
% else:
% for thing in foo.things:
% if thing.status == 'active':
return True
% endif
% endfor
% endif
retur... | [
"Just define the whole function in plain Python:\n<%!\ndef check(foo):\n return not foo\n%>\n%if check([]):\n works\n%endif\n\nOr you could just define the function in Python and pass it to the context.\n",
"Yes, using plain Python syntax in the def works:\n<%def name=\"check(foo)\">\n <%\n if len(foo.t... | [
7,
2
] | [] | [] | [
"function",
"mako",
"python"
] | stackoverflow_0004749458_function_mako_python.txt |
Q:
MySql not comparing utf-8 strings correctly?
I know it sounds weird, but look at this:
mysql> select * from tbl_list_charset where word='aê';
+------+
| word |
+------+
| aª |
+------+
The data is coming from a file with utf-8 strings, which a python program reads and inserts into the table. As word column is d... | MySql not comparing utf-8 strings correctly? | I know it sounds weird, but look at this:
mysql> select * from tbl_list_charset where word='aê';
+------+
| word |
+------+
| aª |
+------+
The data is coming from a file with utf-8 strings, which a python program reads and inserts into the table. As word column is defined unique, the insertion of aê fails.
The utf-... | [
"Do you also use UTF-8 with the mysql client program as well as in your Python application ?\nI.e. call mysql --default-character-set=utf8 and in Python issue at least one SET NAMES='utf8' before doing any other queries ?\n",
"The collation determines which characters compare as \"equal\". And yes, there's quite ... | [
1,
1
] | [] | [] | [
"character_encoding",
"linux",
"mysql",
"python",
"utf_8"
] | stackoverflow_0004749898_character_encoding_linux_mysql_python_utf_8.txt |
Q:
Specify action to be performed at the end of many functions
I have a python object in which a bunch of functions need to perform the same action at the end of execution, just before the return statement. For example:
def MyClass(object):
def __init__(self):
pass
def update_everything(self):
... | Specify action to be performed at the end of many functions | I have a python object in which a bunch of functions need to perform the same action at the end of execution, just before the return statement. For example:
def MyClass(object):
def __init__(self):
pass
def update_everything(self):
'''update everything'''
pass
def f1(self):
... | [
"I think that any solution to your problem would be unpythonic, because (as Tim Peters says in the Zen of Python (import this)):\nExplicit is better than implicit.\n\n",
"Yes, using a decorator is actually more code, but it does have the advantage that you can see that a method updates everything at a glance. It'... | [
6,
3,
2
] | [] | [] | [
"oop",
"python"
] | stackoverflow_0004749060_oop_python.txt |
Q:
Lock free read only List in Python?
I've done some basic performance and memory consumption benchmarks and I was wondering if there is any way to make things even faster...
I have a giant 70,000 element list with a numpy ndarray, and the file path in a tuple in the said list.
My first version passed a sliced up c... | Lock free read only List in Python? | I've done some basic performance and memory consumption benchmarks and I was wondering if there is any way to make things even faster...
I have a giant 70,000 element list with a numpy ndarray, and the file path in a tuple in the said list.
My first version passed a sliced up copy of the list to each of the processes ... | [
"The multiprocessing module provides exactly what you need: a shared array with optional locking, namely the multiprocessing.Array class. Pass lock=False to the constructor to disable locking.\nEdit (taking into account your update): Things are actually considerably more involved than I initially expected. The d... | [
11
] | [] | [] | [
"numpy",
"performance",
"python"
] | stackoverflow_0004750141_numpy_performance_python.txt |
Q:
find and replace within a filename
I am running a script which throws and error if a filename has a '.' or a '+' in it, so i am trying to make a script which replaces all of the '.' with '_', replacing the '+' works fine. But the problem with replacing the '.' is that if i dont split the file - then all of my file... | find and replace within a filename | I am running a script which throws and error if a filename has a '.' or a '+' in it, so i am trying to make a script which replaces all of the '.' with '_', replacing the '+' works fine. But the problem with replacing the '.' is that if i dont split the file - then all of my files get deleted!! So i have tried splittin... | [
"why are you using glob inside the os.walk for loop and also overwriting the filename_zero variable?\nfor root, dirs, filenames in os.walk(folder): \n for filename in filenames:\n filename_split = os.path.splitext(filename) # filename and extensionname (extension in [1])\n filename_zero = filename_... | [
1,
1
] | [] | [] | [
"filenames",
"python",
"replace"
] | stackoverflow_0004746574_filenames_python_replace.txt |
Q:
How to patch Python in order to insert BreakPoints using IDLE on MAC
A patch issue6075_py3k.patch from bugs.python.org is supposed to fix this problem. In the terminal, I copied the patch file into Idlelib directory where Bindings.py and EditorWindow.py are located and proceeded by typing patch -p2 issue6075_py3k.... | How to patch Python in order to insert BreakPoints using IDLE on MAC | A patch issue6075_py3k.patch from bugs.python.org is supposed to fix this problem. In the terminal, I copied the patch file into Idlelib directory where Bindings.py and EditorWindow.py are located and proceeded by typing patch -p2 issue6075_py3k.patch. The patch was successful. I fired up IDLE and I still can't use Bre... | [
"Which version of Python did you patch? And which directory? There are various reason why it might not work. Make sure you are trying to use it correctly. You need to left click on a source line in an IDLE editor window while holding the Control key to set a breakpoint there. Then you'll need to enable the IDLE ... | [
2
] | [] | [] | [
"macos",
"python",
"python_idle"
] | stackoverflow_0004750161_macos_python_python_idle.txt |
Q:
Convert ctime to unicode and unicode to ctime python
I have converted a ctime value to unicode
1295478503.6789999
to
'Wed Jan 19 18:08:23 2011'
Can I go backwards?
From the second line to the first?
A:
You want the Python time module, specifically the strptime() function. (How'd you convert from ctime to unico... | Convert ctime to unicode and unicode to ctime python | I have converted a ctime value to unicode
1295478503.6789999
to
'Wed Jan 19 18:08:23 2011'
Can I go backwards?
From the second line to the first?
| [
"You want the Python time module, specifically the strptime() function. (How'd you convert from ctime to unicode/string? Probably with time.strftime(). So it makes sense to look for the inverse direction of that, which is time.strptime().)\nHere's a good Google query for this, too: http://www.google.com/search?q=... | [
5,
4
] | [] | [] | [
"ctime",
"python",
"unicode"
] | stackoverflow_0004750522_ctime_python_unicode.txt |
Q:
Finding combinations of stems and endings
I have mappings of "stems" and "endings" (may not be the correct words) that look like so:
all_endings = {
'birth': set(['place', 'day', 'mark']),
'snow': set(['plow', 'storm', 'flake', 'man']),
'shoe': set(['lace', 'string', 'maker']),
'lock': set(['down', 'up', 'smi... | Finding combinations of stems and endings | I have mappings of "stems" and "endings" (may not be the correct words) that look like so:
all_endings = {
'birth': set(['place', 'day', 'mark']),
'snow': set(['plow', 'storm', 'flake', 'man']),
'shoe': set(['lace', 'string', 'maker']),
'lock': set(['down', 'up', 'smith']),
'crack': set(['down', 'up',]),
'arm': ... | [
"It's not particularly pretty, but this is quite straightforward if you break your dictionary down into two lists, and use explicit indices:\nall_stems = {\n 'chair' : set(['high', 'arm']),\n 'charge': set(['over', 'under']),\n 'fall' : set(['down', 'water', 'night']),\n 'up' : set(['lock', 'crack', 'vote']),\n... | [
4,
3,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004749418_python.txt |
Q:
pyQt - how to make a widgets selection based on QGroupBox
In my application,
I have three same QGroupBoxes with some pushbuttons.
I want to have same names for pushbuttons and acces to them through QGroupBox name.
Is that possible?
QGroupBox_one.button_export
QGroupBox_one.button_import
QGroupBox_two.button_expo... | pyQt - how to make a widgets selection based on QGroupBox | In my application,
I have three same QGroupBoxes with some pushbuttons.
I want to have same names for pushbuttons and acces to them through QGroupBox name.
Is that possible?
QGroupBox_one.button_export
QGroupBox_one.button_import
QGroupBox_two.button_export
QGroupBox_two.button_import
Than I could make method with Q... | [
"I think a clean way of doing what you want is making a new class (MyQGroupBoxes) that has the push buttons and the configure method you need.\nfrom PyQt4 import QtGui\n\nclass MyQGroupBoxes(QtGui.QGroupBox):\n def __init__(self, parent):\n QtGui.QGroupBox.__init__(self, parent)\n\n self.button_exp... | [
1
] | [] | [] | [
"pyqt",
"python",
"qt"
] | stackoverflow_0004748533_pyqt_python_qt.txt |
Q:
python tarfile without full path
I made a small script as below to read group of files and tar them, its all working fine accept that the compressed file contain full path of the files when uncompressed. Is there a way to do it without the directory structure?
compressor = tarfile.open(PATH_TO_ARCHIVE + re.sub('[\... | python tarfile without full path | I made a small script as below to read group of files and tar them, its all working fine accept that the compressed file contain full path of the files when uncompressed. Is there a way to do it without the directory structure?
compressor = tarfile.open(PATH_TO_ARCHIVE + re.sub('[\s.:"-]+', '',
str(datetime.dateti... | [
"Take a look at the TarFile.add signature:\n\n... If given, arcname specifies an alternative name for the file in the archive. \n\n",
"I created a context manager for changing the current working directory fo handling this with tar files.\nimport contextlib\n@contextlib.contextmanager\ndef cd_change(tmp_location)... | [
8,
2
] | [] | [] | [
"django",
"python",
"tar"
] | stackoverflow_0004751008_django_python_tar.txt |
Q:
libraries in python and upnp
I want to develop some protocols that helps in the functioning of UPNP(universal plug and play) and simple service discovery protocol. I need to find the libraries for python and upnp so that I can read them and it becomes easy for me to understand when i used them. Please provide me t... | libraries in python and upnp | I want to develop some protocols that helps in the functioning of UPNP(universal plug and play) and simple service discovery protocol. I need to find the libraries for python and upnp so that I can read them and it becomes easy for me to understand when i used them. Please provide me the links for it.
| [
"MiniUPnP is a popular UPnP library with Python hooks. For Python libraries, look in the Python distribution. Mine are in /usr/lib/python2.6 and /usr/lib/python3.1. There are libraries galore to read there.\n"
] | [
2
] | [] | [] | [
"python",
"service",
"service_discovery",
"upnp"
] | stackoverflow_0004751213_python_service_service_discovery_upnp.txt |
Q:
How to fix unicode issue when using a web service with Python Suds
I am trying to work with the HORRIBLE web services at Commission Junction (CJ). I can get the client to connect and receive information from CJ, but their database seems to include a bunch of bad characters that cause a UnicideDecodeError.
Right ... | How to fix unicode issue when using a web service with Python Suds | I am trying to work with the HORRIBLE web services at Commission Junction (CJ). I can get the client to connect and receive information from CJ, but their database seems to include a bunch of bad characters that cause a UnicideDecodeError.
Right now I am doing:
from suds.client import Client
wsdlLink = 'https://link-... | [
"Implicit UnicodeDecodeErrors is something you get when trying to add str and unicode objects. Python will then try to decode the str into unicode, but using the ASCII encoding. If your str then contains anything that is not ascii, you will get this error.\nYour solution is the decode it manually like so:\nthestrin... | [
3,
1,
0
] | [] | [] | [
"python",
"soap",
"suds",
"wsdl"
] | stackoverflow_0004703546_python_soap_suds_wsdl.txt |
Q:
Whats wrong with an assignment
what's wrong?
File "trunk/website/auth/user/emailchange/views.py" in email_change_view
102. context['form'] = form
File "/usr/local/lib/python2.6/dist-packages/django/template/context.py" in __setitem__
39. self.dicts[-1][key] = value
Exception Type: TypeError at /accou... | Whats wrong with an assignment | what's wrong?
File "trunk/website/auth/user/emailchange/views.py" in email_change_view
102. context['form'] = form
File "/usr/local/lib/python2.6/dist-packages/django/template/context.py" in __setitem__
39. self.dicts[-1][key] = value
Exception Type: TypeError at /accounts/email/change/
Exception Value: '... | [
"Add form to extra_context dic, not context.\nThe error is literally saying, context['form'] is invalid, so it's a good place to start wondering if RequestContext should be used in that fashion.\nRequestContext docs: http://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.RequestContext\nelse:\n ... | [
2
] | [] | [] | [
"django",
"python",
"web"
] | stackoverflow_0004751425_django_python_web.txt |
Q:
Understanding of CPU seconds
consider following example:
import hotshot
import hotshot.stats
import time
def test_sleep():
time.sleep(1)
def main():
prof = hotshot.Profile("lol.prof")
prof.runcall(test_sleep)
prof.close()
stats = hotshot.stats.load("lol.prof")
stats.sort_stats("time", "c... | Understanding of CPU seconds | consider following example:
import hotshot
import hotshot.stats
import time
def test_sleep():
time.sleep(1)
def main():
prof = hotshot.Profile("lol.prof")
prof.runcall(test_sleep)
prof.close()
stats = hotshot.stats.load("lol.prof")
stats.sort_stats("time", "calls")
stats.print_stats(20)
... | [
"That sounds like a HotShot bug -- it's not getting CPU time from the OS, it's getting elapsed time (and maybe subtracting out I/O wait time, which would be zero in this case). If you do time python lol.py you'll see that you're not in a busy wait.\n"
] | [
1
] | [] | [] | [
"cpu_usage",
"profile",
"python"
] | stackoverflow_0004751545_cpu_usage_profile_python.txt |
Q:
Parsing HTML in Google App Engine in python with BeautifulSoup?
I've been using BeautifulSoup to parse HTML from several sites adding each site to the GAE task queue. However the task queue seems to repeat 2 tasks which seem to either generate ApplicationError: 5 error's in the log or fails with a 'NoneType' objec... | Parsing HTML in Google App Engine in python with BeautifulSoup? | I've been using BeautifulSoup to parse HTML from several sites adding each site to the GAE task queue. However the task queue seems to repeat 2 tasks which seem to either generate ApplicationError: 5 error's in the log or fails with a 'NoneType' object has no attribute 'findAll', which when I tested it on IDLE generate... | [
"The application error probably indicates that your urlfetch to retrieve the HTML has failed. The task queue will automatically retry the task until it succeeds (if used with the default settings). I wouldn't worry too much about this error if it only occurs once in a while and goes away after being retried. If ... | [
2
] | [] | [] | [
"beautifulsoup",
"google_app_engine",
"html_parsing",
"python"
] | stackoverflow_0004751577_beautifulsoup_google_app_engine_html_parsing_python.txt |
Q:
How to generate a Banyan network for n-inputs
I'm trying to understand how one might automatically generate a Banyan Network for n-inputs in code. I haven't been able to get much help from my research so far.
This is what a 8-input banyan network looks like..
How do I model each node in code? is there an algorit... | How to generate a Banyan network for n-inputs | I'm trying to understand how one might automatically generate a Banyan Network for n-inputs in code. I haven't been able to get much help from my research so far.
This is what a 8-input banyan network looks like..
How do I model each node in code? is there an algorithm I can use to generate the nodes and paths for an... | [
"Perhaps nothing related to Banyan network itself, but since Python tagged you could check if networkx could provide any help to your problem. At least it makes easy to implement the network itself.\n"
] | [
1
] | [] | [] | [
"networking",
"python",
"routing",
"switching"
] | stackoverflow_0004751915_networking_python_routing_switching.txt |
Q:
all list values same
In Python, is the a simple way to test that all values in a list are equal to one another?
A:
Many ways come to mind. You could turn it in a set (which filters out duplicates) and check for length of oneEdit: As another poster noted, this only works with hashable types; I revoke the suggesti... | all list values same | In Python, is the a simple way to test that all values in a list are equal to one another?
| [
"Many ways come to mind. You could turn it in a set (which filters out duplicates) and check for length of oneEdit: As another poster noted, this only works with hashable types; I revoke the suggestion as it has worse performance and is less general.\nYou could use a generator expression: all(items[0] == item for i... | [
42,
13,
3,
1
] | [] | [] | [
"list",
"python"
] | stackoverflow_0004752294_list_python.txt |
Q:
How to determine content type of a string
I receive some data as a string. I need to write the data to a file, but the problem is that sometimes the data is compressed/zipped and sometimes it's just plain text. I need to determine the content-type so I know whether to write it to a .txt file or a .tgz file. Any... | How to determine content type of a string | I receive some data as a string. I need to write the data to a file, but the problem is that sometimes the data is compressed/zipped and sometimes it's just plain text. I need to determine the content-type so I know whether to write it to a .txt file or a .tgz file. Any ideas on how to accomplish this? Can I use mi... | [
"If the file is downloaded from a webserver, you should have a content-type to look at, however you are at the mercy of the webserver whether or not it truly describes the type of the file.\nAnother alternative would be to use a heuristic to guess the file type. This can often be done by looking at the first few by... | [
1,
1,
1,
0
] | [] | [] | [
"content_type",
"python",
"string"
] | stackoverflow_0004752451_content_type_python_string.txt |
Q:
Track small differences in 5 files with Mercurial?
I have five httpd.conf files which differ only in the port number that they are listening on. All of the other data between the sites is the same. Is there any way to track this as a single file in Mercurial? So that if I make a different change to the httpd.conf ... | Track small differences in 5 files with Mercurial? | I have five httpd.conf files which differ only in the port number that they are listening on. All of the other data between the sites is the same. Is there any way to track this as a single file in Mercurial? So that if I make a different change to the httpd.conf file, I could push this to all five, and keep the port n... | [
"Consider using the include directive in your httpd.conf files. Then you can keep each of the 5 very small and keep all the common stuff in a separate file.\n",
"Why not just use the Include directive for the single part that differs? It's just a dumb, lexical \"put that file here\" kinda deal so should be idea f... | [
6,
4,
1
] | [] | [] | [
"apache",
"dvcs",
"mercurial",
"python"
] | stackoverflow_0004752695_apache_dvcs_mercurial_python.txt |
Q:
Determine position of values in dictionary, Python
There is a dictionary that may include keys starting from 0 and values: a, b, c, d, e. Each time the values may be assigned to different keys keys. Size of the dictionary may change as well.
I am interested in two values. Let's call them b and d.
Is there any algo... | Determine position of values in dictionary, Python | There is a dictionary that may include keys starting from 0 and values: a, b, c, d, e. Each time the values may be assigned to different keys keys. Size of the dictionary may change as well.
I am interested in two values. Let's call them b and d.
Is there any algorithm that determine situations when b appears earlier t... | [
"A dictionary has no order. So your wording \"b's key is smaller than d's\" is the right one.\nNow, it looks like you could swap keys and values...\n",
"If the values are hashable then you could generate a reverse dictionary and check the values. Otherwise, you'll need to brute-force it.\ndef dictfind(din, tsent,... | [
5,
1,
0,
0,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0004427981_dictionary_python.txt |
Q:
changes inside try-except persist after exception is caught
Since I've learned of exception-handling the first time (not in Python), I was under the impression that when you begin a try block, it's like you start writing in a sandbox: if an exception occurs, everything that happened inside the try block will be li... | changes inside try-except persist after exception is caught |
Since I've learned of exception-handling the first time (not in Python), I was under the impression that when you begin a try block, it's like you start writing in a sandbox: if an exception occurs, everything that happened inside the try block will be like it never happened. To my naive surprise, I noticed this isn't... | [
"You just discovered that exceptions are not a silver bullet for error handling.\nExceptions do not protect you from state changes... whatever was completed without errors before the exception is thrown will have to be undone. This is how exception work in Python, C++, Java and many other languages as well.\nSometi... | [
7,
2,
2,
2
] | [] | [] | [
"exception_handling",
"python"
] | stackoverflow_0004752356_exception_handling_python.txt |
Q:
Using distutils to install INTO a chroot'ed environment
I maintain a chrooted Linux image and I have a package that I'd like to install into that chrooted image.
Both packages end up getting installed into both locations; I can't figure out what is going on and how to fix it.
My setup.py:
import os
from distutils.... | Using distutils to install INTO a chroot'ed environment | I maintain a chrooted Linux image and I have a package that I'd like to install into that chrooted image.
Both packages end up getting installed into both locations; I can't figure out what is going on and how to fix it.
My setup.py:
import os
from distutils.core import setup
setup(name='ServerLibrary',
version='1... | [
"I figured out that I needed to specify a different build directory for set of files. distutils was assuming that everything inside 'build' needed to get installed each time.\nHopefully I'll save someone else the trouble of figuring out how to do this. Here's my fixed 2nd part of the script:\nos.chroot('/srv/nfs/ch... | [
1
] | [] | [] | [
"chroot",
"distutils",
"python"
] | stackoverflow_0004753038_chroot_distutils_python.txt |
Q:
How to create arrayType for WSDL in Python (using suds)?
Environment:
Python v2.6.2
suds v0.3.7
The WSDL (server) I work with, have the following schema sub-sections (I tried to write it clearly using plain text) -
[ sub-section #1 ]
searchRequest: (searchRequest){
userIdentification = (userIdentification){... | How to create arrayType for WSDL in Python (using suds)? | Environment:
Python v2.6.2
suds v0.3.7
The WSDL (server) I work with, have the following schema sub-sections (I tried to write it clearly using plain text) -
[ sub-section #1 ]
searchRequest: (searchRequest){
userIdentification = (userIdentification){
username = ""
password = ""
}
iti... | [
"I'm in the same case, with a RPC/encoded style WS and a method that contains a soap array. a print request (where request = client.factory.create('Request')) gives:\n(Request){\n requestid = None\n option = \n (ArrayOfOption){\n _arrayType = \"\"\n _offset = \"\"\n _id = \"\"\n _href = \"\"\n ... | [
6,
4,
3
] | [] | [] | [
"arrays",
"python",
"suds",
"wsdl",
"xml"
] | stackoverflow_0001130819_arrays_python_suds_wsdl_xml.txt |
Q:
Can I create a drop down combo box within a list control in wxPython?
I am creating a wx.ListCtrl (wxPython 2.8.11.0, Python 2.7) with style=wx.LC_REPORT|wx.LC_VRULES|wx.LC_SINGLE_SEL containing a score column (amongst others). Is it possible to make the score for each item (in order of preference):
a drop down l... | Can I create a drop down combo box within a list control in wxPython? | I am creating a wx.ListCtrl (wxPython 2.8.11.0, Python 2.7) with style=wx.LC_REPORT|wx.LC_VRULES|wx.LC_SINGLE_SEL containing a score column (amongst others). Is it possible to make the score for each item (in order of preference):
a drop down list of possible scores
allow for typing into that column only (I am aware o... | [
"You can override the OnBeginEdit and check which column has been clicked in using event.m_col and act accordingly (i.e. event.Veto() or not). I don't think you can do a drop down in the cell itself, but you could create a simple dialog that does the same thing when the user clicks on that column. Or you might want... | [
4
] | [] | [] | [
"cross_platform",
"drop_down_menu",
"list",
"python",
"wxpython"
] | stackoverflow_0004730915_cross_platform_drop_down_menu_list_python_wxpython.txt |
Q:
Django - managing tree structures
I'm using Django with the following (simplified) models:
class Entity(models.Model):
name = models.CharField(max_length=30)
class Person(models.Model):
last_name = models.CharField(max_length=30)
first_name = models.CharField(max_length=30)
entity = models.Foreign... | Django - managing tree structures | I'm using Django with the following (simplified) models:
class Entity(models.Model):
name = models.CharField(max_length=30)
class Person(models.Model):
last_name = models.CharField(max_length=30)
first_name = models.CharField(max_length=30)
entity = models.ForeignKey(Entity)
I'd like to add hierarchy ... | [
"I don't think your alternatives are really mutually exclusive - anything you end up doing will have some database and some non-database elements.\nI'm a big fan of the Modified Pre-Order Tree Traversal algorithm, and its excellent Django implementation, django-mptt.\nIf you're dead set on Nested Sets, though, take... | [
2
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0004752313_django_django_models_python.txt |
Q:
Django ModelForm - name 'Article' is not defined
I have something like this
from django.forms import ModelForm
from django.shortcuts import render_to_response
class ArticleForm(ModelForm):
class Meta:
model = Article
def articl(request):
tykul = ArticleForm()
return render_to_response('test... | Django ModelForm - name 'Article' is not defined | I have something like this
from django.forms import ModelForm
from django.shortcuts import render_to_response
class ArticleForm(ModelForm):
class Meta:
model = Article
def articl(request):
tykul = ArticleForm()
return render_to_response('test.html',{'tykul':tykul.as_ul()})
And this is a result ... | [
"Have you defined an Article model somewhere? Usually it's in models.py in the same folder as your forms.py and views.py, e.g.:\nfrom django.db import models\n\nclass Article(models.Model):\n title = models.CharField(max_length=100)\n text = models.TextField()\n\nOf course, you'll have to import the Article m... | [
7,
2,
2
] | [] | [] | [
"django",
"django_forms",
"python"
] | stackoverflow_0004753159_django_django_forms_python.txt |
Q:
Doing File I/O in Python with non-ASCII Characters
I'm working on a Python script that reads an XML file encoded with UTF-8, does some manipulation with it and saves it to Google's Datastore (it's an App Engine program).
The way I'm reading and parsing the files is just with file.readline() and a few regular expr... | Doing File I/O in Python with non-ASCII Characters | I'm working on a Python script that reads an XML file encoded with UTF-8, does some manipulation with it and saves it to Google's Datastore (it's an App Engine program).
The way I'm reading and parsing the files is just with file.readline() and a few regular expressions. The only problem is that the file I'm working w... | [
"Specify the UTF-8 encoding on str.decode\n>>> print '\\xe2\\x99\\x9e'.decode('utf-8')\n♞\n\nThat's supposed to be a chess piece but it's too tiny to see :)\n",
"You say you changed the encoding you use with the file to ISO-8859-1. Did you try changing it to UTF-8?\n",
"To expand on the answer and with referenc... | [
4,
1,
0
] | [] | [] | [
"file_io",
"google_app_engine",
"localization",
"python"
] | stackoverflow_0004752784_file_io_google_app_engine_localization_python.txt |
Q:
Using python logging package, how to insert additional formatting into multiple logger handlers that have their own formatters?
I have a single logger with multiple handlers, which have their own formatters. Now I want to add an indenting feature, with the indent level controlled at runtime. I want messages from a... | Using python logging package, how to insert additional formatting into multiple logger handlers that have their own formatters? | I have a single logger with multiple handlers, which have their own formatters. Now I want to add an indenting feature, with the indent level controlled at runtime. I want messages from all the handlers to get this indent. I've tried to create it as a filter, but found that I seem to be unable to alter the message cont... | [
"#!/usr/bin/env python\n\nimport logging\nfrom random import randint\n\nlog = logging.getLogger(\"mylog\")\nlog.setLevel(logging.DEBUG)\n\nclass MyFormatter(logging.Formatter):\n def __init__(self, fmt):\n logging.Formatter.__init__(self, fmt)\n\n def format(self, record):\n indent = \" \" * ran... | [
5,
1,
0
] | [] | [] | [
"formatter",
"logging",
"python"
] | stackoverflow_0004742919_formatter_logging_python.txt |
Q:
Python IndexError when trying to go through a large list
I have a list of approximately 200 000+ objects, each one representing a file (but not actually holding the file's contents, just the full path name and date).
The program I am writing copies any subset of these files, depending on the user-provided date ran... | Python IndexError when trying to go through a large list | I have a list of approximately 200 000+ objects, each one representing a file (but not actually holding the file's contents, just the full path name and date).
The program I am writing copies any subset of these files, depending on the user-provided date range. I first create a list of all of the files in the source di... | [
"From the docs:\n\nIt is not safe to modify the sequence being iterated over in the loop (this can only happen for mutable sequence types, such as lists). If you need to modify the list you are iterating over (for example, to duplicate selected items) you must iterate over a copy.\n\nFor your case, I'd actually sug... | [
7,
3,
2,
1,
1,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004752866_python.txt |
Q:
Oracle instant client can't execute sql update
I can connect to a Oracle 10g release 2 server using instant client. Using pyodbc and cx_Oracle.
Using either module, I can execute a select query without any problems, but when I try to update a table, my program crashes.
For example,
SELECT * FROM table WHERE col1 =... | Oracle instant client can't execute sql update | I can connect to a Oracle 10g release 2 server using instant client. Using pyodbc and cx_Oracle.
Using either module, I can execute a select query without any problems, but when I try to update a table, my program crashes.
For example,
SELECT * FROM table WHERE col1 = 'value'; works fine.
UPDATE table SET col2 = 'value... | [
"Use the instant client with SQL*Plus and see if you can run the update. If there's a problem, SQL*Plus is production quality, so won't crash and it should give you a reasonable error message.\n",
"Sounds more like your user you are connecting with doesn't have those privileges on that table. Do you get an ORA e... | [
1,
0
] | [] | [] | [
"cx_oracle",
"instantclient",
"oracle",
"pyodbc",
"python"
] | stackoverflow_0004748962_cx_oracle_instantclient_oracle_pyodbc_python.txt |
Q:
Python class is a subclass of itself, is this ok? Pitfalls?
I am wrapping a large C library using ctypes. ctypesgen generated the wrapping code (not too far from how I do it myself). As a part of the ctypes wrapping C structures get made as objects, some of these have "setters" in C that would be handy to just s... | Python class is a subclass of itself, is this ok? Pitfalls? | I am wrapping a large C library using ctypes. ctypesgen generated the wrapping code (not too far from how I do it myself). As a part of the ctypes wrapping C structures get made as objects, some of these have "setters" in C that would be handy to just subclass itself to use. What are the possible dangers here? Or t... | [
"You should do this simply by assigning some_struct a new __init__ function.\ndef new_init(self):\n self._old_init()\n set_some_struct_defaults(self)\n\nsome_struct.__dict__[\"_old_init\"] = some_struct.__init__\nsome_struct.__init__ = new_init\n\nThis has the advantage that the original __init__ still gets c... | [
2,
0
] | [] | [] | [
"ctypes",
"python"
] | stackoverflow_0004749360_ctypes_python.txt |
Q:
How do I sort using two fields?
I have a sorting/grouping issue that I'm hoping somebody could add some insight on.
We have a table of stories that have a publish date and an updated date. I'm using Django so it looks like this:
class Story(models.Model):
pub_date = models.DateTimeField(db_index=True)
upd... | How do I sort using two fields? | I have a sorting/grouping issue that I'm hoping somebody could add some insight on.
We have a table of stories that have a publish date and an updated date. I'm using Django so it looks like this:
class Story(models.Model):
pub_date = models.DateTimeField(db_index=True)
update_date = models.DateTimeField(blank... | [
"i can only think of \"union\" being able to do this.\nhere's an example of what that would look like. not sure how fast or good it is for the database to have this type of query sent to it often though D:\nthe query assumes your table name is stories, and uses the columns headline, pub_date and update_date. it als... | [
3,
0,
0
] | [] | [] | [
"django",
"group_by",
"python",
"sorting",
"sql"
] | stackoverflow_0004753633_django_group_by_python_sorting_sql.txt |
Q:
setting installation path for python rpm
Can I set the installation path (relative or absolute) for a python rpm's content?
Would I set this in the spec file?
Specifically I am trying to do this for Fedora.
A:
Yes, if you can build a new RPM, you can set it in the spec file. How to do this depends on the packag... | setting installation path for python rpm | Can I set the installation path (relative or absolute) for a python rpm's content?
Would I set this in the spec file?
Specifically I am trying to do this for Fedora.
| [
"Yes, if you can build a new RPM, you can set it in the spec file. How to do this depends on the package, but basically you get the package to install itself into the desired path inside the buildroot.\nProbably the most common way to do that would be by passing PREFIX and DESTDIR to make in the %install target, e... | [
1
] | [] | [] | [
"fedora",
"linux",
"packaging",
"python",
"rpm"
] | stackoverflow_0004754014_fedora_linux_packaging_python_rpm.txt |
Q:
Dynamically instantiate Player class in a loop
I am making a simple Python game. I have a text file with the following on each line:
player name, player IP, player health, player items
I have a loop which goes through each line in the file and get the variables for each player (each line in the text file is a pla... | Dynamically instantiate Player class in a loop | I am making a simple Python game. I have a text file with the following on each line:
player name, player IP, player health, player items
I have a loop which goes through each line in the file and get the variables for each player (each line in the text file is a player).
I have a class called Player, I need one insta... | [
"Sven has a good answer but you can even do away with the first line and just do\nconfig = [line.split(',') for line in open(\"config\")]\n\nOr as you may want to actually instantiate the players:\nconfig = [Player(line.split(',')) for line in open(\"config\")]\n\nIf you're going to be doing a lot more csv configs ... | [
1,
0
] | [] | [] | [
"list",
"loops",
"python"
] | stackoverflow_0004754003_list_loops_python.txt |
Q:
Increasing speed of python list operations and comparisons in a custom table class
I'm using the following class to create a table and I need to find a way to not only make it faster but make interactions with it faster:
class Table(object):
"""a three dimensional table object"""
def __init__(self, xsize=1... | Increasing speed of python list operations and comparisons in a custom table class | I'm using the following class to create a table and I need to find a way to not only make it faster but make interactions with it faster:
class Table(object):
"""a three dimensional table object"""
def __init__(self, xsize=1, ysize=1, zsize=1):
self.xsize = xsize
self.ysize = ysize
self.... | [
"I think yes, by using numpy you can probably gain alot of speed.\nNot only can you make slices but you can make rectangular, and probably cubic slices too, example:\n>>> a = numpy.array([[1,2,3],[4,5,6],[7,8,9]])\n>>> a[:2,1:]\narray([[2, 3],\n [5, 6]])\n\nI'm not sure what you want to accomplish but you can... | [
2,
1
] | [] | [] | [
"arrays",
"numpy",
"python"
] | stackoverflow_0004753738_arrays_numpy_python.txt |
Q:
I don't know the meaning of one character in a Python code
I wonder what is the signification of the ';' sign in the instructions
if l<p:
if t>0:
if int(num)>=int(lst):
in the code of this question:
Optimizing python code
Maybe an error in the third instruction, ';=' instead of '!='
But I can't imagine t... | I don't know the meaning of one character in a Python code | I wonder what is the signification of the ';' sign in the instructions
if l<p:
if t>0:
if int(num)>=int(lst):
in the code of this question:
Optimizing python code
Maybe an error in the third instruction, ';=' instead of '!='
But I can't imagine the signification of the character in the two other lines.
Is the... | [
"This actually should read\nif l<p:\n ...\nif t>0:\n ...\nif int(num)>=int(lst):\n ...\n\nIt results from broken HTML. The characters < and > are represented by the HTML entities < and >, respectively. And somehow the web page you got this from got it wrong.\n"
] | [
19
] | [] | [] | [
"python"
] | stackoverflow_0004754397_python.txt |
Q:
How can I determine if it's ok to change this word... python script
The goal is to read through html files and change all instances of MyWord to Myword; except, must NOT change the word if it is found inside or as part of a path, file name or script:
href="..."
src="..."
url(...)
class="..."
id="..."
script inli... | How can I determine if it's ok to change this word... python script | The goal is to read through html files and change all instances of MyWord to Myword; except, must NOT change the word if it is found inside or as part of a path, file name or script:
href="..."
src="..."
url(...)
class="..."
id="..."
script inline or linked (file name) --> <script ...></script>
styles inline or linke... | [
"lxml helps with this kind of task.\nhtml = \"\"\"\n<html>\n<body>\n <h1>MyWord</h1>\n <a href=\"http://MyWord\">MyWord</a>\n <img src=\"images/MyWord.png\"/>\n <div class=\"MyWord\">\n <p>MyWord!</p>\n MyWord\n </div>\n MyWord\n</body><!-- MyWord -->\n</html>\n\"\"\"\n\nimport lxml.... | [
1,
0
] | [] | [] | [
"file",
"html",
"python"
] | stackoverflow_0004028834_file_html_python.txt |
Q:
Python OverflowError: cannot fit 'long' into an index=sized integer
I want to generate two really large prime numbers using an algorithm I found online and changed slightly.
I get this error on line 5:
Python OverflowError: cannot fit 'long' into an index=sized integer
My code:
import math
def atkin(end):
... | Python OverflowError: cannot fit 'long' into an index=sized integer | I want to generate two really large prime numbers using an algorithm I found online and changed slightly.
I get this error on line 5:
Python OverflowError: cannot fit 'long' into an index=sized integer
My code:
import math
def atkin(end):
if end < 2: return []
lng = ((end/2)-1+end%2)
**sieve = [Tru... | [
"The following code demonstrates the problem that you are running into:\nimport sys\nx = [True]*(sys.maxint+1)\n\nwhich yields an OverflowError. If you instead do:\nx = [True]*(sys.maxint)\n\nthen you should get a MemoryError.\nHere is what is going on. Python can handle arbitrarily large integers with its own exte... | [
19,
1
] | [] | [] | [
"primes",
"python",
"rsa"
] | stackoverflow_0004751725_primes_python_rsa.txt |
Q:
Django and Python handle changing date format
Im importing records from a CSV file into a django model. The CSV file is uploaded by the user. The problem I'm facing is with the date field.
The date field expects the date to be in YYYY-MM-DDbut different spreadsheet programs default to different types of formats an... | Django and Python handle changing date format | Im importing records from a CSV file into a django model. The CSV file is uploaded by the user. The problem I'm facing is with the date field.
The date field expects the date to be in YYYY-MM-DDbut different spreadsheet programs default to different types of formats and I dont want the user to have to change their defa... | [
"When you convert the date string into a datetime object, you'll likely use datetime.strptime with the format argument. I would ask the user what format they use and/or store it in the database (and by that I mean allow them to choose the format they want).\n",
"The best option I've seen for \"fuzy\" date string ... | [
1,
1
] | [] | [] | [
"date",
"django",
"django_models",
"python"
] | stackoverflow_0004754682_date_django_django_models_python.txt |
Q:
Python and OO Programming (class attributes and derived classes)
I have been a Java programmer for 4,5 years. Now I've switched to Python (and the main reason is that I'm now a freelancer and I work alone). I provide source code to my costumers and sometimes I have to motivated my design choices. Now to the questi... | Python and OO Programming (class attributes and derived classes) | I have been a Java programmer for 4,5 years. Now I've switched to Python (and the main reason is that I'm now a freelancer and I work alone). I provide source code to my costumers and sometimes I have to motivated my design choices. Now to the question.
I have to support my design choice:
class Base(object):
def fo... | [
"There does not seem to be any difference whatsoever. Don't waste your time arguing with him -- it might be quicker to just refactor your classes and take the money.\n",
"If the Base class requires the values to do its thing, then it should be explicit.\nIn other programming languages the requirement could be se... | [
3,
0
] | [
"The second snippet could only be called 'elegant' when compared with Java. Not only it's almost twice as long, the use of '__' variables is a clear sign that the programmer is fighting against the language, and there are a lot of possible errors.\nIf you (or your client) wants Java, you know where to find it.\n"
... | [
-5
] | [
"attributes",
"class",
"oop",
"python"
] | stackoverflow_0004754783_attributes_class_oop_python.txt |
Q:
Python, documentation strings within classes
How do I print documentation strings within classes
For functions i can do this:
def func():
"""
doc string
"""
print func.__doc__
Is it possible to do the same thing with a class
class MyClass(object):
def __init__(self):
"""
doc s... | Python, documentation strings within classes | How do I print documentation strings within classes
For functions i can do this:
def func():
"""
doc string
"""
print func.__doc__
Is it possible to do the same thing with a class
class MyClass(object):
def __init__(self):
"""
doc string
"""
i = MyClass()
print i.__doc_... | [
"It's None because the class does not have a docstring. Try adding one:\nclass MyClass(object):\n \"\"\" Documentation for MyClass goes here. \"\"\"\n\n def __init__(self):\n \"\"\"\n doc string\n \"\"\"\n\ni = MyClass() \nprint i.__doc__ # same as MyClass.__doc__\n\n",
"You defined a ... | [
10,
3
] | [] | [] | [
"python"
] | stackoverflow_0004754832_python.txt |
Q:
top-level package handling with setuptools (or another python egg builder)
I am writing a little python app. I want to be able to easily deploy the app. I know that python 2.6 will allow one to execute an egg directly if there is a main module at the egg's root. I actually have that working.
The one kink is that w... | top-level package handling with setuptools (or another python egg builder) | I am writing a little python app. I want to be able to easily deploy the app. I know that python 2.6 will allow one to execute an egg directly if there is a main module at the egg's root. I actually have that working.
The one kink is that when I try to use the argparse library, I cannot include the library in the egg w... | [
"I believe you can create a subdirectory called toplevel and in your entry point do\nimport sys\nsys.path.insert(0, './toplevel')\n\nUntested, though.\n"
] | [
0
] | [] | [] | [
"distutils",
"egg",
"python",
"setuptools"
] | stackoverflow_0004743013_distutils_egg_python_setuptools.txt |
Q:
Is Python's os.path.join slow?
I've been told os.path.join is horribly slow in python and I should use string concatenation ('%s/%s' % (x, y)) instead. Is there really that big a difference and if so how can I track it?
A:
$ python -mtimeit -s 'import os.path' 'os.path.join("/root", "file")'
1000000 loops, best ... | Is Python's os.path.join slow? | I've been told os.path.join is horribly slow in python and I should use string concatenation ('%s/%s' % (x, y)) instead. Is there really that big a difference and if so how can I track it?
| [
"$ python -mtimeit -s 'import os.path' 'os.path.join(\"/root\", \"file\")'\n1000000 loops, best of 3: 1.02 usec per loop\n$ python -mtimeit '\"/root\" + \"file\"'\n10000000 loops, best of 3: 0.0223 usec per loop\n\nSo yes, it's nearly 50 times slower. 1 microsecond is still nothing though, so I really wouldn't fact... | [
12,
8,
3,
1,
1,
0
] | [
"Everyone sholud know one inevident feature of os.path.join()\nos.path.join( 'a', 'b' ) == 'a/b'\nos.path.join( 'a', '/b' ) == '/b'\n\n"
] | [
-2
] | [
"path",
"performance",
"python",
"string"
] | stackoverflow_0004664306_path_performance_python_string.txt |
Q:
Pythonic proportion calculation of two conditions
Here's a really simple question regarding pythonic coding.
Given a list, if you want to calculate the proportion of items satisfying (A and B), out of those satisfying (A), a natural solution would be:
Imagine the list is of integers, condition A is (>3), condition... | Pythonic proportion calculation of two conditions | Here's a really simple question regarding pythonic coding.
Given a list, if you want to calculate the proportion of items satisfying (A and B), out of those satisfying (A), a natural solution would be:
Imagine the list is of integers, condition A is (>3), condition B is (>5)
count = 0
correct = 0
for item in items:
... | [
"Your (alternate) solution is great, except for this small change:\ncount = sum(1 for i in items if i > 3)\ncorrect = sum(1 for i in items if i > 5)\n\nscore = float(correct) / count\nprint '%.2f' % score\n\nThe syntax that looks like a list comprehension without the brackets is called a generator expression.\nI'm ... | [
6,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0004754891_python.txt |
Q:
List of big-O analysis for Python datastructures
Is there a list of the different data structures and their big-O access times for Python?
I was rummaging through the standard library docs and didn't see any, hence the question. :-)
A:
It's not in the manual, it's here on the python wiki.
The table also includes... | List of big-O analysis for Python datastructures | Is there a list of the different data structures and their big-O access times for Python?
I was rummaging through the standard library docs and didn't see any, hence the question. :-)
| [
"It's not in the manual, it's here on the python wiki.\nThe table also includes complexities for methods for the data structures as well. Thanks for asking, I'd never seen this before until I looked for it.\n"
] | [
30
] | [] | [] | [
"data_structures",
"performance",
"python"
] | stackoverflow_0004755221_data_structures_performance_python.txt |
Q:
How to use Qt Delegates for custom painting?
I'm trying to override the way QTreeWidgetItems are drawn when an item is dragged over them. I've overridden the drag Events to set the Qt.UserRole data to 1 for the QTreeWidgetItems that I want to paint. In the Item Delegate, I read the UserRole and draw accordingly.... | How to use Qt Delegates for custom painting? | I'm trying to override the way QTreeWidgetItems are drawn when an item is dragged over them. I've overridden the drag Events to set the Qt.UserRole data to 1 for the QTreeWidgetItems that I want to paint. In the Item Delegate, I read the UserRole and draw accordingly.
My custom painting is showing up exactly as expec... | [
"this is easily solvable with qt using c++: you can define a new style, override drawPrimitive method and do custom painting (or just do nothing) there whenever QStyle::PE_IndicatorItemViewItemDrop constant is received via element parameter. Below is an example:\nclass TestStyle : public QProxyStyle\n{\npublic:\n ... | [
2
] | [] | [] | [
"pyqt",
"python",
"qt"
] | stackoverflow_0004754500_pyqt_python_qt.txt |
Q:
Is there a function in Python's standard library that does something similar to the loop function?
I was looking for a function to loop through a list of lists that would automatically put the results together and yield each result produced by the (internal) loops. Not seeing any recognizable candidates from Pytho... | Is there a function in Python's standard library that does something similar to the loop function? | I was looking for a function to loop through a list of lists that would automatically put the results together and yield each result produced by the (internal) loops. Not seeing any recognizable candidates from Python's standard library, the loop function below was the result. Does anyone know of any available function... | [
"itertools.product(*groups)\n"
] | [
4
] | [] | [] | [
"iteration",
"nested_loops",
"python",
"standards"
] | stackoverflow_0004755363_iteration_nested_loops_python_standards.txt |
Q:
python for loop adding commas between items
I want to loop through the list adding commas between items. There has to be an easier way to write this, so that it just pulls out all the tags at once instead of having to loop through over and over.
for top_item in items.get_top_tags():
tag1 = top_item.item.get_na... | python for loop adding commas between items | I want to loop through the list adding commas between items. There has to be an easier way to write this, so that it just pulls out all the tags at once instead of having to loop through over and over.
for top_item in items.get_top_tags():
tag1 = top_item.item.get_name(0)
for top_item in items.get_top_tags(1):
... | [
"It seems like items.get_top_tags() returns a list with a single item in it? If so, try this:\n# 'n' is the number of tags you'll be returning, I suppose\n', '.join(items.get_top_tags(i)[0].get_name() for i in range(n))\n\n",
"I'm not sure what exactly your trying to do in the first bit of your example but I susp... | [
2,
1,
0
] | [] | [] | [
"django",
"for_loop",
"python"
] | stackoverflow_0004755429_django_for_loop_python.txt |
Q:
Including satchmo-livesettings in main django-admin site
I plan to use the sachmo-livesettings module in my django application (not using or related to satchmo). In the satchmo store the livesettings are visible on the main django-admin site. When adding livesettings to my app, though I can access them directly us... | Including satchmo-livesettings in main django-admin site | I plan to use the sachmo-livesettings module in my django application (not using or related to satchmo). In the satchmo store the livesettings are visible on the main django-admin site. When adding livesettings to my app, though I can access them directly using a dedicated url (e.g. ../settings) I don't manage to make ... | [
"I'm not too familiar with the satchmo specific bits, but generally the way you handle this kind of thing in Django is by overriding admin templates and creating your own /admin/ urls/views.\n"
] | [
1
] | [] | [] | [
"django",
"django_admin",
"python",
"satchmo"
] | stackoverflow_0004746121_django_django_admin_python_satchmo.txt |
Q:
ValueError: invalid literal for int() with base 10: 'SOH'
I received the following error when I try to insert values into sqlite database
Traceback (most recent call last):
File "C:\SS\Problem13\src\database.py", line 23, in <module>
sql = """INSERT INTO students (name, student_id, email, school_id, gender, ... | ValueError: invalid literal for int() with base 10: 'SOH' | I received the following error when I try to insert values into sqlite database
Traceback (most recent call last):
File "C:\SS\Problem13\src\database.py", line 23, in <module>
sql = """INSERT INTO students (name, student_id, email, school_id, gender, gpa, address) VALUES ('%s','%i','%s','%i','%s','%f','%s')"""%(d... | [
"\nI received the following error when I try to insert values into sqlite database\n\nInstead of using string formatting to insert your parameters into your queries, you should pass them as parameters to the conn.execute() method. By doing so, you protect yourself from SQL injection attacks and the data is treated... | [
4
] | [] | [] | [
"python",
"sqlite"
] | stackoverflow_0004755446_python_sqlite.txt |
Q:
Python: How to show license text in msi installer generated from setup.py
In setup.py the call to the setup function may look like this:
setup(name="my_package",
version="1.0",
packages = ['pack1', 'pack2'],
license = "We're all mad here"
)
And I use the very nice feature to generate an msi inst... | Python: How to show license text in msi installer generated from setup.py | In setup.py the call to the setup function may look like this:
setup(name="my_package",
version="1.0",
packages = ['pack1', 'pack2'],
license = "We're all mad here"
)
And I use the very nice feature to generate an msi installer:
python setup.py bdist_msi
Is there any way to get the license text "We'... | [
"Optimistic, detailed answer: you extend distutils, creating a new command based on bdist_msi. You'll probably have to create a new PyDialog in (your equivalent to) bdist_msi.add_ui. I think you'll have to add your dialog to UI Sequences. The simplest dialog seems to be Prepare Dialog. Knowing your way around msil... | [
1
] | [] | [] | [
"distutils",
"installation",
"python",
"windows_installer"
] | stackoverflow_0004374586_distutils_installation_python_windows_installer.txt |
Q:
Use decodebin with adder
I'm trying to create an audio stream that has a constant audio source (in this case, audiotestsrc) to which I can occasionally add sounds from files (of various formats, that's why I'm using decodebin) through the play_file() method. I use an adder for that purpose. However, for some reaso... | Use decodebin with adder | I'm trying to create an audio stream that has a constant audio source (in this case, audiotestsrc) to which I can occasionally add sounds from files (of various formats, that's why I'm using decodebin) through the play_file() method. I use an adder for that purpose. However, for some reason, I cannot add the second sou... | [
"Thanks to moch on #gstreamer, I realized that all adder sources should have the same format. I modified the above script so as to have the caps \"audio/x-raw-int, endianness=(int)1234, channels=(int)1, width=(int)16, depth=(int)16, signed=(boolean)true, rate=(int)11025\" (example) go before every input in the adde... | [
4
] | [] | [] | [
"gstreamer",
"python"
] | stackoverflow_0004750239_gstreamer_python.txt |
Q:
Python regex help, match anything before meet a letter
Test Cases:
22 s # 22
1.4 I # 1.4
4.4.5 Apple # 4.4.5
1993 # 1993
All i'm trying to get is everything before [A-z] or [a-z]
Thanks
A:
Try this regex:
r'^[^a-zA-Z]+'
A:
I suspect you want to not include trailing spaces, so matching "22 s" gives... | Python regex help, match anything before meet a letter | Test Cases:
22 s # 22
1.4 I # 1.4
4.4.5 Apple # 4.4.5
1993 # 1993
All i'm trying to get is everything before [A-z] or [a-z]
Thanks
| [
"Try this regex:\nr'^[^a-zA-Z]+'\n\n",
"I suspect you want to not include trailing spaces, so matching \"22 s\" gives you \"22\" rather than \"22 \":\n>>> regex = r\"^([^A-Za-z]+?)\\s*(?:[A-Za-z]|$)\"\n>>> for input, expected in [\n... (\"22 s\", \"22\"),\n... (\"1.4 I\", \"1.4\"),\n... (\"4.4.5 Apple\", \"... | [
1,
1
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0004755567_python_regex.txt |
Q:
Python: I'm getting an 'indented block' error on the last 3 quotes (""") of my comments under functions. What's up?
Super odd, no? The offending code:
def main():
"""
main function
"""
# Argument handling
args = sys.argv[1:]
if not args:
print "usage is: ...
The third quote is where I get the... | Python: I'm getting an 'indented block' error on the last 3 quotes (""") of my comments under functions. What's up? | Super odd, no? The offending code:
def main():
"""
main function
"""
# Argument handling
args = sys.argv[1:]
if not args:
print "usage is: ...
The third quote is where I get the usual indentation error:
>>>Import someScript
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
... | [
"You need to indent the docstring along with the block for your function.\nEvery colon (:) must be immediately followed by an indented block.\n",
"As said, the docstring isn't indented. It would be nicer to get the error on the first line of the string, but that's not the way the lexer currently works. Instead,... | [
18,
2
] | [] | [] | [
"comments",
"indentation",
"python"
] | stackoverflow_0004755566_comments_indentation_python.txt |
Q:
Python: Adding new line after return in recursive function
I am new to python and faced the following problem.. I am trying to do a recursive sum function but the sum does not get returned on a new line
For example, sum(2,2) should return
4
2
sum(2,3) will return
6
4
2
But I get 4 2 and 6 4 2 all on the same lin... | Python: Adding new line after return in recursive function | I am new to python and faced the following problem.. I am trying to do a recursive sum function but the sum does not get returned on a new line
For example, sum(2,2) should return
4
2
sum(2,3) will return
6
4
2
But I get 4 2 and 6 4 2 all on the same line. This is my code:
def sum(a,b):
if a>0 and b>0:
re... | [
"def sum(a,b):\n if a>0 and b>0:\n return str(a*b) + \"\\n\" + str(sum(a,b-1))\n else:\n return \"\"\n\nworks fine here.\n",
"You wrote that changing \" \" to \"\\n\" doesn't work, but did you try printing the result?\nprint sum(2, 2)\n\n"
] | [
1,
0
] | [] | [] | [
"line",
"new_operator",
"python",
"recursion",
"return"
] | stackoverflow_0004756188_line_new_operator_python_recursion_return.txt |
Q:
Implementation of quartic equation solver doesn't work
What's going wrong with my implementation of a quartic equation solver?
Here is my code on GitHub. I followed this: http://www.1728.com/quartic2.htm
In fact the real implementation starts at line 271, where I create the monic poly.
If I try it with a polynom... | Implementation of quartic equation solver doesn't work | What's going wrong with my implementation of a quartic equation solver?
Here is my code on GitHub. I followed this: http://www.1728.com/quartic2.htm
In fact the real implementation starts at line 271, where I create the monic poly.
If I try it with a polynomial with 4 real roots it works fine (for example with 3x^4 +... | [
"If it isn't a problem with your cubic solver (as phkahler suggested), then I'm betting that it is a case of int division in these lines:\nf = float(c - (3*b**2 / 8))\ng = float(d + (b**3/ 8) - (b*c / 2))\nh = e - (3*b**4 / 256) + (b**2 * c / 16) - (b*d / 4)\n\nIf you are using a version of Python that is less than... | [
4,
1,
1
] | [] | [] | [
"equation",
"math",
"python",
"solver"
] | stackoverflow_0004728069_equation_math_python_solver.txt |
Q:
Any simple method to make an image unrecognizable?
I want to make an image unrecognizable effeciently.
I don't want to just make it completely black - I want people looking at this to be convinced that this is indeed a unique picture generated from a picture they have seen before.
I tried blurring an image 100 tim... | Any simple method to make an image unrecognizable? | I want to make an image unrecognizable effeciently.
I don't want to just make it completely black - I want people looking at this to be convinced that this is indeed a unique picture generated from a picture they have seen before.
I tried blurring an image 100 times but it's slow as hell and I was wondering whether the... | [
"Take one pixel from a 3x3 block and replace the block with it. Essentially you get a smaller image, though you don't have to resize it (which would make some images much too small to see). This is related to blurring, but is much simpler/faster and results in a pixellated effect rather than an optical blur.\nFor... | [
1,
0,
0,
0
] | [] | [] | [
"image",
"python"
] | stackoverflow_0004756155_image_python.txt |
Q:
Accessing $_GET and $_POST query string or form value equivalents in Python
In PHP, I can retrieve the value in a query string like so:
So, if the request URI is http://example.com/index.php?foo=bar
<?php echo $_GET['foo']; //bar ?>
How can I emulate the above code in Python? (and not using a heavy web framework)... | Accessing $_GET and $_POST query string or form value equivalents in Python | In PHP, I can retrieve the value in a query string like so:
So, if the request URI is http://example.com/index.php?foo=bar
<?php echo $_GET['foo']; //bar ?>
How can I emulate the above code in Python? (and not using a heavy web framework)
I cannot find simple documentation for the easiest way to do this in Python. Is ... | [
"All the web frameworks do it differently. As you say, Python is not a templating language, so there is no automatic way to handle HTTP requests.\nThere is a cgi module which is part of the standard library, and which you can use to access POSTed data via cgi.FieldStorage() - but serving an app via standard CGI is ... | [
3,
0
] | [] | [] | [
"environment_variables",
"http_get",
"http_post",
"python"
] | stackoverflow_0004756388_environment_variables_http_get_http_post_python.txt |
Q:
How can I write this Python code in Java (parsing a string of ints, using delimiter)?
Python code:
str = "123;456;789"
strlist = str.split(";")
strlist = [int("%s" % s) for s in strlist]
print strlist
A:
String str = "123;456;789";
String[] strList = str.split(";");
ArrayList<Integer> intList = new ArrayList<In... | How can I write this Python code in Java (parsing a string of ints, using delimiter)? | Python code:
str = "123;456;789"
strlist = str.split(";")
strlist = [int("%s" % s) for s in strlist]
print strlist
| [
"String str = \"123;456;789\";\nString[] strList = str.split(\";\");\n\nArrayList<Integer> intList = new ArrayList<Integer>();\nfor (String s : strList) {\n intList.add(Integer.parseInt(s));\n}\n\nSystem.out.println(intList);\n\n",
"System.out.println(\"[123, 456, 789]\");\n"
] | [
3,
0
] | [] | [] | [
"java",
"parsing",
"python"
] | stackoverflow_0004756687_java_parsing_python.txt |
Q:
Converting fractional days to H:M:S.MS - Two examples
Of the two methods of calculating a fractional day to local time, which one would you consider the best way and why?
Edit: 'Fractional day' means here the decimal part of a Julian day jd: jd - (math.floor(jd - 0.5) + 0.5) (this is because 0:00:00 is at jd.5)
@c... | Converting fractional days to H:M:S.MS - Two examples | Of the two methods of calculating a fractional day to local time, which one would you consider the best way and why?
Edit: 'Fractional day' means here the decimal part of a Julian day jd: jd - (math.floor(jd - 0.5) + 0.5) (this is because 0:00:00 is at jd.5)
@classmethod
def fromfractional(cls, frac, **kwargs):
cha... | [
"I think you are trying to get from something like:\n1.2256 days\n\nTo:\n1 day, 5 hours, 24 minutes, 51 seconds\n\nbut with microseconds, too?\nHere's how I generated the above response:\ndef nice_repr(timedelta, display=\"long\"):\n \"\"\"\n Turns a datetime.timedelta object into a nice string repr.\n\n d... | [
2
] | [] | [] | [
"datetime",
"python"
] | stackoverflow_0004756764_datetime_python.txt |
Q:
How to save a whole project in python
Hello I have developed a small game in python using ZODB as backend for DB processing.I have never done game programming before.I was hoping if someone can tell me as to how I can save my current game and then reload it using python.The database filename is data.fs and there a... | How to save a whole project in python | Hello I have developed a small game in python using ZODB as backend for DB processing.I have never done game programming before.I was hoping if someone can tell me as to how I can save my current game and then reload it using python.The database filename is data.fs and there are three more ZODB files in my folder.One b... | [
"I don't know your particular case but maybe ZODB is overkill for this. Check first pickle and also anydbm, both at the standard library. If they are not enough for your requirements you can then go for ZODB.\nIn ZODB, once you are connected, you can put anything you want inside as you would with a plain Python dic... | [
2
] | [] | [] | [
"python",
"zodb"
] | stackoverflow_0002828962_python_zodb.txt |
Q:
output mysql table into comma separated file with python: syntax error
I am trying to write a MySQL table into a csv table with proper comma separation. It works without formatting and the result is a tab separated file. I need however a comma separated file and I am getting a syntax error. Here is the code:
def e... | output mysql table into comma separated file with python: syntax error | I am trying to write a MySQL table into a csv table with proper comma separation. It works without formatting and the result is a tab separated file. I need however a comma separated file and I am getting a syntax error. Here is the code:
def export_csv(cxn, filename,filestamp,table, cols='*', where='1'):
cur = ... | [
"\nUse triple quotes ''' around a\nstring that spans multiple lines, in\nthis case around the select\nstatement.\n\nEDIT (there's more...)\n\nDon't add a backslash at end of line inside the triple-quoted string\nTo pass a backslash to MySQL, escape with backslash \\\\, or add an r before opening quotes to mark raw ... | [
2
] | [] | [] | [
"csv",
"mysql",
"python"
] | stackoverflow_0004757391_csv_mysql_python.txt |
Q:
How to model recursive calls in UML
I want to model function calls of my application (written in Python) in UML and I've two problems.
First is that I've tried to draw sequence diagram, but it is for modeling method calls of objects and my application is written procedurally, i.e. the only objects I actually have ... | How to model recursive calls in UML | I want to model function calls of my application (written in Python) in UML and I've two problems.
First is that I've tried to draw sequence diagram, but it is for modeling method calls of objects and my application is written procedurally, i.e. the only objects I actually have are instances of types from libraries I u... | [
"You can easily model recursive calls. You don't even need to have objects to use sequence diagrams. But if you are interested only in called methods and their sequence, I think the best fit would be the communication diagram http://en.wikipedia.org/wiki/Communication_diagram . Recursive calls can be modeled using ... | [
2,
0
] | [] | [] | [
"python",
"recursion",
"uml"
] | stackoverflow_0004738490_python_recursion_uml.txt |
Q:
Catching the Access Token sent by Facebook after successful authentication
I am trying to make an app for authenticating user with their facebook account in python. App opens the facebook login page in web browser. After user logs in, facebook redirects it to thei dummy success page. At that moment i need to captu... | Catching the Access Token sent by Facebook after successful authentication | I am trying to make an app for authenticating user with their facebook account in python. App opens the facebook login page in web browser. After user logs in, facebook redirects it to thei dummy success page. At that moment i need to capture that redirect url in my app. I am not able to catch that URL.
I am opening f... | [
"There's a getLoginUrl in the facebook SDK. You might want to look at that.\n-Roozbeh\n",
"I think you should use Facebook Python lib https://github.com/facebook/python-sdk/\n"
] | [
0,
0
] | [] | [] | [
"facebook",
"python"
] | stackoverflow_0003930129_facebook_python.txt |
Q:
Is HTTLlib2 support NTLM authentication.IF Not what exact explanation for that?
I am accessing SharePoint data using SharePoint web services through Python application.
Does HTTLlib2 support NTLM authentication?
If not, what's the exact explanation for that?
How to solve the issue?
A:
Have you tried python-ntlm?... | Is HTTLlib2 support NTLM authentication.IF Not what exact explanation for that? | I am accessing SharePoint data using SharePoint web services through Python application.
Does HTTLlib2 support NTLM authentication?
If not, what's the exact explanation for that?
How to solve the issue?
| [
"Have you tried python-ntlm?\nhttp://code.google.com/p/python-ntlm/\n"
] | [
2
] | [] | [] | [
"authentication",
"ntlm",
"python",
"sharepoint",
"web_services"
] | stackoverflow_0004756350_authentication_ntlm_python_sharepoint_web_services.txt |
Q:
Using a variable for an import
I have the following pattern:
databasename = "mydatabase"
import databasefunctions
and in databasefunctions I have the following method.
def checkStatusOfDatabase(database=databasename):
I however get an error saying: NameError: name 'databasename' is not defined on the line defini... | Using a variable for an import | I have the following pattern:
databasename = "mydatabase"
import databasefunctions
and in databasefunctions I have the following method.
def checkStatusOfDatabase(database=databasename):
I however get an error saying: NameError: name 'databasename' is not defined on the line defining checkStatusOfDatabase.
I could of... | [
"You cannot (and should not) do that; doing so would make it impossible to just import databasefunctions without the main module. However, you can implement a default like this:\n# databasefunctions\nDEFAULT_NAME = \"\"\ndef checkStatusOfDatabase(database=DEFAULT_NAME):\n\n# main\nimport databasefunctions\ndatabase... | [
4,
0
] | [] | [] | [
"python",
"python_3.x",
"python_import"
] | stackoverflow_0004758207_python_python_3.x_python_import.txt |
Q:
cx_Oracle. How to access remote machine?
I had a look at cx_Oracle but I have a couple of problems with it. First , my oracle server is on remote machine. Second I do not know on what platform my software will be deployed. All the examples I have founded
like this
http://www.len.ro/2009/08/cx_oracle-on-ubuntu-9-... | cx_Oracle. How to access remote machine? | I had a look at cx_Oracle but I have a couple of problems with it. First , my oracle server is on remote machine. Second I do not know on what platform my software will be deployed. All the examples I have founded
like this
http://www.len.ro/2009/08/cx_oracle-on-ubuntu-9-04-jaunty/
or
this https://stackoverflow.com... | [
"Of course cx_Oracle can work with server working on other machine. But on client machines you will have to install Oracle client and configure it. I don't know if Oracle client installation can be added to installer of your application. Normally it is huge (600 MiB or so) so it is not a good idea. Then on all clie... | [
0
] | [] | [] | [
"cx_oracle",
"oracle",
"python"
] | stackoverflow_0004757146_cx_oracle_oracle_python.txt |
Q:
Perl equivalent of Python's list comprehensions with the embedded if statement?
In python, I can do the following to get all the objects in a list with a specific property. In this example I grab the list of id fields of every obj in list objs where obj.id is greater than 100:
ids = [ obj.id for obj in objs if obj... | Perl equivalent of Python's list comprehensions with the embedded if statement? | In python, I can do the following to get all the objects in a list with a specific property. In this example I grab the list of id fields of every obj in list objs where obj.id is greater than 100:
ids = [ obj.id for obj in objs if obj.id > 100]
How would I do the same in perl? I think I want to use map, but I don't ... | [
"The map block can return 0 or more elements for each element in the original list. To omit an element, just return the empty list ():\nmy @ids = map { $_->id > 100 ? $_->id : () } @objs;\n\nThis assumes that the objects in @objs have an id attribute and associated accessor. If you want direct hash access, you ca... | [
13,
2,
1,
0
] | [] | [] | [
"perl",
"python"
] | stackoverflow_0004753969_perl_python.txt |
Q:
How can I add class attributes to Models in Django?
I'm using django to build an internal webapp where devices and analysis reports on those devices are managed.
Currently an abstract Analysis is defined like this:
class Analysis(models.Model):
project = models.ForeignKey(Project)
dut = models.ForeignKey(D... | How can I add class attributes to Models in Django? | I'm using django to build an internal webapp where devices and analysis reports on those devices are managed.
Currently an abstract Analysis is defined like this:
class Analysis(models.Model):
project = models.ForeignKey(Project)
dut = models.ForeignKey(Dut) # Device Under Test
date = models.DateTimeField()... | [
"How about a property or method that returns an AnalysisType dependent on an attribute in the particular Analysis subclass?\nclass Analysis(models.Model):\n ...\n @property\n def analysis_type(self):\n return AnalysisType.objects.get(name=self.analysis_type_name)\n\nclass ColorAnalysis(Analysis):\n ... | [
2
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0004758968_django_django_models_python.txt |
Q:
Built-in function to get value of object if callable?
class Thing():
xyz = "I'm a string"
class Truc():
def xyz(self):
return "I'm a function"
def valueOrCalledValue(input):
if callable(input):
return input()
else:
return input
thing = Thing()
print valueOrCalledValue(thi... | Built-in function to get value of object if callable? | class Thing():
xyz = "I'm a string"
class Truc():
def xyz(self):
return "I'm a function"
def valueOrCalledValue(input):
if callable(input):
return input()
else:
return input
thing = Thing()
print valueOrCalledValue(thing.xyx)
>>> "I'm a string"
truc = Truc()
print valueOrCal... | [
"Try properties using decorators to make it tidy.\n",
"I don't know any built-in function to do that. Alternatively, you could do this in one line using a \"if else\" expression:\nprint my_thing() if callable(my_thing) else my_thing\n\nassigning it to a variable works the same way:\nmy_var = my_thing() if callabl... | [
6,
1,
1
] | [] | [] | [
"callable",
"python"
] | stackoverflow_0004758406_callable_python.txt |
Q:
A more elegant way to control overwriting with try-except-else in python? or Can I do better than C-style code?
I have code that makes a folder and places output files in it. I want to use a try-except-else block and an overwrite option, which can be set to True or False, so that in the case where the folder alrea... | A more elegant way to control overwriting with try-except-else in python? or Can I do better than C-style code? | I have code that makes a folder and places output files in it. I want to use a try-except-else block and an overwrite option, which can be set to True or False, so that in the case where the folder already exists and overwrite is set to false it will just print that the folder already exists, and in all other cases it ... | [
"You're pretty close already. Adapting from this answer:\nimport os, errno\n\ndef mkdir(path, overwrite=False):\n try:\n os.makedirs(path)\n except OSError as exc: # Python >2.5\n if exc.errno == errno.EEXIST:\n if not overwrite:\n print \"path '%s' already exists\" % ... | [
5,
3,
0
] | [] | [] | [
"coding_style",
"python",
"repeat",
"try_catch"
] | stackoverflow_0004753686_coding_style_python_repeat_try_catch.txt |
Q:
determining file changes in python
I have a text file being written by another process on a server which I want to watch for changes. Each time a change occurs I'd like to read the new data and send it to client .
Any suggestions will be valuable . Using Django,Python
Tazim.
A:
If you're using a recent Linux you... | determining file changes in python | I have a text file being written by another process on a server which I want to watch for changes. Each time a change occurs I'd like to read the new data and send it to client .
Any suggestions will be valuable . Using Django,Python
Tazim.
| [
"If you're using a recent Linux you should look into this:\nhttp://trac.dbzteam.org/pyinotify\nHow do I watch a file for changes?\ngoes into details for win32\n",
"On Linux a convenient interface for file modification monitoring is Gamin the File Alteration Monitor. Python bindings are provided and they are reall... | [
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0003051208_django_python.txt |
Q:
Python/Django: How to Prepend a # on to all URLS
I am building a mobile web app with Django and jQuery Mobile. My problem is that jQuery Mobile likes for all links to be prepended with a # so it can accurately keep track of browsing history.
Example: http://www.fest.com/#/foo/1/
I would like know how to automatic... | Python/Django: How to Prepend a # on to all URLS | I am building a mobile web app with Django and jQuery Mobile. My problem is that jQuery Mobile likes for all links to be prepended with a # so it can accurately keep track of browsing history.
Example: http://www.fest.com/#/foo/1/
I would like know how to automatically redirect all urls that point From: /foo/1/ To: /#... | [
"You have misunderstood what the # does. \nThe # in a URL is the \"fragment\" separator. Nothing after that is sent to the server. So there is no such URL as \"foo. com#/foo\" - as far as the server is concerned, it's just \"foo.com\". So you can't do any server-side redirection. \nIf your JS library is using the f... | [
3,
0
] | [] | [] | [
"django",
"jquery_mobile",
"mod_rewrite",
"python",
"redirect"
] | stackoverflow_0004753266_django_jquery_mobile_mod_rewrite_python_redirect.txt |
Q:
How do I refer to the current directory in functions from the Python 'os' module?
I want to use the function os.listdir(path) to get a list of files from the directory I'm running the script in, but how do I say the current directory in the "path" argument?
A:
Use os.curdir, and then if you want a full path you ... | How do I refer to the current directory in functions from the Python 'os' module? | I want to use the function os.listdir(path) to get a list of files from the directory I'm running the script in, but how do I say the current directory in the "path" argument?
| [
"Use os.curdir, and then if you want a full path you can use other functions from os.path:\nimport os\nprint os.path.abspath(os.curdir)\n\n",
"You'd typically use os.listdir('.') for this purpose. If you need a standard module, the variable os.curdir is available.\n",
"You can also use the getcwd() function\nos... | [
4,
3,
3
] | [] | [] | [
"path",
"python",
"working_directory"
] | stackoverflow_0004758855_path_python_working_directory.txt |
Q:
Getting the primary key (id) in fixture (Python, SQLAlchemy)
I'm using fixture to test a Pylons app, but I stumbled upon a problem.
Let's say I have such data set:
class CompanyData(DataSet):
class test_company:
company_full_name = u'Firma Tęst'
company_short_name = u'TęstCo'
class UserData(D... | Getting the primary key (id) in fixture (Python, SQLAlchemy) | I'm using fixture to test a Pylons app, but I stumbled upon a problem.
Let's say I have such data set:
class CompanyData(DataSet):
class test_company:
company_full_name = u'Firma Tęst'
company_short_name = u'TęstCo'
class UserData(DataSet):
class test_user:
user_login = 'testuser'
... | [
"UserData.test_user.company.ref('id')\nor\nUserData.test_user.ref('company_id')\n\n"
] | [
0
] | [] | [] | [
"fixture",
"pylons",
"python",
"sqlalchemy"
] | stackoverflow_0004700642_fixture_pylons_python_sqlalchemy.txt |
Q:
Is there an equivalent of ActiveRecord's find(:include) in Elixir/SQLAlchemy?
I had been using ActiveRecord previously and it allowed to load all associations of an object using an optional :include argument to its dynamic finders. I have recently started using Elixir for a python project and am unable to find any... | Is there an equivalent of ActiveRecord's find(:include) in Elixir/SQLAlchemy? | I had been using ActiveRecord previously and it allowed to load all associations of an object using an optional :include argument to its dynamic finders. I have recently started using Elixir for a python project and am unable to find any documentation that'd suggest if it's possible to do the same.
| [
"Using plain SQLAlchemy (without Elixir): http://www.sqlalchemy.org/docs/orm/loading.html\nI assume you can configure the loading strategies using Elixir as well, but I have never used it.\nEDIT 1:\nAccording to the Elixir documentation, options to the relationship constructs (for instance ManyToOne) can include op... | [
1
] | [] | [] | [
"activerecord",
"python",
"python_elixir",
"ruby",
"sql"
] | stackoverflow_0004759939_activerecord_python_python_elixir_ruby_sql.txt |
Q:
python extend or append a list when appropriate
Is there a simple way to append a list if X is a string, but extend it if X is a list? I know I can simply test if an object is a string or list, but I was wondering if there is a quicker way than this?
A:
mylist.extend( [x] if type(x) == str else x )
or maybe the ... | python extend or append a list when appropriate | Is there a simple way to append a list if X is a string, but extend it if X is a list? I know I can simply test if an object is a string or list, but I was wondering if there is a quicker way than this?
| [
"mylist.extend( [x] if type(x) == str else x )\nor maybe the opposite would be safer if you want to catch things other than strings too:\nmylist.extend( x if type(x) == list else [x] )\n",
"I do not think so. extend takes any iterable as input, and strings as well as lists are iterables in python.\n",
"buffer =... | [
11,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0004760815_python.txt |
Q:
Convert python object to XML representation
In my database I have some objects that need to be represented in xml file. What is the simplest/easiest way to convert the item objects into a xml representation of the items? What python library should I use?
<items>
<item>
<picture><![CDATA[foo.jpg]]></pic... | Convert python object to XML representation | In my database I have some objects that need to be represented in xml file. What is the simplest/easiest way to convert the item objects into a xml representation of the items? What python library should I use?
<items>
<item>
<picture><![CDATA[foo.jpg]]></picture>
<title><![CDATA[Foo]]></title>
... | [
"How important is it to have that exact structure? Django includes a serialization framework that can convert querysets to XML, but it doesn't match your format at all. \nOtherwise you'll need to write it manually - for this I find it's easiest to write a model method that can output a single instance in the desire... | [
4,
4,
4
] | [] | [] | [
"django",
"object",
"python",
"xml"
] | stackoverflow_0004757402_django_object_python_xml.txt |
Q:
Why this python program is not working? AttributeError: 'module' object has no attribute
I wrote a very simple python program.
#!/usr/bin/env python
import random
x = random.uniform(-1, 1)
print str(x)
I run this from command prompt.
python random.py
It returned with error:
Traceback (most recent call last):
F... | Why this python program is not working? AttributeError: 'module' object has no attribute | I wrote a very simple python program.
#!/usr/bin/env python
import random
x = random.uniform(-1, 1)
print str(x)
I run this from command prompt.
python random.py
It returned with error:
Traceback (most recent call last):
File "random.py", line 2, in <module>
import random
File "D:\python practise\random.py", ... | [
"Don't name your file random.py, it is importing itself and looking for uniform in it.\nIt's a bit of a quirk with how Python imports things, it looks in the local directory first and then starts searching the PYTHONPATH. Basically, be careful naming any of your .py files the same as one of the standard library mo... | [
27,
4,
3,
1
] | [] | [] | [
"python",
"random"
] | stackoverflow_0004761138_python_random.txt |
Q:
Differences between webapp and web.py
Webpy.org - Who uses web.py?
"[web.py inspired the] web framework
we use at FriendFeed [and] the webapp
framework that ships with App
Engine..."
— Brett Taylor,
co-founder of FriendFeed and original
tech lead on Google App Engine
Google App Engine Getting S... | Differences between webapp and web.py | Webpy.org - Who uses web.py?
"[web.py inspired the] web framework
we use at FriendFeed [and] the webapp
framework that ships with App
Engine..."
— Brett Taylor,
co-founder of FriendFeed and original
tech lead on Google App Engine
Google App Engine Getting Started for Python
HTML embedded in code i... | [
"web.py experience:\nI started to use web.py three years ago when I decided to learn some Python web frameworks.\nThe first thing I loved of web.py was its simplicity; I was searching for an essential microframework without all the batteries that you can find in other bigger projects like Django or Web2py for examp... | [
19,
4,
3
] | [] | [] | [
"google_app_engine",
"python",
"web.py",
"web_applications"
] | stackoverflow_0004759565_google_app_engine_python_web.py_web_applications.txt |
Q:
Encode a string to gbk in Python
I am trying to see what different strings would look like in different encodings...
For example:
>>> str1 = "asdf"
>>> str1.encode('utf-16')
'\xff\xfea\x00s\x00d\x00f\x00'
>>> str1.encode('base64')
'YXNkZg==\n'
And those all get me what I want.
But I'd like to see what certain str... | Encode a string to gbk in Python | I am trying to see what different strings would look like in different encodings...
For example:
>>> str1 = "asdf"
>>> str1.encode('utf-16')
'\xff\xfea\x00s\x00d\x00f\x00'
>>> str1.encode('base64')
'YXNkZg==\n'
And those all get me what I want.
But I'd like to see what certain strings would look like in gbk, gb2312, o... | [
"As long as only byte values 0-127 are used, these encodings are equivalent to ASCII. The same is true for UTF-8. To really see the difference, try with some actual Chinese.\n",
"From the Wikipedia page:\n\nA character is encoded as 1 or 2\n bytes. A byte in the range 00–7F is a\n single byte that means the sam... | [
2,
1
] | [] | [] | [
"character",
"encoding",
"gbk",
"python"
] | stackoverflow_0004761442_character_encoding_gbk_python.txt |
Q:
Add new navigate modes in matplotlib
I'm writing a wx/matplotlib application, and I'm having considerable difficulty adding a new tool to the matplotlib NavigationToolbar.
Basically I want to add tools for selection (marquee, lasso, etc) that will toggle the controlled subplots mouse mode. As of yet I have been un... | Add new navigate modes in matplotlib | I'm writing a wx/matplotlib application, and I'm having considerable difficulty adding a new tool to the matplotlib NavigationToolbar.
Basically I want to add tools for selection (marquee, lasso, etc) that will toggle the controlled subplots mouse mode. As of yet I have been unable to find any features that will let me... | [
"Here's an improved version of MyNavToolbar. The main thing to note is the addition of the add_user_tool method. I call it from within __init__, but you'd probably want to call it from outside the MyNavToolbar class. This way you could have different tools for plot types.\nclass MyNavToolbar(NavigationToolbar2WxAgg... | [
7,
2
] | [] | [] | [
"matplotlib",
"python",
"toolbar"
] | stackoverflow_0004740988_matplotlib_python_toolbar.txt |
Q:
Java to Python RSA
I'm trying to encrypt a string from Java to Python, using the library Bouncy Castle J2ME on the client side and Python M2Crypto on the other.
Everything is pretty good, I can decrypt it properly, but the padding is the issue.
The M2Crypto lib gives me (as far as I can tell) only these Padding sc... | Java to Python RSA | I'm trying to encrypt a string from Java to Python, using the library Bouncy Castle J2ME on the client side and Python M2Crypto on the other.
Everything is pretty good, I can decrypt it properly, but the padding is the issue.
The M2Crypto lib gives me (as far as I can tell) only these Padding schemes:
no_padding = 3
pk... | [
"Bouncy castle provides padding. If you want for example to make an RSA with PKCS1 padding you have to do this:\npublic static PKCS1Encoding create_rsa_public(RSAKeyParameters PublicKey){\n RSAEngine engine=new RSAEngine();\n PKCS1Encoding encrypto=new PKCS1Encoding(engine);\n encrypto.init(true,PublicKey)... | [
2,
1
] | [] | [] | [
"bouncycastle",
"java",
"m2crypto",
"python",
"rsa"
] | stackoverflow_0001788421_bouncycastle_java_m2crypto_python_rsa.txt |
Q:
Not quite sure what the point of the %s is in Python, help?
I'm learning Python from a book right now and I can't figure out what the point is of using the %s to site a specific item in a list, string, dictionary, etc.
For example:
names = ["jones", "cohen", "smith", "griffin"]
print(names[1])
print("%s" % names[... | Not quite sure what the point of the %s is in Python, help? | I'm learning Python from a book right now and I can't figure out what the point is of using the %s to site a specific item in a list, string, dictionary, etc.
For example:
names = ["jones", "cohen", "smith", "griffin"]
print(names[1])
print("%s" % names[1])
Both commands print "cohen," what's the point of ever using ... | [
"The idea is to allow you to easily create more complicated output like\nprint(\"The name is %s!\" % names[1])\n\ninstead of\nprint(\"The name is \" + names[1] + \"!\")\n\nHowever, as you're just starting to use Python, you should start learning the new string formatting syntax right away:\nprint(\"The name is {}!\... | [
14,
3,
2,
2,
0
] | [] | [] | [
"python",
"string_formatting",
"syntax"
] | stackoverflow_0004756423_python_string_formatting_syntax.txt |
Q:
Python or Perl for creating an Excel spreadsheet on Linux
I have a Python program running on a Linux machine that writes out data to a CSV file. The client now wants the CSV data written to an Excel file. The Excel file needs to be based on a template - company Logo etc. It also needs to highlight certain rows if ... | Python or Perl for creating an Excel spreadsheet on Linux | I have a Python program running on a Linux machine that writes out data to a CSV file. The client now wants the CSV data written to an Excel file. The Excel file needs to be based on a template - company Logo etc. It also needs to highlight certain rows if a date field is in a certain range.
The program is proprietary ... | [
"The perl libraries are Excel::Writer::XLSX (for .xlsx) or Spreadsheet::WriteExcel (for .xls).\n",
"I dont know how complex the template is, but check out http://sourceforge.net/projects/pyexcelerator/\nIts a library to create excel files in python.\n",
"If you want to attempt this in Perl, have a look at Sprea... | [
6,
3,
3
] | [] | [] | [
"excel",
"perl",
"python"
] | stackoverflow_0004762080_excel_perl_python.txt |
Q:
need a little help "translating" a base64decoder script from PHP to Python
I have been trying to get something called simplesamlphp hooked up to a django app.
I'm almost there… although i need to duplicate, in Python, the functionality of this php script:
I have copied the contents of the $raw variable in php, to... | need a little help "translating" a base64decoder script from PHP to Python | I have been trying to get something called simplesamlphp hooked up to a django app.
I'm almost there… although i need to duplicate, in Python, the functionality of this php script:
I have copied the contents of the $raw variable in php, to the file 64.rtf. However when i run the Python equivalent i get an error statin... | [
"Here it is, in all of its glory.\n#!/usr/bin/env python\n\nimport base64\nimport zlib\nimport cgi\nimport urlparse\n\ndef getValue(raw):\n args = urlparse.parse_qs(urlparse.urlparse(raw).query)\n keys = ['SAMLResponse', 'SAMLRequest', 'LogoutRequest', 'LogoutResponse']\n for key in keys:\n if key i... | [
0
] | [] | [] | [
"base64",
"php",
"python"
] | stackoverflow_0004760623_base64_php_python.txt |
Q:
How to access a drive by volume label in a python script in Ubuntu
I am writing a python script that copies some data to an external drive attached to Ubuntu host. I do not want to pass the device file of the drive to the python script. But I can set the Volume label of the drive and export it as an environment va... | How to access a drive by volume label in a python script in Ubuntu | I am writing a python script that copies some data to an external drive attached to Ubuntu host. I do not want to pass the device file of the drive to the python script. But I can set the Volume label of the drive and export it as an environment variable in the linux shell.
My question is how to I access this shell env... | [
"The os module provides access to environmental variables. Suppose that you have exported $VOL=\"/BLAH\". Then, in Python:\nimport os\nmy_path = os.environ['VOL']\n\n"
] | [
3
] | [] | [] | [
"bash",
"python",
"shell"
] | stackoverflow_0004762468_bash_python_shell.txt |
Q:
Is it possible to override .objects on a django model?
I'd like to by default only return "published" instances (published=True). Is it possible to override .objects so that MyModel.objects.all() actually returns MyModel.objects.filter(published=True)?
Is this sensible? How would I get the unpublished ones in the ... | Is it possible to override .objects on a django model? | I'd like to by default only return "published" instances (published=True). Is it possible to override .objects so that MyModel.objects.all() actually returns MyModel.objects.filter(published=True)?
Is this sensible? How would I get the unpublished ones in the rare cases where I did want them?
| [
"You can do this by writing a custom Manager -- just override the get_queryset method and set your objects to a Manager instance. For example:\nclass MyModelManager(models.Manager):\n def get_queryset(self):\n return super(MyModelManager, self).get_queryset().filter(published=True)\n\nclass MyModel(model... | [
32
] | [] | [] | [
"django",
"filtering",
"python"
] | stackoverflow_0004762524_django_filtering_python.txt |
Q:
Broken link images in python google app engine
Hi I've tried many times to make an image link work using python/google app engine but it still shows a broken link.
i've the folder images in my root folder containing the images i want.
my app.yaml file:
handlers:
- url: /.*
script: helloworld.py
- u... | Broken link images in python google app engine | Hi I've tried many times to make an image link work using python/google app engine but it still shows a broken link.
i've the folder images in my root folder containing the images i want.
my app.yaml file:
handlers:
- url: /.*
script: helloworld.py
- url: /images
static_dir: images
my index.html... | [
"Handlers are matching in order. /.* will match any URL, so your /images handler will never be matched. Reverse the order of them, and always put a /.* handler last in app.yaml.\n",
"I think you are missing the '/' at the beginning of the static path in your html file. Try:\nimg src=\"/images/_image01.gif\" \n... | [
4,
1
] | [] | [] | [
"google_app_engine",
"image",
"python"
] | stackoverflow_0004762132_google_app_engine_image_python.txt |
Q:
list sorting case insensitive using operator.attrgetter
hi i have list of dictionaries .. and i want to sort it case insensitive
members = Person.objects.filter(person=person_id)
members_list = list(members)
members_list.sort( key = operator.attrgetter( sort_by ), reverse = False )
here sort_by have attribute n... | list sorting case insensitive using operator.attrgetter | hi i have list of dictionaries .. and i want to sort it case insensitive
members = Person.objects.filter(person=person_id)
members_list = list(members)
members_list.sort( key = operator.attrgetter( sort_by ), reverse = False )
here sort_by have attribute name by whom i want to sort.
Now how can i sort with case inse... | [
"members_list.sort( key = lambda member: getattr(member,sort_by).lower(), reverse = False )\n\n",
"If sort_by is a variable containing a string with the name of the attribute you want to use for sorting and you want to use operator.attrgetter(), you could use this which converts the value of the attribute it fetc... | [
6,
4,
1
] | [] | [] | [
"case_insensitive",
"list",
"python",
"sorting"
] | stackoverflow_0004759798_case_insensitive_list_python_sorting.txt |
Q:
Python convention: function constructor for a private class
I have noticed this in Python's threading module source:
def Event(*args, **kwargs):
return _Event(*args, **kwargs)
class _Event(_Verbose):
...
Am I correct in assuming this is an attempt in mimicking a "sealed" class (c#) or a "final" class (java) ... | Python convention: function constructor for a private class | I have noticed this in Python's threading module source:
def Event(*args, **kwargs):
return _Event(*args, **kwargs)
class _Event(_Verbose):
...
Am I correct in assuming this is an attempt in mimicking a "sealed" class (c#) or a "final" class (java) in other languages? Is this a common pattern in Python? Are there... | [
"I don't think I like this choice of identifiers. It is conventional to start class names with an uppercase letter, so you'd think that you could say isinstance(x, Event), but you can't. I think a name such as make_event that unambiguously identifies the function as a function would have been better.\nThis issue ha... | [
5,
1
] | [] | [] | [
"design_patterns",
"python"
] | stackoverflow_0004762384_design_patterns_python.txt |
Q:
What is the meaning of the traceback?
I am using django-email-change-0.2.1 just to change an emailadress in the auth_user-table. When I am going to add the app emailchange in the settings.py. I get an error message!
Actually you can install the app. But I didn't do that in the site-packages of python. I have copi... | What is the meaning of the traceback? | I am using django-email-change-0.2.1 just to change an emailadress in the auth_user-table. When I am going to add the app emailchange in the settings.py. I get an error message!
Actually you can install the app. But I didn't do that in the site-packages of python. I have copied the code into my code of the website.
Ro... | [
"This:\nInsalled_apps= {\n'auth.user.emailchange'\n}\n\nis wrong in many ways. First, it's not valid Python syntax (curly brackets are for making dicts, not lists) and secondly it's not even close to the valid way of adding an app to a Django settings.py file, which is something like:\nINSTALLED_APPS = (\n 'foos... | [
2
] | [] | [] | [
"django",
"python",
"web"
] | stackoverflow_0004761874_django_python_web.txt |
Q:
Is it safe to mix readline() and line iterators in python file processing?
Is it safe to read some lines with readline() and also use for line in file, and is it guaranteed to use the same file position?
Usually, I want to disregard the first line (headers), so I do this:
FI = open("myfile.txt")
FI.readline() ... | Is it safe to mix readline() and line iterators in python file processing? | Is it safe to read some lines with readline() and also use for line in file, and is it guaranteed to use the same file position?
Usually, I want to disregard the first line (headers), so I do this:
FI = open("myfile.txt")
FI.readline() # disregard the first line
for line in FI:
my_process(line)
FI.close... | [
"No, it isn't safe:\n\nAs a consequence of using a read-ahead\n buffer, combining next() with other\n file methods (like readline()) does\n not work right.\n\nYou could use next() to skip the first line here. You should also test for StopIteration, which will be raised if the file is empty.\nwith open('myfile.tx... | [
16,
4,
2
] | [] | [] | [
"file_io",
"python"
] | stackoverflow_0004762262_file_io_python.txt |
Q:
Django South - turning a null=True field into a null=False field
My question is, what is the best practice for turning a null=True field into a null=False field using Django South. Specifically, I'm working with a ForeignKey.
A:
You should write first a data migration: http://south.aeracode.org/docs/tutorial/par... | Django South - turning a null=True field into a null=False field | My question is, what is the best practice for turning a null=True field into a null=False field using Django South. Specifically, I'm working with a ForeignKey.
| [
"You should write first a data migration: http://south.aeracode.org/docs/tutorial/part3.html\nand then make the schemamigration.\n",
"If you want to turn nullable ForeignKey into non-nullable one, then it can be problematic if you have any rows with NULL for that field (column). In such case you need to either re... | [
6,
3
] | [] | [] | [
"django",
"django_models",
"django_south",
"python"
] | stackoverflow_0004761048_django_django_models_django_south_python.txt |
Q:
What's better to use for Django?
Django-rest or Django Pistons?
What's better plugin for API stuff?
A:
I've not used django-rest, but I have used django-piston and found it really effective and pretty easy to get up and running quickly.
It also seems to be a popular choice with a lot of devs I know - and it pow... | What's better to use for Django? | Django-rest or Django Pistons?
What's better plugin for API stuff?
| [
"I've not used django-rest, but I have used django-piston and found it really effective and pretty easy to get up and running quickly. \nIt also seems to be a popular choice with a lot of devs I know - and it powers the API for bitbucket, which I take as a good sign.\nFor me, the primary pinch-points are: \n\nif yo... | [
4,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004762828_django_python.txt |
Q:
Difference between character sets in Python and re2c regular expressions
Character sets in regular expressions are specified using []. Character sets match any one of the enclosed characters. For example, [abc] will match one of 'a', 'b', or 'c'.
I realize there are potentially differences between character sets i... | Difference between character sets in Python and re2c regular expressions | Character sets in regular expressions are specified using []. Character sets match any one of the enclosed characters. For example, [abc] will match one of 'a', 'b', or 'c'.
I realize there are potentially differences between character sets in Python and re2c regular expressions. I know what is the same in both:
Both ... | [
"Looking at the re2c manual link that you provided, it appears that re2c uses the same syntax, just a subset of that syntax.\nTo address your specific questions about regex syntax\n\nCharacters that need to be escaped inside of the character set.\n\nWhat characters are you referring to specifically?\n\nWhere to pla... | [
1,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0004761306_python_regex.txt |
Q:
numpy.ndarray: converting to a "normal" class
[Python 3]
I like ndarray but I find it annoying to use.
Here's one problem I face. I want to write class Array that will inherit much of the functionality of ndarray, but has only one way to be instantiated: as a zero-filled array of a certain size. I was hoping to wr... | numpy.ndarray: converting to a "normal" class | [Python 3]
I like ndarray but I find it annoying to use.
Here's one problem I face. I want to write class Array that will inherit much of the functionality of ndarray, but has only one way to be instantiated: as a zero-filled array of a certain size. I was hoping to write:
class Array(numpy.ndarray):
def __init__(siz... | [
"\nWhy does ndarray use global (module) functions instead of constructors in many cases?\n\n\nTo be compatible/similar to Matlab, where functions like zeros or ones originally came from.\nGlobal factory functions are quick to write and easy to understand. What should the semantics of a constructor be, e.g. how woul... | [
8,
6,
4
] | [] | [] | [
"numpy",
"python",
"python_3.x",
"wrapper"
] | stackoverflow_0004757611_numpy_python_python_3.x_wrapper.txt |
Q:
Overriding class variables in python
I'm trying to understand a bit how Python (2.6) deals with class, instances and so on, and at a certain point, I tried this code:
#/usr/bin/python2.6
class Base(object):
default = "default value in base"
def __init__(self):
super(Base, self).__init__()
@c... | Overriding class variables in python | I'm trying to understand a bit how Python (2.6) deals with class, instances and so on, and at a certain point, I tried this code:
#/usr/bin/python2.6
class Base(object):
default = "default value in base"
def __init__(self):
super(Base, self).__init__()
@classmethod
def showDefaultValue(cls, d... | [
"The class variable is being overwritten. Try \n@classmethod\ndef showDefaultValue(cls):\n print \"defl == %s\" % (cls.default,)\n\nThe reason your way doesn't work has more to do with the way Python treats default arguments to functions than with class attributes. The default value for defl is evaluated at the ... | [
12,
12
] | [] | [] | [
"class_design",
"inheritance",
"oop",
"python"
] | stackoverflow_0004763743_class_design_inheritance_oop_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.