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:
django views question
In my django views i have the following
def create(request):
query=header.objects.filter(id=a)[0]
a=query.criteria_set.all()
logging.debug(a.details)
I get an error saying 'QuerySet' object has no attribute 'details' in the debug statement
.What is this error and what should be the... | django views question | In my django views i have the following
def create(request):
query=header.objects.filter(id=a)[0]
a=query.criteria_set.all()
logging.debug(a.details)
I get an error saying 'QuerySet' object has no attribute 'details' in the debug statement
.What is this error and what should be the correct statemnt to query ... | [
"QuerySet.all() returns a QuerySet. Index it or iterate over it if you want to access the individual models:\nlogging.debug(a[0].details)\n\nfor m in a:\n logging.debug(m.details)\n\n"
] | [
3
] | [] | [] | [
"django",
"django_queryset",
"django_views",
"python"
] | stackoverflow_0002532304_django_django_queryset_django_views_python.txt |
Q:
Python: ImportError no module named urllib
I just rented a VPS from Linode which has python2.5 and ubuntu 8.04. When I run this command from python shell:
import urllib
I get:
ImportError: No module named urllib
What can be the reason? How can I add this module to python? Isn't it prepackaged with the basic vers... | Python: ImportError no module named urllib | I just rented a VPS from Linode which has python2.5 and ubuntu 8.04. When I run this command from python shell:
import urllib
I get:
ImportError: No module named urllib
What can be the reason? How can I add this module to python? Isn't it prepackaged with the basic version?
Can it be PYTHONPATH problem?
| [
"Ok, I resolved the issue.\nSomehow, python-tk package (which includes urllib) was missing.\nSo the following line fixed the problem\napt-get install python-tk\n\n"
] | [
1
] | [
"I use a later OS, so I don't know if this will help, but just in case:\nmarcelo@localhost:~$ lsb_release -a\nNo LSB modules are available.\nDistributor ID: Ubuntu\nDescription: Ubuntu 9.10\nRelease: 9.10\nCodename: karmic\nmarcelo@localhost:~$ python\nPython 2.6.4rc2 (r264rc2:75497, Oct 20 2009, 02... | [
-1
] | [
"importerror",
"python",
"pythonpath",
"urllib"
] | stackoverflow_0002532321_importerror_python_pythonpath_urllib.txt |
Q:
Python - Is a dictionary slow to find frequency of each character?
I am trying to find a frequency of each symbol in any given text using an algorithm of O(n) complexity. My algorithm looks like:
s = len(text)
P = 1.0/s
freqs = {}
for char in text:
try:
freqs[char]+=P
except:
freqs[cha... | Python - Is a dictionary slow to find frequency of each character? | I am trying to find a frequency of each symbol in any given text using an algorithm of O(n) complexity. My algorithm looks like:
s = len(text)
P = 1.0/s
freqs = {}
for char in text:
try:
freqs[char]+=P
except:
freqs[char]=P
but I doubt that this dictionary-method is fast enough, because i... | [
"Performance comparison\nNote: time in the table doesn't include the time it takes to load files.\n| approach | american-english, | big.txt, | time w.r.t. defaultdict |\n| | time, seconds | time, seconds | |\n|----------------+-------------------+---------------... | [
47,
16,
10,
6,
5,
4,
2,
2,
2,
2,
1,
1
] | [] | [] | [
"algorithm",
"frequency",
"probability",
"python"
] | stackoverflow_0002522152_algorithm_frequency_probability_python.txt |
Q:
mod_cgi , mod_fastcgi, mod_scgi , mod_wsgi, mod_python, FLUP. I don't know how many more. what is mod_php equivalent?
I recently learnt Python. I liked it. I just wanted to use it for web development. This thought caused all the troubles. But I like these troubles :)
Coming from PHP world where there is only one w... | mod_cgi , mod_fastcgi, mod_scgi , mod_wsgi, mod_python, FLUP. I don't know how many more. what is mod_php equivalent? | I recently learnt Python. I liked it. I just wanted to use it for web development. This thought caused all the troubles. But I like these troubles :)
Coming from PHP world where there is only one way standardized. I expected the same and searched for python & apache.
Setting up Python on Windows/ Apache? says
Stay aw... | [
"The standard way to deploy a Python application to the web is via WSGI. These days there's no reason to use anything else.\nmod_wsgi is the Apache module that supports WSGI. Other web servers will have different names for their WSGI modules.\n",
"There is no exact equivalent to mod_php in the Python world.\n\nFa... | [
10,
7,
4,
2
] | [] | [] | [
"apache",
"php",
"python"
] | stackoverflow_0002532477_apache_php_python.txt |
Q:
How do I make this simple list comprehension?
I'm new to python, and I'm trying to get to know the list comprehensions better.
I'm not even really sure if list comprehension is the word I'm looking for, since I'm not generating a list. But I am doing something similar.
This is what I am trying to do:
I have a list... | How do I make this simple list comprehension? | I'm new to python, and I'm trying to get to know the list comprehensions better.
I'm not even really sure if list comprehension is the word I'm looking for, since I'm not generating a list. But I am doing something similar.
This is what I am trying to do:
I have a list of numbers, the length of which is divisible by th... | [
"See sum(iterable[, start]) builtin, and use it on slices.\n\nSums start and the items of an iterable from left to right and returns the total. start defaults to 0. The iterable‘s items are normally numbers, and are not allowed to be strings. \n\n>>> nums\n[1, 2, 3, 4, 5, 6]\n>>> [sum(nums[i:i+3]) for i in range(0... | [
6,
4,
1
] | [] | [] | [
"list_comprehension",
"python"
] | stackoverflow_0002532525_list_comprehension_python.txt |
Q:
How to implement this mechanism:
i want to implement a dynamic relation mechanism with python something like:
a:=10
b:=30
c:=a+b
print c
a+=20
print c
output:
40
60
c is always result of a+b.
so if a or b change, then c automatically updates value. i write a code in C# and do this by set and get mechanism. now w... | How to implement this mechanism: | i want to implement a dynamic relation mechanism with python something like:
a:=10
b:=30
c:=a+b
print c
a+=20
print c
output:
40
60
c is always result of a+b.
so if a or b change, then c automatically updates value. i write a code in C# and do this by set and get mechanism. now want to translate it to python code for... | [
"This is probably overkill, but it illustrates how you should create getters/setters in Python and achieve the functionality you want:\nclass Calc(object):\n def __init__(self, a = 0, b = 0):\n self._a = a\n self._b = b\n\n @property\n def a(self):\n return self._a\n\n @a.setter\n ... | [
4,
3,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0002532664_python.txt |
Q:
What is the best library in python to use to interface with a SQL database?
I am currently processing text/html data and I wish to store my results in some sort of database. My current setup is Pydev with Eclipse.
What is the best non-distributed database to use with my current development environment?
What is t... | What is the best library in python to use to interface with a SQL database? | I am currently processing text/html data and I wish to store my results in some sort of database. My current setup is Pydev with Eclipse.
What is the best non-distributed database to use with my current development environment?
What is the best library in python to use to interface with suggested database?
| [
"If you won't be using the database itself from multiple locations at once then you can use the built-in sqlite3 module with a SQLite database.\n",
"\"Best\" of course depends on your needs, and aside from \"text/html data\" you haven't given us anything to go on. One might say that a relational database is not ... | [
2,
2
] | [] | [] | [
"database",
"eclipse",
"python"
] | stackoverflow_0002532135_database_eclipse_python.txt |
Q:
Free Cryptography libraries
What are the most stable and useful Cryptography libraries, that they are:
written with/for python, c++, c#, .net
opensource, GNU, or other free license
A:
For C# and Java, there is bouncycastle. The granddaddy of crypto libraries is openssl. For C++, another very mature library is c... | Free Cryptography libraries | What are the most stable and useful Cryptography libraries, that they are:
written with/for python, c++, c#, .net
opensource, GNU, or other free license
| [
"For C# and Java, there is bouncycastle. The granddaddy of crypto libraries is openssl. For C++, another very mature library is crypto++.\n",
"The standard Python library (implementing common ciphers like AES and RSA) is PyCrypto. It doesn't support things like PKCS yet, however. There is a partial Python wrapper... | [
2,
2,
1,
0
] | [] | [] | [
"c#",
"c++",
"cryptography",
"python"
] | stackoverflow_0002532983_c#_c++_cryptography_python.txt |
Q:
how to convert Python 3 to Python 2 code?
I had written a program in Python 3, but now want to convert it into Python 2 code. Are there any utilities to do that automatically?
A:
You want 3to2 for that.
| how to convert Python 3 to Python 2 code? | I had written a program in Python 3, but now want to convert it into Python 2 code. Are there any utilities to do that automatically?
| [
"You want 3to2 for that.\n"
] | [
47
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0002533217_python_python_3.x.txt |
Q:
unittest tests reuse for family of classes
I have problem organizing my unittest based class test for family of tests. For example assume I implement a "dictionary" interface, and have 5 different implementations want to testing.
I do write one test class that tests a dictionary interface. But how can I nicely reu... | unittest tests reuse for family of classes | I have problem organizing my unittest based class test for family of tests. For example assume I implement a "dictionary" interface, and have 5 different implementations want to testing.
I do write one test class that tests a dictionary interface. But how can I nicely reuse it to test my all classes? So far I do ugly:
... | [
"The way I tackle this with standard unittest is by subclassing -- overriding data is as easy as overriding methods, after all.\nSo, I have a base class for the tests:\nclass MappingTestBase(unittest.TestCase):\n dictype = None\n # write all the tests using self.dictype\n\nand subclasses:\nclass HashtableTest... | [
5,
0
] | [] | [] | [
"python",
"unit_testing"
] | stackoverflow_0002532197_python_unit_testing.txt |
Q:
Python: How do sets work
I have a list of objects which I want to turn into a set. My objects contain a few fields that some of which are o.id and o.area. I want two objects to be equal if these two fields are the same. ie: o1==o2 if and only if o1.area==o2.area and o1.id==o2.id.
I tried over-writing __eq__ and __... | Python: How do sets work | I have a list of objects which I want to turn into a set. My objects contain a few fields that some of which are o.id and o.area. I want two objects to be equal if these two fields are the same. ie: o1==o2 if and only if o1.area==o2.area and o1.id==o2.id.
I tried over-writing __eq__ and __cmp__ but I get the error: Typ... | [
"Define the __hash__ method to return a meaningful hash based on the id and area fields. E.g.:\ndef __hash__(self):\n return hash(self.id) ^ hash(self.area)\n\n",
"\"TypeError: unhashable instance.\" error is probably due to old-style class definition i.e.: \nclass A:\n pass\n\nUse new style instead:\nclass A... | [
38,
9
] | [] | [] | [
"hash",
"python",
"set"
] | stackoverflow_0002532365_hash_python_set.txt |
Q:
How to use a python api on iPhone?
There is an "Unofficial Plurk API in Python".
Plurk is a twitter-like website.
Can I use the API(python) from Objective-C? Or i have to port them?
A:
Apple's iPhone developer license prohibits applications that use interpreted code. So, python is out, unfortunately.
A:
The wa... | How to use a python api on iPhone? | There is an "Unofficial Plurk API in Python".
Plurk is a twitter-like website.
Can I use the API(python) from Objective-C? Or i have to port them?
| [
"Apple's iPhone developer license prohibits applications that use interpreted code. So, python is out, unfortunately.\n",
"The way I see it, one option is to try this this.\nAlternatively, ths plurk api (which is really more of a python-automated abstraction than an API) isn't very big and is unlikely to take ver... | [
4,
3,
2,
1
] | [
"Unfortunately, you can only do what Apple allows you to do (they are VERY controlling). However, if you jail break your device (this violates your usage agreement with Apple) you can do many, many things with what I consider to be an amazing device (unfortunatly, Apple limits it's true possibilities). \n"
] | [
-6
] | [
"iphone",
"objective_c",
"python"
] | stackoverflow_0000768941_iphone_objective_c_python.txt |
Q:
How to setup and teardown temporary django db for unit testing?
I would like to have a python module containing some unit tests that I can pass to hg bisect --command.
The unit tests are testing some functionality of a django app, but I don't think I can use hg bisect --command manage.py test mytestapp because my... | How to setup and teardown temporary django db for unit testing? | I would like to have a python module containing some unit tests that I can pass to hg bisect --command.
The unit tests are testing some functionality of a django app, but I don't think I can use hg bisect --command manage.py test mytestapp because mytestapp would have to be enabled in settings.py, and the edits to set... | [
"Cracked it. I now have one python file completely independent of any django app that can run unit tests with a test database:\n#!/usr/bin/env python\n\"\"\"Run a unit test and return result.\n\nThis can be used with `hg bisect`.\nIt is assumed that this file resides in the same dir as settings.py\n\n\"\"\"\n\nimpo... | [
10,
5
] | [] | [] | [
"django",
"mercurial",
"python",
"unit_testing"
] | stackoverflow_0002533457_django_mercurial_python_unit_testing.txt |
Q:
Standardizing a Release/Tools group on a specific language
I'm part of a six-member build and release team for an embedded software company. We also support a lot of developer tools, such as Atlassian's Fisheye, Jira, etc., Perforce, Bugzilla, AnthillPro, and a couple of homebrew tools (like my Django release note... | Standardizing a Release/Tools group on a specific language | I'm part of a six-member build and release team for an embedded software company. We also support a lot of developer tools, such as Atlassian's Fisheye, Jira, etc., Perforce, Bugzilla, AnthillPro, and a couple of homebrew tools (like my Django release notes generator).
Most of the time, our team just writes little plug... | [
"Two points:\n\n\"Eww Perl gross\" is somewhat of an urban legend. You can write great clean self-documenting code in Perl, and your can write write-only code in pretty much any language. It's a property of a developer, not a language. \nJust because you're writing glue code, doesn't mean the code has to suck like ... | [
6,
4,
1
] | [
"First, it's important to note that it is very hard to convince someone they're wrong.\n\nHe's advocating bash scripts and Perl,\n due to their universality and\n simplicity\n\nBash scripts are not simple. The bash programming model is really complex and unfriendly. if statements and expressions, in particular ... | [
-1
] | [
"groovy",
"perl",
"python"
] | stackoverflow_0002527867_groovy_perl_python.txt |
Q:
Python: UTF-8 problems (again...)
I have a database which is synchronized against an external web source twice a day. This web source contains a bunch of entries, which have names and some extra information about these names.
Some of these names are silly and I want to rename them when inserting them into my own d... | Python: UTF-8 problems (again...) | I have a database which is synchronized against an external web source twice a day. This web source contains a bunch of entries, which have names and some extra information about these names.
Some of these names are silly and I want to rename them when inserting them into my own database. To rename these silly names, I... | [
"The error you are receiving is due to the unicode string you want not being in the dictionary. Recall that in Python 2.x (I assume you are using that), the default string type is 8-bit, not unicode, so you are actually keying the dictionary with 8-bit strings. To declare a unicode string, use u\"my unicode string\... | [
4
] | [] | [] | [
"django",
"encoding",
"python",
"utf_8"
] | stackoverflow_0002534596_django_encoding_python_utf_8.txt |
Q:
Python inter-computer communication
This whole topic is way out of my depth, so forgive my imprecise question, but I have two computers both connected to one LAN.
What I want is to be able to communicate one string between the two, by running a python script on the first (the host) where the string will originate,... | Python inter-computer communication | This whole topic is way out of my depth, so forgive my imprecise question, but I have two computers both connected to one LAN.
What I want is to be able to communicate one string between the two, by running a python script on the first (the host) where the string will originate, and a second on the client computer to r... | [
"First, lets get the nomenclature straight. Usually the part that initiate the communication is the client, the parts that is waiting for a connection is a server, which then will receive the data from the client and generate a response. From your question, the \"host\" is the client and the \"client\" seems to be ... | [
4,
3
] | [
"File share and polling filesystem every minute. No joke. Of course, it depends on what are requirements for your applications and what lag is acceptable but in practice using file shares is quite common.\n"
] | [
-2
] | [
"python"
] | stackoverflow_0002534527_python.txt |
Q:
do the Python libraries have a natural dependence on the global namespace?
I first ran into this when trying to determine the relative performance of two generators:
t = timeit.repeat('g.get()', setup='g = my_generator()')
So I dug into the timeit module and found that the setup and statement are evaluated with t... | do the Python libraries have a natural dependence on the global namespace? | I first ran into this when trying to determine the relative performance of two generators:
t = timeit.repeat('g.get()', setup='g = my_generator()')
So I dug into the timeit module and found that the setup and statement are evaluated with their own private, initially empty namespaces so naturally the binding of g never... | [
"The pickle protocol(s) would have a serious problem picking classes and functions in the most general case; by pickling them \"by name\" instead, it makes the difficulty go away, but nds up requiring that they be bound to (and recoverable by) names that are top-level in a module (which, since a module is its own n... | [
3
] | [] | [] | [
"namespaces",
"python"
] | stackoverflow_0002534847_namespaces_python.txt |
Q:
Deleting dirs after finishing a command prompt
I have a python script that ends with running a program (iexpress.exe) in a dos prompt.
The program that runs in dos prompt, uses a dir called workdir.
After the program has finished in the dos prompt I would like python to delete the dir.
I have just made a simple s... | Deleting dirs after finishing a command prompt | I have a python script that ends with running a program (iexpress.exe) in a dos prompt.
The program that runs in dos prompt, uses a dir called workdir.
After the program has finished in the dos prompt I would like python to delete the dir.
I have just made a simple solution of putting a delay of 30sec:
time.sleep(30)
... | [
"Make the python program call the exe and not fall off the end\nie call the exe using subprocess.Popen\nThe when the exe finishes you are still in python\n"
] | [
0
] | [] | [] | [
"cmd",
"python",
"python_3.x"
] | stackoverflow_0002534917_cmd_python_python_3.x.txt |
Q:
Rest Web Service with App Engine and Webapp
I want to build a REST web service on app engine. Currently i have this:
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
class UsersHandler(webapp.RequestHandler):
def get(self, name):
self.response.out.write('Hello '+ name+'!... | Rest Web Service with App Engine and Webapp | I want to build a REST web service on app engine. Currently i have this:
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
class UsersHandler(webapp.RequestHandler):
def get(self, name):
self.response.out.write('Hello '+ name+'!')
def main():
util.run_wsgi_app(application)
... | [
"Sure, you can -- change your handler's get method to\ndef get(self, name=None):\n if name is None:\n \"\"\"deal with the /rest/users case\"\"\"\n else:\n # deal with the /rest/users/(.*) case\n self.response.out.write('Hello '+ name+'!') \n\nand your application to\napplication = webapp.... | [
14
] | [] | [] | [
"google_app_engine",
"python",
"rest",
"web_applications"
] | stackoverflow_0002534947_google_app_engine_python_rest_web_applications.txt |
Q:
Way to call super(MyClass, self).__init__() without MyClass?
I find this syntax astoundingly annoying. Every time I rename my class, I have to change this call for no apparent reason. Isn't there some __class__ magic variable or something I can use at least? Interested in answers for Python 2.5, but it doesn't hur... | Way to call super(MyClass, self).__init__() without MyClass? | I find this syntax astoundingly annoying. Every time I rename my class, I have to change this call for no apparent reason. Isn't there some __class__ magic variable or something I can use at least? Interested in answers for Python 2.5, but it doesn't hurt to know if later versions fixed this.
| [
"As far as I know, this isn't possible in 2.5. However, in 3.0, this was changed so that you can simply call super().__init__().\n",
"This is fixed in Python 3. http://docs.python.org/py3k/library/functions.html#super\nhttp://www.python.org/dev/peps/pep-3135/\n",
"If your class only inherits from one class it... | [
4,
4,
3,
2
] | [
"EDIT: As pointed out by Alex, this causes infinite recursion when there is more than a single level of inheritance. Do not use this approach.\nYes, \"new\" style classes have a __class__ attribute available which can be used, eg.\nclass B(object):\n def __init__(self):\n print \"B.__init__():\"\n\nclass ... | [
-1
] | [
"python",
"syntax"
] | stackoverflow_0002535037_python_syntax.txt |
Q:
How to load google map geo-location not using kml
How to load google map geo-location not using kml. Like this site: http://www.housingmaps.com/
A:
This example from Google is what you're looking for.
| How to load google map geo-location not using kml | How to load google map geo-location not using kml. Like this site: http://www.housingmaps.com/
| [
"This example from Google is what you're looking for.\n"
] | [
1
] | [] | [] | [
"django",
"google_maps",
"javascript",
"kml",
"python"
] | stackoverflow_0002535379_django_google_maps_javascript_kml_python.txt |
Q:
motion computation from video using pyglet in python
I am writing a simple motion detection program but i want it to be cross platform so im using python and the pyglet library since it provides a simple way to load videos in different formats (specially wmv and mpeg). So far i have the code given below which load... | motion computation from video using pyglet in python | I am writing a simple motion detection program but i want it to be cross platform so im using python and the pyglet library since it provides a simple way to load videos in different formats (specially wmv and mpeg). So far i have the code given below which loads the movie and plays it in a window. Now i need to:
1) gr... | [
"To me it seems like you have to skip the play function and manually step through the video/animation, maybe using source.get_animation().frames which is a list of frames where each frame is a simple image. I'm guessing this isn't really going to be pracitical with large videos but that is generally not something y... | [
0
] | [] | [] | [
"motion_detection",
"pyglet",
"python",
"video_processing"
] | stackoverflow_0002532261_motion_detection_pyglet_python_video_processing.txt |
Q:
Potential annoyances of tab delimited Python source?
Edit: This question has already been asked and answered, and I apparently am not good at using the search wizard. See Why does Python pep-8 strongly recommend spaces over tabs for indentation? and the link in the comments. Thanks for replying to those who did ... | Potential annoyances of tab delimited Python source? | Edit: This question has already been asked and answered, and I apparently am not good at using the search wizard. See Why does Python pep-8 strongly recommend spaces over tabs for indentation? and the link in the comments. Thanks for replying to those who did so.
I want to start a new project, and I want this to be m... | [
"Most Python programmers will have their editors configured to automatically use four spaces for all .py files… Which could, at least initially, cause some minor headaches if they try to edit your source.\nBut apart from that (given that PEP 666 was rejected), it shouldn't cause any major trouble.\nOf course, if yo... | [
1,
1
] | [] | [] | [
"ide",
"python",
"tabs"
] | stackoverflow_0002535397_ide_python_tabs.txt |
Q:
What is a really simple explanation of unit testing?
I've never done any unit testing before, and would like to learn what it is and how it can be useful in my Python code.
I've read through a few Python unit testing tutorials online but they're all so complicated and assume an extended programming background. ... | What is a really simple explanation of unit testing? | I've never done any unit testing before, and would like to learn what it is and how it can be useful in my Python code.
I've read through a few Python unit testing tutorials online but they're all so complicated and assume an extended programming background. I'm using Python with Pylons to create a simple web app. ... | [
"Consider this.\nHere's a class we've written.\nclass Something( object ):\n def __init__( self, a, b ):\n self.a= a\n self.b= b\n def sum( self ):\n return self.a+self.b+self.a\n\nThat's a test for that class.\nimport unittest\nclass TestSomething( unittest.TestCase ):\n def setUp( se... | [
5
] | [] | [] | [
"pylons",
"python",
"unit_testing"
] | stackoverflow_0002535431_pylons_python_unit_testing.txt |
Q:
Catching a python app before it exits
I have a python app which is supposed to be very long-lived, but sometimes the process just disappears and I don't know why. Nothing gets logged when this happens, so I'm at a bit of a loss.
Is there some way in code I can hook in to an exit event, or some other way to get ... | Catching a python app before it exits | I have a python app which is supposed to be very long-lived, but sometimes the process just disappears and I don't know why. Nothing gets logged when this happens, so I'm at a bit of a loss.
Is there some way in code I can hook in to an exit event, or some other way to get some of my code to run just before the proc... | [
"atexit is pronounced \"at exit\". The first times I read that function name, I read it as \"a texit\", which doesn't make nearly as much sense.\n",
"You might try running your application directly from a console (cmd on windows, sh/bash/etc on unix), so you can see any stack trace, etc printed to the console wh... | [
8,
3,
3
] | [] | [] | [
"crash",
"python"
] | stackoverflow_0002535403_crash_python.txt |
Q:
Looking for a smarter way to convert a Python list to a GList?
I'm really new to C -> Python interaction and am currently writing a small app in C which will read a file (using Python to parse it) and then using the parsed information to execute small Python snippets. At the moment I'm feeling very much like I'm r... | Looking for a smarter way to convert a Python list to a GList? | I'm really new to C -> Python interaction and am currently writing a small app in C which will read a file (using Python to parse it) and then using the parsed information to execute small Python snippets. At the moment I'm feeling very much like I'm reinventing wheels, for example this function:
typedef gpointer (list... | [
"I recommend PySequence_Fast and friends:\nelse\n{\n PyObject *pSeqfast = PySequence_Fast(pylist, \"must be a sequence\");\n Py_ssize_t n = PySequence_Fast_GET_SIZE(pSeqFast);\n\n for(Py_ssize_t i = 0; i < n ; ++i)\n {\n gpointer obj = func(PySequence_Fast_GET_ITEM(pSeqfast, i));\n if (obj... | [
1
] | [] | [] | [
"c",
"glib",
"python",
"python_embedding"
] | stackoverflow_0002535448_c_glib_python_python_embedding.txt |
Q:
How to change the value of None in Python?
I'm currently reading chapter 5.8 of Dive Into Python and Mark Pilgrim says:
There are no constants in Python. Everything can be changed if you try hard enough. This fits with one of the core principles of Python: bad behavior should be discouraged but not banned. If you... | How to change the value of None in Python? | I'm currently reading chapter 5.8 of Dive Into Python and Mark Pilgrim says:
There are no constants in Python. Everything can be changed if you try hard enough. This fits with one of the core principles of Python: bad behavior should be discouraged but not banned. If you really want to change the value of None, you ca... | [
"You first have to install an old version of Python (I think it needs to be 2.2 or older). In 2.4 and newer for certain (and I believe in 2.3) the assignment in question is a syntax error. Mark's excellent book is, alas, a bit dated by now.\n"
] | [
13
] | [] | [] | [
"python",
"syntax"
] | stackoverflow_0002535477_python_syntax.txt |
Q:
Using numpy.apply
What's wrong with this snippet of code?
import numpy as np
from scipy import stats
d = np.arange(10.0)
cutoffs = [stats.scoreatpercentile(d, pct) for pct in range(0, 100, 20)]
f = lambda x: np.sum(x > cutoffs)
fv = np.vectorize(f)
# why don't these two lines output the same values?
[f(x) for x ... | Using numpy.apply | What's wrong with this snippet of code?
import numpy as np
from scipy import stats
d = np.arange(10.0)
cutoffs = [stats.scoreatpercentile(d, pct) for pct in range(0, 100, 20)]
f = lambda x: np.sum(x > cutoffs)
fv = np.vectorize(f)
# why don't these two lines output the same values?
[f(x) for x in d] # => [0, 1, 2, 2,... | [
"cutoffs is a list. The numbers you extract from d are all turned into float and applied using numpy.vectorize. (It's actually rather odd—it looks like first it tries numpy floats that work like you want then it tries normal Python floats.) By a rather odd, stupid behavior in Python, floats are always less than lis... | [
1
] | [] | [] | [
"numpy",
"python",
"scipy"
] | stackoverflow_0002535556_numpy_python_scipy.txt |
Q:
llvm-py questions
1) Is it possible to use llvm-py on Windows without Visual Studio 2008? Maybe I can compile files on another computer and use on my?
2) Is llvm-py mature enough in your opinion? If not, what are the problems?
A:
As far as I know, llvm-py is unmaintained. The project would require some kind of c... | llvm-py questions | 1) Is it possible to use llvm-py on Windows without Visual Studio 2008? Maybe I can compile files on another computer and use on my?
2) Is llvm-py mature enough in your opinion? If not, what are the problems?
| [
"As far as I know, llvm-py is unmaintained. The project would require some kind of compiler, although you should be able to use the free VS express edition I would imagine.\nOn the other hand, the LLVM C bindings are maintained, so it is always possible to use the Python ctypes module to wrap the LLVM C API, withou... | [
3
] | [] | [] | [
"llvm",
"python"
] | stackoverflow_0002355019_llvm_python.txt |
Q:
XML RPC client for C# over secured socket (https)
I have a secured (https) XML-RPC server written in python, and I have tested it with a python based client. but I need a C# based client for it, I have given a try to xml-rpc.net
but it is not working with https? can any one please help me out? or I will have to wr... | XML RPC client for C# over secured socket (https) | I have a secured (https) XML-RPC server written in python, and I have tested it with a python based client. but I need a C# based client for it, I have given a try to xml-rpc.net
but it is not working with https? can any one please help me out? or I will have to write a client from scratch?
Thanks
| [
"Your https server probably has a self-signed or other invalid certificate. Get a valid certificate or suppress https certificate validation with\nServicePointManager.ServerCertificateValidationCallback = (a, b, c, e) => true ;\n\n"
] | [
2
] | [] | [] | [
"c#",
"https",
"python",
"xml_rpc"
] | stackoverflow_0002536271_c#_https_python_xml_rpc.txt |
Q:
Intra-package references in python and GUI tests
I have problem concerning python packages and testing. I'm writing an application using wx python and have the following basic folder/package structure for the gui parts. The mainframe.py window has a dependency to the logpane.py panel, which is easily imported usin... | Intra-package references in python and GUI tests | I have problem concerning python packages and testing. I'm writing an application using wx python and have the following basic folder/package structure for the gui parts. The mainframe.py window has a dependency to the logpane.py panel, which is easily imported using an absolute import in mainframe.py:
import guiapp.ut... | [
"You could use PYTHONPATH. Set it to your main project directory, before executing your test file. It will then be able to resolve all your imports just as if you would be executing from that directory.\n$ find\n.\n./test\n./test/test.py\n./some\n./some/__init__.py\n\n$ cat some/__init__.py \nx = 10\n\n$ cat test/t... | [
2
] | [] | [] | [
"package",
"project_layout",
"python",
"testing"
] | stackoverflow_0002536335_package_project_layout_python_testing.txt |
Q:
Simple way to create possible case
I have lists of data such as
a = [1,2,3,4]
b = ["a","b","c","d","e"]
c = ["001","002","003"]
And I want to create new another list that was mixed from all possible case of a,b,c like this
d = ["1a001","1a002","1a003",...,"4e003"]
Is there any module or method to generate d with... | Simple way to create possible case | I have lists of data such as
a = [1,2,3,4]
b = ["a","b","c","d","e"]
c = ["001","002","003"]
And I want to create new another list that was mixed from all possible case of a,b,c like this
d = ["1a001","1a002","1a003",...,"4e003"]
Is there any module or method to generate d without write many for loop?
| [
"[''.join(str(y) for y in x) for x in itertools.product(a, b, c)]\n\n",
"This is a little simpler to do if you convert a to be a list of str too.\nand saves needlessly calling str() on each element of b and c\n>>> from itertools import product\n>>> a = [1,2,3,4]\n>>> b = [\"a\",\"b\",\"c\",\"d\",\"e\"]\n>>> c = [... | [
17,
1,
1,
1
] | [] | [] | [
"case",
"methods",
"module",
"python"
] | stackoverflow_0002535924_case_methods_module_python.txt |
Q:
Pylons: View latest debug message
Is there a way to view the latest debug message instead of having to copy and paste something like "_debug/view/1269848287" to the browser everytime?
A:
(On the off-chance that this helps...)
Ubuntu's default Terminal program auto-detects URLs. When my pylons programs burp, I j... | Pylons: View latest debug message | Is there a way to view the latest debug message instead of having to copy and paste something like "_debug/view/1269848287" to the browser everytime?
| [
"(On the off-chance that this helps...)\nUbuntu's default Terminal program auto-detects URLs. When my pylons programs burp, I just ctrl-click on the link in the console.\n"
] | [
0
] | [] | [] | [
"debugging",
"pylons",
"python"
] | stackoverflow_0002536468_debugging_pylons_python.txt |
Q:
python: list modules within the package
I have a package with a few modules, each module has a class (or a few classes) defined within it. I need to get the list of all modules within the package. Is there an API for this in python?
Here is the file structure:
\pkg\
\pkg\__init__.py
\pkg\module1.py -> defines Clas... | python: list modules within the package | I have a package with a few modules, each module has a class (or a few classes) defined within it. I need to get the list of all modules within the package. Is there an API for this in python?
Here is the file structure:
\pkg\
\pkg\__init__.py
\pkg\module1.py -> defines Class1
\pkg\module2.py -> defines Class2
\pkg\mod... | [
"One ad-hoc approach is list the files in the directory, import each file dynamically with __import__ and then list the classes of the resulting module.\n",
"ok, this was actually pretty straightforward:\nimport pkg\n\nsub_modules = ( \n pkg.__dict__.get(a) for a in dir(pkg) \n ... | [
1,
0
] | [] | [] | [
"import",
"module",
"package",
"python"
] | stackoverflow_0002536610_import_module_package_python.txt |
Q:
How to improve my Python regex syntax?
I very new to Python, and fairly new to regex. (I have no Perl experience.)
I am able to use regular expressions in a way that works, but I'm not sure that my code is particularly Pythonic or consise.
For example, If I wanted to read in a text file and print out text that ap... | How to improve my Python regex syntax? | I very new to Python, and fairly new to regex. (I have no Perl experience.)
I am able to use regular expressions in a way that works, but I'm not sure that my code is particularly Pythonic or consise.
For example, If I wanted to read in a text file and print out text that appears directly between the words 'foo' and '... | [
"I think it's fine.\nSome minor points:-\n\nYou can replace result.groups()[x] with result.group(x+1).\nIf you don't need to capture foo and bar, just use r'foo(.*)bar'.\nIf you're using Python 2.5+, try to use the with statement so even when there's exception the file can be closed properly.\n\n\nBTW, as a 5-liner... | [
3,
1,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0002536684_python_regex.txt |
Q:
Counts of events grouped by date in python?
This is no doubt another noobish question, but I'll ask it anyways:
I have a data set of events with exact datetime in UTC. I'd like to create a line chart showing total number of events by day (date) in the specified date range. Right now I can retrieve the total data s... | Counts of events grouped by date in python? | This is no doubt another noobish question, but I'll ask it anyways:
I have a data set of events with exact datetime in UTC. I'd like to create a line chart showing total number of events by day (date) in the specified date range. Right now I can retrieve the total data set for the needed date range, but then I need to ... | [
"You'll have to do the binning in-memory (i.e. after the datastore fetch).\nThe .date() method of a datetime instance will facilitate your binning; it chops off the time element. Then you can use a dictionary to hold the bins:\nbins = {}\nfor event in Event.all().fetch(1000):\n bins.setdefault(event.doe.date(), ... | [
1,
0,
0
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0002534424_django_google_app_engine_python.txt |
Q:
Python Introspection: How to get varnames of class methods?
I want to get the names of the keyword arguments of the methods of a class. I think I understood how to get the names of the methods and how to get the variable names of a specific method, but I don't get how to combine these:
class A(object):
def A1(... | Python Introspection: How to get varnames of class methods? | I want to get the names of the keyword arguments of the methods of a class. I think I understood how to get the names of the methods and how to get the variable names of a specific method, but I don't get how to combine these:
class A(object):
def A1(self, test1=None):
self.test1 = test1
def A2(self, te... | [
"import inspect\n\nfor name, method in inspect.getmembers(a, inspect.ismethod):\n print name\n (args, varargs, varkw, defaults) = inspect.getargspec(method)\n for arg in args:\n print arg\n\n",
"Well, as a direct extension of what you did:\nfor varname in a.__class__.__dict__['A1'].__code__.co_var... | [
10,
5
] | [] | [] | [
"class",
"introspection",
"python"
] | stackoverflow_0002536879_class_introspection_python.txt |
Q:
Where do you use generators feature in your python code?
I have studied generators feature and i think i got it but i would like to understand where i could apply it in my code.
I have in mind the following example i read in "Python essential reference" book:
# tail -f
def tail(f):
f.seek(0,2)
while True:
... | Where do you use generators feature in your python code? | I have studied generators feature and i think i got it but i would like to understand where i could apply it in my code.
I have in mind the following example i read in "Python essential reference" book:
# tail -f
def tail(f):
f.seek(0,2)
while True:
line = f.readline()
if not line:
time.sleep(0.1)
... | [
"I use them a lot when I implement scanners (tokenizers) or when I iterate over data containers.\nEdit: here is a demo tokenizer I used for a C++ syntax highlight program:\nwhitespace = ' \\t\\r\\n'\noperators = '~!%^&*()-+=[]{};:\\'\"/?.,<>\\\\|'\n\ndef scan(s):\n \"returns a token and a state/token id\"\n w... | [
6,
4,
2,
1
] | [] | [] | [
"generator",
"python"
] | stackoverflow_0002536241_generator_python.txt |
Q:
Generation of an array of Random numbers with defined Min, Max, Mean and Stdev with given number of elements and error level
I'd like to generate an array of Random numbers with defined Min, Max, Mean and Stdev with given number of elements and error level. Is there such a library in C, C++, PHP or Python to do so... | Generation of an array of Random numbers with defined Min, Max, Mean and Stdev with given number of elements and error level | I'd like to generate an array of Random numbers with defined Min, Max, Mean and Stdev with given number of elements and error level. Is there such a library in C, C++, PHP or Python to do so? Please kindly advise. Thanks!
| [
"The Boost C++ random number library may do some of what you want, certainly you can with some distributions select the modal value of the distribution. That's all I've needed in my own code, so I've never investigated further. The library doesn't generate arrays - you would typically use a C++ std::vector to cont... | [
4,
4
] | [] | [] | [
"c++",
"generator",
"python",
"statistics"
] | stackoverflow_0002536615_c++_generator_python_statistics.txt |
Q:
Prevent wxPython from showing 'Unhandled exception' dialog
I have complex GUI application written in Python and wxPython.
I want it to be certified for Windows Vista, so it has to crash in a way that causes Windows Error Reporting dialog (The one that asks "Do you want to send report to Microsoft?") to appear. Thi... | Prevent wxPython from showing 'Unhandled exception' dialog | I have complex GUI application written in Python and wxPython.
I want it to be certified for Windows Vista, so it has to crash in a way that causes Windows Error Reporting dialog (The one that asks "Do you want to send report to Microsoft?") to appear. This is relevant to test case no 32 from "Certified for Windows Vis... | [
"It all ended up with compiling my own wxWidgets and wxPython, with just one compilation flag changed: wxUSE_EXCEPTIONS should be set to 0.\nRobin Dunn wrote that he will try to patch wxPython, so this behaviour could be modified without recompiling of the whole library.\n",
"If I remember correctly, this is a ca... | [
2,
1,
1,
0
] | [] | [] | [
"error_reporting",
"python",
"windows",
"wxpython"
] | stackoverflow_0000618429_error_reporting_python_windows_wxpython.txt |
Q:
How do I have signed fields in Django?
class MyTable(models.Model):
lat = models.FloatField(blank=True)
long = models.FloatField(blank=True)
How do I make them signed? Able to accept negative .
A:
FloatField can accept floating point numbers, negatives included.
If you need positive-only integers, there... | How do I have signed fields in Django? | class MyTable(models.Model):
lat = models.FloatField(blank=True)
long = models.FloatField(blank=True)
How do I make them signed? Able to accept negative .
| [
"FloatField can accept floating point numbers, negatives included.\nIf you need positive-only integers, there's PositiveIntegerField. Positive-only floats are a much rarer need, so I don't think they're natively supported - but you can, of course, implement this restriction programatically.\n"
] | [
11
] | [] | [] | [
"database",
"django",
"mysql",
"python"
] | stackoverflow_0002537319_database_django_mysql_python.txt |
Q:
Some jQuery-powered features not working in Chrome
I'm using a jCarouselLite plugin for creating two image galleries on the main page of my Django-powered site. The code of elements with navigation arrows is generating dynamically like this:
$(document).ready(function ()
{
$('[jq\\:corner]').each(function(inde... | Some jQuery-powered features not working in Chrome | I'm using a jCarouselLite plugin for creating two image galleries on the main page of my Django-powered site. The code of elements with navigation arrows is generating dynamically like this:
$(document).ready(function ()
{
$('[jq\\:corner]').each(function(index, item)
{
item = $(item); item.corner(item.... | [
"No idea if this matches your issues, but I've been running the dev channel of chrome for linux and this weekend had issues with it working with the jquery ui 1.8 release button plugin. Come to find out it was a Chrome bug and updating solved the issue. \n"
] | [
0
] | [] | [] | [
"django",
"javascript",
"jquery",
"python"
] | stackoverflow_0002537096_django_javascript_jquery_python.txt |
Q:
Exception Handling in google app engine
i am raising exception using
if UserId == '' and Password == '':
raise Exception.MyException , "wrong userId or password"
but i want print the error message on same page
class MyException(Exception):
def __init__(self,msg):
Exception.__init__(self,msg)
A:
... | Exception Handling in google app engine | i am raising exception using
if UserId == '' and Password == '':
raise Exception.MyException , "wrong userId or password"
but i want print the error message on same page
class MyException(Exception):
def __init__(self,msg):
Exception.__init__(self,msg)
| [
"You are not using the Users API? Assuming you are handling a POST request, how about this:\nclass LoginError(Exception):\n CODES = { 'mismatch': 'Wrong credentials', 'disabled': 'Account disabled' }\n ...\n\ntry:\n // your authentication code\n raise LoginError('mismatch')\n ...\n raise LoginErro... | [
1,
0
] | [] | [] | [
"exception_handling",
"google_app_engine",
"python"
] | stackoverflow_0002537357_exception_handling_google_app_engine_python.txt |
Q:
django views getid
class host(models.Model):
emp = models.ForeignKey(getname)
def __unicode__(self):
return self.topic
In views there is the code as,
real =[]
for emp in my_emp:
real.append(host.objects.filter(emp=emp.id))
This above results only the values of emp,My question is th... | django views getid | class host(models.Model):
emp = models.ForeignKey(getname)
def __unicode__(self):
return self.topic
In views there is the code as,
real =[]
for emp in my_emp:
real.append(host.objects.filter(emp=emp.id))
This above results only the values of emp,My question is that how to get the ids al... | [
"Just add them to the list when you are processing my_emp list, something like that:\nreal = []\nfor emp in my_emp:\n real.append((emp.id, host.objects.filter(emp=emp.id)))\n\nLater\nfor emp_id, host in real:\n # do something usefull\n\nYou can also get list of all emp objects for given host object by:\nemp_l... | [
1,
1
] | [] | [] | [
"django",
"django_models",
"django_views",
"python"
] | stackoverflow_0002537469_django_django_models_django_views_python.txt |
Q:
How to best design a date/geographic proximity query on GAE?
I'm building a directory for finding athletic tournaments on GAE with
web2py and a Flex front end. The user selects a location, a radius, and a maximum
date from a set of choices. I have a basic version of this query implemented, but it's
inefficient and... | How to best design a date/geographic proximity query on GAE? | I'm building a directory for finding athletic tournaments on GAE with
web2py and a Flex front end. The user selects a location, a radius, and a maximum
date from a set of choices. I have a basic version of this query implemented, but it's
inefficient and slow. One way I know I can improve it is by condensing
the many i... | [
"GeoModel is the best I found. You may look how my GAE app return geospatial queries. For instance India http query is with optional cc (country code) using geomodel library lat=20.2095231&lon=79.560344&cc=IN\n",
"You might be interested by geohash, which enables you to do an inequality query like this:\n\nSELECT... | [
2,
1
] | [] | [] | [
"caching",
"google_app_engine",
"google_cloud_datastore",
"python",
"web2py"
] | stackoverflow_0002525747_caching_google_app_engine_google_cloud_datastore_python_web2py.txt |
Q:
In Google's Protocol Buffers, what is a suitable protocol file/model for Exceptions?
Protocol Buffers doesn't have a native Exception type. What would a suitable .proto file for cross-language exceptions look like?
A:
The technical lead of Protocol Buffers, Kenton Varda, says in comment 9 on this blog post:
If ... | In Google's Protocol Buffers, what is a suitable protocol file/model for Exceptions? | Protocol Buffers doesn't have a native Exception type. What would a suitable .proto file for cross-language exceptions look like?
| [
"The technical lead of Protocol Buffers, Kenton Varda, says in comment 9 on this blog post:\n\nIf you need to return structured\n errors, then the right way to do it is\n to make your response type be able to\n represent that information... We felt\n that supporting exceptions explicitly\n would add too much c... | [
5
] | [] | [] | [
"exception",
"java",
"php",
"protocol_buffers",
"python"
] | stackoverflow_0002532236_exception_java_php_protocol_buffers_python.txt |
Q:
How can I format strings to query with mysqldb in Python?
How do I do this correctly:
I want to do a query like this:
query = """SELECT * FROM sometable
order by %s %s
limit %s, %s;"""
conn = app_globals.pool.connection()
cur = conn.cursor()
cur.execute(query, (sortname, s... | How can I format strings to query with mysqldb in Python? | How do I do this correctly:
I want to do a query like this:
query = """SELECT * FROM sometable
order by %s %s
limit %s, %s;"""
conn = app_globals.pool.connection()
cur = conn.cursor()
cur.execute(query, (sortname, sortorder, limit1, limit2) )
results = cur.fetchall()
All work... | [
"\nparamstyle\n Parameter placeholders can only be used to insert column values. They can not be used for other parts of SQL, such as table names, statements, etc.\n\n",
"%s placeholders inside query string are reserved for parameters. %s in 'order by %s %s' are not parameters. You should make query string in 2... | [
9,
6,
0
] | [
"You could try this alternatively...\nquery = \"\"\"SELECT * FROM sometable \n order by {0} {1} \n limit {2}, {3};\"\"\"\n\nsortname = 'somecol'\nsortorder = 'DESC'\nlimit1 = 'limit1'\nlimit2 = 'limit2'\n\nprint(query.format(sortname, sortorder, limit1, limit2))\n\n"
] | [
-1
] | [
"mysql",
"python",
"string"
] | stackoverflow_0002538311_mysql_python_string.txt |
Q:
Rearranging a sequence
I'm have trouble rearranging sequences so the amount of letters in the given original sequence are the same in the random generated sequences. For example:
If i have a string 'AAAC'
I need that string rearranged randomly so the amount of A's and C's are the same.
A:
import random
chars = l... | Rearranging a sequence | I'm have trouble rearranging sequences so the amount of letters in the given original sequence are the same in the random generated sequences. For example:
If i have a string 'AAAC'
I need that string rearranged randomly so the amount of A's and C's are the same.
| [
"import random\nchars = list(\"AAAC\")\nrandom.shuffle(chars)\nreturn ''.join(chars)\n\n"
] | [
6
] | [] | [] | [
"python",
"random"
] | stackoverflow_0002538538_python_random.txt |
Q:
virtualenv does not copy standard modules like shutil and urllib2
When I create a new virtualenv, virtualenv .virtualenvs/my_env, there is only a subset of the standard python modules copied/linked to the new virtualenv.
For example, when I do ls -l in .virtualenvs/my_env/lib/python2.6, I see:
...
... os.py -> /us... | virtualenv does not copy standard modules like shutil and urllib2 | When I create a new virtualenv, virtualenv .virtualenvs/my_env, there is only a subset of the standard python modules copied/linked to the new virtualenv.
For example, when I do ls -l in .virtualenvs/my_env/lib/python2.6, I see:
...
... os.py -> /usr/lib/python2.6/os.py
... os.pyc -> /usr/lib/python2.6/os.pyc
but modu... | [
"virtualenv munges sys.path to insert your virtual environment in front of the system libraries, but the system libraries are still on the path, so they should still be accessible.\nSo, for instance, do:\n>>> import os\n>>> os\n<module 'posixpath' from '/environments/userpython/lib/python2.6/posixpath.pyc'>\n>>> im... | [
7
] | [] | [] | [
"python",
"virtualenv"
] | stackoverflow_0002538523_python_virtualenv.txt |
Q:
Django says the "id may not be NULL" but why is it?
I'm going crazy today. I just tried to insert a new record and it threw back a "post_blogpost.id may not be NULL" error. Here's my model:
class BlogPost(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField(max_length=100)
... | Django says the "id may not be NULL" but why is it? | I'm going crazy today. I just tried to insert a new record and it threw back a "post_blogpost.id may not be NULL" error. Here's my model:
class BlogPost(models.Model):
title = models.CharField(max_length=100)
slug = models.SlugField(max_length=100)
who = models.ForeignKey(User, default=1)
when ... | [
"The only thing I can think of is that the table schema has become desynchronized from the model in that someone removed the AUTOINCREMENT attribute from the PK of the table.\n",
"I've also experienced odd editing results in the admin. Usually they were related to foreign keys. When the edit page has a bunch of e... | [
6,
1
] | [] | [] | [
"django",
"django_models",
"python"
] | stackoverflow_0002538771_django_django_models_python.txt |
Q:
python: image to 2-dimensional list
Is there a python lib that could make a 2-dimensional list of (R,G,B) data out of an image file?
A:
You might want to take a look at the Python Imaging Library. It has the ability to be directly converted to a 2 by 2 by 3 numpy array:
from PIL import Image
import numpy
im = Im... | python: image to 2-dimensional list | Is there a python lib that could make a 2-dimensional list of (R,G,B) data out of an image file?
| [
"You might want to take a look at the Python Imaging Library. It has the ability to be directly converted to a 2 by 2 by 3 numpy array:\nfrom PIL import Image\nimport numpy\nim = Image.open( filename )\ndata = numpy.asarray( im )\n\n",
"Or ImageMagick at http://wiki.python.org/moin/ImageMagick\n"
] | [
12,
3
] | [] | [] | [
"python"
] | stackoverflow_0002539002_python.txt |
Q:
Lightweight Object->Database in Python
I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that:
Creates a database table from a simple type description (int, float, datetime etc)
Takes a dictionary object and inserts it into the database (including handling ... | Lightweight Object->Database in Python | I am in need of a lightweight way to store dictionaries of data into a database. What I need is something that:
Creates a database table from a simple type description (int, float, datetime etc)
Takes a dictionary object and inserts it into the database (including handling datetime objects!)
If possible: Can handle b... | [
"SQLAlchemy's SQL expression layer can easily cover the first two requirements. If you also want reference handling then you'll need to use the ORM, but this might fail your lightweight requirement depending on your definition of lightweight.\n",
"SQLAlchemy offers an ORM much like django, but does not require th... | [
4,
3,
1,
0
] | [] | [] | [
"orm",
"python",
"sql"
] | stackoverflow_0002539147_orm_python_sql.txt |
Q:
What is the easiest way to ping/notify a .NET Windows Service?
What is the easiest way to ping/notify a .NET Windows Service? Do I have to use WCF for this? Or is there an easier way?
I would like to be able to wake up the service using a Python (or an Iron Python) script from anywhere.
Also is there a way I can b... | What is the easiest way to ping/notify a .NET Windows Service? | What is the easiest way to ping/notify a .NET Windows Service? Do I have to use WCF for this? Or is there an easier way?
I would like to be able to wake up the service using a Python (or an Iron Python) script from anywhere.
Also is there a way I can be notified (by email) if that the service has stopped?
| [
"\nThere is a command line tool SC which can be used start stop and query the service. \nI don't know if there is an easy way to use WMI from python but WMI provides the ability to control services remotely as well. \nIf you want to use .net use the ServiceController Class.\n\n",
"If you want to go to the low lev... | [
1,
1,
0
] | [] | [] | [
".net",
"ironpython",
"python",
"windows_services"
] | stackoverflow_0002436927_.net_ironpython_python_windows_services.txt |
Q:
django: grouping in an order_by query?
I want to allocate rankings to users, based on a points field.
Easy enough you'd think with an order_by query. But how do I deal with the situation where two users have the same number of points and need to share the same ranking? Should I use annotate to find users with the... | django: grouping in an order_by query? | I want to allocate rankings to users, based on a points field.
Easy enough you'd think with an order_by query. But how do I deal with the situation where two users have the same number of points and need to share the same ranking? Should I use annotate to find users with the same number of points?
My current code, and... | [
"I'd just use itertools.groupby. Something like:\ntop_users = [(k, list(g)) for k,g in groupby(top_users, key=lambda x: x.score))]\nfor u in top_users[0][1]:\n u.status = 'First prize'\nfor u in top_users[1][1]:\n u.status = 'Second prize'\nfor u in top_users[2][1]:\n u.status = 'Third prize'\nfor score, ... | [
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0002538096_django_python.txt |
Q:
Sunrise / set calculations
I'm trying to calculate the sunset / rise times using python based on the link provided below.
My results done through excel and python do not match the real values. Any ideas on what I could be doing wrong?
My Excel sheet can be found under .. http://transpotools.com/sun_time.xls
# Crea... | Sunrise / set calculations | I'm trying to calculate the sunset / rise times using python based on the link provided below.
My results done through excel and python do not match the real values. Any ideas on what I could be doing wrong?
My Excel sheet can be found under .. http://transpotools.com/sun_time.xls
# Created on 2010-03-28
# @author: da... | [
"You could use ephem python module:\n#!/usr/bin/env python\nimport datetime\nimport ephem # to install, type$ pip install pyephem\n\ndef calculate_time(d, m, y, lat, long, is_rise, utc_time):\n o = ephem.Observer()\n o.lat, o.long, o.date = lat, long, datetime.date(y, m, d)\n sun = ephem.Sun(o)\n next_e... | [
10,
3,
1
] | [] | [] | [
"astronomy",
"math",
"python"
] | stackoverflow_0002538190_astronomy_math_python.txt |
Q:
Drawing a clamped uniform cubic B-spline using Cairo
I have a bunch of coordinates which are the control points of a clamped uniform cubic B-spline on the 2D plane. I would like to draw this curve using Cairo calls (in Python, using Cairo's Python bindings), but as far as I know, Cairo supports Bézier curves only.... | Drawing a clamped uniform cubic B-spline using Cairo | I have a bunch of coordinates which are the control points of a clamped uniform cubic B-spline on the 2D plane. I would like to draw this curve using Cairo calls (in Python, using Cairo's Python bindings), but as far as I know, Cairo supports Bézier curves only. I also know that the segments of a B-spline between two c... | [
"Okay, so I searched a lot using Google and I think I came up with a reasonable solution that is suitable for my purposes. I'm posting it here - maybe it will be useful to someone else as well.\nFirst, let's start with a simple Point class:\nfrom collections import namedtuple\n\nclass Point(namedtuple(\"Point\", \"... | [
7,
2
] | [] | [] | [
"bezier",
"cairo",
"python"
] | stackoverflow_0002534786_bezier_cairo_python.txt |
Q:
Return current 11-digit timestamp in Python
How can I return the current time of the local machine?
A:
Do you mean this: time.time()?
From the docs:
Return the time as a floating point number expressed in seconds since the epoch, in UTC
>>> import time
>>> time.time()
1269884900.480978
>>>
| Return current 11-digit timestamp in Python | How can I return the current time of the local machine?
| [
"Do you mean this: time.time()?\nFrom the docs:\nReturn the time as a floating point number expressed in seconds since the epoch, in UTC\n>>> import time\n>>> time.time()\n1269884900.480978\n>>> \n\n"
] | [
41
] | [] | [] | [
"python",
"timestamp"
] | stackoverflow_0002540043_python_timestamp.txt |
Q:
Suppose I have a dictionary. How do I strip out all the keys? Edit: This is a nested dictionary
And have a big blob of values, with a space in between?
Edit: What if I have nested dictionaries? The current solutions work if my values are all strings. But what if my values are nested dictionaries?
A:
Assuming the... | Suppose I have a dictionary. How do I strip out all the keys? Edit: This is a nested dictionary | And have a big blob of values, with a space in between?
Edit: What if I have nested dictionaries? The current solutions work if my values are all strings. But what if my values are nested dictionaries?
| [
"Assuming the values are already strings:\n>>> d = { 1 : 'foo', 2 : 'bar' }\n>>> ' '.join(d.values())\n'foo bar'\n\nIf not, you can try to convert them to strings using for example str:\n>>> d = { 1 : 2, 3: 4 }\n>>> ' '.join(str(v) for v in d.values())\n'2 4'\n\n",
">>> a = {1: 'hello', 2: 'world'}\n>>> a.values(... | [
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0002536336_python.txt |
Q:
Timezones and the DateTimeField - Django
I'm trying to implement a "time ago" feature, for the displaying of items on a site.
As I'm caching the pages I wish to use javascript in order to render the "time ago".
Javascript knows local time and problably the Timezone of the local machine so I could play with that, b... | Timezones and the DateTimeField - Django | I'm trying to implement a "time ago" feature, for the displaying of items on a site.
As I'm caching the pages I wish to use javascript in order to render the "time ago".
Javascript knows local time and problably the Timezone of the local machine so I could play with that, but that would require to hard code the server'... | [
"The python datetime objects has a method for outputting an ISO 8601 timestamp here.\nThat page also has information on timezone manipulation. The timedelta object should also be useful for you.\n",
"I wouldn't use javascript to do this personally. Yes it has their local time, but it also means that the user wil... | [
2,
0
] | [] | [] | [
"django",
"iso8601",
"javascript",
"python",
"timezone"
] | stackoverflow_0002540298_django_iso8601_javascript_python_timezone.txt |
Q:
Python NLTK figure out tense
I have a web application that translates sentences into English; the user chooses options from drop downs that basically provide the context. Now I want to turn the word and the context into an English sentence.
One case is that the user chooses 'who' and 'when', 'who' could be: I, you... | Python NLTK figure out tense | I have a web application that translates sentences into English; the user chooses options from drop downs that basically provide the context. Now I want to turn the word and the context into an English sentence.
One case is that the user chooses 'who' and 'when', 'who' could be: I, you, you two, he, she, we, they. 'Whe... | [
"NLTK is a fairly large project containing a lot of useful tools. I'd suggest starting out by reading the NLTK Book, which is very well done. You can probably skim the first few chapters.\nThe stuff you're looking for is in chapters 7 and beyond.\n"
] | [
3
] | [] | [] | [
"nltk",
"python"
] | stackoverflow_0002539782_nltk_python.txt |
Q:
Python mechanize to follow image links?
mechanize's Browser class is great and it's follow_link() function is great too. But what to do with this kind of links:
<a href="http://example.com"><img src="…"></a>
Is there any way to follow such links? The text attribute of this type of links is simply '[IMG]', so AFAI... | Python mechanize to follow image links? | mechanize's Browser class is great and it's follow_link() function is great too. But what to do with this kind of links:
<a href="http://example.com"><img src="…"></a>
Is there any way to follow such links? The text attribute of this type of links is simply '[IMG]', so AFAIK, there is no way to differentiate such link... | [
"To follow such links you need to add nr parameter to follow_link() method.\nTry this:\nimport mechanize\nbr = mechanize.Browser()\nbr.open('http://www.systempuntoout.com')\nfor link in br.links():\n print(link)\nbr.follow_link(text='[IMG]', nr=0)\nprint br\n>>><Browser visiting http://www.systempuntoout.com/qui... | [
5
] | [] | [] | [
"hyperlink",
"image",
"mechanize",
"python"
] | stackoverflow_0002539498_hyperlink_image_mechanize_python.txt |
Q:
How to URL encode this so I can pass it to Facebook Share?
This is the URL I want to share:
http://mydomain.com/#url=http://stackoverflow.com
Inside my site, I do this in Django so that everything will work:
http://mydomain.com/#url={{external|urlencode}}
However, when I pass it to Facebook Share, everything get... | How to URL encode this so I can pass it to Facebook Share? | This is the URL I want to share:
http://mydomain.com/#url=http://stackoverflow.com
Inside my site, I do this in Django so that everything will work:
http://mydomain.com/#url={{external|urlencode}}
However, when I pass it to Facebook Share, everything gets messed up.
http://www.facebook.com/sharer.php?u=<url to share>... | [
"I think the problem is, that you first urlencode the last part of url, which you then include into another url.\ntry use urllib for that:\nimport urllib\nurllib.quote(\"http://mydomain.com/#url=http://stackoverflow.com\")\n\nor when you have to unquote something:\nurllib.unquote(\"http%3A//mydomain.com/%23url%3Dht... | [
0
] | [] | [] | [
"django",
"encoding",
"html",
"javascript",
"python"
] | stackoverflow_0002540944_django_encoding_html_javascript_python.txt |
Q:
Return template as string - Django
I'm still not sure this is the correct way to go about this, maybe not, but I'll ask anyway. I'd like to re-write wordpress (justification: because I can) albeit more simply myself in Django and I'm looking to be able to configure elements in different ways on the page. So for ex... | Return template as string - Django | I'm still not sure this is the correct way to go about this, maybe not, but I'll ask anyway. I'd like to re-write wordpress (justification: because I can) albeit more simply myself in Django and I'm looking to be able to configure elements in different ways on the page. So for example I might have:
Blog models
A site ... | [
"First, some puzzelement.\n InstanceNum = models.IntegerField() # all models have primary keys.\n\nIn Django, all model are assigned an integer primary key. \nThe comment doesn't make sense, since you don't need to add a primary key like this. The PageItem already has a primary key.\nAlso, please use lower case l... | [
2,
1
] | [] | [] | [
"django",
"django_models",
"django_templates",
"django_views",
"python"
] | stackoverflow_0002541485_django_django_models_django_templates_django_views_python.txt |
Q:
Exposing a pointer in Boost.Python
I have this very simple C++ class:
class Tree {
public:
Node *head;
};
BOOST_PYTHON_MODULE(myModule)
{
class_<Tree>("Tree")
.def_readwrite("head",&Tree::head)
;
}
I want to access the head variable from Python, but the message I see is:
No to_python... | Exposing a pointer in Boost.Python | I have this very simple C++ class:
class Tree {
public:
Node *head;
};
BOOST_PYTHON_MODULE(myModule)
{
class_<Tree>("Tree")
.def_readwrite("head",&Tree::head)
;
}
I want to access the head variable from Python, but the message I see is:
No to_python (by-value) converter found for C++ type... | [
"Of course, I find the answer ten minutes after asking the question...here's how it's done:\nclass_<Tree>(\"Tree\")\n .add_property(\"head\",\n make_getter(&Tree::head, return_value_policy<reference_existing_object>()),\n make_setter(&Tree::head, return_value_policy<reference_existing_object>()))\n;\n\n"... | [
21
] | [] | [] | [
"boost",
"boost_python",
"c++",
"python"
] | stackoverflow_0002541446_boost_boost_python_c++_python.txt |
Q:
Python - compare nested lists and append matches to new list?
I wish to compare to nested lists of unequal length. I am interested only in a match between the first element of each sub list. Should a match exist, I wish to add the match to another list for subsequent transformation into a tab delimited file. Here ... | Python - compare nested lists and append matches to new list? | I wish to compare to nested lists of unequal length. I am interested only in a match between the first element of each sub list. Should a match exist, I wish to add the match to another list for subsequent transformation into a tab delimited file. Here is an example of what I am working with:
x = [['1', 'a', 'b'], ['2'... | [
"\nUse sets to obtain collections with no duplicates. \n\nYou'll have to use tuples instead of lists as the items because set items must be hashable.\n\nThe code you posted doesn't seem to generate the output you posted. I do not have any idea how you are supposed to generate that output from that input. For exampl... | [
6,
2,
2,
1,
0
] | [] | [] | [
"compare",
"list",
"python"
] | stackoverflow_0002538708_compare_list_python.txt |
Q:
iterating through a list removing items, some items are not removed
I'm trying to transfer the contents of one list to another, but it's not working and I don't know why not. My code looks like this:
list1 = [1, 2, 3, 4, 5, 6]
list2 = []
for item in list1:
list2.append(item)
list1.remove(item)
But if I r... | iterating through a list removing items, some items are not removed | I'm trying to transfer the contents of one list to another, but it's not working and I don't know why not. My code looks like this:
list1 = [1, 2, 3, 4, 5, 6]
list2 = []
for item in list1:
list2.append(item)
list1.remove(item)
But if I run it my output looks like this:
>>> list1
[2, 4, 6]
>>> list2
[1, 3, 5]
... | [
"You're deleting items from list1 while you're iterating over it.\nThat's asking for trouble.\nTry this:\n>>> list1 = [1,2,3,4,5,6]\n>>> list2 = []\n>>> list2 = list1[:] # we copy every element from list1 using a slice\n>>> del list1[:] # we delete every element from list1\n\n",
"The reason is that you're (append... | [
8,
8,
4,
3,
1,
1,
1,
1,
1,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0002541528_list_python.txt |
Q:
Why am I getting a " instance has no attribute '__getitem__' " error?
Here's the code:
class BinaryTree:
def __init__(self,rootObj):
self.key = rootObj
self.left = None
self.right = None
root = [self.key, self.left, self.right]
def getRootVal(root):
return root[0]
... | Why am I getting a " instance has no attribute '__getitem__' " error? | Here's the code:
class BinaryTree:
def __init__(self,rootObj):
self.key = rootObj
self.left = None
self.right = None
root = [self.key, self.left, self.right]
def getRootVal(root):
return root[0]
def setRootVal(newVal):
root[0] = newVal
def getLeftChild(... | [
"Because you declared your methods wrong:\nLets have a look what happens if you call tree.getRootVal(). .getRootVal() is declared this way:\ndef getRootVal(root):\n return root[0]\n\nAs you probably know, the first parameter passed to a method is always the instance and it is provided implicitly. So you basicall... | [
22,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0002541718_python.txt |
Q:
Read/Write a file from/to network folder/share using Python?
How to Write/Read a file to/from a network folder/share using python? The application will run under Linux and network folder/share can be a Linux/Windows System.
Also, how to check that network folder/share has enough space before writing a file?
What t... | Read/Write a file from/to network folder/share using Python? | How to Write/Read a file to/from a network folder/share using python? The application will run under Linux and network folder/share can be a Linux/Windows System.
Also, how to check that network folder/share has enough space before writing a file?
What things should i consider?
| [
"Mount the shares using Samba, check the free space on the share using df or os.statvfs and read/write to it like any other folder.\n"
] | [
1
] | [] | [] | [
"network_shares",
"python"
] | stackoverflow_0002542025_network_shares_python.txt |
Q:
Python 3: receive user input including newline characters
I'm trying to read in the following text from the command-line in Python 3 (copied verbatim, newlines and all):
lcbeika
rraobmlo
grmfina
ontccep
emrlin
tseiboo
edosrgd
mkoeys
eissaml
knaiefr
Using input, I can only read in the first word as once it reads t... | Python 3: receive user input including newline characters | I'm trying to read in the following text from the command-line in Python 3 (copied verbatim, newlines and all):
lcbeika
rraobmlo
grmfina
ontccep
emrlin
tseiboo
edosrgd
mkoeys
eissaml
knaiefr
Using input, I can only read in the first word as once it reads the first newline it stops reading.
Is there a way I could read ... | [
"You can import sys and use the methods on sys.stdin for example:\ntext = sys.stdin.read()\n\nor:\nlines = sys.stdin.readlines()\n\nor:\nfor line in sys.stdin:\n # Do something with line.\n\n"
] | [
11
] | [
"if you are passing the text into your script as a file , you can use readlines()\neg\ndata=open(\"file\").readlines()\n\nor you can use fileinput\nimport fileinput\nfor line in fileinput.input():\n print line\n\n"
] | [
-1
] | [
"input",
"python",
"python_3.x"
] | stackoverflow_0002542171_input_python_python_3.x.txt |
Q:
Get a user's timezone in Python + Pylons
Is there a way to get the timezone of the connecting user using Pylons, and to adjust the content before rendering accordingly? Or can this only be done by JS?
Thanks.
A:
You can't get the client's timezone using server-side code, you can, however:
use Javascript: Date.... | Get a user's timezone in Python + Pylons | Is there a way to get the timezone of the connecting user using Pylons, and to adjust the content before rendering accordingly? Or can this only be done by JS?
Thanks.
| [
"You can't get the client's timezone using server-side code, you can, however:\n\nuse Javascript: Date.getTimezoneOffset();\nuse geolocation to determine where the user is located and deduce the timezone from the location\n\n"
] | [
2
] | [] | [] | [
"pylons",
"python",
"timezone"
] | stackoverflow_0002542206_pylons_python_timezone.txt |
Q:
Google Federated Login vs Hybrid Protocol vs Google Data Authentication. Whats's the Difference?
I am trying to implement Google Authentication in my website, in which I would also be pulling some Google Data using the Google Data API and I am using Google App Engine with Jinja2.
My question is, so many ways are m... | Google Federated Login vs Hybrid Protocol vs Google Data Authentication. Whats's the Difference? | I am trying to implement Google Authentication in my website, in which I would also be pulling some Google Data using the Google Data API and I am using Google App Engine with Jinja2.
My question is, so many ways are mentioned to do it. I am confused between Google Federated Login,Google Data Protocol, Hybrid Protocol.... | [
"Here is an article specifically on Retrieving Authenticated Google Data Feeds with Google App Engine\nThe way I understand this example: \n\nYou use the gdata-python-client to set up this AuthSub interaction\n\ngdata.auth.extract_auth_sub_token_from_url extracts the token you get from AuthSub (step 4 above)\nyou c... | [
1
] | [] | [] | [
"google_data",
"oauth",
"openid",
"python"
] | stackoverflow_0001854467_google_data_oauth_openid_python.txt |
Q:
Find elements based on xsd type with lxml
I am trying to get a list of elements with a specific xsd type with lxml 2.x and I can't figure out how to traverse the xsd for specific types.
Example of schema:
<xsd:element name="ServerOwner" type="srvrs:string90" minOccurs="0">
<xsd:element name="HostName" type="srvrs:... | Find elements based on xsd type with lxml | I am trying to get a list of elements with a specific xsd type with lxml 2.x and I can't figure out how to traverse the xsd for specific types.
Example of schema:
<xsd:element name="ServerOwner" type="srvrs:string90" minOccurs="0">
<xsd:element name="HostName" type="srvrs:string35" minOccurs="0">
Example xml data:
<sr... | [
"Really the only special support lxml has for XML Schema, as seen here, is to tell you if some document is valid according to some schema or not. Anything more sophisticated you'll have to do yourself.\nThis should be a relatively simple two-phase process, I'd think -- get all the xsd:element elements in the schema... | [
5
] | [] | [] | [
"lxml",
"python",
"xml",
"xsd"
] | stackoverflow_0002542580_lxml_python_xml_xsd.txt |
Q:
What is the most efficient way to populate class attributes with a row from a database query?
Looking to have a database query set all the instance variables in a class:
Example:
def populate(self, if):
#Perform mysql query
self._name = row['name']
self._email = row['email']
...
What's the fastes... | What is the most efficient way to populate class attributes with a row from a database query? | Looking to have a database query set all the instance variables in a class:
Example:
def populate(self, if):
#Perform mysql query
self._name = row['name']
self._email = row['email']
...
What's the fastest way to do this? Or is this not recommended (with a better approach)?
| [
"\nIt makes your code the most readable and predictable to do it manually like this. That way you know exactly what attributes exist and what attributes do not pretty easily.\nYou can use setattr to automate tons of these. \nOne fairly nice way would be to define a list attributes = ['name', 'email'...] as a class... | [
4,
3
] | [] | [] | [
"mysql",
"pylons",
"python"
] | stackoverflow_0002542887_mysql_pylons_python.txt |
Q:
Problem with room/screen/menu controller in python game: old rooms are not removed from memory
I'm literally banging my head against a wall here (as in, yes, physically, at my current location, I am damaging my cranium). Basically, I've got a Python/Pygame game with some typical game "rooms", or "screens." EG titl... | Problem with room/screen/menu controller in python game: old rooms are not removed from memory | I'm literally banging my head against a wall here (as in, yes, physically, at my current location, I am damaging my cranium). Basically, I've got a Python/Pygame game with some typical game "rooms", or "screens." EG title screen, high scores screen, and the actual game room. Something bad is happening when I switch bet... | [
"When you do something like this:\nreturn rooms.TitleScreen(self.screen, self.ev_manager) \n\nI'm assuming that you're creating a new TitleScreen object.\nIf this is what you want to do then you probably want to delete the old room object when switching rooms.\ndef notify(self, event):\n if isinstance(event, Chang... | [
1,
0,
0
] | [] | [] | [
"event_handling",
"performance",
"pygame",
"python"
] | stackoverflow_0002540437_event_handling_performance_pygame_python.txt |
Q:
python on 32 bit
Hi I am running Windows XP, on 32bit. How do I install python? When I run the installation file, it gives me an error saying "installation package not supported by processor type" does python need 64 bit to execute?
A:
Your 32-bit options (for Windows) include ActivePython 2.6.5 and ActivePytho... | python on 32 bit | Hi I am running Windows XP, on 32bit. How do I install python? When I run the installation file, it gives me an error saying "installation package not supported by processor type" does python need 64 bit to execute?
| [
"Your 32-bit options (for Windows) include ActivePython 2.6.5 and ActivePython 3.1.2 (ActivePython comes with some extras in addition to the standard python.org release), plain Python 2.6.5 and 3.1.2, and commercial solutions such as Enthought Python (ActiveState also offers commercial options, but the ones I point... | [
4,
3
] | [] | [] | [
"python",
"windows_xp"
] | stackoverflow_0002543120_python_windows_xp.txt |
Q:
Pylons: Set global variable for Authkit user
How can I can set a global variable for the username of the logged-in user? At the moment i have the following code in all my controllers to get the username. I rather set it as a global variable if possible.
request.environ.get("REMOTE_USER")
I tried putting the same c... | Pylons: Set global variable for Authkit user | How can I can set a global variable for the username of the logged-in user? At the moment i have the following code in all my controllers to get the username. I rather set it as a global variable if possible.
request.environ.get("REMOTE_USER")
I tried putting the same code in the app_globals.py file but it gave me the ... | [
"There is no single \"logged-in user\" if you're serving requests on multiple threads -- by setting a single global variable the threads would trample upon each other and end up very very confused on who \"the logged-in user\" actually is. There is (at most;-) a single logged-in user per request, so keeping that i... | [
1
] | [] | [] | [
"authkit",
"pylons",
"python"
] | stackoverflow_0002543315_authkit_pylons_python.txt |
Q:
Python's equivalence?
Is there anyway to transform the following code in Java to Python's equivalence?
public class Animal{
public enum AnimalBreed{
Dog, Cat, Cow, Chicken, Elephant
}
private static final int Animals = AnimalBreed.Dog.ordinal();
private static final String[] myAnimal = new String[Anima... | Python's equivalence? | Is there anyway to transform the following code in Java to Python's equivalence?
public class Animal{
public enum AnimalBreed{
Dog, Cat, Cow, Chicken, Elephant
}
private static final int Animals = AnimalBreed.Dog.ordinal();
private static final String[] myAnimal = new String[Animals];
private static Ani... | [
"Translating this code directly would be a waste of time. The hardest thing when moving from Java to Python is giving up most of what you know. But the simple fact is that Python is not Java, and translating line by line won't work as you expect. It's better to translate algorithms rather than code, and let Python ... | [
7,
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0002536318_python.txt |
Q:
Do you know any Augmented Reality library for python?
I would like to code something with augmented reality, do you know any python library to play with?
A:
OpenCV would be the closest match I can think of ...
A:
ARToolKit apparently has python bindings:
http://www.hitlabnz.org/forum/showthread.php?548-PyARTK-... | Do you know any Augmented Reality library for python? | I would like to code something with augmented reality, do you know any python library to play with?
| [
"OpenCV would be the closest match I can think of ...\n",
"ARToolKit apparently has python bindings:\nhttp://www.hitlabnz.org/forum/showthread.php?548-PyARTK-0.1-Python-binding-for-ARToolKit-released\nI've not experimented, ymmv.\n"
] | [
3,
1
] | [] | [] | [
"augmented_reality",
"python"
] | stackoverflow_0002543520_augmented_reality_python.txt |
Q:
In python, what is the fastest way to determine if a string is an email or an integer?
I'd like to be able to pull users from a database using either a supplied e-mail address or the user id (an integer). To do this, I have to detect if the supplied string is an integer, or an e-mail. Looking for the fastest way... | In python, what is the fastest way to determine if a string is an email or an integer? | I'd like to be able to pull users from a database using either a supplied e-mail address or the user id (an integer). To do this, I have to detect if the supplied string is an integer, or an e-mail. Looking for the fastest way to do this. Thanks.
def __init__(self, data):
#populate class data
self._fetchInfo... | [
"The canonical way to handle this in Python is to try first, ask forgiveness later: \ndef _fetchInfo(self, data):\n try:\n data=int(data)\n sql='SELECT ... WHERE id = %s'\n args=[data]\n except ValueError:\n sql='SELECT ... WHERE email = %s'\n args=[data]\n # This mig... | [
4,
2,
2,
1
] | [] | [] | [
"integer",
"python",
"string"
] | stackoverflow_0002542642_integer_python_string.txt |
Q:
Django Distinct on queryset in forms.py
I try to get a list with distinct into the forms.py like this:
forms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname'), required=False).distinct()
In the python shell this command works perfect, but when trying it in forms.py leaves me a blank form, so noth... | Django Distinct on queryset in forms.py | I try to get a list with distinct into the forms.py like this:
forms.ModelMultipleChoiceField(queryset=Events.objects.values('hostname'), required=False).distinct()
In the python shell this command works perfect, but when trying it in forms.py leaves me a blank form, so nothing appears. When i just do Events.objects.al... | [
"For a ModelMultipleChoiceField, Django expects a model object - because it stores the value of the selected item's primary key. In other words, it's meant to be used to manage ManyToMany fields.\nIt sounds like you're wanting to store the actual string value, so this might not be the right choice for you. You pro... | [
0
] | [] | [] | [
"distinct",
"django",
"forms",
"python"
] | stackoverflow_0002543672_distinct_django_forms_python.txt |
Q:
How to call Twitter's Streaming/Filter Feed with urllib2/httplib?
Update:
I switched this back from answered as I tried the solution posed in cogent Nick's answer and switched to Google's urlfetch:
logging.debug("starting urlfetch for http://%s%s" % (self.host, self.url))
result = urlfetch.fetch("http://%s%s" % (... | How to call Twitter's Streaming/Filter Feed with urllib2/httplib? | Update:
I switched this back from answered as I tried the solution posed in cogent Nick's answer and switched to Google's urlfetch:
logging.debug("starting urlfetch for http://%s%s" % (self.host, self.url))
result = urlfetch.fetch("http://%s%s" % (self.host, self.url), payload=self.body, method="POST", headers=self.he... | [
"urllib on App Engine is a thin wrapper around the urlfetch API. You're right about what's happening: Twitter's streaming API never terminates its response, so it times out, and urlfetch throws an exception.\nIf you use urlfetch directly, you can set the timeout (up to 10 seconds), and set allow_truncated to True s... | [
1
] | [] | [] | [
"google_app_engine",
"python",
"twitter_feed"
] | stackoverflow_0002543339_google_app_engine_python_twitter_feed.txt |
Q:
Average of two strings in alphabetical/lexicographical order
Suppose you take the strings 'a' and 'z' and list all the strings that come between them in alphabetical order: ['a','b','c' ... 'x','y','z']. Take the midpoint of this list and you find 'm'. So this is kind of like taking an average of those two strings... | Average of two strings in alphabetical/lexicographical order | Suppose you take the strings 'a' and 'z' and list all the strings that come between them in alphabetical order: ['a','b','c' ... 'x','y','z']. Take the midpoint of this list and you find 'm'. So this is kind of like taking an average of those two strings.
You could extend it to strings with more than one character, for... | [
"If you define an alphabet of characters, you can just convert to base 10, do an average, and convert back to base-N where N is the size of the alphabet.\nalphabet = 'abcdefghijklmnopqrstuvwxyz'\n\ndef enbase(x):\n n = len(alphabet)\n if x < n:\n return alphabet[x]\n return enbase(x/n) + alphabet[x%... | [
8,
6,
6,
2,
1,
0,
0,
0
] | [] | [] | [
"algorithm",
"python"
] | stackoverflow_0002510755_algorithm_python.txt |
Q:
wxPython, Threads, and PostEvent between modules
I'm relatively new to wxPython (but not Python itself), so forgive me if I've missed something here.
I'm writing a GUI application, which at a very basic level consists of "Start" and "Stop" buttons that start and stop a thread. This thread is an infinite loop, whic... | wxPython, Threads, and PostEvent between modules | I'm relatively new to wxPython (but not Python itself), so forgive me if I've missed something here.
I'm writing a GUI application, which at a very basic level consists of "Start" and "Stop" buttons that start and stop a thread. This thread is an infinite loop, which only ends when the thread is stopped. The loop gener... | [
"The easiest solution would be to use wx.CallAfter\nwx.CallAfter(text_control.SetValue, \"some_text\")\n\nYou can call CallAfter from any thread and the function that you pass it to be called will be called from the main thread.\n"
] | [
2
] | [] | [] | [
"events",
"multithreading",
"python",
"user_interface",
"wxpython"
] | stackoverflow_0002544339_events_multithreading_python_user_interface_wxpython.txt |
Q:
How do you determine which file is imported in Python with an "import" statement?
How do you determine which file is imported in Python with an "import" statement?
I want to determine that I am loading the correct version of a locally modified .py file. Basically the equivalent of "which" in a POSIX environment... | How do you determine which file is imported in Python with an "import" statement? | How do you determine which file is imported in Python with an "import" statement?
I want to determine that I am loading the correct version of a locally modified .py file. Basically the equivalent of "which" in a POSIX environment.
| [
"Start python with the -v parameter to enable debugging output. When you then import a module, Python will print out where the module was imported from:\n$ python -v\n...\n>>> import re\n# /usr/lib/python2.6/re.pyc matches /usr/lib/python2.6/re.py\nimport re # precompiled from /usr/lib/python2.6/re.pyc\n...\n\nIf y... | [
12,
10,
3,
0
] | [] | [] | [
"import",
"python"
] | stackoverflow_0002542809_import_python.txt |
Q:
"No module named slimmer.middleware"
I'm trying to setup blog engine django-mingus, but meet this obstacle:
[Tue Mar 30 04:14:02 2010] [error] [client 192.168.12.161] mod_wsgi (pid=12908): Exception occurred processing WSGI script '/home/piv/srv/python-env/myblog/project/django-mingus/mingus/deploy/django.wsgi'.
[... | "No module named slimmer.middleware" | I'm trying to setup blog engine django-mingus, but meet this obstacle:
[Tue Mar 30 04:14:02 2010] [error] [client 192.168.12.161] mod_wsgi (pid=12908): Exception occurred processing WSGI script '/home/piv/srv/python-env/myblog/project/django-mingus/mingus/deploy/django.wsgi'.
[Tue Mar 30 04:14:02 2010] [error] [client ... | [
"Read:\nhttp://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html\nTry the alternate WSGI script file described at the end.\nThis will resolve some sys.path issues if you hadn't done anything to address them yourself.\nIf still doesn't work, may be a permissions issue given that Apache normally runs a... | [
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0002544002_django_python.txt |
Q:
Django Sum all values with a distinct ForeignKey ID & zip them with fields from related table
I would like to perform something similar to this (ie get the sum of distinct event amounts in a payment table then group the payments by event details and total money paid for them. Also getting users and what they have ... | Django Sum all values with a distinct ForeignKey ID & zip them with fields from related table | I would like to perform something similar to this (ie get the sum of distinct event amounts in a payment table then group the payments by event details and total money paid for them. Also getting users and what they have paid for an event will be done) in Django using PostgreSQL.
My models are as below:
class UserProf... | [
"after some nerve cracking, the solution was to split the query into 2, i.e, one for grouping and summing and the other one for getting the matching values. \nFor grouping and summing, refer here\n"
] | [
0
] | [] | [] | [
"django",
"django_models",
"postgresql",
"python"
] | stackoverflow_0002534783_django_django_models_postgresql_python.txt |
Q:
How to localize an app on Google App Engine?
What options are there for localizing an app on Google App Engine? How do you do it using Webapp, Django, web2py or [insert framework here].
1. Readable URLs and entity key names
Readable URLs are good for usability and search engine optimization (Stack Overflow is a go... | How to localize an app on Google App Engine? | What options are there for localizing an app on Google App Engine? How do you do it using Webapp, Django, web2py or [insert framework here].
1. Readable URLs and entity key names
Readable URLs are good for usability and search engine optimization (Stack Overflow is a good example on how to do it). On Google App Engine,... | [
"Regarding point 1, there's really no need to go to such lengths: Simply use unicode key names. They'll be encoded as UTF-8 in the datastore for you.\nRegarding point 3, there are many ways to handle language detection. Certainly accept_language should be part of it, and you'll find webob's accept_language support ... | [
3,
2
] | [] | [] | [
"django",
"google_app_engine",
"internationalization",
"localization",
"python"
] | stackoverflow_0002544843_django_google_app_engine_internationalization_localization_python.txt |
Q:
How to create instances of related models in Django
I'm working on a CMSy app for which I've implemented a set of models which allow for creation of custom Template instances, made up of a number of Fields and tied to a specific Customer. The end-goal is that one or more templates with a set of custom fields can b... | How to create instances of related models in Django | I'm working on a CMSy app for which I've implemented a set of models which allow for creation of custom Template instances, made up of a number of Fields and tied to a specific Customer. The end-goal is that one or more templates with a set of custom fields can be defined through the Admin interface and associated to a... | [
"If you want to stick with this model architecture, you need to add another field to the ContentObject class that will serve to store the actual content. It could be something like:\nContentObject(models.Model):\n ...\n fields_content = models.ManyToManyField(Field, through=FieldContent)\n ...\n\nand then:... | [
1,
0,
0,
0
] | [] | [] | [
"django",
"models",
"python"
] | stackoverflow_0002481860_django_models_python.txt |
Q:
Class Decorators, Inheritance, super(), and maximum recursion
I'm trying to figure out how to use decorators on subclasses that use super(). Since my class decorator creates another subclass a decorated class seems to prevent the use of super() when it changes the className passed to super(className, self). Below ... | Class Decorators, Inheritance, super(), and maximum recursion | I'm trying to figure out how to use decorators on subclasses that use super(). Since my class decorator creates another subclass a decorated class seems to prevent the use of super() when it changes the className passed to super(className, self). Below is an example:
def class_decorator(cls):
class _DecoratedClass(... | [
"Basically, you can see the problem after entering your code sample at the interactive Python prompt:\n>>> SubClassAgain\n<class '__main__._DecoratedClass'>\n\ni.e., the name SubClassAgain is now bound (in global scope, in this case) to a class that in fact isn't the \"real\" SubClassAgain, but a subclass thereof. ... | [
5,
3,
3,
2,
0
] | [] | [] | [
"decorator",
"python"
] | stackoverflow_0002542747_decorator_python.txt |
Q:
python web framework for webmail service
I'm planning to write a webmail service in Python but I can't decide which framework to choose. What criteria should I look into when trying to decide which framework to use ?
A:
I know you're asking about which web framework but this might be very useful to you. Lamson i... | python web framework for webmail service | I'm planning to write a webmail service in Python but I can't decide which framework to choose. What criteria should I look into when trying to decide which framework to use ?
| [
"I know you're asking about which web framework but this might be very useful to you. Lamson is a framework for dealing with email, it lets you basically write your own mail server and do all sorts of useful stuff in Python, check it out here http://lamsonproject.org/\nFor the framework I'd recommend Django, while ... | [
2,
0,
0
] | [] | [] | [
"frameworks",
"python",
"webmail"
] | stackoverflow_0002395585_frameworks_python_webmail.txt |
Q:
Python calling pipe.communicate() in a thread
Using Python 2.6.1 on Mac OS X 10.6.2, I've the following problem:
I have a threaded process (a Thread class), and each of those threads has a pipe (a subprocess.Popen) something likeso:
from threading import Thread
cmd = "some_cmd"
class Worker(Thread):
def r... | Python calling pipe.communicate() in a thread | Using Python 2.6.1 on Mac OS X 10.6.2, I've the following problem:
I have a threaded process (a Thread class), and each of those threads has a pipe (a subprocess.Popen) something likeso:
from threading import Thread
cmd = "some_cmd"
class Worker(Thread):
def run(self):
pipe = Popen(cmd,
stdin=PI... | [
"Using multiple threads and multiple processes will often cause problems, particularly (though not exclusively) on Unix-based systems; I recommend you just avoid mixing the two.\n",
"If you call sys.exit() in the main thread, other threads will terminate at the next opportunity (on most operating systems). Howev... | [
1,
1
] | [] | [] | [
"deadlock",
"multiprocessing",
"multithreading",
"python"
] | stackoverflow_0002542423_deadlock_multiprocessing_multithreading_python.txt |
Q:
How to pass SOAP headers into python SUDS that are not defined in WSDL file
I have a camera on my network which I am trying to connect to with suds but suds doesn't send all the information needed. I need to put extra soap headers not defined in the WSDL file so the camera can understand the message. All the heade... | How to pass SOAP headers into python SUDS that are not defined in WSDL file | I have a camera on my network which I am trying to connect to with suds but suds doesn't send all the information needed. I need to put extra soap headers not defined in the WSDL file so the camera can understand the message. All the headers are contained in a SOAP envelope and then the suds command should be in the bo... | [
"I have worked out how to enter in new headers and namespaces in suds.\nAs stated above you create an Element and pass it in as a soapheader as so:\nfrom suds.sax.element import Element \nclient = client(url) \nssnns = ('ssn', 'http://namespaces/sessionid') \nssn = Element('SessionID', ns=ssnns).setText('123') \ncl... | [
22
] | [] | [] | [
"python",
"soapheader",
"suds",
"wsdl",
"xml"
] | stackoverflow_0002469988_python_soapheader_suds_wsdl_xml.txt |
Q:
cache backend works on devserver but not mod_wsgi
I am using a custom cache backend to wrap the built-in cache backends so that I can add the current site_id to all the cache_keys (this is useful for multi-site functionality with a single memcached instance)
unfortunately it works great on the django built-in devs... | cache backend works on devserver but not mod_wsgi | I am using a custom cache backend to wrap the built-in cache backends so that I can add the current site_id to all the cache_keys (this is useful for multi-site functionality with a single memcached instance)
unfortunately it works great on the django built-in devserver, but give a nasty error when I try to run it on t... | [
"Have you set the CACHE_BACKEND in your settings.py? When DEBUG=True, this is not an issue, as I believe a dummy backend is installed, but in production, you will need to set this value, presumedley even if you're writing your own backend.\ncache backend docs\nIf that's set and you're still having issues, try swit... | [
1,
0
] | [] | [] | [
"caching",
"django",
"memcached",
"python"
] | stackoverflow_0002278662_caching_django_memcached_python.txt |
Q:
How can I keep the system environments set by a bat file, which called by a python script
I call .bat files in Python to set system environments, and check the system environments were set properly, and then back to run python code, the system environments are changed back to original. How can I solve this problem... | How can I keep the system environments set by a bat file, which called by a python script | I call .bat files in Python to set system environments, and check the system environments were set properly, and then back to run python code, the system environments are changed back to original. How can I solve this problem?
| [
"Environment settings always happen in the child process and never directly affect the parent process. However you can run (in the same child process that has changed its environment, at the very end of that process) a command (env in Unix-like environment, I believe set in DOS where .bat files lived and in Window... | [
3,
1
] | [] | [] | [
"python",
"windows"
] | stackoverflow_0002546197_python_windows.txt |
Q:
Python and App Engine project structure
I am relatively new to python and app engine, and I just finished my first project.
It consists of several *.py files (usually py file for every page on the site) and respectively temple files for each py file.
In addition, I have one big PY file that has many functions that... | Python and App Engine project structure | I am relatively new to python and app engine, and I just finished my first project.
It consists of several *.py files (usually py file for every page on the site) and respectively temple files for each py file.
In addition, I have one big PY file that has many functions that are common to a lot of pages, in I also decl... | [
"I usually organize my projects in this way:\nproject \n main.py\n README\n models\n bar.py\n foo.py\n views\n foolist.hml\n barlist.hml\n controllers\n controller1.py\n controller2.py\n api\n controllerapi.py\n helpers\n utilities.py\n lib\n extfoo.py\n db\n ... | [
3,
3
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0002546199_google_app_engine_python.txt |
Q:
Python Process won't call atexit
I'm trying to use atexit in a Process, but unfortunately it doesn't seem to work. Here's some example code:
import time
import atexit
import logging
import multiprocessing
logging.basicConfig(level=logging.DEBUG)
class W(multiprocessing.Process):
def run(self):
loggin... | Python Process won't call atexit | I'm trying to use atexit in a Process, but unfortunately it doesn't seem to work. Here's some example code:
import time
import atexit
import logging
import multiprocessing
logging.basicConfig(level=logging.DEBUG)
class W(multiprocessing.Process):
def run(self):
logging.debug("%s Started" % self.name)
... | [
"As the docs say, \n\nOn Unix this is done using the SIGTERM\n signal; on Windows TerminateProcess()\n is used. Note that exit handlers and\n finally clauses, etc., will not be\n executed.\n\nIf you're on Unix, you should be able intercept SIGTERM with signal, and perform whatever \"termination activities\" you... | [
18
] | [] | [] | [
"atexit",
"multiprocessing",
"python",
"terminate"
] | stackoverflow_0002546276_atexit_multiprocessing_python_terminate.txt |
Q:
Cleaning an XML file in Python before parsing
I'm using minidom to parse an xml file and it threw an error indicating that the data is not well formed. I figured out that some of the pages have characters like ไà¸à¹€à¸Ÿà¸¥ &, causing the parser to hiccup. Is there an easy way to clean the file before I start pa... | Cleaning an XML file in Python before parsing | I'm using minidom to parse an xml file and it threw an error indicating that the data is not well formed. I figured out that some of the pages have characters like ไà¸à¹€à¸Ÿà¸¥ &, causing the parser to hiccup. Is there an easy way to clean the file before I start parsing it? Right now I'm using a regular expressing ... | [
"Try\nxmltext = re.sub(u\"[^\\x20-\\x7f]+\",u\"\",xmltext)\n\nIt will get rid of everything except 0x20-0x7F range.\nYou may start from \\x01, if you want want to keep control characters like tab, line breaks.\nxmltext = re.sub(u\"[^\\x01-\\x7f]+\",u\"\",xmltext)\n\n",
"Take a look at µTidyLib, a Python wrapper t... | [
3,
1,
0,
0
] | [
"I'd throw out all non-ASCII characters which can be identified by having the 8th bit (0x80) set (128 .. 255 respectively 0x80 .. 0xff).\n\nYou could read in the file into a Python string named old_str\nThen perform a filter call in conjunction with a lambda statement:\nnew_str = filter(lambda x: x in string.ascii_... | [
-1
] | [
"python",
"xml"
] | stackoverflow_0002545783_python_xml.txt |
Q:
xmlrpc client call in python does not come back
Using Python 2.6.4, windows
With the following script I want to test a certain xmlrpc server. I call a non-existent function and hope for a traceback with an error. Instead, the function does not return. What could be the cause?
import xmlrpclib
s = xmlrpclib.Server(... | xmlrpc client call in python does not come back | Using Python 2.6.4, windows
With the following script I want to test a certain xmlrpc server. I call a non-existent function and hope for a traceback with an error. Instead, the function does not return. What could be the cause?
import xmlrpclib
s = xmlrpclib.Server("http://127.0.0.1:80", verbose=True)
s.functioncall()... | [
"As you noticed, this is a bug in the server (the client claims to understand 1.0 and the server ignores that and responds in 1.1 anyway, so doesn't close the socket). Python has a workaround for such buggy servers in 2.7 and 3.2, see this issue, but that workaround wasn't in 2.6.4. Unfortunately, from 2.6.5's NE... | [
5,
2
] | [] | [] | [
"client",
"python",
"xml_rpc"
] | stackoverflow_0002545655_client_python_xml_rpc.txt |
Q:
py2app prescripts
The py2app documentation mentions prescripts, being run by __boot__.py prior to the main python script. I couldn't find a way to easily specify any prescript on the setup.py file or build process.
I did however manage to 'hack' __boot__.py manually and add another _run(prescript) command before m... | py2app prescripts | The py2app documentation mentions prescripts, being run by __boot__.py prior to the main python script. I couldn't find a way to easily specify any prescript on the setup.py file or build process.
I did however manage to 'hack' __boot__.py manually and add another _run(prescript) command before my main _run(main_script... | [
"See the docs: your py2app.recipes package must contain a recipe whose check method returns a dict including the 'prescripts' key whose value is, and I quote,\n\nA list of additional Python scripts to\n run before initializing the main\n script. This is often used to\n monkey-patch included modules so that\n th... | [
2
] | [] | [] | [
"monkeypatching",
"py2app",
"python"
] | stackoverflow_0002544619_monkeypatching_py2app_python.txt |
Q:
Create static instances of a class inside said class in Python
Apologies if I've got the terminology wrong here—I can't think what this particular idiom would be called.
I've been trying to create a Python 3 class that statically declares instances of itself inside itself—sort of like an enum would work. Here's a ... | Create static instances of a class inside said class in Python | Apologies if I've got the terminology wrong here—I can't think what this particular idiom would be called.
I've been trying to create a Python 3 class that statically declares instances of itself inside itself—sort of like an enum would work. Here's a simplified version of the code I wrote:
class Test:
A = Test("A"... | [
"After you defined the class, just add these two lines:\nTest.A = Test(\"A\")\nTest.B = Test(\"B\")\n\nA class in Python is an object like any other and you can add new variables at any time. You just can't do it inside the class since it's not defined at that time (it will be added to the symbol table only after t... | [
22,
4,
4
] | [] | [] | [
"python"
] | stackoverflow_0002546608_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.