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: Matching blank entries in django queryset for optional field with corresponding ones in a required field I have a django queryset in my views whose values I pack before passing to my template. There is a problem when the queryset returns none since associated values are not unpacked. the quersyet is called commen...
Matching blank entries in django queryset for optional field with corresponding ones in a required field
I have a django queryset in my views whose values I pack before passing to my template. There is a problem when the queryset returns none since associated values are not unpacked. the quersyet is called comments. Here is my views.py def forums(request ): post_list = list(forum.objects.filter(child='0')&forum.object...
[ "You could just do this:\ncomments = list(queryset or [])\n\nif the queryset resolves to None, then the empty list will be used and comments will just be an empty list.\n", "I don't think you are doing it right. I don't believe that queryset can return None. Why not just chain the filter methods?\nlist(forum.obje...
[ 3, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0002603694_django_python.txt
Q: Django sub-applications & module structure I am developing a Django application, which is a large system that requires multiple sub-applications to keep things neat. Therefore, I have a top level directory that is a Django app (as it has an empty models.py file), and multiple subdirectories, which are also applica...
Django sub-applications & module structure
I am developing a Django application, which is a large system that requires multiple sub-applications to keep things neat. Therefore, I have a top level directory that is a Django app (as it has an empty models.py file), and multiple subdirectories, which are also applications in themselves. The reason I have laid my a...
[ "You are doing it the right way, since django itself does it that way. The admin app for instance is registered in INSTALLED_APPS as django.contrib.admin, but to reset it you have to use manage.py reset admin, and indeed, manage.py reset django.contrib.admin does not work.\nIt could be considered as a bug in django...
[ 12 ]
[]
[]
[ "django", "django_apps", "python" ]
stackoverflow_0002617522_django_django_apps_python.txt
Q: Why is this logical expression in python False? My question is, why are these expressions False? Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> num = raw_input("Choose a number: ") Choose a number: 5 >>> print num ...
Why is this logical expression in python False?
My question is, why are these expressions False? Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> num = raw_input("Choose a number: ") Choose a number: 5 >>> print num 5 >>> print ( num < 18 ) False >>> print ( num == 5 )...
[ "This statement:\nnum = raw_input(\"Choose a number: \")\n\nmakes num a string, not a number, despite its misleading name. It so happens that Python 2 lets you compare strings with numbers, and in your version considers all strings larger than all numbers (the contents of the string play no role).\nUse num = int(n...
[ 9, 3, 2, 1 ]
[]
[]
[ "expression", "python" ]
stackoverflow_0002617681_expression_python.txt
Q: BOO Vs IronPython What is the difference between IronPython and BOO? Is there a need for 2 Python-like languages? A: IronPython is designed to be a faithful implementation of Python on the .NET platform. Version 1 targets Python 2.4 for compatibility, and version 2 targets version 2.5 (although most of the Pytho...
BOO Vs IronPython
What is the difference between IronPython and BOO? Is there a need for 2 Python-like languages?
[ "IronPython is designed to be a faithful implementation of Python on the .NET platform. Version 1 targets Python 2.4 for compatibility, and version 2 targets version 2.5 (although most of the Python standard library modules implemented in C aren't supported).\nBoo's stated aim is to be a \"wrist-friendly [dynamic] ...
[ 18, 11, 3, 1 ]
[]
[]
[ "boo", "clr", "ironpython", "python" ]
stackoverflow_0000600539_boo_clr_ironpython_python.txt
Q: How does ironpython speed compare to other .net languages? I would like to give sources for what I'm saying but I just dont have them, it's something I heard. Once a programming professor told me that some software benchmarking done to .net vs Python in some particular items it gave a relation of 5:8 in favor of ....
How does ironpython speed compare to other .net languages?
I would like to give sources for what I'm saying but I just dont have them, it's something I heard. Once a programming professor told me that some software benchmarking done to .net vs Python in some particular items it gave a relation of 5:8 in favor of .NET . That was his argument in favor of Python not being so much...
[ "Here are two interesting links with comparisons between IronPython, CPython, and C# (among others):\n\nCPython vs C# (Mono) benchmarks, based on several programs detailed on the site.\nCPython vs IronPython benchmarks, based on PyStone and PyBench, for versions 2.6.\n\nSo apparently it does along the lines of what...
[ 9, 1, 0 ]
[]
[]
[ ".net", "ironpython", "performance", "python" ]
stackoverflow_0001693205_.net_ironpython_performance_python.txt
Q: How do I write raw binary data in Python? I've got a Python program that stores and writes data to a file. The data is raw binary data, stored internally as str. I'm writing it out through a utf-8 codec. However, I get UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 25: character maps to ...
How do I write raw binary data in Python?
I've got a Python program that stores and writes data to a file. The data is raw binary data, stored internally as str. I'm writing it out through a utf-8 codec. However, I get UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 25: character maps to <undefined> in the cp1252.py file. This looks t...
[ "NOTE: this was written for Python 2.x. Not sure if applicable to 3.x.\nYour use of str for raw binary data in memory is correct.\n[If you're using Python 2.6+, it's even better to use bytes which in 2.6+ is just an alias to str but expresses your intention better, and will help if one day you port the code to Pyt...
[ 22, 0, 0 ]
[]
[]
[ "codec", "python", "string" ]
stackoverflow_0002611205_codec_python_string.txt
Q: Python Pyme: Simple decryption without user interaction I am using Pyme to interface with GPGME and have had no problems signing / encrypting. When I try to decrypt, however, it always brings up the prompt for the passphrase despite having set it via a c.set_passphrase_cb callback. Am I doing something wrong? A:...
Python Pyme: Simple decryption without user interaction
I am using Pyme to interface with GPGME and have had no problems signing / encrypting. When I try to decrypt, however, it always brings up the prompt for the passphrase despite having set it via a c.set_passphrase_cb callback. Am I doing something wrong?
[ "I have a similar problem.\nMy code looks like this:\ndef passphrase_callback(hint='', desc='', prev_bad=''):\n return 'password'\nclass CryptoEngine:\n class NoSignKeys(Exception):\n def init(self, str):\n Exception.init(self, str)\ndef __init__(self, user_id, passphrase):\n \"Initialize...
[ 1, 0 ]
[]
[]
[ "gnupg", "gpgme", "pyme", "python" ]
stackoverflow_0001288959_gnupg_gpgme_pyme_python.txt
Q: How to replace empty string with zero in comma-separated string? "8,5,,1,4,7,,,,7,,1,9,3,6,,,8,6,3,9,,2,5,4,,,,,3,2,,,7,4,1,1,,4,,6,9,,5,,,,5,,,1,,6,3,,,6,5,,,,7,4,,1,7,6,,,,8,,5,,,7,1,,3,9," I'm doing a programming challenge where i need to parse this sequence into my sudoku script. Need to get the above sequence...
How to replace empty string with zero in comma-separated string?
"8,5,,1,4,7,,,,7,,1,9,3,6,,,8,6,3,9,,2,5,4,,,,,3,2,,,7,4,1,1,,4,,6,9,,5,,,,5,,,1,,6,3,,,6,5,,,,7,4,,1,7,6,,,,8,,5,,,7,1,,3,9," I'm doing a programming challenge where i need to parse this sequence into my sudoku script. Need to get the above sequence into 8,5,0,1,4,7,0,0,0,7,0,1,9,3,6,0,0,8......... I tried re but with...
[ "You could use \n[(int(x) if x else 0) for x in data.split(',')]\n\ndata.split(',') splits the string into a list. It splits on the comma character:\n['8', '5', '', '1', '4', '7', '', '', '', ...]\n\nThe expression\n(int(x) if x else 0)\n\nreturns int(x) if x is True, 0 if x is False. Note that the empty string is ...
[ 11, 5, 4, 0, 0, 0 ]
[]
[]
[ "python", "string" ]
stackoverflow_0002606976_python_string.txt
Q: SQLAlchemy Mapping problem I am trying to sqlalchemy to correctly map my data. Note that a unified group is basically a group of groups. (One unifiedGroup maps to many groups but each group can only map to one ug). So basically this is the definition of my unifiedGroups: CREATE TABLE `unifiedGroups` ( `u...
SQLAlchemy Mapping problem
I am trying to sqlalchemy to correctly map my data. Note that a unified group is basically a group of groups. (One unifiedGroup maps to many groups but each group can only map to one ug). So basically this is the definition of my unifiedGroups: CREATE TABLE `unifiedGroups` ( `ugID` INT AUTO_INCREMENT, `gI...
[ "If you want a one-to-many relationship between unifiedgroups and groups, you will need to have the foreign key be in the groups table. It simply doesn't make sense any other way.\n" ]
[ 1 ]
[]
[]
[ "python", "sqlalchemy" ]
stackoverflow_0002617697_python_sqlalchemy.txt
Q: Exposing classes inside modules within a Python package directly in the package's namespace I have a wxPython application with the various GUI classes in their own modules in a package called gui. With this setup, importing the main window would be done as follows: from gui.mainwindow import MainWindow This looke...
Exposing classes inside modules within a Python package directly in the package's namespace
I have a wxPython application with the various GUI classes in their own modules in a package called gui. With this setup, importing the main window would be done as follows: from gui.mainwindow import MainWindow This looked messy to me so I changed the __init__.py file for the gui package to import the class directly ...
[ "Well, this is a quite common pattern and I think it is also the reason why you can include things inside __init__.py files.\nAs a confirmation, just grep for import statements in __init__.py files, and you will see that it is widely used in both standard library and common packages.\n" ]
[ 6 ]
[]
[]
[ "namespaces", "python", "wxpython" ]
stackoverflow_0002618425_namespaces_python_wxpython.txt
Q: sampling integers uniformly efficiently in python using numpy/scipy I have a problem where depending on the result of a random coin flip, I have to sample a random starting position from a string. If the sampling of this random position is uniform over the string, I thought of two approaches to do it: one using m...
sampling integers uniformly efficiently in python using numpy/scipy
I have a problem where depending on the result of a random coin flip, I have to sample a random starting position from a string. If the sampling of this random position is uniform over the string, I thought of two approaches to do it: one using multinomial from numpy.random, the other using the simple randint function...
[ "I changed your code to actually return values (and used randint instead of rand - isn't that what you meant?) like this...\ndef use_multinomial(length, num_points):\n probs = ones(length)/float(length)\n return multinomial(1, probs, num_points)\n\ndef use_rand(length, num_points):\n return [randint(1,leng...
[ 3 ]
[]
[]
[ "numpy", "python", "random", "scipy" ]
stackoverflow_0002618400_numpy_python_random_scipy.txt
Q: build an API service in Django I want to build an API service using Django. A basic workflow goes like this: First, an http request goes to http://mycompany.com/create?id=001&callback=http://callback.com. It will create a folder on the server with name 001. Second, if the folder does not exist, it will be created....
build an API service in Django
I want to build an API service using Django. A basic workflow goes like this: First, an http request goes to http://mycompany.com/create?id=001&callback=http://callback.com. It will create a folder on the server with name 001. Second, if the folder does not exist, it will be created. You get response immediately in XML...
[ "I have a feeling that you might be missing some Django fundamentals here. \nWhy is create.py inside of your url? \nIf you're using Django's url routing and views, the render_to_response should work fine. You might be jumping to an incorrect conclusion regarding why your response isn't getting returned.\nI'm not su...
[ 4, 2 ]
[]
[]
[ "api", "django", "python" ]
stackoverflow_0002618126_api_django_python.txt
Q: Python Game using pyGame with Window Menu elements Here's the deal. I'm trying to write an arkanoid clone game and the thing is that I need a window menu like you get in pyGTK. For example File->(Open/Save/Exit) .. something like that and opening an "about" context where the author should be written. I'm already ...
Python Game using pyGame with Window Menu elements
Here's the deal. I'm trying to write an arkanoid clone game and the thing is that I need a window menu like you get in pyGTK. For example File->(Open/Save/Exit) .. something like that and opening an "about" context where the author should be written. I'm already using pyGame for writting the game logic. I've tried pgu...
[ "wxPython allows you to integrate a Pygame window inside of a \"normal\" wxPython window - check out their wiki entry for how to do it. This should allow you to have a normal window (with File/Help/etc.) menus, but have a Pygame surface to which you can draw for your game.\n" ]
[ 4 ]
[]
[]
[ "menu", "pygame", "python", "user_interface" ]
stackoverflow_0002618446_menu_pygame_python_user_interface.txt
Q: Storing URLs while Spidering I created a little web spider in Python which I'm using to collect URLs. I'm not interested in the content. Right now I'm keeping all the visited URLs in a set in memory, because I don't want my spider to visit URLs twice. Of course that's a very limited way of accomplishing this. So w...
Storing URLs while Spidering
I created a little web spider in Python which I'm using to collect URLs. I'm not interested in the content. Right now I'm keeping all the visited URLs in a set in memory, because I don't want my spider to visit URLs twice. Of course that's a very limited way of accomplishing this. So what's the best way to keep track o...
[ "I've written a lot of spiders. To me, a bigger problem than running out of memory is the potential of losing all the URLs you've spidered already if the code or machine crashes or you decide you need to tweak the code. If you run out of RAM most machines and OSes these days will page so you'll slow down but still ...
[ 9, 7, 4, 2, 1, 0 ]
[]
[]
[ "database", "python", "storage", "url", "web_crawler" ]
stackoverflow_0002615830_database_python_storage_url_web_crawler.txt
Q: Error install PyGtk I tried to install pygtk on mac. I downloaded the pygtk file, opened up terminal and set it to my working directory, then ran the command "python setup.py install". There was an import error because there was no module dsextras. Does anyone know how to install pygtk on a mac or get dsextras. A...
Error install PyGtk
I tried to install pygtk on mac. I downloaded the pygtk file, opened up terminal and set it to my working directory, then ran the command "python setup.py install". There was an import error because there was no module dsextras. Does anyone know how to install pygtk on a mac or get dsextras.
[ "PyGtk is a beast to install because has many dependencies (see this post).\nI recommend you to install pyGtk using macports, it will handle dependencies hell for you.\n" ]
[ 2 ]
[]
[]
[ "pygtk", "python" ]
stackoverflow_0002618006_pygtk_python.txt
Q: Generating all possible subsets of a given QuerySet in Django This is just an example, but given the following model: class Foo(models.model): bar = models.IntegerField() def __str__(self): return str(self.bar) def __unicode__(self): return str(self.bar) And the following QuerySet o...
Generating all possible subsets of a given QuerySet in Django
This is just an example, but given the following model: class Foo(models.model): bar = models.IntegerField() def __str__(self): return str(self.bar) def __unicode__(self): return str(self.bar) And the following QuerySet object: foobar = Foo.objects.filter(bar__lt=20).distinct() (meaning...
[ "S = [list(itertools.combinations(foobar,i)) for i in xrange(1, len(foobar))]\n\nIt produces non-flat list. You can flatten it by:\nlist(itertools.chain.from_iterable(S))\n\n", "This will give you the powerset of foobar (as a list)\nfrom itertools import combinations\n[j for i in range(len(foobar)+1) for j in com...
[ 3, 1 ]
[]
[]
[ "django", "django_queryset", "python" ]
stackoverflow_0002618641_django_django_queryset_python.txt
Q: Does Python's shelve module use memory-mapped IO? Does anyone know if Python's shelve module uses memory-mapped IO? Maybe that question is a bit misleading. I realize that shelve uses an underlying dbm-style module to do its dirty work. What are the chances that the underlying module uses mmap? I'm prototyping ...
Does Python's shelve module use memory-mapped IO?
Does anyone know if Python's shelve module uses memory-mapped IO? Maybe that question is a bit misleading. I realize that shelve uses an underlying dbm-style module to do its dirty work. What are the chances that the underlying module uses mmap? I'm prototyping a datastore, and while I realize premature optimization...
[ "Existing dbm implementations in the Python standard library all use \"normal\" I/O, not memory mapping. You'll need to code your own dbmish implementation with memory mapping, and integrate it with shelve (directly, or, more productively, through anydbm).\n", "I'm not sure what you're trying to learn by asking ...
[ 4, 3 ]
[]
[]
[ "dbm", "mmap", "python", "shelve" ]
stackoverflow_0002618921_dbm_mmap_python_shelve.txt
Q: Error when feeding a mysql db with a python-parsed data I use this bit of code to feed some data i have parsed from a web page to a mysql database c=db.cursor() c.executemany( """INSERT INTO data (SID, Time, Value1, Level1, Value2, Level2, Value3, Level3, Value4, Level4, Value5, Level5, ObsDate) VALUES (%s, %s, %s...
Error when feeding a mysql db with a python-parsed data
I use this bit of code to feed some data i have parsed from a web page to a mysql database c=db.cursor() c.executemany( """INSERT INTO data (SID, Time, Value1, Level1, Value2, Level2, Value3, Level3, Value4, Level4, Value5, Level5, ObsDate) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", clean_data ) T...
[ "This is a guess...\nprocessThis returns a string. It doesn't return a list of tuples.\nWhat happens if you try repr(clean_data)? I think you will get something like the following:\n\"[(161,00:00:00,8.19,1,4.46,4,7.87,4,6.54,null,4.45,6,2010-04-12)]\"\n\nThat is a single string. So you are passing in a single strin...
[ 1, 0 ]
[]
[]
[ "mysql", "parsing", "python" ]
stackoverflow_0002618030_mysql_parsing_python.txt
Q: Safest python code running How can I protect my web server, if I run custom users code on server. If any user can submit his python source on my server and run it. Maybe some modules or linux tools for close any network and hardware activity for this script. Thank's all for help! A: The concept you're thinking o...
Safest python code running
How can I protect my web server, if I run custom users code on server. If any user can submit his python source on my server and run it. Maybe some modules or linux tools for close any network and hardware activity for this script. Thank's all for help!
[ "The concept you're thinking of is sandboxing. Check out the Python wiki page about it:\nhttp://wiki.python.org/moin/SandboxedPython\n", "In general, python is not the best language choice if you want to allow the execution of untrusted code. The JVM and .NET have much better support for sandboxing, so Jython an...
[ 9, 0 ]
[]
[]
[ "python", "system" ]
stackoverflow_0002618862_python_system.txt
Q: socket server framework like Tcl "socket -server" I'm looking to reimplement some Tcl code that uses the socket -server construct [1]. What's the best option in Python for a small, industrial strength multi-user network-based server that includes event loop processing/integration? [1] http://www.tcl.tk/man/tcl8.4/...
socket server framework like Tcl "socket -server"
I'm looking to reimplement some Tcl code that uses the socket -server construct [1]. What's the best option in Python for a small, industrial strength multi-user network-based server that includes event loop processing/integration? [1] http://www.tcl.tk/man/tcl8.4/TclCmd/socket.htm
[ "Sounds like Python's socketserver module. \nThere are more advanced frameworks too, asyncore is included in the stdlib and twisted is a huge networking framework.\n" ]
[ 2 ]
[]
[]
[ "event_loop", "python", "socketserver" ]
stackoverflow_0002619192_event_loop_python_socketserver.txt
Q: Difference between cellPressed and cellClicked signals of PyQt4 QTableWidget The PyQt4 QTableWidget has both cellPressed and cellClicked signals. From the name, and the little experimentation I did with them, they appear to do exactly the same thing. Is there a difference between the two? A: These signals on cel...
Difference between cellPressed and cellClicked signals of PyQt4 QTableWidget
The PyQt4 QTableWidget has both cellPressed and cellClicked signals. From the name, and the little experimentation I did with them, they appear to do exactly the same thing. Is there a difference between the two?
[ "These signals on cells are not sharply documented (that I can find) but I'd interpret them by analogy with the pressed, clicked, and released signals on buttons:\npressed means the mouse's left button's been pressed down inside the widget,\nreleased means the mouse's left button's been released (let up) inside the...
[ 3 ]
[]
[]
[ "pyqt4", "python" ]
stackoverflow_0002619446_pyqt4_python.txt
Q: Getting last insert id with SQLAlchemy I'm using SQLAlchemy import hashlib import sqlalchemy as sa from sqlalchemy import orm from allsun.model import meta t_user = sa.Table("users",meta.metadata,autoload=True) class Duplicat(Exception): pass class LoginExistsException(Exception): pass class EmailExistsExcep...
Getting last insert id with SQLAlchemy
I'm using SQLAlchemy import hashlib import sqlalchemy as sa from sqlalchemy import orm from allsun.model import meta t_user = sa.Table("users",meta.metadata,autoload=True) class Duplicat(Exception): pass class LoginExistsException(Exception): pass class EmailExistsException(Exception): pass class User(object):...
[ "You can access user.id (or whatever name you use for autoincremeted primary key field) after saving user object. SQLAlchemy automatically fills fields assigned by database.\n" ]
[ 21 ]
[]
[]
[ "python", "sqlalchemy" ]
stackoverflow_0002618714_python_sqlalchemy.txt
Q: Finding inline style with lxml.cssselector New to this library (no more familiar with BeautifulSoup either, sadly), trying to do something very simple (search by inline style): <td style="padding: 20px">blah blah </td> I just want to select all tds where style="padding: 20px", but I can't seem to figure it out. A...
Finding inline style with lxml.cssselector
New to this library (no more familiar with BeautifulSoup either, sadly), trying to do something very simple (search by inline style): <td style="padding: 20px">blah blah </td> I just want to select all tds where style="padding: 20px", but I can't seem to figure it out. All the examples show how to select td, such as: ...
[ "Well, there's a better way: XPath.\nimport lxml.html\ndata = \"\"\"<td style=\"padding: 20px\">blah blah </td>\n<td style=\"padding: 21px\">bow bow</td>\n<td style=\"padding: 20px\">buh buh</td>\n\"\"\"\ndoc = lxml.html.document_fromstring(data)\nfor col in doc.xpath(\"//td[@style='padding: 20px']\"):\n print c...
[ 4, 3, 2 ]
[]
[]
[ "lxml", "python" ]
stackoverflow_0002619536_lxml_python.txt
Q: how python http request and response works I'm newbie for python, I'm having task so I need to scan wifi and send the data to the server, the below is the format which i have to send, this work fine when enter manually in browser url text box, http://223.56.124.58:8080/ppod-web/ProcessRawData?data={"userId":"2220...
how python http request and response works
I'm newbie for python, I'm having task so I need to scan wifi and send the data to the server, the below is the format which i have to send, this work fine when enter manually in browser url text box, http://223.56.124.58:8080/ppod-web/ProcessRawData?data={"userId":"2220081127-14","timestamp":"2010-04-12 10:54:24","wi...
[ "Most likely, the issue with the script you posted in the question is you cannot directly do:\nconn=httplib.HTTPConnection(\"http://223.56.124.58:8080/wireless\") \n\nThe exception is triggered in getaddrinfo(), which calls the C function getaddrinfo() which returns EAI_NONAME:\n\nThe node or service is not known; ...
[ 10, 1, 0 ]
[]
[]
[ "http", "python" ]
stackoverflow_0002620228_http_python.txt
Q: unit test for proxy checking Proxy configuration of a machine can be easily fetched using def check_proxy(): import urllib2 http_proxy = urllib2.getproxies().get('http') I need to write a test for the above written function. In order to do that I need to:- Set the system-wide proxy to an invalid UR...
unit test for proxy checking
Proxy configuration of a machine can be easily fetched using def check_proxy(): import urllib2 http_proxy = urllib2.getproxies().get('http') I need to write a test for the above written function. In order to do that I need to:- Set the system-wide proxy to an invalid URL during the test(sounds like a b...
[ "Looking at the question tags I see you want to write unit-tests for the function. And where is your unit here? Where is your business logic? getproxies and get are functions of the standard Python library. You shouldn't test others' code in your unit-tests. Furthermore it enough to test only Things That Could Poss...
[ 2, 1 ]
[]
[]
[ "proxy", "python", "unit_testing" ]
stackoverflow_0002616999_proxy_python_unit_testing.txt
Q: pb with callback in the python optparse module I'm playing with Python 2.6 and its optparse module. I would like to convert one of my arguments to a datetime through a callback but it fails. Here is the code: def parsedate(option, opt_str, value, parser): option.date = datetime.strptime(value, "%Y/%m/%d") de...
pb with callback in the python optparse module
I'm playing with Python 2.6 and its optparse module. I would like to convert one of my arguments to a datetime through a callback but it fails. Here is the code: def parsedate(option, opt_str, value, parser): option.date = datetime.strptime(value, "%Y/%m/%d") def parse_options(args): parser = OptionParser(usa...
[ "You have parsedate in quotes. It should not be.\n" ]
[ 3 ]
[]
[]
[ "callback", "optparse", "python" ]
stackoverflow_0002620637_callback_optparse_python.txt
Q: Django 1.1 equivalent of the 'in' operator I need to display a piece of HTML only if a variable value appears in a list. I know that Django 1.2 has an 'in' operator. But I am working on a Google App Engine app. Is there a workaround I can use? A: You can use your own template tag to achieve it or put it in your ...
Django 1.1 equivalent of the 'in' operator
I need to display a piece of HTML only if a variable value appears in a list. I know that Django 1.2 has an 'in' operator. But I am working on a Google App Engine app. Is there a workaround I can use?
[ "You can use your own template tag to achieve it or put it in your controller's logic. \nHave a look at this snippet: http://www.djangosnippets.org/snippets/302/\n", "If what you need to know is whether you should render a piece of HTML, and you are going to reuse this rule in other templates, you may try to use ...
[ 1, 0 ]
[]
[]
[ "django", "django_templates", "python" ]
stackoverflow_0002620967_django_django_templates_python.txt
Q: Convert a python numpy array to c++ stl vector I'm looking for a way to read in c++ a text file containing numpy arrays and put the data into vector< vector< ... > > , can anyone help me out please ? Thanks a lot. Archy EDIT: format of the text file [[[ 0 1] [ 2 3] [ 4 5] [ 6 7] [ 8 9]] [[10 11] [12 13] [14 15] [1...
Convert a python numpy array to c++ stl vector
I'm looking for a way to read in c++ a text file containing numpy arrays and put the data into vector< vector< ... > > , can anyone help me out please ? Thanks a lot. Archy EDIT: format of the text file [[[ 0 1] [ 2 3] [ 4 5] [ 6 7] [ 8 9]] [[10 11] [12 13] [14 15] [16 17] [18 19]] [[20 21] [22 23] [24 25] [26 27] [28 ...
[ "float val;\n::std::vector<float> vals;\nifstream stream(\"c:/file.txt\");\nwhile(stream >> val) {\n vals.push_back(val);\n}\n\n", "It's going to depend on your level of expertise.\nIf you are experienced, I would suggest something like Boost.Spirit.Qi, which is a true parser library. However it might take some...
[ 0, 0 ]
[]
[]
[ "arrays", "c++", "numpy", "python", "vector" ]
stackoverflow_0002620722_arrays_c++_numpy_python_vector.txt
Q: SQLAlchemy: who is in charge of the "session"? ( and how to unit-test with sessions ) I need some guidance on how to use session objects with SQLAlchemy, and how to organize Unit Tests of my mapped objects. What I would like to able to do is something like this: thing = BigThing() # mapped object child = thing.new...
SQLAlchemy: who is in charge of the "session"? ( and how to unit-test with sessions )
I need some guidance on how to use session objects with SQLAlchemy, and how to organize Unit Tests of my mapped objects. What I would like to able to do is something like this: thing = BigThing() # mapped object child = thing.new_child() # create and return a related object thing.save() # will also save the child objec...
[ "Session is like a box where you store objects. Sure you can write __init__ method to automatically add object to it, but this implies that it's there is some global (the only) session. Sure this will cause problems in a lot of cases, but also this will simplify writing code a bit. It's explicit vs. implicit dilemm...
[ 2 ]
[]
[]
[ "orm", "python", "session", "sqlalchemy", "unit_testing" ]
stackoverflow_0002611517_orm_python_session_sqlalchemy_unit_testing.txt
Q: random() in python In python the function random() generates a random float uniformly in the semi-open range [0.0, 1.0). In principle can it ever generate 0.0 (i.e. zero) and 1.0 (i.e. unity)? What is the scenario in practicality? A: 0.0 can be generated; 1.0 cannot (since it isn't within the range, hence the ) ...
random() in python
In python the function random() generates a random float uniformly in the semi-open range [0.0, 1.0). In principle can it ever generate 0.0 (i.e. zero) and 1.0 (i.e. unity)? What is the scenario in practicality?
[ "0.0 can be generated; 1.0 cannot (since it isn't within the range, hence the ) as opposed to [).\nThe probability of generating 0.0 is equal to the probability of generating any other number within that range, namely, 1/X where X is the number of different possible results. For a standard unsigned double-precision...
[ 13, 11 ]
[]
[]
[ "python", "random" ]
stackoverflow_0002621055_python_random.txt
Q: Starter question of declarative style SQLAlchemy relation() I am quite new to SQLAlchemy, or even database programming, maybe my question is too simple. Now I have two class/table: class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) name = Column(String(40)) ... class ...
Starter question of declarative style SQLAlchemy relation()
I am quite new to SQLAlchemy, or even database programming, maybe my question is too simple. Now I have two class/table: class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) name = Column(String(40)) ... class Computer(Base): __tablename__ = 'comps' id = Column(Integ...
[ "The correct syntax should be:\nbuyer = relation(User, backref=backref('buys', order_by=id))\nuser = relation(User, backref=backref('usings', order_by=id))\n\nP.S. Next time please specify what do you mean by \"cannot run\" by posting a traceback.\nUpdate: the traceback in updated question says exactly what you nee...
[ 10 ]
[]
[]
[ "orm", "python", "relation", "sqlalchemy" ]
stackoverflow_0002621042_orm_python_relation_sqlalchemy.txt
Q: the error "invalid literal for int() with base 10:" keeps coming up I'm trying to write a very simple program, I want to print out the sum of all the multiples of 3 and 5 below 100, but, an error keeps accuring, saying "invalid literal for int() with base 10:" my program is as follows: sum = "" sum_int = int(sum) ...
the error "invalid literal for int() with base 10:" keeps coming up
I'm trying to write a very simple program, I want to print out the sum of all the multiples of 3 and 5 below 100, but, an error keeps accuring, saying "invalid literal for int() with base 10:" my program is as follows: sum = "" sum_int = int(sum) for i in range(1, 101): if i % 5 == 0: sum += i elif i %...
[ "The \"\" are the cause of these problems.\nChange \nsum = \"\"\n\nto\nsum = 0\n\nand get rid of \nelse:\n sum += \"\"\n\n", "Python is not JavaScript: \"\" does not automatically convert to 0, and 0 does not automatically convert to \"0\".\nYour program also seems to be confused between printing the sum of all t...
[ 10, 7, 3 ]
[]
[]
[ "int", "python", "string", "syntax" ]
stackoverflow_0002621243_int_python_string_syntax.txt
Q: Run unittest in a Class I have a test suite to perform smoke tests. I have all my script stored in various classes but when I try and run the test suite I can't seem to get it working if it is in a class. The code is below: (a class to call the tests) from alltests import SmokeTests class CallTests(SmokeTests): ...
Run unittest in a Class
I have a test suite to perform smoke tests. I have all my script stored in various classes but when I try and run the test suite I can't seem to get it working if it is in a class. The code is below: (a class to call the tests) from alltests import SmokeTests class CallTests(SmokeTests): def integration(self): ...
[ "Got it working, sorry for wasting everyones time, the answer was to change the default test name.\nclass SmokeTests(): \n\n def suite(self): #Function stores all the modules to be tested \n modules_to_test = ('external_sanity', 'internal_sanity') \n alltests = unittest.TestSuite() \n fo...
[ 2, 1 ]
[]
[]
[ "automated_tests", "class", "oop", "python", "unit_testing" ]
stackoverflow_0002620837_automated_tests_class_oop_python_unit_testing.txt
Q: how to make fillable forms with reportlab in python can anyone please help me with creating forms in python using the reportlab lib. i am totally new to this and i would appreciate sample code thanks A: Apparently reportlab does not support creating fillable pdf forms. The only thing I found about it being prese...
how to make fillable forms with reportlab in python
can anyone please help me with creating forms in python using the reportlab lib. i am totally new to this and i would appreciate sample code thanks
[ "Apparently reportlab does not support creating fillable pdf forms. The only thing I found about it being present in the API dates from 2003, afterwards all statements clearly say no.\nI'm answering this so late because this is one of the highest hits when you enter 'reportlab forms' in google. I do agree with Trav...
[ 7 ]
[]
[]
[ "pdf_generation", "python", "reportlab" ]
stackoverflow_0002021764_pdf_generation_python_reportlab.txt
Q: Using PyQt signals correctly A while ago I did some work in Qt for C++; now I'm working with PyQt. I have a subclass of QStackedWidget, and inside that a subclass of QWidget. In the QWidget I want to click a button that goes to the next page of the QStackedWidget. My (simplified) approach is as follows: class Stac...
Using PyQt signals correctly
A while ago I did some work in Qt for C++; now I'm working with PyQt. I have a subclass of QStackedWidget, and inside that a subclass of QWidget. In the QWidget I want to click a button that goes to the next page of the QStackedWidget. My (simplified) approach is as follows: class Stacked(QtGui.QStackedWidget): def...
[ "No, this makes perfect sense. Think of signals as people waving from the top of buildings. They don't want to cross the street (all those staircases ...), so they watch what other people on other buildings are doing. This way, no one has to care what's going on inside the buildings.\n" ]
[ 6 ]
[]
[]
[ "pyqt", "python", "signals_slots" ]
stackoverflow_0002622210_pyqt_python_signals_slots.txt
Q: A python random function acts differently when assigned to a list or called directly I have a python function that randomize a dictionary representing a position specific scoring matrix. for example: mat = { 'A' : [ 0.53, 0.66, 0.67, 0.05, 0.01, 0.86, 0.03, 0.97, 0.33, 0.41, 0.26 ] 'C' : [ 0.14, 0.04...
A python random function acts differently when assigned to a list or called directly
I have a python function that randomize a dictionary representing a position specific scoring matrix. for example: mat = { 'A' : [ 0.53, 0.66, 0.67, 0.05, 0.01, 0.86, 0.03, 0.97, 0.33, 0.41, 0.26 ] 'C' : [ 0.14, 0.04, 0.13, 0.92, 0.99, 0.04, 0.94, 0.00, 0.07, 0.23, 0.35 ] 'T' : [ 0.25, 0.07, 0.01, ...
[ "Your scrambling function is modifying the existing matrix, it is not creating a new one.\nYou create a matrix, scramble it and add it to a list. Then you scramble it again and add it again to the list. Both elements of the list contain now the same matrix object, which got scrambled twice.\n", "You are shuffling...
[ 4, 3 ]
[]
[]
[ "function", "mutable", "python" ]
stackoverflow_0002622395_function_mutable_python.txt
Q: python mechanize.browser submit() related problem im making some script with mechanize.browser module. one of problem is all other thing is ok, but when submit() form,it not working, so i was found some suspicion source part. in the html source i was found such like following. <form method="post" onsubmit="return ...
python mechanize.browser submit() related problem
im making some script with mechanize.browser module. one of problem is all other thing is ok, but when submit() form,it not working, so i was found some suspicion source part. in the html source i was found such like following. <form method="post" onsubmit="return loginCheck(this)" name="FRMLOGIN"/> im thinking, login...
[ "mechanize doesn't support Javascript at all. If you absolutely have to run that Javascript, look into Selenium. It offers python bindings to control a real, running browser like Firefox or IE.\n", "onsubmit is just ignored by mechanize, no javascript interpretation is done.\nYou need to verify what loginCheck();...
[ 2, 1, 1 ]
[]
[]
[ "mechanize", "python" ]
stackoverflow_0002544430_mechanize_python.txt
Q: Splitting a string using space delimiters and a maximum length I'd like to split a string in a similar way to .split() (so resulting in a list) but in a more intelligent way: I'd like it to split it into chunks that are up to 15 characters, but are not split mid word so: string = 'A string with words' [splitting ...
Splitting a string using space delimiters and a maximum length
I'd like to split a string in a similar way to .split() (so resulting in a list) but in a more intelligent way: I'd like it to split it into chunks that are up to 15 characters, but are not split mid word so: string = 'A string with words' [splitting process takes place] list = ('A string with','words') The string i...
[ ">>> import textwrap\n>>> string = 'A string with words'\n>>> textwrap.wrap(string,15)\n['A string with', 'words']\n\n", "You can do this two different ways:\n>>> import re, textwrap\n>>> s = 'A string with words'\n>>> textwrap.wrap(s, 15)\n['A string with', 'words']\n>>> re.findall(r'\\b.{1,15}\\b', s)\n['A stri...
[ 30, 6, 1 ]
[]
[]
[ "python", "split", "string" ]
stackoverflow_0002622572_python_split_string.txt
Q: Is there a standard lexer/parser tool for Python? A volunteer job requires us to convert a large number of LaTeX documents into ePub file format. It's a series of open-source fiction book which has so far only been produced only on paper via a print on demand service. We'd like to be able to offer the book to user...
Is there a standard lexer/parser tool for Python?
A volunteer job requires us to convert a large number of LaTeX documents into ePub file format. It's a series of open-source fiction book which has so far only been produced only on paper via a print on demand service. We'd like to be able to offer the book to users of book-reader devices (such as Kindle) which require...
[ "Try pyparsing.\nSe http://pyparsing.wikispaces.com/WhosUsingPyparsing, search for TeX. There's a project where pyparsing is used to parse a subset of TeX syntax mentioned on that page.\nFor documentation, I recommend the \"Getting started with pyparsing\" e-book, by pyparsing's author.\nEDIT: According to PaulMcG,...
[ 5, 3, 3 ]
[]
[]
[ "bnf", "compiler_construction", "parsing", "python", "tex" ]
stackoverflow_0002622038_bnf_compiler_construction_parsing_python_tex.txt
Q: How to send raw XML in Python? I am trying to send raw xml to a service in Python. I have a the address of the service and my question is how would I wrap XML in python and send it to the service. The address is in the format below. 192.1100.2.2:54239 And say the XML is: <xml version="1.0" encoding="UTF-8"><heade...
How to send raw XML in Python?
I am trying to send raw xml to a service in Python. I have a the address of the service and my question is how would I wrap XML in python and send it to the service. The address is in the format below. 192.1100.2.2:54239 And say the XML is: <xml version="1.0" encoding="UTF-8"><header/><body><code><body/> Anyone know ...
[ "This should do the trick.\nimport socket\nimport time\n\ncommand = '<xml version=\"1.0\" encoding=\"UTF-8\"><header/><body><code><body/>'\n\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.connect((\"192.1100.2.2\", 54239))\n\ns.send(command)\n\ntime.sleep(2)\nresp = s.recv(3000)\n\nprint resp\n\n", "py...
[ 7, 1 ]
[]
[]
[ "python", "xml" ]
stackoverflow_0002623054_python_xml.txt
Q: Python: how to enclose strings in a list with < and > i would like to enclose strings inside of list into <> (formatted like <%s>). The current code does the following: def create_worker (general_logger, general_config): arguments = ["worker_name", "worker_module", "worker_class"] __check_arguments(argumen...
Python: how to enclose strings in a list with < and >
i would like to enclose strings inside of list into <> (formatted like <%s>). The current code does the following: def create_worker (general_logger, general_config): arguments = ["worker_name", "worker_module", "worker_class"] __check_arguments(arguments) def __check_arguments(arguments): if len(sys.argv)...
[ "What about:\nprint \"Usage: %s delete-project %s\" % (__file__,\" \".join('<%s>'% arg for arg in arguments))\n\n", "Use a list comprehension: ['<%s>' % s for s in arguments].\n", "Replace your join bit with:\n' '.join('<%s>' % s for s in arguments)\n\n", "Replace\n(__file__,\" \".join(arguments))\n\nwith\n(_...
[ 5, 1, 0, 0 ]
[]
[]
[ "python", "string" ]
stackoverflow_0002623247_python_string.txt
Q: Why is Standard Input is not displayed as I type in Mac OS X Terminal application? I'm confused by some behavior of my Mac OS X Terminal and my Django manage.py shell and pdb. When I start a new terminal, the Standard Input is displayed as I type. However, if there is an error, suddenly Standard Input does not app...
Why is Standard Input is not displayed as I type in Mac OS X Terminal application?
I'm confused by some behavior of my Mac OS X Terminal and my Django manage.py shell and pdb. When I start a new terminal, the Standard Input is displayed as I type. However, if there is an error, suddenly Standard Input does not appear on the screen. This error continues until I shut down that terminal window. The Inpu...
[ "Maybe this is because there was an error while running Django. Sometimes it happens that the std input disappears because stty was used. You can manually hide your input by typing:\n$ stty -echo\nNow you won't see what you typed. To restore this and solve your problem just type\n$ stty echo\nThis could help.\n", ...
[ 26, 3 ]
[ "Try installing readline on Mac OS X:\n$ sudo easy_install readline\n\nThis is a blind guess, but perhaps it solves your problem.\n" ]
[ -1 ]
[ "django", "macos", "python", "shell", "terminal" ]
stackoverflow_0001301887_django_macos_python_shell_terminal.txt
Q: How do I insert data from a Python dictionary to MySQL? I manipulated some data from MySQL and the resulting dictionary "data" (print data) displays something like this : {'1': ['1', 'K', abc, 'xyz', None, None, None, datetime.date(2009, 6, 18)], '2': ['2', 'K', efg, 'xyz', None, None, None, None], '3': ['3', 'K...
How do I insert data from a Python dictionary to MySQL?
I manipulated some data from MySQL and the resulting dictionary "data" (print data) displays something like this : {'1': ['1', 'K', abc, 'xyz', None, None, None, datetime.date(2009, 6, 18)], '2': ['2', 'K', efg, 'xyz', None, None, None, None], '3': ['3', 'K', ijk, 'xyz', None, None, None, datetime.date(2010, 2, 5, 16...
[ "datetime.date matches DATE fields, and None becomes NULL. Use .executemany() in conjunction with dict.values() in order to perform the INSERT.\n", "Most dbapi-compliant connectors to MySQL will automatically convert Python's None to SQL's NULL and Python's datetime objects to SQL TIMESTAMPs.\nReally, you just ne...
[ 1, 1, 1 ]
[]
[]
[ "dictionary", "mysql", "python" ]
stackoverflow_0002623418_dictionary_mysql_python.txt
Q: Creating multiple csv files from data within a csv file System OSX or Linux I'm trying to automate my work flow at work, each week I receive an excel file, which I convert to a csv. An example is: ,,L1,,,L2,,,L3,,,L4,,,L5,,,L6,,,L7,,,L8,,,L9,,,L10,,,L11, Title,r/t,needed,actual,Inst,needed,actual,Inst,needed,actua...
Creating multiple csv files from data within a csv file
System OSX or Linux I'm trying to automate my work flow at work, each week I receive an excel file, which I convert to a csv. An example is: ,,L1,,,L2,,,L3,,,L4,,,L5,,,L6,,,L7,,,L8,,,L9,,,L10,,,L11, Title,r/t,needed,actual,Inst,needed,actual,Inst,needed,actual,Inst,needed,actual,Inst,neede d,actual,Inst,needed,actual,I...
[ "Perl \"one-liner\"\nperl -MText::CSV_XS -e'$c=Text::CSV_XS->new({binary=>1,eol=>\"\\n\"});%a=map{$i++;/^L\\d+$/?($_=>$i):()}@{$c->getline(*ARGV)};open$b{$_},\">$_\"for keys%a;while($f=$c->getline(*ARGV)){$c->print($b{$_},[@$f[0,1,$a{$_}]])for keys%a}'\n\nFor ones which have problem with reading:\n$ echo '$c=Te...'...
[ 3, 2, 2, 1, 1, 0 ]
[]
[]
[ "awk", "bash", "perl", "python", "sed" ]
stackoverflow_0002621549_awk_bash_perl_python_sed.txt
Q: Python ReportLab use of splitfirst/splitlast I'm trying to use Python with ReportLab 2.2 to create a PDF report. According to the user guide, Special TableStyle Indeces [sic] In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that the style sh...
Python ReportLab use of splitfirst/splitlast
I'm trying to use Python with ReportLab 2.2 to create a PDF report. According to the user guide, Special TableStyle Indeces [sic] In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that the style should be used only for the last row of a split tabl...
[ "Well, it looks as if I will be answering my own question.\nFirst, the documentation flat out lies where it reads \"In any style command the first row index may be set to one of the special strings 'splitlast' or 'splitfirst' to indicate that the style should be used only for the last row of a split table, or the f...
[ 3, 1, 0 ]
[]
[]
[ "python", "reportlab" ]
stackoverflow_0000078450_python_reportlab.txt
Q: Can't import obj in Python on OS X 10.6.3 Snow Leopard - libiconv.2.dylib? on OS X 10.6.3 Snow Leopard % python Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import objc Traceback (most rec...
Can't import obj in Python on OS X 10.6.3 Snow Leopard - libiconv.2.dylib?
on OS X 10.6.3 Snow Leopard % python Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) [GCC 4.2.1 (Apple Inc. build 5646)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import objc Traceback (most recent call last): File "", line 1, in File "/Library/Python/2.6/site-packages...
[ "First I'd try to temporary move /Library/Python/2.6/site-packages/pyobjc_core-2.2-py2.6-macosx-10.6-universal.egg/ to somewhere else and try the import statement again. This will enable the OS to import the version of objc that came with the OS by default (this is in /System/Library). By using the version in /Syst...
[ 2 ]
[ "You more than likely screwed with the OS's Python installation, so you'll more than likely need to reinstall your OS. \n" ]
[ -3 ]
[ "osx_snow_leopard", "pyobjc", "python" ]
stackoverflow_0002624100_osx_snow_leopard_pyobjc_python.txt
Q: Deleting rows in a text file A sample of the following text file i have is: > 1 -4.6 -4.6 -7.6 > > 2 -1.7 -3.8 -3.1 > > 3 -1.6 -1.6 -3.1 the data is separated by tabs in the text file and the first column indicates the position. I need to iterate through every value in the text file apart from...
Deleting rows in a text file
A sample of the following text file i have is: > 1 -4.6 -4.6 -7.6 > > 2 -1.7 -3.8 -3.1 > > 3 -1.6 -1.6 -3.1 the data is separated by tabs in the text file and the first column indicates the position. I need to iterate through every value in the text file apart from column 0 and find the lowest valu...
[ "Open this file for reading, another file for writing, and copy all the lines that don't match the filter:\nreadfile = open('somefile', 'r')\nwritefile = open('otherfile', 'w')\n\nfor line in readfile:\n if not somepredicate(line):\n writefile.write(line)\n\nreadfile.close()\nwritefile.close()\n\n", "Here's a...
[ 1, 0 ]
[]
[]
[ "python", "text_files" ]
stackoverflow_0002623475_python_text_files.txt
Q: Serialize Dictionary with a string key and List[] value to JSON How can I serialize a python Dictionary to JSON and pass back to javascript, which contains a string key, while the value is a List (i.e. []) if request.is_ajax() and request.method == 'GET': groupSet = GroupSet.objects.get(id=int(request.GET["gro...
Serialize Dictionary with a string key and List[] value to JSON
How can I serialize a python Dictionary to JSON and pass back to javascript, which contains a string key, while the value is a List (i.e. []) if request.is_ajax() and request.method == 'GET': groupSet = GroupSet.objects.get(id=int(request.GET["groupSetId"])) groups = groupSet.groups.all() group_items = [] #l...
[ "Your 'groups' variable is a QuerySet object, not a dict. You will want to be more explicit with the data that you want to return.\nimport json\ngroups_and_items = {}\nfor group in groups:\n group_items = []\n for item in group.group_items.all():\n group_items.append( {'id': item.id, 'name': item.name...
[ 1, 0 ]
[]
[]
[ "ajax", "django", "json", "python", "serialization" ]
stackoverflow_0002622866_ajax_django_json_python_serialization.txt
Q: Installing Django/Python on IIS6 We are currently installing the latest version of Django and Python on IIS6. We have followed the instructions on the following site: http://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer We are receiving a 403 error when trying to access our Django application via...
Installing Django/Python on IIS6
We are currently installing the latest version of Django and Python on IIS6. We have followed the instructions on the following site: http://code.djangoproject.com/wiki/DjangoOnWindowsWithIISAndSQLServer We are receiving a 403 error when trying to access our Django application via the IIS server. We have verified the ...
[ "Did you create a separate Application Pool to run PyISAPI (i.e. not the DefaultAppPool)? If so, what user/group does the pool run under? It's possible that you need to assign that user the proper rights. For example, see this page:\nhttp://support.asimo.nl/activekb/questions.php?questionid=6\nUPDATE: Here's ano...
[ 0 ]
[]
[]
[ "django", "iis_6", "linker", "pyisapie", "python" ]
stackoverflow_0002624343_django_iis_6_linker_pyisapie_python.txt
Q: What's the __repr__ equivalence in ruby? The __repr__ function of python is fancy as it is called when print OBJECT is used automatically. Is there a ruby equivalence for it? I thought it was to_s, but, I had p OBJECT doesn't seem to call the to_s method. Added I got something wrong, p OBJECT seems to call to_s m...
What's the __repr__ equivalence in ruby?
The __repr__ function of python is fancy as it is called when print OBJECT is used automatically. Is there a ruby equivalence for it? I thought it was to_s, but, I had p OBJECT doesn't seem to call the to_s method. Added I got something wrong, p OBJECT seems to call to_s method as follows. I got some hints from my th...
[ " obj.inspect => string\n\nReturns a string containing a human-readable representation of obj. If not overridden, uses the to_s method to generate the string.\n [ 1, 2, 3..4, 'five' ].inspect #=> \"[1, 2, 3..4, \\\"five\\\"]\"\n Time.new.inspect #=> \"Wed Apr 09 08:54:39 CDT 2003\"\n\n\n obj....
[ 17, 3 ]
[]
[]
[ "python", "ruby" ]
stackoverflow_0002625132_python_ruby.txt
Q: Python soap using soaplib (server) and suds (client) This question is related to: Python SOAP server / client In the case of soap with python, there are recommendation to use soaplib (http://wiki.github.com/jkp/soaplib) as soap server and suds (https://fedorahosted.org/suds/) as soap client. My target is to create...
Python soap using soaplib (server) and suds (client)
This question is related to: Python SOAP server / client In the case of soap with python, there are recommendation to use soaplib (http://wiki.github.com/jkp/soaplib) as soap server and suds (https://fedorahosted.org/suds/) as soap client. My target is to create soap services in python that can be consumed by several c...
[ "try to import primitives into your class:\nclass HelloWorldService(SimpleWSGISoapApp):\n from soaplib.serializers.primitive import String, Integer, Arraycode\n @soapmethod(String,Integer,_returns=Array(String))\n\n", "this bug is fixed if you get the latest sources from the trunk, see https://github.com/so...
[ 2, 1 ]
[]
[]
[ "python", "soap", "suds" ]
stackoverflow_0001992239_python_soap_suds.txt
Q: How do I prepare myself for a summer of working on Python using Linux environment? I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to...
How do I prepare myself for a summer of working on Python using Linux environment?
I have used just Windows for programming so far. Now, I have an internship starting in two weeks and I will be using just Linux environment with Python programming language. I've installed Ubuntu on my system but have no exposure to shell scripting. I need some advice on how I can quickly learn to use the Linux termina...
[ "As an intern you'll want to use the tools your mentor is most comfortable with. If you get stuck you'll be able to ask for advice quickly. \nLearning your way around either vi, vim, or emacs to start with will help. The basic concepts used in one will transfer to the other. You'll need to be able to open and read ...
[ 5, 2, 2, 1, 1, 1, 0, 0, 0, 0 ]
[]
[]
[ "development_environment", "linux", "python", "shell" ]
stackoverflow_0002624968_development_environment_linux_python_shell.txt
Q: In Django, I want to insert a database record by sending myself an email? I'm looking into a possible feature for my little to-do application... I like the idea that I can send an email to a particular email address, containing a to-do task I need to complete, and this will be read by my web application and be put...
In Django, I want to insert a database record by sending myself an email?
I'm looking into a possible feature for my little to-do application... I like the idea that I can send an email to a particular email address, containing a to-do task I need to complete, and this will be read by my web application and be put in the database... So, when I come to log into my application, the to-do task ...
[ "If I were to implement this, I'd use a scheduler and a job to be scheduled.\nThat job would connect to the mail server (be it POP3 or IMAP) and parse the unread messages (or messages unread by the job). Based on that I would insert that record.\nYou'd get 2 types of records that way. A list of mail message ids whi...
[ 5, 2, 1, 0 ]
[]
[]
[ "django", "email", "mysql", "python" ]
stackoverflow_0002616896_django_email_mysql_python.txt
Q: Decoding not reversing unicode encoding in Django/Python Ok, I have a hardcoded string I declare like this name = u"Par Catégorie" I have a # -- coding: utf-8 -- magic header, so I am guessing it's converted to utf-8 Down the road it's outputted to xml through xml_output.toprettyxml(indent='....', encoding='utf...
Decoding not reversing unicode encoding in Django/Python
Ok, I have a hardcoded string I declare like this name = u"Par Catégorie" I have a # -- coding: utf-8 -- magic header, so I am guessing it's converted to utf-8 Down the road it's outputted to xml through xml_output.toprettyxml(indent='....', encoding='utf-8') And I get a UnicodeDecodeError: 'ascii' codec can't dec...
[ "The coding header in your source file tells Python what encoding your source is in. It's the encoding Python uses to decode the source of the unicode string literal (u\"Par Catégorie\") into a unicode object. The unicode object itself has no encoding; it's raw unicode data. (Internally, Python will use one of two ...
[ 4, 1 ]
[]
[]
[ "character_encoding", "django", "encoding", "minidom", "python" ]
stackoverflow_0002625297_character_encoding_django_encoding_minidom_python.txt
Q: For-loops in Python What is the best way of doing this in Python? for (v = n / 2 - 1; v >= 0; v--) I actually tried Google first, but as far as I can see the only solution would be to use while. A: I would do this: for i in reversed(range(n // 2)): # Your code pass It's a bit clearer that this is a rev...
For-loops in Python
What is the best way of doing this in Python? for (v = n / 2 - 1; v >= 0; v--) I actually tried Google first, but as far as I can see the only solution would be to use while.
[ "I would do this:\nfor i in reversed(range(n // 2)):\n # Your code\n pass\n\nIt's a bit clearer that this is a reverse sequence, what the lower limit is, and what the upper limit is.\n", "The way to do it is with xrange():\nfor v in xrange(n // 2 - 1, -1, -1):\n\n(Or, in Python 3.x, with range() instead of ...
[ 15, 13, 5, 0 ]
[]
[]
[ "for_loop", "python" ]
stackoverflow_0002625540_for_loop_python.txt
Q: Python module seeing a full list as empty in another module I'm working on a pygame project and have the main engine layed out. The problem is I hit a bug that I just can not seem to figure out. What happens is one module can't read a variable from another module. It's not that the variable can't be read, it jus...
Python module seeing a full list as empty in another module
I'm working on a pygame project and have the main engine layed out. The problem is I hit a bug that I just can not seem to figure out. What happens is one module can't read a variable from another module. It's not that the variable can't be read, it just sees an empty list instead of what it really is. Instead of pos...
[ "Don't import the main script. When you run the main.py file directly, it becomes the __main__ module. When you then import main, it will find the same file (main.py) but load it a second time, under a different module object (main instead of __main__.)\nThe solution is to not do this. Don't put things you want to ...
[ 4, 0 ]
[]
[]
[ "import", "module", "python" ]
stackoverflow_0002626003_import_module_python.txt
Q: Where is Python support for PEM + RSA + DES3? I need a Python library that supports PEM files and both RSA signing and DES3 encryption. pycrypto doesn't seem to support PEM, and its mechanism for loading existing keys is undocumented and cryptic. m2crypto doesn't seem to support DES/DES3, oddly. I've been running ...
Where is Python support for PEM + RSA + DES3?
I need a Python library that supports PEM files and both RSA signing and DES3 encryption. pycrypto doesn't seem to support PEM, and its mechanism for loading existing keys is undocumented and cryptic. m2crypto doesn't seem to support DES/DES3, oddly. I've been running an openssl subprocess, but I'd rather have somethin...
[ "Check out the libraries mentioned in this overview: Comparison of Python cryptography modules\n" ]
[ 6 ]
[]
[]
[ "cryptography", "m2crypto", "pycrypto", "python" ]
stackoverflow_0002626084_cryptography_m2crypto_pycrypto_python.txt
Q: web2py error while using distinct in the queries I am using web2py with GAE. While using some of the queries which has a distinct clause, GAE throws out an error.I have pasted the Traceback. Can someone please help me out with this. In FILE: /base/data/home/apps/panneersoda/1.341206242889687944/applications/init/...
web2py error while using distinct in the queries
I am using web2py with GAE. While using some of the queries which has a distinct clause, GAE throws out an error.I have pasted the Traceback. Can someone please help me out with this. In FILE: /base/data/home/apps/panneersoda/1.341206242889687944/applications/init/controllers/default.py Traceback (most recent call la...
[ "Sorry distinct does not work on GAE, only RDBS.\n" ]
[ 2 ]
[]
[]
[ "google_app_engine", "python", "web2py" ]
stackoverflow_0002624117_google_app_engine_python_web2py.txt
Q: Beautiful Soup Unicode encode error I am trying the following code with a particular HTML file from BeautifulSoup import BeautifulSoup import re import codecs import sys f = open('test1.html') html = f.read() soup = BeautifulSoup(html) body = soup.body.contents para = soup.findAll('p') print str(para).encode('utf-...
Beautiful Soup Unicode encode error
I am trying the following code with a particular HTML file from BeautifulSoup import BeautifulSoup import re import codecs import sys f = open('test1.html') html = f.read() soup = BeautifulSoup(html) body = soup.body.contents para = soup.findAll('p') print str(para).encode('utf-8') I get the following error: UnicodeEn...
[ "The str(para) builtin is trying to use the default (ascii) encoding for the unicode in para.\nThis is done before the encode() call:\n>>> s=u'123\\u2019'\n>>> str(s)\nTraceback (most recent call last):\n File \"<interactive input>\", line 1, in <module>\nUnicodeEncodeError: 'ascii' codec can't encode character u'...
[ 2 ]
[]
[]
[ "beautifulsoup", "python", "unicode" ]
stackoverflow_0002627071_beautifulsoup_python_unicode.txt
Q: Adding python script to c++ project How would I go about adding a script written in python to a c++ project? Thanks Edit: Basically all the script does is email some data. I would like to pass the data and maybe the email address to a function written in python. Hope that clears things up.. A: You could look at ...
Adding python script to c++ project
How would I go about adding a script written in python to a c++ project? Thanks Edit: Basically all the script does is email some data. I would like to pass the data and maybe the email address to a function written in python. Hope that clears things up..
[ "You could look at Boost.Python which is a \"a C++ library which enables seamless interoperability between C++ and the Python programming language.\"\nYou have to be more specific, though.\n", "You may be interested in Boost.Python: Embedding the Interpreter, or Python/C API: Embedding the Python Interpreter. You...
[ 3, 3, 1 ]
[]
[]
[ "boost_python", "c++", "python", "visual_studio" ]
stackoverflow_0002627173_boost_python_c++_python_visual_studio.txt
Q: Get Cygwin installation path in a Python script I'm writing a cross-platform python script that needs to know if and where Cygwin is installed if the platform is NT. Right now I'm just using a naive check for the existence of the default install path 'C:\Cygwin'. I would like to be able to determine the installati...
Get Cygwin installation path in a Python script
I'm writing a cross-platform python script that needs to know if and where Cygwin is installed if the platform is NT. Right now I'm just using a naive check for the existence of the default install path 'C:\Cygwin'. I would like to be able to determine the installation path programmatically. The Windows registry doesn'...
[ "Valid for Cygwin 1.7 only:\nYou need to check both HKEY_CURRENT_USER and HKEY_LOCAL_MAHINE for the Cygwin registry key. Depending on how Cygwin was installed it could be under either key.\nThe following is an example of how to query the value using the current user.\nCYGWIN_KEY = \"SOFTWARE\\\\Cygwin\\\\setup\"\nh...
[ 2, 1, 0 ]
[]
[]
[ "cygwin", "python", "registry", "windows" ]
stackoverflow_0001925552_cygwin_python_registry_windows.txt
Q: How do I sanitize LaTeX input? I'd like to take user input (sometimes this will be large paragraphs) and generate a LaTeX document. I'm considering a couple of simple regular expressions that replaces all instances of \ with \textbackslash and all instances of { or } with \} or \{. I doubt that this is sufficient...
How do I sanitize LaTeX input?
I'd like to take user input (sometimes this will be large paragraphs) and generate a LaTeX document. I'm considering a couple of simple regular expressions that replaces all instances of \ with \textbackslash and all instances of { or } with \} or \{. I doubt that this is sufficient. What else do I need to do? Note:...
[ "If your input is plain text and you are in a normal catcode regime, you must do the following substitutions:\n\n\\ → \\textbackslash{} (note the empty group!)\n{ → \\{\n} → \\}\n$ → \\$\n& → \\&\n# → \\#\n^ → \\textasciicircum{} (requires the textcomp package)\n_ → \\_\n~ → \\textasciitilde{}\n% → \\%\n\nIn additi...
[ 16 ]
[]
[]
[ "latex", "python", "sanitization" ]
stackoverflow_0002627135_latex_python_sanitization.txt
Q: Help calling class from a class above How to call from class oneThread: back to class fun:? As in, address a class written below. Is it possible? class oneThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.start() def run(self): ...
Help calling class from a class above
How to call from class oneThread: back to class fun:? As in, address a class written below. Is it possible? class oneThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.start() def run(self): print "1" ti...
[ "You need to use the right references to the full object\nor just a field of (the wTree).\nself.fun.wTree if you pass self to the oneThread class\nself.wTree if you pass the gtk.glade.XML Object\nsee the comments...\nclass oneThread(threading.Thread):\n def __init__(self, reference):\n self.fun = referenc...
[ 1, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0002625440_python.txt
Q: What kind of client/server protocols python supports out of the box? Without installing third party libraries, what kind of Client/Server protocols Python supports out of the box ? A: Basic Web Protocols: Downloading from http, ftp and file: with urllib, but note that in python 3 that urllib.urlopen has moved t...
What kind of client/server protocols python supports out of the box?
Without installing third party libraries, what kind of Client/Server protocols Python supports out of the box ?
[ "\nBasic Web Protocols:\n\n\nDownloading from http, ftp and file: with urllib, but note that in python 3 that urllib.urlopen has moved to urllib2.urlopen and is deprecated from python 2.6\nDownloading from https and http with basic proxy and authentication support with urllib2\nhttp with httplib, and server modules...
[ 11 ]
[]
[]
[ "client_server", "python" ]
stackoverflow_0002627715_client_server_python.txt
Q: Accessing Python module fails although its package is imported My Django project's directory hierarchy looks like this: + pybsd |---+ devices |---+ templates |---+ views |---+ interaction |---- __init__.py |---- geraete.py |---- geraetemodelle.py |---...
Accessing Python module fails although its package is imported
My Django project's directory hierarchy looks like this: + pybsd |---+ devices |---+ templates |---+ views |---+ interaction |---- __init__.py |---- geraete.py |---- geraetemodelle.py |---- geraetegruppen.py |---- __init__.py |---- ajax.py ...
[ "When modules live in packages, and you import the package, Python does not automatically import all the modules in the package. Something in your program needs to import the modules you want to use. That can either be your urls module:\nimport views.interaction.gaerete\n\nor, if you want interaction.garaete to alw...
[ 3, 0, 0 ]
[]
[]
[ "import", "package", "python" ]
stackoverflow_0002628192_import_package_python.txt
Q: python file manipulation I have a directory /tmp/dir with two types of file names /tmp/dir/abc-something-server.log /tmp/dir/xyz-something-server.log .. .. and /tmp/dir/something-client.log I need append a few lines (these lines are constant) to files end with "client.log" line 1 line 2 line 3 line 4 append ...
python file manipulation
I have a directory /tmp/dir with two types of file names /tmp/dir/abc-something-server.log /tmp/dir/xyz-something-server.log .. .. and /tmp/dir/something-client.log I need append a few lines (these lines are constant) to files end with "client.log" line 1 line 2 line 3 line 4 append these four lines to files end ...
[ "not tested\nimport os,glob,fileinput\nroot=\"/tmp\"\npath=os.path.join(root,\"dir\")\nalines=[\"line 1\\n\",\"line 2\\n\",\"line 3\\n\",\"line 4\\n\"]\nos.chdir(path)\n# for clients\nfor clientfile in glob.glob(\"*.client.log\"):\n data=open(clientfile).readlines()\n data.append(alines)\n open(\"temp\",\"...
[ 3 ]
[]
[]
[ "file", "python" ]
stackoverflow_0002628370_file_python.txt
Q: Best practise when using httplib2.Http() object I'm writing a pythonic web API wrapper with a class like this import httplib2 import urllib class apiWrapper: def __init__(self): self.http = httplib2.Http() def _http(self, url, method, dict): ''' Im using this wrapper arround the ...
Best practise when using httplib2.Http() object
I'm writing a pythonic web API wrapper with a class like this import httplib2 import urllib class apiWrapper: def __init__(self): self.http = httplib2.Http() def _http(self, url, method, dict): ''' Im using this wrapper arround the http object all the time inside the class ...
[ "Supplying 'connection': 'close' in your headers should according to the docs close the connection after a response is received.:\nheaders = {'connection': 'close'}\nresp, content = h.request(url, headers=headers)\n\n", "You should keep the Http object if you reuse connections. It seems httplib2 is capable of reu...
[ 7, 2 ]
[]
[]
[ "httplib2", "python" ]
stackoverflow_0001248926_httplib2_python.txt
Q: How can a total, complete beginner read source code? I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML. I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a pa...
How can a total, complete beginner read source code?
I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML. I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a particular order I should look for? Thanks. EDIT: Sorry guys...
[ "Have you looked at these:\nPython tutorial for total beginners?\nWhat is the best quick-read Python book out there?\nSO Python Book Search\n", "I would recommend you understand the basics. What are methods, classes, variables and so on. It would be important to understand the constructs you are seeing. If you do...
[ 9, 6, 3, 3, 3, 2, 1, 0, 0 ]
[]
[]
[ "code_readability", "coding_style", "python" ]
stackoverflow_0001854827_code_readability_coding_style_python.txt
Q: python reportlab - registerFont - django - font not available after some time I'm wondering what is the best time to register a font for use in reportlab. I added the following line into my settings.py: pdfmetrics.registerFont(TTFont('Calibri', FONT_DIR + '/fonts/Calibri.ttf')) After this call the font is availab...
python reportlab - registerFont - django - font not available after some time
I'm wondering what is the best time to register a font for use in reportlab. I added the following line into my settings.py: pdfmetrics.registerFont(TTFont('Calibri', FONT_DIR + '/fonts/Calibri.ttf')) After this call the font is available for pdf generation. But it occurs that after a few days the font is not availabl...
[ "I don't know what anything about how reportlabs works, but I can say about django.\nDjango doesn't warrant that settings will be imported once (may be, there are any other problems) and it's not a good place for such things. Usually, urls.py is used for objects registration (for example, admin.autodiscover).\n" ]
[ 1 ]
[]
[]
[ "django", "python", "reportlab" ]
stackoverflow_0002628377_django_python_reportlab.txt
Q: In Django, how to create tables from an SQL file when syncdb is run How do I make syncdb execute SQL queries (for table creation) defined by me, rather then generating tables automatically. I'm looking for this solution as some particular models in my app represent SQL-table-views for a legacy-database table. So, ...
In Django, how to create tables from an SQL file when syncdb is run
How do I make syncdb execute SQL queries (for table creation) defined by me, rather then generating tables automatically. I'm looking for this solution as some particular models in my app represent SQL-table-views for a legacy-database table. So, I've created their SQL-views in my django-DB like this: CREATE VIEW legac...
[ "There are 2 possible approaches I know of to adapt your models to a legacy database table (without using views that is):\n1) Run python manage.py inspectdb within your project. This will generate models for existing database tables, you can then continue to work with those.\n2) Modify your tables with some specifi...
[ 5, 4 ]
[]
[]
[ "django", "django_models", "mysql", "python", "views" ]
stackoverflow_0002628431_django_django_models_mysql_python_views.txt
Q: Looking for a good example usage of get_or _create in Django views and raising a Form error I am looking for a good example of how to achieve the following: I would like to use get_or_create to check whether an object already exists in my database. If it does not, then it will be created. If it does exist, then I ...
Looking for a good example usage of get_or _create in Django views and raising a Form error
I am looking for a good example of how to achieve the following: I would like to use get_or_create to check whether an object already exists in my database. If it does not, then it will be created. If it does exist, then I will not create the new object, but need to raise a form error to inform the user that they need ...
[ "This is not a good example usage of get_or_create. Form validation (which you obviously try to do) comes before saving and those shouldn't be mixed at all. You should be sure your form validated before saving, but the 'already exists' check is part of the validating.\nIn your form's clean() method, write something...
[ 3 ]
[]
[]
[ "django", "django_forms", "python" ]
stackoverflow_0002628755_django_django_forms_python.txt
Q: What's the purpose of "import package"? As I just found out import package does not make the package's modules available through package.module. The same obviously holds true for from package import subpackage as well as from package import * What's the purpose of importing a package at all then if I can't access ...
What's the purpose of "import package"?
As I just found out import package does not make the package's modules available through package.module. The same obviously holds true for from package import subpackage as well as from package import * What's the purpose of importing a package at all then if I can't access its submodules but only the objects defined i...
[ "It's up to the package if it automatically imports submodules in its __init__.py or not. For example os automatically imports os.path, so this works:\nimport os\nprint os.path.abspath('somefile')\n\nSo the creator of the package can decide what is best. If automatically loading all submodules would take a rather l...
[ 4, 1 ]
[]
[]
[ "import", "package", "python" ]
stackoverflow_0002628783_import_package_python.txt
Q: TypeError: coercing to Unicode: need string or buffer, User found i have to crawl last.fm for users (university exercise). I'm new to python and get following error: Traceback (most recent call last): File "crawler.py", line 23, in <module> for f in user_.get_friends(limit='200'): File "/opt/local/Library...
TypeError: coercing to Unicode: need string or buffer, User found
i have to crawl last.fm for users (university exercise). I'm new to python and get following error: Traceback (most recent call last): File "crawler.py", line 23, in <module> for f in user_.get_friends(limit='200'): File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/p...
[ "It looks like get_friends will return a list of User objects, so you don't need to call get_user on its entries. Just use:\nfor friend in friends:\n for f in friend.get_friends(limit='200'):\n ...\n\n" ]
[ 6 ]
[]
[]
[ "last.fm", "loops", "python", "typeerror", "web_crawler" ]
stackoverflow_0002629524_last.fm_loops_python_typeerror_web_crawler.txt
Q: how to create a pure browser/javascript search engine for a bunch of static files? I was wondering if there exists some kind of indexer (in python language for exemple) that would take a bunch of html files and create an index in javascript. In the solution, these javascript files would then be used to create a pu...
how to create a pure browser/javascript search engine for a bunch of static files?
I was wondering if there exists some kind of indexer (in python language for exemple) that would take a bunch of html files and create an index in javascript. In the solution, these javascript files would then be used to create a pure browser search engine. Jerome
[ "A bit old and not in python:\nhttp://jssindex.sourceforge.net/\n", "another very simple option is\nhttp://dentedreality.com.au/projects/jssearch/\n" ]
[ 1, 1 ]
[]
[]
[ "full_text_search", "javascript", "python", "search_engine" ]
stackoverflow_0002607283_full_text_search_javascript_python_search_engine.txt
Q: python sqlite fails My program uses sqlite3 plus python. It works fine with python 2.6.2 I moved it another machine and installed 2.6.4 and running the program gave me this error File "", line 1, in File "/opt/python-2.6.4/lib/python2.6/sqlite3/init.py", line 24, in from dbapi2 import * File "/opt/python-2.6.4/...
python sqlite fails
My program uses sqlite3 plus python. It works fine with python 2.6.2 I moved it another machine and installed 2.6.4 and running the program gave me this error File "", line 1, in File "/opt/python-2.6.4/lib/python2.6/sqlite3/init.py", line 24, in from dbapi2 import * File "/opt/python-2.6.4/lib/python2.6/sqlite3/dba...
[ "See cannot-import-sqlite-with-python-2-6.\nYou are missing the .so (shared object) - probably an installation step.\n" ]
[ 1 ]
[]
[]
[ "python", "sqlite" ]
stackoverflow_0002629789_python_sqlite.txt
Q: app-engine-rest-server to raise KeyError("name %s already used" % model_name) I'm playing with the project appengine-rest-server to create the REST webservices for all the existing models. I got a strange error, the first time I query the browser: http://localhost:8080/rest/metadata/user, it gives me the result: ...
app-engine-rest-server to raise KeyError("name %s already used" % model_name)
I'm playing with the project appengine-rest-server to create the REST webservices for all the existing models. I got a strange error, the first time I query the browser: http://localhost:8080/rest/metadata/user, it gives me the result: <xs:schema> − <xs:element name="user"> − <xs:complexTy...
[ "Since you have a main() function, the App Engine caches your module and imports. Hence within the same runtime, you may call add_models() more than once. If you move the rest initialization code to module level (or into a function that gets called once during module initialization, not during every call to main())...
[ 3 ]
[]
[]
[ "google_app_engine", "python", "rest" ]
stackoverflow_0002629813_google_app_engine_python_rest.txt
Q: Copying contents of a model If there exists an old data of a model say , query=Emp.objects.filter(pk=profile.id) Is there a easier way to copy the same values into the same model again.. Now that the id will be different so.. I have this requirement. Thanks.. A: object = Emp.objects.get(pk=profile.id) object.sa...
Copying contents of a model
If there exists an old data of a model say , query=Emp.objects.filter(pk=profile.id) Is there a easier way to copy the same values into the same model again.. Now that the id will be different so.. I have this requirement. Thanks..
[ "object = Emp.objects.get(pk=profile.id)\nobject.save(force_insert=True)\n\nIt's much more explicit then removing primary key's value. See also \"forcing an insert or update\" in Django documentation.\n", "Unless you have a complex model with inheritance, this should work:\nquery.pk = None\nquery.save() #Will ins...
[ 7, 3 ]
[]
[]
[ "django", "django_models", "django_queryset", "django_views", "python" ]
stackoverflow_0002628893_django_django_models_django_queryset_django_views_python.txt
Q: Python - multi-line array in c++ I can wrote: int someArray[8][8]; for (int i=0; i < 7; i++) for (int j=0; j < 7; j++) someArray[i][j] = 0; And how can I initialize multi-line arrays in python? I tried: array = [[],[]] for i in xrange(8): for j in xrange(8): array[i][j] = 0 A: >>> [[0]*8 for...
Python - multi-line array
in c++ I can wrote: int someArray[8][8]; for (int i=0; i < 7; i++) for (int j=0; j < 7; j++) someArray[i][j] = 0; And how can I initialize multi-line arrays in python? I tried: array = [[],[]] for i in xrange(8): for j in xrange(8): array[i][j] = 0
[ ">>> [[0]*8 for x in xrange(8)]\n[[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]\n>>>\n\n", "You asked about initializing a list of lists. Its a very use...
[ 7, 7, 3, 3, 2 ]
[]
[]
[ "arrays", "python" ]
stackoverflow_0002630211_arrays_python.txt
Q: django create list from a queryset list I have a list of objects from a django queryset, e.g. my_list = MyObject.objects.filter(variable=something) MyObject has a field called year which is set to a particular year, e.g. 2005, 2007, 2009 I want to take my_list and create a dictionary of years which holds all MyOb...
django create list from a queryset list
I have a list of objects from a django queryset, e.g. my_list = MyObject.objects.filter(variable=something) MyObject has a field called year which is set to a particular year, e.g. 2005, 2007, 2009 I want to take my_list and create a dictionary of years which holds all MyObject values for that year. e.g. my_dict['2005...
[ "import collections\n\nmydict = collections.defaultdict(list)\n\nfor obj in my_list:\n mydict[obj.year].append(obj)\n\n", "(Don't call the queryset 'my_list', it's not actually a list but a queryset. Call it something like 'my_objects'.)\nmy_dict = {}\nfor obj in my_objects:\n my_dict.setdefault(obj.year, [])...
[ 4, 1 ]
[]
[]
[ "django", "python" ]
stackoverflow_0002630680_django_python.txt
Q: python: sorting hi im doing a loop so i could get dict of data, but since its a dict it's sorting alphabetical and not as i push it trought the loop ... is it possible to somehow turn off alphabetical sorting? here is how do i do that data = {} for item in container: data[item] = {} ... for key, val in item...
python: sorting
hi im doing a loop so i could get dict of data, but since its a dict it's sorting alphabetical and not as i push it trought the loop ... is it possible to somehow turn off alphabetical sorting? here is how do i do that data = {} for item in container: data[item] = {} ... for key, val in item_container.iteritems(...
[ "If you really need to use a dictionary and not a list, take a look at the new OrderedDict (Python 3.1, soon to be available in Python 2.7, too). This will preserve the order in which its items were added.\nfrom collections import OrderedDict\ndata = OrderedDict()\nfor item in container:\n data[item] = OrderedDict...
[ 5, 3, 0 ]
[]
[]
[ "dictionary", "loops", "python", "sorting" ]
stackoverflow_0002630241_dictionary_loops_python_sorting.txt
Q: sqlalchemy relation through another (declarative) Is anyone familiar with ActiveRecord's "has_many :through" relations for models? I'm not really a Rails guy, but that's basically what I'm trying to do. As a contrived example consider Projects, Programmers, and Assignments: from sqlalchemy import create_engine fr...
sqlalchemy relation through another (declarative)
Is anyone familiar with ActiveRecord's "has_many :through" relations for models? I'm not really a Rails guy, but that's basically what I'm trying to do. As a contrived example consider Projects, Programmers, and Assignments: from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sqlalchemy ...
[ "There are two ways I see:\n\nDefine a relation Programmer.projects with secondary='assignment'.\nI define Assignment.project as relation and Programmer.projects as association_proxy('assignments', 'project') (probably you'd also like to define a creator). See Simplifying Association Object Relationships chapter fo...
[ 3 ]
[]
[]
[ "declarative", "one_to_many", "python", "relation", "sqlalchemy" ]
stackoverflow_0002630146_declarative_one_to_many_python_relation_sqlalchemy.txt
Q: Python analog of Unix 'which' In *nix systems one can use which to find out the full path to a command. For example: $ which python /usr/bin/python or whereis to show all possible locations for a given command $ whereis python python: /bin/python.exe /bin/python2.5-config /usr/bin/python.exe /usr/bin/python2.5-c...
Python analog of Unix 'which'
In *nix systems one can use which to find out the full path to a command. For example: $ which python /usr/bin/python or whereis to show all possible locations for a given command $ whereis python python: /bin/python.exe /bin/python2.5-config /usr/bin/python.exe /usr/bin/python2.5-config /lib/python2.4 /lib/python2.5...
[ "If you do:\nmodulename.__file__\nYou will get a full path return of that exact module. For example, importing django:\n>>>> import django\n>>> django.__file__\n'/home/bartek/.virtualenvs/safetyville/lib/python2.6/site-packages/django/__init__.pyc'\n\nEdit: I recommend seeing the comments below for some good insigh...
[ 5, 1 ]
[]
[]
[ "bash", "python" ]
stackoverflow_0002629472_bash_python.txt
Q: Checkers board structure I am implementing a checkers game board with python. Here is how I generate the board structure as an [8][8] array: _matrix = [] for i in xrange(8): _matrix.append( [' '] * 8 ) for row in xrange(0, 8): for col in xrange(0, 8): if _darkQuad(row, col) == True: ...
Checkers board structure
I am implementing a checkers game board with python. Here is how I generate the board structure as an [8][8] array: _matrix = [] for i in xrange(8): _matrix.append( [' '] * 8 ) for row in xrange(0, 8): for col in xrange(0, 8): if _darkQuad(row, col) == True: _matrix[row][...
[ "Update for newly posted code\nThe problem is with the line:\nself._matrix.append( [gameSquare()] * 8 )\n\nThis will create 8 references on each line to the same object. When you change one of them, it will actually change the whole row. To fix it:\nself._matrix.append( [gameSquare() for _ in xrange(8)] )\n\nEnd up...
[ 6, 1, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0002631165_python.txt
Q: Converting BMP to Grey Scale in Image Module Python I was wondering how I can convert BMPs to a grey scale using Image Module of Python? Thanks A: Greyscale image mode is 'L'. >>> import Image >>> Image.open('input.bmp').convert('L').save('output.bmp')
Converting BMP to Grey Scale in Image Module Python
I was wondering how I can convert BMPs to a grey scale using Image Module of Python? Thanks
[ "Greyscale image mode is 'L'.\n>>> import Image\n>>> Image.open('input.bmp').convert('L').save('output.bmp')\n\n" ]
[ 4 ]
[]
[]
[ "image", "python" ]
stackoverflow_0002631311_image_python.txt
Q: Best Way to Run Functional Tests of a WSGI Application? I'm writing a pair of simple WSGI applications to get a feel for the standard, and I'm to the point where I'd like to test that my applications are working as expected. Now I'm trying to figure out the best way start and stop a server hosting those applicatio...
Best Way to Run Functional Tests of a WSGI Application?
I'm writing a pair of simple WSGI applications to get a feel for the standard, and I'm to the point where I'd like to test that my applications are working as expected. Now I'm trying to figure out the best way start and stop a server hosting those applications. My first thought was to start up the SimpleServer from ws...
[ "The best way to test WSGI applications is WebTest, which eliminates the need to spawn test servers for your app. Instead, it allows you to do make HTTP requests to your WSGI app as method calls on a TestApp object:\n>>> from webtest import TestApp\n>>> from myapp import my_wsgi_app\n>>> app = TestApp(my_wsgi_app)...
[ 4, 1 ]
[]
[]
[ "functional_testing", "python", "testing", "wsgi" ]
stackoverflow_0002630843_functional_testing_python_testing_wsgi.txt
Q: Which software for intranet CMS - Django or Joomla? In my company we are thinking of moving from wiki style intranet to a more bespoke CMS solution. Natural choice would be Joomla, but we have a specific architecture. There is a few hundred people who will use the system. System should be self explainable (easier ...
Which software for intranet CMS - Django or Joomla?
In my company we are thinking of moving from wiki style intranet to a more bespoke CMS solution. Natural choice would be Joomla, but we have a specific architecture. There is a few hundred people who will use the system. System should be self explainable (easier than wiki). We use a lot of tools web, applications and i...
[ "Django isn't a CMS. If you want to build an application then you'd use Django (by the sound of your post you understand that though). If you just want to be able to edit/store content and have permissions for your users - a CMS would be the way to go. I really don't know anything about Joomla though. It should be ...
[ 8, 7, 3, 2, 1, 1, 0, 0, 0 ]
[]
[]
[ "content_management_system", "django", "joomla", "python" ]
stackoverflow_0000423916_content_management_system_django_joomla_python.txt
Q: Is there a programmatic way to transform a sequence of image files into a PDF? I have a sequence of JPG images. Each of the scans is already cropped to the exact size of one page. They are sequential pages of a valuable and out of print book. The publishing application requires that these pages be submitted as a s...
Is there a programmatic way to transform a sequence of image files into a PDF?
I have a sequence of JPG images. Each of the scans is already cropped to the exact size of one page. They are sequential pages of a valuable and out of print book. The publishing application requires that these pages be submitted as a single PDF file. I could take each of these images and just past them into a word-pr...
[ "\nIt occurred to me that there must be a simpler way - so any suggestions? \n\nYou're right, there is! Try this:\nsudo apt-get install imagemagick\ncd ~/rare-book-images\nconvert \"*.jpg\" rare-book.pdf\n\nNote: depending on what shell you're using \"*.jpg\" might not work as expected. Try omitting the quotes and ...
[ 12, 6, 0 ]
[]
[]
[ "documentation", "latex", "pdf_generation", "python", "tex" ]
stackoverflow_0002619071_documentation_latex_pdf_generation_python_tex.txt
Q: Converting IPv4 or IPv6 address to a long for comparisons In order to check if an IPv4 or IPv6 address is within a certain range, I've got code that takes an IPv4 address, turns that into a long, then does that same conversion on the upper/lower bound of the subnet, then checks to see if the long is between those ...
Converting IPv4 or IPv6 address to a long for comparisons
In order to check if an IPv4 or IPv6 address is within a certain range, I've got code that takes an IPv4 address, turns that into a long, then does that same conversion on the upper/lower bound of the subnet, then checks to see if the long is between those values. I'd like to be able to do the same thing for IPv6, but ...
[ "IPy allows you to do all sorts of transforms on both IPv4 and IPv6 addresses.\n" ]
[ 2 ]
[]
[]
[ "ipv6", "python" ]
stackoverflow_0002631588_ipv6_python.txt
Q: using a "temporary files" folder in python I recently wrote a script which queries PyPI and downloads a package; however, the package gets downloaded to a user defined folder. I`d like to modify the script in such a way that my downloaded files go into a temporary folder, if the folder is not specified. The tempor...
using a "temporary files" folder in python
I recently wrote a script which queries PyPI and downloads a package; however, the package gets downloaded to a user defined folder. I`d like to modify the script in such a way that my downloaded files go into a temporary folder, if the folder is not specified. The temporary-files folder in *nix machines is "/tmp" ; wo...
[ "Python has a built-in module for using temporary files and folders. You probably want tempfile.mkdtemp().\n", "Perhaps the tempfile module?\n" ]
[ 8, 0 ]
[]
[]
[ "operating_system", "python", "temporary_directory", "temporary_files" ]
stackoverflow_0002631923_operating_system_python_temporary_directory_temporary_files.txt
Q: difference in logging mechanism: API and application(python) I am currently writing an API and an application which uses the API. I have gotten suggestions from people stating that I should perform logging using handlers in the application and use a "logger" object for logging from the API. In light of the advice ...
difference in logging mechanism: API and application(python)
I am currently writing an API and an application which uses the API. I have gotten suggestions from people stating that I should perform logging using handlers in the application and use a "logger" object for logging from the API. In light of the advice I received above, is the following implementation correct? class t...
[ "It's not very clear whether your question is about the specifics of how to use logging or about logging exceptions, but if the latter, I would agree with Adam Crossland that log-and-swallow is a pattern to be avoided.\nIn terms of the mechanics of logging, I would make the following observations:\n\nYou don't need...
[ 15, 4, 1 ]
[]
[]
[ "api", "logging", "python" ]
stackoverflow_0002630926_api_logging_python.txt
Q: Python thinks I'm a different IP I'm trying to set a page that displays the visitor's IP. All the methods I have tried show an IP different from the IP my computer has. I've tried: Looking up http://www.whatismyip.com/automation/n09230945.asp Using socket.getaddrinfo(socket.gethostname(), None)[0][4][0] How can ...
Python thinks I'm a different IP
I'm trying to set a page that displays the visitor's IP. All the methods I have tried show an IP different from the IP my computer has. I've tried: Looking up http://www.whatismyip.com/automation/n09230945.asp Using socket.getaddrinfo(socket.gethostname(), None)[0][4][0] How can I find the real IP of the visitor?
[ "Using the low level networking interface you are actually getting the address of the server the python interpreter is running on:\n\"socket.gethostname(): Return a string containing the hostname of the machine where the Python interpreter is currently executing.\"\nGetting the client ip using low-level network int...
[ 4, 0 ]
[]
[]
[ "ip", "python" ]
stackoverflow_0002630371_ip_python.txt
Q: Rewriting Live TCP/IP (Layer 4) (i.e. Socket Layer) Streams I have a simple problem which I'm sure someone here has done before... I want to rewrite Layer 4 TCP/IP streams (Not lower layer individual packets or frames.) Ettercap's etterfilter command lets you perform simple live replacements of Layer 4 TCP/IP str...
Rewriting Live TCP/IP (Layer 4) (i.e. Socket Layer) Streams
I have a simple problem which I'm sure someone here has done before... I want to rewrite Layer 4 TCP/IP streams (Not lower layer individual packets or frames.) Ettercap's etterfilter command lets you perform simple live replacements of Layer 4 TCP/IP streams based on fixed strings or regexes. Example ettercap scriptin...
[ "Take a look on Scapy, or another packet crafting tool. There are not much of this type out there.\n", "Ettercap is seemingly an open source project, since it is hosted on SourceForge. Perhaps you should look at how it does it.\n", "At the time I was writing a network traffic analysis tool using libpcap for th...
[ 2, 1, 1, 0, 0, 0, 0 ]
[]
[]
[ "c", "network_programming", "python", "security", "sockets" ]
stackoverflow_0002563978_c_network_programming_python_security_sockets.txt
Q: Reading an image from the clipboard with wxPython How can I read an image from the clipboard? I'm able to read text from the clipboard using wx.Clipboard, but not images. Is it possible to read images with wx.Clipboard? If not, is there another way? I'm using Python 2.5 and Windows Vista 64-bit. A: The following...
Reading an image from the clipboard with wxPython
How can I read an image from the clipboard? I'm able to read text from the clipboard using wx.Clipboard, but not images. Is it possible to read images with wx.Clipboard? If not, is there another way? I'm using Python 2.5 and Windows Vista 64-bit.
[ "The following works for me (tested on Mac OSX)\nimport wx\nclass MyFrame(wx.Frame):\n def __init__(self):\n wx.Frame.__init__(self, None, -1, 'test frame',size=(790, 524))\n self.Bind(wx.EVT_LEFT_DOWN, self.OnClick)\n self.Bind(wx.EVT_PAINT, self.OnPaint)\n self.clip = wx.Clipboard()...
[ 2, 0 ]
[]
[]
[ "image", "memory", "python", "wxpython" ]
stackoverflow_0002629907_image_memory_python_wxpython.txt
Q: What does binding mean exactly? I always see people mention that "Python binding" and "C Sharp binding" etc. when I am actually using their C++ libraries. What does binding mean? If the library is written in C, and does Python binding means that they use SWIG kind of tool to mock a Python interface? Newbie in this...
What does binding mean exactly?
I always see people mention that "Python binding" and "C Sharp binding" etc. when I am actually using their C++ libraries. What does binding mean? If the library is written in C, and does Python binding means that they use SWIG kind of tool to mock a Python interface? Newbie in this field, and any suggestion will be we...
[ "When someone talks about something like a \"C# binding\" of a library, they are indicating that you and API is being provided in C# for a library written in a different language. This may or may not involve an autogeneration tool like SWIG.\n", "In short, yes. A binding is just that, an interface to a library or...
[ 2, 0, 0, 0 ]
[]
[]
[ "binding", "c++", "python" ]
stackoverflow_0002632466_binding_c++_python.txt
Q: Can Python directory names be keywords? E.g. 'import'? Am I allowed to have a directory named 'import' containing Python code? Or will the import command fail to parse it as a result? Is there any way around that? A: You can use the built-in __import__ function which accepts any string. Thus you may write: __i...
Can Python directory names be keywords? E.g. 'import'?
Am I allowed to have a directory named 'import' containing Python code? Or will the import command fail to parse it as a result? Is there any way around that?
[ "You can use the built-in __import__ function which accepts any string. Thus you may write:\n__import__('keyword.submodule')\n\n", "You can have a directory with a name that is a Python keyword storing your Python code. This directory should not be used as a package, since package names should be valid Python ide...
[ 9, 4, 0 ]
[]
[]
[ "keyword", "module", "python" ]
stackoverflow_0002632179_keyword_module_python.txt
Q: Is it possible to do a wx.TextCtrl with no border? I want to do a wx.TextCtrl with no border usign wxpython :P How can I do it? A: How about wx.BORDER_NONE as in: t1 = wx.TextCtrl(self, -1, "my text", style=wx.BORDER_NONE)
Is it possible to do a wx.TextCtrl with no border?
I want to do a wx.TextCtrl with no border usign wxpython :P How can I do it?
[ "How about wx.BORDER_NONE as in:\nt1 = wx.TextCtrl(self, -1, \"my text\", style=wx.BORDER_NONE)\n\n" ]
[ 16 ]
[]
[]
[ "python", "wxpython" ]
stackoverflow_0002632479_python_wxpython.txt
Q: Regex pattern problem in python I need to extract parts of a string using regex in Python. I'm good with basic regex but I'm terrible at lookarounds. I've shown two sample records below. The last big is always a currency field e.g. in the first one it is 4,76. In the second one it is 2,00. The second has an accoun...
Regex pattern problem in python
I need to extract parts of a string using regex in Python. I'm good with basic regex but I'm terrible at lookarounds. I've shown two sample records below. The last big is always a currency field e.g. in the first one it is 4,76. In the second one it is 2,00. The second has an account number that is the pattern of \d{6}...
[ "import re\n\ndef extract_current(s):\n s = s[s.rfind(' ')+1:-1]\n s = re.sub('\\d{6}-\\d{6}', '', s)\n s = re.sub('[A-Z]+', '', s)\n return s\n\nprint extract_current('24.02 24.02VALINTATALO MEGAHERTSI4,76-')\nprint extract_current('24.02 24.02DOE MRIDANG 157235-1234582,00-')\n\nOutput:\n4,76\n2,00\n\n...
[ 1, 1, 0, 0 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0002632416_python_regex.txt
Q: Python integer incrementing with ++ I've always laughed to myself when I've looked back at my VB6 days and thought, "What modern language doesn't allow incrementing with double plus signs?": number++ To my surprise, I can't find anything about this in the Python docs. Must I really subject myself to number = numb...
Python integer incrementing with ++
I've always laughed to myself when I've looked back at my VB6 days and thought, "What modern language doesn't allow incrementing with double plus signs?": number++ To my surprise, I can't find anything about this in the Python docs. Must I really subject myself to number = number + 1? Don't people use the ++ / -- nota...
[ "Python doesn't support ++, but you can do:\nnumber += 1\n\n", "Simply put, the ++ and -- operators don't exist in Python because they wouldn't be operators, they would have to be statements. All namespace modification in Python is a statement, for simplicity and consistency. That's one of the design decisions. A...
[ 1677, 518, 61, 35, 25, 12, 9 ]
[]
[]
[ "increment", "python", "syntax" ]
stackoverflow_0002632677_increment_python_syntax.txt
Q: Python SQLite FTS3 alternatives? Are there any good alternatives to SQLite + FTS3 for python? I'm iterating over a series of text documents, and would like to categorize them according to some text queries. For example, I might want to know if a document mentions the words "rating" or "upgraded" within three words...
Python SQLite FTS3 alternatives?
Are there any good alternatives to SQLite + FTS3 for python? I'm iterating over a series of text documents, and would like to categorize them according to some text queries. For example, I might want to know if a document mentions the words "rating" or "upgraded" within three words of "buy." The FTS3 syntax for this qu...
[ "I suggest you install pysqlite2 module separately. You should make sure that you have sqlite3 installed in your system which should have the FTS3 module ;-)\nCheckout http://code.google.com/p/pysqlite/downloads/list for the latest code (as of April 13, it's version 2.6.0). It's the usual setuptools build. It sho...
[ 2 ]
[]
[]
[ "full_text_search", "python", "search", "text" ]
stackoverflow_0001874957_full_text_search_python_search_text.txt
Q: How to check wether a path represented by a QString with german umlauts exists? i get a QString which represents a directory from a QLineEdit. Now i want to check wether a certain file exists in this directory. But if i try this with os.path.exists and os.path.join and get in trouble when german umlauts occur in t...
How to check wether a path represented by a QString with german umlauts exists?
i get a QString which represents a directory from a QLineEdit. Now i want to check wether a certain file exists in this directory. But if i try this with os.path.exists and os.path.join and get in trouble when german umlauts occur in the directory path: #the direcory coming from the user input in the QLineEdit #i take ...
[ "I was getting no where with this on my Ubuntu box with an ext3 filesystem. So, I guess make sure the filesystem supports unicode filenames first, or else I believe the behavior is undefined?\n>>> os.path.supports_unicode_filenames\nTrue\n\nIf that's True, you should be able to pass unicode strings to the os.path ...
[ 1 ]
[]
[]
[ "diacritics", "pyqt4", "python", "qstring" ]
stackoverflow_0002631405_diacritics_pyqt4_python_qstring.txt