content stringlengths 85 101k | title stringlengths 0 150 | question stringlengths 15 48k | answers list | answers_scores list | non_answers list | non_answers_scores list | tags list | name stringlengths 35 137 |
|---|---|---|---|---|---|---|---|---|
Q:
Django admin StackedInline customisation
I have a Django database of books, with attached transactions. In the admin interface, on each book page, I'd like to show the transactions attached to each book.
Ideally, this should be read-only, with no ability to add or delete transactions. I'd like to show only some o... | Django admin StackedInline customisation | I have a Django database of books, with attached transactions. In the admin interface, on each book page, I'd like to show the transactions attached to each book.
Ideally, this should be read-only, with no ability to add or delete transactions. I'd like to show only some of the model's fields.
In models.py:
class Book... | [
"1: set max_num to 0\nhttp://docs.djangoproject.com/en/dev/topics/forms/modelforms/#model-formsets-max-num\n2: specify the fields attribute \nhttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.fields\nAlso: override the __unicode__ method in your model\nhttp://docs.djangoproject... | [
8
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0004890981_django_django_admin_python.txt |
Q:
Django: String representation of models
I would like my models to have two string representations: one that is displayed in the backend logs for debugging purposes, and a cleaner one that is displayed to end users when the model is represented in the HTML. Right now, I'm just overriding __unicode__(). Is there a w... | Django: String representation of models | I would like my models to have two string representations: one that is displayed in the backend logs for debugging purposes, and a cleaner one that is displayed to end users when the model is represented in the HTML. Right now, I'm just overriding __unicode__(). Is there a way to do this?
| [
"You can also try __repr__ and __str__ for your logging/debugging purposes. It is possible (at least it should be this way) that your logger/debugger uses repr( object ) to log your objects.\n",
"Use properties\nclass SomeThing( models.Model ):\n foo=\n bar= \n baz=\n def __unicode__( self ):\n ... | [
24,
8
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004892049_django_python.txt |
Q:
finding the type of encoding
I was wondering if we can find out the type of encoding used for an encoded string? Or at least find out if a given entity or word is a string or bytes in python3.x.
Thanks in advance.
A:
I would recommend the chardet library. It's based off of some work from Mozilla and seems to me... | finding the type of encoding | I was wondering if we can find out the type of encoding used for an encoded string? Or at least find out if a given entity or word is a string or bytes in python3.x.
Thanks in advance.
| [
"I would recommend the chardet library. It's based off of some work from Mozilla and seems to meet your need.\nUsage is pretty easy:\n>>> import urllib\n>>> rawdata = urllib.urlopen('http://yahoo.co.jp/').read()\n>>> import chardet\n>>> chardet.detect(rawdata)\n{'encoding': 'EUC-JP', 'confidence': 0.99}\n\nAnd the... | [
7,
3
] | [] | [] | [
"character_encoding",
"python"
] | stackoverflow_0004891679_character_encoding_python.txt |
Q:
How to output the conents of a wx.ListView box to an external log file
I have a wx.ListView box named lvActions that I add data to using code similar to
self.lvActions.Append([datetime.datetime.now(),filename,"Moved"])
What I want to do is when I am all done with my actions and have a list, I want to output the f... | How to output the conents of a wx.ListView box to an external log file | I have a wx.ListView box named lvActions that I add data to using code similar to
self.lvActions.Append([datetime.datetime.now(),filename,"Moved"])
What I want to do is when I am all done with my actions and have a list, I want to output the full contents of this file to a logfile. This is how I tried to do it
logfil... | [
"As you have pointed out, the listview itself is not iterable in the way that you'd like. As with most of the wx widgets, you need to get a count of the items in the widget and then ask for the text of the item at that location. Since you are working with a listview (which is derived from listctrl), you will have... | [
1
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0004891542_python_wxpython.txt |
Q:
Python client socket event handling like that found in Adobe ActionScript
I'm porting some ActionScript code to Python and I'm struggling with some sort of event dispatcher implementation similar to that available in Flash (flash.events.EventDispatcher).
I need to create a client socket connection to a server whic... | Python client socket event handling like that found in Adobe ActionScript | I'm porting some ActionScript code to Python and I'm struggling with some sort of event dispatcher implementation similar to that available in Flash (flash.events.EventDispatcher).
I need to create a client socket connection to a server which will respond with a banner. The client will then send some information, recei... | [
"Did you try overriding the handle_write event, as described in the asyncore documentation?\nEdit: Alternatively, you can use the -W command-line option or the warnings module if you want to suppress the warning rather than override the event.\n"
] | [
0
] | [] | [] | [
"asyncore",
"python",
"sockets"
] | stackoverflow_0004892343_asyncore_python_sockets.txt |
Q:
Does this Scala Perl/Python architecture make sense
In another question I asked for "the best" language for a certain purpose. Realizing this goal was a bit too much to start, I simplified my idea :) But there were really useful language hints. So I decided on Scala for the desktop-app and consider between Perl an... | Does this Scala Perl/Python architecture make sense | In another question I asked for "the best" language for a certain purpose. Realizing this goal was a bit too much to start, I simplified my idea :) But there were really useful language hints. So I decided on Scala for the desktop-app and consider between Perl and Python on the webserver.
I want to program something li... | [
"If you ask me, I think Scala is most suitable for the server side. Scala runs on the JVM and Java has a really big ecosystem at the server side. You have a big variety of application servers for every taste (tomcat, jetty, glassfish, etc.).\nChat is a classical use case for actors. I think Akka can inspire you ... | [
1,
1,
0
] | [] | [] | [
"client_server",
"perl",
"python",
"scala",
"sockets"
] | stackoverflow_0004891911_client_server_perl_python_scala_sockets.txt |
Q:
Picasa Python API: Get recently uploaded photos from all contacts
I'm using the Python Picasa API to get the 20 most recent photos from all my contacts (so only 20 photos, the most recent). I coded this in Python, but it is very - very slow. It's not really optimized too, because I'm fetching like 20 photos per co... | Picasa Python API: Get recently uploaded photos from all contacts | I'm using the Python Picasa API to get the 20 most recent photos from all my contacts (so only 20 photos, the most recent). I coded this in Python, but it is very - very slow. It's not really optimized too, because I'm fetching like 20 photos per contact (and I only want 20 pictures in total).
def getRecentPhotos(self... | [
"You could get 20 photos from the first user, then for each user after that, start by getting just the one most recent photo. If that's recent enough to be in the most recent 20, get some more (until they're no longer new enough). If not, move on to the next contact straight away.\nIf you're not too concerned about... | [
1
] | [] | [] | [
"api",
"picasa",
"python"
] | stackoverflow_0004891612_api_picasa_python.txt |
Q:
Using C# code in IronPython
I'm about to undertake a .NET project: We need to create a create a program that utilize some existing C# code, and I'm hoping to use IronPython. (I'm an experienced Python programmer, but a bit of a .NET newbie).
My question is: Is IronPython a good fit for using mostly C# code, or wo... | Using C# code in IronPython | I'm about to undertake a .NET project: We need to create a create a program that utilize some existing C# code, and I'm hoping to use IronPython. (I'm an experienced Python programmer, but a bit of a .NET newbie).
My question is: Is IronPython a good fit for using mostly C# code, or would it be better just to use C#? ... | [
"You'll need to compile the C# code into an assembly (DLL) you can use within IronPython. Once you do this, IronPython can use this just like any other .NET assembly.\nThis is a common usage scenario for IronPython.\n",
"If you are in a Windows environment for reasons beyond your control, there are a lot of adva... | [
5,
1
] | [] | [] | [
".net",
"c#",
"ironpython",
"python"
] | stackoverflow_0004890407_.net_c#_ironpython_python.txt |
Q:
Is there a way to see if there are updates available from a central Mercurial repostiory before pulling them?
I am using Fabric to deploy my Python application from my local machine. I would like to hit our central Mercurial repository (hosted on BitBucket.org) to see if my local repository is at the same rev as t... | Is there a way to see if there are updates available from a central Mercurial repostiory before pulling them? | I am using Fabric to deploy my Python application from my local machine. I would like to hit our central Mercurial repository (hosted on BitBucket.org) to see if my local repository is at the same rev as the tip.
Is there a command I can call to see if there are updates available from the repository without actually pu... | [
"$ hg help incoming\nhg incoming [-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]\n\naliases: in\n\nshow new changesets found in source\n\n",
"Also, for completeness, you can use a GUI tool, like TortoiseHg, which has the same functionality, but presents the incoming changesets visually, like this:\n\... | [
9,
3
] | [] | [] | [
"fabric",
"mercurial",
"python"
] | stackoverflow_0004892349_fabric_mercurial_python.txt |
Q:
how to hide black file background about wxpython
please see the image first http://libertygroupllc.com/twowindow.jpg
hi, look at this image, if i click the py.exe file which was setted up by py2exe, there are two windows to be showed.... apparently, i don't want the black background (that is python.exe)... so how... | how to hide black file background about wxpython | please see the image first http://libertygroupllc.com/twowindow.jpg
hi, look at this image, if i click the py.exe file which was setted up by py2exe, there are two windows to be showed.... apparently, i don't want the black background (that is python.exe)... so how to hide it so that when i click the py.exe, and only ... | [
"Rename your python file to be a .pyw file. Doing so will prevent the first command prompt window from displaying.\nEDIT: After your clarification, the problem is in your setup.py file. You should use 'windows=' instead of 'console='. You can find a more complete list of options that you can use in your setup.py... | [
4
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0004892785_python_wxpython.txt |
Q:
Is there something like AC_CHECK_LIB for python setup.py build instructions?
I have a python package that builds its own extension module. currently I'm doing all the compilation in setup.py as an ext_module, but I really need AC_CHECK_LIB type capability - is there something like this for setup.py, or do I need ... | Is there something like AC_CHECK_LIB for python setup.py build instructions? | I have a python package that builds its own extension module. currently I'm doing all the compilation in setup.py as an ext_module, but I really need AC_CHECK_LIB type capability - is there something like this for setup.py, or do I need to write a autoconf for my module?
Specific case here is that quite a few distros ... | [
"From my poking around, it doesn't look like there's much you can do. You might have luck using autoconf to generate setup.py, or you could use automake and libtool and do the whole thing with autofoo. Automake provides a macro AM_PATH_PYTHON that sets a whole pile of useful variables and gives the following exampl... | [
1
] | [] | [] | [
"autoconf",
"gcc",
"iconv",
"python"
] | stackoverflow_0004878892_autoconf_gcc_iconv_python.txt |
Q:
Read/Write Text to an Open Word Doc on a Mac?
I have a python application that needs to interact with an open MsWord document on Office for Mac '04 and above. I know that on Windows I could use OLE automation to accomplish this, but I don't think this is available on Mac OS. Is there any fairly simple way to accom... | Read/Write Text to an Open Word Doc on a Mac? | I have a python application that needs to interact with an open MsWord document on Office for Mac '04 and above. I know that on Windows I could use OLE automation to accomplish this, but I don't think this is available on Mac OS. Is there any fairly simple way to accomplish this?
Edit: Sorry, I should clarify that I am... | [
"You could consider using AppleScript, which was added in Microsoft Office:mac 2008.\nHere's an example:\nhttp://pogue.blogs.nytimes.com/2008/02/01/applescript-code-for-microsoft-office-2008/\nVBA has made a comeback in Office:mac 2011 (after being shelved in 2008; exists in 2004), so depending on your needs, that ... | [
2,
1
] | [] | [] | [
"macos",
"ms_office",
"python"
] | stackoverflow_0004892471_macos_ms_office_python.txt |
Q:
How to use Python/CGI for file uploading
I'm trying to make a file uploader page that will prompt the user for a file and will upload while displaying progress.
At the moment I've managed to make a simple HTML page that can calls my python script. The python script will then get the file and upload in 1000 byte c... | How to use Python/CGI for file uploading | I'm trying to make a file uploader page that will prompt the user for a file and will upload while displaying progress.
At the moment I've managed to make a simple HTML page that can calls my python script. The python script will then get the file and upload in 1000 byte chunks.
I have two main problem (mainly due to ... | [
"This is more complex than it seems, given how file uploading works in the HTTP protocol. Most web servers will give control to the CGI script only when the uploaded file has been completely transferred, so there's no way to give feedback in the meanwhile.\nThere are some Python libraries that attempt to tackle thi... | [
6
] | [] | [] | [
"cgi",
"html",
"javascript",
"python"
] | stackoverflow_0004890820_cgi_html_javascript_python.txt |
Q:
Is Jython capable of making a QT application (and is a transition from Python worth it)?
I've built a fairly complicated application with PyQt4 and Python, but it is a pain to send to people (and once I do, they have no idea how to run it). Then there are dependencies to wrestle. Ugh.
Anyways, I just learned about... | Is Jython capable of making a QT application (and is a transition from Python worth it)? | I've built a fairly complicated application with PyQt4 and Python, but it is a pain to send to people (and once I do, they have no idea how to run it). Then there are dependencies to wrestle. Ugh.
Anyways, I just learned about Jython, and since virtually everybody has Java installed, it seems like a perfect solution to... | [
"If you did move this application to Jython, you would have to convert the GUI from QT to Jambi.\nJython is the Python language implemented in Java to run on the Java virtual machine. Because it runs on the JVM, Jython apps can use any Java libraries, such as SWING or Jambi. \nIt is possible that the differences be... | [
3
] | [] | [] | [
"jambi",
"jython",
"python",
"qt_jambi"
] | stackoverflow_0004893369_jambi_jython_python_qt_jambi.txt |
Q:
How does one import in python if the filename or filepath contains a non-alpha, non-underscore character?
I need to import a function from a file which is in a folder whose name contains a special character, with the file itself also containing a special character. I cannot change the names to correct the issue. H... | How does one import in python if the filename or filepath contains a non-alpha, non-underscore character? | I need to import a function from a file which is in a folder whose name contains a special character, with the file itself also containing a special character. I cannot change the names to correct the issue. How does one perform the importation in such a situation?
| [
"Yeah that is some horrible naming, but this should work for you:\nInstrument_Control = __import__(\"Instrument-Control.audio$pecial\")\naudiospecial = getattr(Instrument_Control, \"audio$pecial\")\nprint audiospecial\n# <module 'Instrument-Control.audio$pecial' from 'Instrument-Control/audio$pecial/__init__.py'>\n... | [
6
] | [] | [] | [
"import",
"python",
"special_characters"
] | stackoverflow_0004893358_import_python_special_characters.txt |
Q:
Reload a function in python?
Hey I am very new to python but I am trying to make a simple registration system. I would like to be able to have a function update when I add a member but I cannot figure out how. As you will see in the code below, once I am finished adding a member in menu option 2, when I go back an... | Reload a function in python? | Hey I am very new to python but I am trying to make a simple registration system. I would like to be able to have a function update when I add a member but I cannot figure out how. As you will see in the code below, once I am finished adding a member in menu option 2, when I go back and try menu option 1 the member I h... | [
"In this code:\nif selection == 2:\n add_member(members)\n\nyou are returning members, but not doing anything with the return value.\nEasiest thing to do is change it to:\nif selection == 2:\n members = add_member(members)\n\n",
"I wouldn't reload a Python file each time. Instead, simply store your members ... | [
1,
0
] | [] | [] | [
"python",
"registration",
"reload"
] | stackoverflow_0004893407_python_registration_reload.txt |
Q:
Searching for substrings with an in operator out of a list of words in Python
I am attempting to run a program that will find a new value for A if there is a period contained within a certain index range of it. The problem is, in order to determine the domain of the search, it is necessary to have the words separa... | Searching for substrings with an in operator out of a list of words in Python | I am attempting to run a program that will find a new value for A if there is a period contained within a certain index range of it. The problem is, in order to determine the domain of the search, it is necessary to have the words separated within a list, such as this ('A', 'B.', 'C', 'D', 'E', 'F', 'G', 'A', 'B', 'C',... | [
"There is no need for regex here, but regex would work. Remember to escape the dot as it is special. Then remember to use a raw string to escape your escape. :)\nThe problem with your while loop is you're looking for an item exactly equal to \".\" in that slice, rather than an item in that slice that contains \".... | [
1,
1,
1
] | [] | [] | [
"list",
"python",
"search",
"substring"
] | stackoverflow_0004892563_list_python_search_substring.txt |
Q:
Large sortable data structures? Dictionary or something else?
I have a large python dictionary (65535 key:value pairs), where key is range(0, 65536) and the values are integers.
The solution I found to sorting this data structure is posted here:
Sort a Python dictionary by value
That solution works, but is not ne... | Large sortable data structures? Dictionary or something else? | I have a large python dictionary (65535 key:value pairs), where key is range(0, 65536) and the values are integers.
The solution I found to sorting this data structure is posted here:
Sort a Python dictionary by value
That solution works, but is not necessarily very fast.
To further complicate the problem, there is a... | [
"A dictionary populated with 65535 entries with keys from the range (0:65536) sounds suspiciously like an array. If you need sorted arrays, why are you using dictionaries?\nNormally, in Python, you would use a list for this type of data. In your case, since the values are integers, you might also want to consider u... | [
2,
0,
0
] | [] | [] | [
"dictionary",
"python",
"sorting"
] | stackoverflow_0004892641_dictionary_python_sorting.txt |
Q:
Komodo Edit Changes Python sys.path If you "Show in Explorer"
I am using Komodo Edit, a code editor.
When I right click on projects and click "Show in Explorer", it will pop up a box just like Windows Explorer at the directory my project is. This is very convenient.
However, I noticed an insidious side effect. Whe... | Komodo Edit Changes Python sys.path If you "Show in Explorer" | I am using Komodo Edit, a code editor.
When I right click on projects and click "Show in Explorer", it will pop up a box just like Windows Explorer at the directory my project is. This is very convenient.
However, I noticed an insidious side effect. When you try to run a python file with this window that looks exactly ... | [
"This is indeed a problem in Komodo. It actually stems from the Explorer window spawned by Komodo having the PYTHONHOME environment variable set to include Komodo's path, since the child process inherits the parent's environment. I noticed this by opening a Command Prompt window through an Explorer spawned by Komod... | [
4,
2,
0,
0
] | [] | [] | [
"komodo",
"komodoedit",
"module",
"path",
"python"
] | stackoverflow_0001107865_komodo_komodoedit_module_path_python.txt |
Q:
Extract some info from email using regular expression with Python
I need to parse the email file in elmx (Mac OS X email file format) to extract some information using regular expression with Python
The email contains the following format, and there are a lot of text before and after.
...
Name and Address (multi ... | Extract some info from email using regular expression with Python | I need to parse the email file in elmx (Mac OS X email file format) to extract some information using regular expression with Python
The email contains the following format, and there are a lot of text before and after.
...
Name and Address (multi line)
Delivery estimate: SOMEDATE
BOOKNAME
AUTHOR and PRICE
SELLER
... | [
"I don't think that you need regular expressions. You could probably do this by using readlines to load the file, then iterate over that looking for \"Delivery estimate:\" using the startswith() method in the string module. At that point, you have a line number where the data is located.\nYou can get the address by... | [
1,
0,
0
] | [] | [] | [
"parsing",
"python",
"regex"
] | stackoverflow_0004892565_parsing_python_regex.txt |
Q:
Look up a tuple in a python dictionary matching (x,y) or (y,x)
I've a dictionary with a (x,y) key, where (x,y) means the same as (y,x), How should I do this ?
I can do:
>>> d = {(1,2): "foo"}
>>> i = d.get(2,1)
>>> if i is None:
... i = d.get((1,2))
...
>>> i
'foo'
Is there a better way of doing this, so d.ge... | Look up a tuple in a python dictionary matching (x,y) or (y,x) | I've a dictionary with a (x,y) key, where (x,y) means the same as (y,x), How should I do this ?
I can do:
>>> d = {(1,2): "foo"}
>>> i = d.get(2,1)
>>> if i is None:
... i = d.get((1,2))
...
>>> i
'foo'
Is there a better way of doing this, so d.get((2,1)) would match the key (1,2) directly ?
ideally i'd want to in... | [
"Use frozensets rather than tuples.\nd = {frozenset((1,2)): \"foo\"}\nprint d.get(frozenset((2,1)))\n\n",
"You need your own datatype. Something that return the same value for __hash__ for (1, 2) and (2, 1).\nBut why do you want to do this? Do you want a set rather than a tuple? That would look something like:... | [
10,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0004893452_python.txt |
Q:
Update entity from a sharded counter - Python
In my appengine python app, I have sharded counters that count the number of favs for a photo, and number of views.
I have Photo and Counter models. To order photos by popularity (# of favs), I should have the # of favs stored in my Photo entities (Photo.all().order('... | Update entity from a sharded counter - Python | In my appengine python app, I have sharded counters that count the number of favs for a photo, and number of views.
I have Photo and Counter models. To order photos by popularity (# of favs), I should have the # of favs stored in my Photo entities (Photo.all().order('num_favs')).
Since I'm keeping track of the num of ... | [
"If you need to sort or filter based on a value, you probably shouldn't use a sharded counter, but rather use one of the alternatives. In short, they are:\n\nSimply use a regular counter. If you don't expect the rate of updates to exceed 1-5QPS for extended periods (brief spikes are okay), then this should work fin... | [
9
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0004893588_google_app_engine_python.txt |
Q:
python 3: log function signature problem
I often write the following code:
print('object', 'moved', 'from =', object.location, 'dest =', new_location)
print('object', 'created', 'at =', object.location, 'status =', status)
and so on.
I was planning to replace all of these with a function log:
def log(self, action... | python 3: log function signature problem | I often write the following code:
print('object', 'moved', 'from =', object.location, 'dest =', new_location)
print('object', 'created', 'at =', object.location, 'status =', status)
and so on.
I was planning to replace all of these with a function log:
def log(self, action, **details):
print('object', action, end = ... | [
"You know about the logging module, I take it?\nI would just use preformed messages, and substitute the necessary bits in:\nmovedmsg = \"object moved from = %s to = %s\"\nprint(movedmsg % (object.location, new_location))\n\nYou might prefer the new style of string formatting:\nmovedmsg = \"object moved from = {0} t... | [
4,
0
] | [] | [] | [
"argument_passing",
"function",
"python",
"python_3.x"
] | stackoverflow_0004893575_argument_passing_function_python_python_3.x.txt |
Q:
How to restrict query of a ManyToMany relationship with Q.AND in Django
I want to get all images that have 2 specific tags, 'tag1' AND 'tag2'. My simplified models:
class Image(models.Model):
title = models.CharField(max_length=100)
class Tag(models.Model):
name = models.CharField(max_length=64, unique=Tr... | How to restrict query of a ManyToMany relationship with Q.AND in Django | I want to get all images that have 2 specific tags, 'tag1' AND 'tag2'. My simplified models:
class Image(models.Model):
title = models.CharField(max_length=100)
class Tag(models.Model):
name = models.CharField(max_length=64, unique=True)
images = models.ManyToManyField(Image, null=True, blank=True)
Concat... | [
"I wasn't even aware of that format! \nWhat's wrong with the way the docs show Q object usage? http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects\nImage.objects.filter(Q(tag__name='tag1') & Q(tag__name='tag2'))\nUPDATE:\nI tested the qobj.add() method on my model with m2m and it ... | [
0
] | [] | [] | [
"django",
"django_queryset",
"python"
] | stackoverflow_0004893768_django_django_queryset_python.txt |
Q:
Fastest Python method for search and replace on a large string
I'm looking for the fastest way to replace a large number of sub-strings inside a very large string. Here are two examples I've used.
findall() feels simpler and more elegant, but it takes an astounding amount of time.
finditer() blazes through a larg... | Fastest Python method for search and replace on a large string | I'm looking for the fastest way to replace a large number of sub-strings inside a very large string. Here are two examples I've used.
findall() feels simpler and more elegant, but it takes an astounding amount of time.
finditer() blazes through a large file, but I'm not sure this is the right way to do it.
Here's some... | [
"The standard method is to use the built-in\nre.sub(reg, rep, text)\n\nIncidentally the reason for the performance difference between your versions is that each replacement in your first version causes the entire string to be recopied. Copies are fast, but when you're copying 10 MB at a go, enough copies will beco... | [
27,
6,
4
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0004893506_python_regex.txt |
Q:
Image Path Returning a 404 on Django Admin
Whenever I visit the path for an uploaded image in the admin, I get a 404. The image is successfully uploaded in the specified path but I don't know what URL structure to use to access the image. There is not URL structure specified yet for the image (that's what I want t... | Image Path Returning a 404 on Django Admin | Whenever I visit the path for an uploaded image in the admin, I get a 404. The image is successfully uploaded in the specified path but I don't know what URL structure to use to access the image. There is not URL structure specified yet for the image (that's what I want to know, or am I missing anything else?). Here ar... | [
"Your MEDIA_URL defines this.\nYou either have it defined to '' and the admin is generating a relative URL or you have it set to http://localhost:8000/admin/products/product/1/ which is unlikely :P \n"
] | [
4
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004893821_django_python.txt |
Q:
math syntax checker written in python
All I need is to check, using python, if a string is a valid math expression or not.
For simplicity let's say I just need + - * / operators (+ - as unary too) with numbers and nested parenthesis. I add also simple variable names for completeness.
So I can test this way:
test("... | math syntax checker written in python | All I need is to check, using python, if a string is a valid math expression or not.
For simplicity let's say I just need + - * / operators (+ - as unary too) with numbers and nested parenthesis. I add also simple variable names for completeness.
So I can test this way:
test("-3 * (2 + 1)") #valid
test("-3 * ") ... | [
"This is because the pyparsing code allows functions. (And by the way, it does a lot more than what you need, i.e. create a stack and evaluate that.)\nFor starters, you could remove pi and ident (and possibly something else I'm missing right now) from the code to disallow characters.\nThe reason is different: PyPar... | [
3,
2,
1,
1,
0
] | [] | [] | [
"math",
"python",
"syntax_checking"
] | stackoverflow_0004887627_math_python_syntax_checking.txt |
Q:
In ASP - Why is it that I can call python functions from vbscript but not vice-versa?
I'm planning on writting some new code for a legacy ASP application in Python, and I ran into some odd behavior. If I write a function in python I can easily call it from a VBScript block. However, if I try to call a function d... | In ASP - Why is it that I can call python functions from vbscript but not vice-versa? | I'm planning on writting some new code for a legacy ASP application in Python, and I ran into some odd behavior. If I write a function in python I can easily call it from a VBScript block. However, if I try to call a function defined in VBScript from python, I get an error:
Python ActiveX Scripting Engine error '8002... | [
"It probably has to do with the order in which the script tags are processed.\nIn this case, it seems that the script tags containing python code are processed first, and then the ones with vbscript. The result is that you are trying to call PrintVBS() before it is available.\nIf you would change the default langua... | [
3,
1
] | [] | [] | [
"asp_classic",
"python",
"vbscript"
] | stackoverflow_0002157241_asp_classic_python_vbscript.txt |
Q:
How do I return this as a list
I have this data:
inventory = { HAMMER: (10,100),
SCREW: (1, 1000),
NAIL: (1, 1000),
SCREWDRIVER: (8, 100),
DRILL: (50, 20),
WORKBENCH: (150, 5),
HANDSAW: (15, 50),
CHAINSAW: (80, 30)
... | How do I return this as a list | I have this data:
inventory = { HAMMER: (10,100),
SCREW: (1, 1000),
NAIL: (1, 1000),
SCREWDRIVER: (8, 100),
DRILL: (50, 20),
WORKBENCH: (150, 5),
HANDSAW: (15, 50),
CHAINSAW: (80, 30)
}
Which I have written th... | [
"This code is more functional and may be easier to maintain:\ndef get_items(cheapness):\n def a(value):\n if cheapness == 'CHEAP':\n return value < 20\n if cheapness == 'MODERATE':\n return value >= 20 and value < 100\n if cheapness == 'EXPENSIVE':\n return v... | [
5,
3,
1
] | [] | [] | [
"dictionary",
"nested_lists",
"python"
] | stackoverflow_0004893972_dictionary_nested_lists_python.txt |
Q:
How can I unpack an integer into a float in PostgreSQL?
I'm using Python's struct.pack function to pack various data types into a common 32-bit integer field in PostgreSQL. The drawback is that I can't operate with these values in the database, I have to perform a struct.unpack in Python on the data to know what ... | How can I unpack an integer into a float in PostgreSQL? | I'm using Python's struct.pack function to pack various data types into a common 32-bit integer field in PostgreSQL. The drawback is that I can't operate with these values in the database, I have to perform a struct.unpack in Python on the data to know what it represents.
If I pack a 32-bit float into this field, is t... | [
"An answer you are probably not looking for: Don't do that.\nThis is a violation of the basics: a value in a database should be atomic, not divisible into other values. All of the database's operations (did I mention all) are tuned to handling individual values. You are \"fighting the framework\" here. \nEven if... | [
4,
1
] | [] | [] | [
"pack",
"postgresql",
"python",
"sql"
] | stackoverflow_0004891634_pack_postgresql_python_sql.txt |
Q:
Django: Add my own form to the admin backend?
I'm using the Django Admin module. It displays a list of models to edit by app. I would like to add another form to this list. It won't edit a specific model, but it will edit settings that are stored in the database. Is this possible?
A:
You may check out Django Li... | Django: Add my own form to the admin backend? | I'm using the Django Admin module. It displays a list of models to edit by app. I would like to add another form to this list. It won't edit a specific model, but it will edit settings that are stored in the database. Is this possible?
| [
"You may check out Django Live Settings. It was split out of the Satchmo project and looks to do what you're looking for.\nOtherwise, you may look into Overriding the Django Admin Templates. You could just override the index template and add your links to the bottom.\n"
] | [
1
] | [] | [] | [
"django_admin",
"python"
] | stackoverflow_0004893852_django_admin_python.txt |
Q:
Python, checking data file for certain lines
I've never taken a class that used python, just c, c++, c#, java, etc..
This should be easy but I'm feeling like I'm missing something huge that python reacts to.
All I'm doing is reading in a file, checking for lines that are only digits, counting how many lines like t... | Python, checking data file for certain lines | I've never taken a class that used python, just c, c++, c#, java, etc..
This should be easy but I'm feeling like I'm missing something huge that python reacts to.
All I'm doing is reading in a file, checking for lines that are only digits, counting how many lines like that and displaying it.
So I'm opening, reading, st... | [
"The correct way in Python to tell if you've reached the end of a file is not to see if it returns an empty line.\nInstead, iterate over all the lines in the file, and the loop will end when the end of the file is reached.\nnum_digits = 0\nwith open(\"data.txt\") as f:\n for line in f:\n if line.strip().i... | [
4,
2,
0,
0,
0
] | [] | [] | [
"counter",
"python",
"readline"
] | stackoverflow_0004893918_counter_python_readline.txt |
Q:
How to "run" a "Paypal Subscriptions Service" inside Google App Engine?
before anything, I wanna you to Know that I'm a Complete Newbie
in these things about developing "paid" webapps. I have been reading some posts
about how to integrate Paypal's IPN with Google App Engine, and I have some questions
about the top... | How to "run" a "Paypal Subscriptions Service" inside Google App Engine? | before anything, I wanna you to Know that I'm a Complete Newbie
in these things about developing "paid" webapps. I have been reading some posts
about how to integrate Paypal's IPN with Google App Engine, and I have some questions
about the topic, the thing is like this:
I want to use a paypal's Subscribe button in my w... | [
"To make a short answer (as I'm not exactly sure what's the scope of your question).\n\nIt's not paypal's job to maintain your data model. You need to create a database entry with your users.\n\nFor an example of that, look Google's documentation at \nhttp://code.google.com/appengine/docs/python/gettingstarted/usin... | [
6
] | [] | [] | [
"google_app_engine",
"paypal",
"paypal_ipn",
"python"
] | stackoverflow_0004893282_google_app_engine_paypal_paypal_ipn_python.txt |
Q:
How do you flush Python sockets?
I've written a server in Python that is meant to send data to the client in the form "Header:Message"
I would like to be able to have each message sent individually so that the client will need to perform minimal work in order to read the "header" and the "message"
Unfortunately, ... | How do you flush Python sockets? | I've written a server in Python that is meant to send data to the client in the form "Header:Message"
I would like to be able to have each message sent individually so that the client will need to perform minimal work in order to read the "header" and the "message"
Unfortunately, I can't figure out how to properly flu... | [
"I guess you are talking over a TCP connection.\nYour approach is flawed. A TCP stream is defined as a stream of bytes. You always have to use some sort of separator and may not rely on the network stack to separate your messages.\nIf you really need datagram based services switch to UDP. You'll need to handle retr... | [
24,
1,
0
] | [] | [] | [
"flush",
"python",
"sockets"
] | stackoverflow_0001655560_flush_python_sockets.txt |
Q:
django-piston: properly formatting POST data from a client application
I have a Django app running django-piston for the first time.
I've got a handler configured for a model and it's rigged for GET and POST.
GET works fine. Tried and true.
POST however is sucking. When I post data to it, I am getting this error
R... | django-piston: properly formatting POST data from a client application | I have a Django app running django-piston for the first time.
I've got a handler configured for a model and it's rigged for GET and POST.
GET works fine. Tried and true.
POST however is sucking. When I post data to it, I am getting this error
Responded: Piston/0.2.3rc1 (Django 1.2.4) crash report:
Method signature doe... | [
"I solved this for myself.\nThe relevant cause of the error is this line in the create method\nif request.content_type:\n\nwhich does not evaluate as True as I think the creators of the django-piston documentation intended. Even if the value is a string with a value.\nRemoving this line solved it. And I'm sure you ... | [
0
] | [] | [] | [
"django",
"django_piston",
"json",
"python",
"rest"
] | stackoverflow_0004894427_django_django_piston_json_python_rest.txt |
Q:
How to run a function in a transaction with MySQL and SQLite?
How can a function be run "in a transaction" (see http://code.google.com/appengine/docs/python/datastore/functions.html#run_in_transaction with MySQL and SQLite? (and other RDBMSs if anyone knows how)?
EDIT: I want to do so in Python, but a way to do it... | How to run a function in a transaction with MySQL and SQLite? | How can a function be run "in a transaction" (see http://code.google.com/appengine/docs/python/datastore/functions.html#run_in_transaction with MySQL and SQLite? (and other RDBMSs if anyone knows how)?
EDIT: I want to do so in Python, but a way to do it in other programming languages would also be okay.
| [
"That depends on the RDBMS you use, what programming language you're writing in, and what library you use to connect.\nWith MySQL, you issue a START TRANSACTION query before the queries you want to be run in a transaction, and a COMMIT query to run that transaction.\nhttp://dev.mysql.com/doc/refman/5.0/en/commit.ht... | [
0
] | [] | [] | [
"mysql",
"python",
"sqlite",
"transactions"
] | stackoverflow_0004894558_mysql_python_sqlite_transactions.txt |
Q:
Problem using scrapy to scrape a yahoo group
I'm new to web scraping and just started experimenting with Scrapy, a scraping framework written in Python. My goal is to scrape an old Yahoo Group since they don't provide an API or any other means to retrieve message archives. The Yahoo Group is set such that you have... | Problem using scrapy to scrape a yahoo group | I'm new to web scraping and just started experimenting with Scrapy, a scraping framework written in Python. My goal is to scrape an old Yahoo Group since they don't provide an API or any other means to retrieve message archives. The Yahoo Group is set such that you have to log in before you can view the archives.
The ... | [
"I think Yahoo is redirecting for an authorization check, and it finally redirects me back to the page I really wanted to get. Scrapy has already seen this request, however, and stops because it doesn't want to get into a loop. The solution, in my case, is to add dont_filter=True to the Request constructor. This wi... | [
5
] | [] | [] | [
"python",
"scrapy",
"screen_scraping",
"yahoo"
] | stackoverflow_0004893897_python_scrapy_screen_scraping_yahoo.txt |
Q:
Python 3.1 Grid Simulation Question
Based on the answers from this question, I have created a grid from a 1D array, which modifies a value and its surrounding neighbours; if that value is found in another array. The main value is converted by a specific % and the surrounding elements by another.
However, how do I ... | Python 3.1 Grid Simulation Question | Based on the answers from this question, I have created a grid from a 1D array, which modifies a value and its surrounding neighbours; if that value is found in another array. The main value is converted by a specific % and the surrounding elements by another.
However, how do I ensure that the changed values are not co... | [
"First off, let's walk through your code section by section... There are several problems with what you have written now...\nIncidentally, there's a loose convention in python to reserve Uppercase and CamelCased names for classes. (You'll often see code like foo = FooBar(baz), where foo is an instance of the class ... | [
3
] | [] | [] | [
"numpy",
"python",
"python_3.x"
] | stackoverflow_0004894312_numpy_python_python_3.x.txt |
Q:
Avoid hang when writing to named pipe which disappears and comes back
I have a program which dumps information into a named pipe like this:
cmd=open(destination,'w')
cmd.write(data)
cmd.close()
This works pretty well until the pipe (destination) disappears while my program is writing to it. The problem is that it... | Avoid hang when writing to named pipe which disappears and comes back | I have a program which dumps information into a named pipe like this:
cmd=open(destination,'w')
cmd.write(data)
cmd.close()
This works pretty well until the pipe (destination) disappears while my program is writing to it. The problem is that it keeps hanging on the write part(?)
I was expecting some exception to happe... | [
"If the process reading from the pipe is not reading as fast as your writing, your script will block when it tries to write to the pipe. From the Wikipedia article:\n\n\"If the queue buffer fills up, the\n sending program is suspended (blocked)\n until the receiving program has had a\n chance to read some data ... | [
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0004892623_python.txt |
Q:
How to I read several lines in a file faster using python?
As of now I use the following python code:
file = open(filePath, "r")
lines=file.readlines()
file.close()
Say my file has several lines (10,000 or more), then my program becomes slow if I do this for more than one file. Is there a way to speed this up in ... | How to I read several lines in a file faster using python? | As of now I use the following python code:
file = open(filePath, "r")
lines=file.readlines()
file.close()
Say my file has several lines (10,000 or more), then my program becomes slow if I do this for more than one file. Is there a way to speed this up in Python? Reading various links I understand that readlines stores... | [
"for line in file:\n\nThis gives you an iterator that reads the file object one line at a time and then discards the previous line from memory.\n\nA file object is its own iterator, for example iter(f) returns f (unless f is closed). When a file is used as an iterator, typically in a for loop (for example, for line... | [
6
] | [] | [] | [
"file",
"python",
"readlines"
] | stackoverflow_0004895022_file_python_readlines.txt |
Q:
python 3: random.seed(): where to call it?
I need to make sure all the randomness in my program is fully replicable. Where should I place a call to random.seed()?
I thought it should be in my main.py module, but it imports other modules that happen to use random functions.
I can carefully navigate through my impor... | python 3: random.seed(): where to call it? | I need to make sure all the randomness in my program is fully replicable. Where should I place a call to random.seed()?
I thought it should be in my main.py module, but it imports other modules that happen to use random functions.
I can carefully navigate through my imports to see which one is the first to execute, but... | [
"It is actually safe to execute code in the \"import section\" of your main module, so if you are unsure about importing other modules that might or might not use the random module, maybe bypassing your seed, you can of course use something like\nimport random\nrandom.seed(seed_value)\n\nimport something\nimport el... | [
7,
4,
1
] | [] | [] | [
"coding_style",
"python",
"python_3.x",
"random"
] | stackoverflow_0004881248_coding_style_python_python_3.x_random.txt |
Q:
Python 3.1.3 ctypes.structure does not order bits properly and unexpectedly modifies data
I defined the following structure
import ctypes
from ctypes import *
class r( BigEndianStructure ):
_fields_ = [( "d0", c_uint32, 28 ),
( "d1", c_uint32, 18 ),
( "d2", c_uint32, 18 ),
... | Python 3.1.3 ctypes.structure does not order bits properly and unexpectedly modifies data | I defined the following structure
import ctypes
from ctypes import *
class r( BigEndianStructure ):
_fields_ = [( "d0", c_uint32, 28 ),
( "d1", c_uint32, 18 ),
( "d2", c_uint32, 18 ),
( "d3", c_uint16, 16 ),
( "d4", c_uint16, 16 ), ]
then tested with ... | [
"The fields are left aligned (padded to the right)\nField d0 - \n(AAAA AAAA & FFFFFFF (28 bits)) << (32 - 28 = 4) = AAAA AAA0\n\nField d1 - \n(BBBB BBBB & 3FFFF (18 bits)) << (32 - 18 = 14) = EEEE C000\n\nField d2 - \n(CCCC CCCC & 3FFFF (18 bits)) << (32 - 18 = 14) = 3333 0000\n\nFields d1 & d2 will not both fit w... | [
0,
0,
0
] | [] | [] | [
"ctypes",
"python",
"structure"
] | stackoverflow_0004891186_ctypes_python_structure.txt |
Q:
Strange behavior parsing JSON dicts into objects using object_hook
I have been exploring the json library, and am attempting to convert an object into JSON data and back again. I have run into trouble running this example code:
import json
class Obj:
'''
classdocs
'''
def __init__(self,s,hello="... | Strange behavior parsing JSON dicts into objects using object_hook | I have been exploring the json library, and am attempting to convert an object into JSON data and back again. I have run into trouble running this example code:
import json
class Obj:
'''
classdocs
'''
def __init__(self,s,hello="Hello world!"):
'''
Constructor
'''
self... | [
"Since you specified that objects should be reconstructed using the function jSONToObj, the deserializer assumes that all dicts are to be objects and tries to call your deserializer on them.\nFrom the docs:\n\nobject_hook is an optional function\n that will be called with the result of\n any object literal decode... | [
3
] | [] | [] | [
"json",
"python"
] | stackoverflow_0004895103_json_python.txt |
Q:
xml parsing takes extra spaces
I have been trying to write/parse xml file in python. The tags are very simple
<main>
<data>
abcdef
</data>
</main>
I have written this xml using xml document writer from xml.dom.minidom.
How-ever when i try to parse this and try to fetch data-text value, i get 'abcdef' ... | xml parsing takes extra spaces | I have been trying to write/parse xml file in python. The tags are very simple
<main>
<data>
abcdef
</data>
</main>
I have written this xml using xml document writer from xml.dom.minidom.
How-ever when i try to parse this and try to fetch data-text value, i get 'abcdef' with spaces/carriage return/newline ... | [
"Just use strip() to take out the extra white space. If you only want to take out the leading white space, do lstrip(), as in clipData.lstrip().\n",
"In XML, whitespace is significant. If you don't want whitespace in the data element, write it like this:\n<main>\n <data>abcdef</data>\n</main>\n\n"
] | [
2,
2
] | [] | [] | [
"python",
"xml",
"xml_parsing"
] | stackoverflow_0004888103_python_xml_xml_parsing.txt |
Q:
Macports sudo expands ~ to /var/root in python
I installed the macports version of sudo. All is well, except for one thing. Using python 2.6 to expand ~ to the user's home directory results in a different output than the version of sudo that comes with Snow Leopard.
For example consider the following python code... | Macports sudo expands ~ to /var/root in python | I installed the macports version of sudo. All is well, except for one thing. Using python 2.6 to expand ~ to the user's home directory results in a different output than the version of sudo that comes with Snow Leopard.
For example consider the following python code:
#expand_home_dir.py
import os
os.path.expanduser(... | [
"The HOME environment variable controls what ~ expands to. It sounds like your MacPorts-installed version of sudo is resetting HOME to the root user's home directory, while the system-installed version doesn't. What happens if you type sudo sh -c 'echo $HOME'?\n"
] | [
2
] | [] | [] | [
"bash",
"macos",
"macports",
"python",
"sudo"
] | stackoverflow_0004895516_bash_macos_macports_python_sudo.txt |
Q:
Find how many levels of child elements an element has in Beautiful Soup
I'm having a problem trying to find out how many "levels" of child elements an element has. For example
<div id="first">
<div id="second">
<div id="third">
<div id="fourth">
<div id="fifth">
</div>
</div>
</div>
</div>
<di... | Find how many levels of child elements an element has in Beautiful Soup | I'm having a problem trying to find out how many "levels" of child elements an element has. For example
<div id="first">
<div id="second">
<div id="third">
<div id="fourth">
<div id="fifth">
</div>
</div>
</div>
</div>
<div id="second2">
</div>
</div>
In this code the div with the id of first wou... | [
"Here's an example using xml.etree.ElementTree;\nimport xml.etree.ElementTree as et\n\ndef height(branch):\n if len(branch) == 0:\n return 0\n else:\n return max([height(child) for child in branch.getchildren()])+1\n\ntree = et.fromstring(text)\nprint height(tree)\n\n"
] | [
0
] | [] | [] | [
"beautifulsoup",
"html_parsing",
"python"
] | stackoverflow_0004894622_beautifulsoup_html_parsing_python.txt |
Q:
Writing a curl proxy under linux
Hello
I am working with a legacy system where an ASP.NET application posts an XML file to a server via curl.exe (this url to send is configurable by a .config file).
Now due to legacy system limitations, I need curl post this XML to my ubuntu server by changing the said .congfig fi... | Writing a curl proxy under linux | Hello
I am working with a legacy system where an ASP.NET application posts an XML file to a server via curl.exe (this url to send is configurable by a .config file).
Now due to legacy system limitations, I need curl post this XML to my ubuntu server by changing the said .congfig file, modify the received XML as I need ... | [
"Since ASP.NET application is posting XML, you simply need to handle a normal POST request, modify XML to match your requirement and post it using cURL to the real cURL server. In PHP, it would look something like this (more or less meta code, error checking and additional logic is needed):\n$xml = $_POST['xml'];\n... | [
1
] | [] | [] | [
"curl",
"php",
"python"
] | stackoverflow_0004886924_curl_php_python.txt |
Q:
Twisted: Communicate between deferred sub-process and http requests?
Background:
I have a long running sub-process that twisted spawns.
I have subclassed the process protocol in such a way that I'm aware when I receive std out, std err, etc
I would like the ability for separate http requests (over a series of time... | Twisted: Communicate between deferred sub-process and http requests? | Background:
I have a long running sub-process that twisted spawns.
I have subclassed the process protocol in such a way that I'm aware when I receive std out, std err, etc
I would like the ability for separate http requests (over a series of time) to check on the status of these running processes through shared variabl... | [
"Make a 'mailbox' object; for argument's sake, let's say it's a list. This could be a dictionary, or an object, or a file, or a database; whatever you want. Whatever's appropriate to your application.\nThen when you instantiate your ProcessProtocol, pass a reference to the mailbox. When relevant data arrives, se... | [
3
] | [] | [] | [
"linux",
"process",
"python",
"twisted"
] | stackoverflow_0004892820_linux_process_python_twisted.txt |
Q:
How to get ISBN number from a book title and author programmatically?
Is there a way to get ISBN number from the title of the book and author programmatically (preferably in Python)?
Does Amazon provide web services for this? If so, how can one use it?
A:
http://isbndb.com/data-intro.html
Someone has already wr... | How to get ISBN number from a book title and author programmatically? | Is there a way to get ISBN number from the title of the book and author programmatically (preferably in Python)?
Does Amazon provide web services for this? If so, how can one use it?
| [
"http://isbndb.com/data-intro.html\nSomeone has already written a python wrapper: http://code.google.com/p/isbndb-py/\n",
"You can take a look at this Amazon Product Advertising API (btw it demands you to have as AWS account), it provides possibility to look for book, probably in your case it will fit. \nAlternat... | [
13,
3
] | [] | [] | [
"isbn",
"python"
] | stackoverflow_0004893908_isbn_python.txt |
Q:
How would I go about categorizing sentences according to tense (present, past, future, etc.)?
I want to parse a text and categorize the sentences according to their grammatical structure, but I have a very small understanding of NLP so I don't even know where to start.
As far as I have read, I need to parse the te... | How would I go about categorizing sentences according to tense (present, past, future, etc.)? | I want to parse a text and categorize the sentences according to their grammatical structure, but I have a very small understanding of NLP so I don't even know where to start.
As far as I have read, I need to parse the text and find out (or tag?) the part-of-speech of every word. Then I search for the verb clause or wh... | [
"Python Natural Language Toolkit is a library which is suitable for doing such a work. As with any NLP library, you will have to download the dataset for training separately and corpus(data) and scripts for training are available too.\nThere are also certain example tutorials which will help you identify parts of t... | [
3,
0
] | [] | [] | [
"grammar",
"nlp",
"nltk",
"python"
] | stackoverflow_0004895661_grammar_nlp_nltk_python.txt |
Q:
Django: disallow can_delete on GenericStackedInline
I've built this model which contains a generic foreign key:
class MyModel(models.Model):
content_type = models.ForeignKey(ContentType, verbose_name=_('content type'))
object_id = models.PositiveIntegerField(_('object id'))
content_object = generic.Gen... | Django: disallow can_delete on GenericStackedInline | I've built this model which contains a generic foreign key:
class MyModel(models.Model):
content_type = models.ForeignKey(ContentType, verbose_name=_('content type'))
object_id = models.PositiveIntegerField(_('object id'))
content_object = generic.GenericForeignKey('content_type', 'object_id')
Next I've ma... | [
"Maybe It is a post '09 feature, but you can specify that without overriding the __init__() method :\nclass StupidCarOptionsInline(admin.StackedInline):\n model = models.StupidOption\n form = StupidCarOptionAdminForm\n extra = 0\n can_delete = False\n\n",
"Update 2016: as per Stan's answer below, mode... | [
45,
14
] | [] | [] | [
"django",
"django_admin",
"formset",
"generics",
"python"
] | stackoverflow_0001470811_django_django_admin_formset_generics_python.txt |
Q:
Calculating EuropeanOptionImpliedVolatility in quantlib-python
I have R code that uses RQuantlib library. In order to run it from python I am using RPy2. I know python has its own bindings for quantlib (quantlib-python). I'd like to switch from R to python completely.
Please let me know how I can run the following... | Calculating EuropeanOptionImpliedVolatility in quantlib-python | I have R code that uses RQuantlib library. In order to run it from python I am using RPy2. I know python has its own bindings for quantlib (quantlib-python). I'd like to switch from R to python completely.
Please let me know how I can run the following using quantlib-python
import rpy2.robjects as robjects
robjects.r(... | [
"You'll need a bit of setup. For convenience, and unless you get name clashes, you better import everything:\nfrom QuantLib import *\n\nthen, create the option, which needs an exercise and a payoff:\nexercise = EuropeanExercise(Date(3,August,2011))\npayoff = PlainVanillaPayoff(Option.Call, 100.0)\noption = Europea... | [
27
] | [] | [] | [
"python",
"quantlib",
"r",
"rpy2"
] | stackoverflow_0004891490_python_quantlib_r_rpy2.txt |
Q:
Python HTML parsing
I am currently trying to make a program that given a word will look up its definition and return it. Although I have gotten this to work, I had to resort to using RegEx to search for the text between the tags where the definitions are stored. What is a more efficient way to do this using python... | Python HTML parsing | I am currently trying to make a program that given a word will look up its definition and return it. Although I have gotten this to work, I had to resort to using RegEx to search for the text between the tags where the definitions are stored. What is a more efficient way to do this using python 3.x?
| [
"lxml works for Python 3. It has an ElementTree compatible API, but is using c libraries behind the scenes, so it's fast, and it supports Xpaths, which is a nice way of parsing (sometimes).\n",
"Try BeautifulSoup a good HTML parser for Python. (works with Python 3.x too, although unless you are deep into a Python... | [
5,
4,
2
] | [] | [] | [
"html",
"html_parsing",
"python",
"python_3.x"
] | stackoverflow_0004895102_html_html_parsing_python_python_3.x.txt |
Q:
string encode / decode
'=?KOI8-R?B?W1JFUS0wMDI1NDEtNDc5NzddIO/h7yAi89TSz8rGwdLGz9IiIDs=?=\r\n\t=?KOI8-R?B?Ry43MjkgKDEwKQ==?='
How can I convert this into something readable ?
Thanks !
A:
>>> email.header.decode_header('=?KOI8-R?B?W1JFUS0wMDI1NDEtNDc5NzddIO/h7yAi89TSz8rGwdLGz9IiIDs=?=\r\n\t=?KOI8-R?B?Ry43MjkgKDE... | string encode / decode | '=?KOI8-R?B?W1JFUS0wMDI1NDEtNDc5NzddIO/h7yAi89TSz8rGwdLGz9IiIDs=?=\r\n\t=?KOI8-R?B?Ry43MjkgKDEwKQ==?='
How can I convert this into something readable ?
Thanks !
| [
">>> email.header.decode_header('=?KOI8-R?B?W1JFUS0wMDI1NDEtNDc5NzddIO/h7yAi89TSz8rGwdLGz9IiIDs=?=\\r\\n\\t=?KOI8-R?B?Ry43MjkgKDEwKQ==?=')\n[('[REQ-002541-47977] \\xef\\xe1\\xef \"\\xf3\\xd4\\xd2\\xcf\\xca\\xc6\\xc1\\xd2\\xc6\\xcf\\xd2\" ;G.729 (10)', 'koi8-r')]\n>>> print '[REQ-002541-47977] \\xef\\xe1\\xef \"\\xf... | [
11,
3
] | [] | [] | [
"encoding",
"python"
] | stackoverflow_0004896194_encoding_python.txt |
Q:
Creating a tree from self referential tables in SQLalchemy
I'm building a basic CMS in flask for an iPhone oriented site and I'm having a little trouble with something. I have a very small database with just 1 table (pages). Here's the model:
class Page(db.Model):
__tablename__ = 'pages'
id = db.Column(db.... | Creating a tree from self referential tables in SQLalchemy | I'm building a basic CMS in flask for an iPhone oriented site and I'm having a little trouble with something. I have a very small database with just 1 table (pages). Here's the model:
class Page(db.Model):
__tablename__ = 'pages'
id = db.Column(db.Integer, primary_key=True)
title = db.Column(db.String(100),... | [
"Look at http://sqlamp.angri.ru/index.html\nor http://www.sqlalchemy.org/trac/browser/examples/adjacency_list/adjacency_list.py\nUPD: For adjacency_list.py declarative example\nfrom sqlalchemy.ext.declarative import declarative_base\nBase = declarative_base(metadata=metadata)\n\nclass TreeNode(Base):\n\n __table... | [
17
] | [] | [] | [
"flask",
"python",
"sqlalchemy"
] | stackoverflow_0004896104_flask_python_sqlalchemy.txt |
Q:
Which programming language to choose?
I am a 3rd year CS engineering student, I have done some basic programming in languages like C,C++,Java,Shell,Perl,PHP,Ruby on Rails, Python. But now I wanted to settle for one language, so I thought of finally mastering one scripting language and other compiled one. So I deci... | Which programming language to choose? | I am a 3rd year CS engineering student, I have done some basic programming in languages like C,C++,Java,Shell,Perl,PHP,Ruby on Rails, Python. But now I wanted to settle for one language, so I thought of finally mastering one scripting language and other compiled one. So I decided to stick with C++ and Python. Can someo... | [
"Go with what you feel most comfortable. But don't \"settle\" for one language. Programming languages are tools and you should be able to apply the right tool for the right problem.\nFor web dev in python:\nhttp://wiki.python.org/moin/WebProgramming\n",
"Presently ROR is high in demand for web. As a professional ... | [
4,
0,
0
] | [] | [] | [
"c++",
"python",
"ruby_on_rails"
] | stackoverflow_0004896361_c++_python_ruby_on_rails.txt |
Q:
Complex Django query
I have theses models:
class Person(models.Model):
position = models.CharField(max_length=64)
group = models.ForeignKey('Group')
class Group(models.Model):
...
Now I want a query that will give me back all the distinct Group where all the persons in each group have the position wo... | Complex Django query | I have theses models:
class Person(models.Model):
position = models.CharField(max_length=64)
group = models.ForeignKey('Group')
class Group(models.Model):
...
Now I want a query that will give me back all the distinct Group where all the persons in each group have the position worker. So I will have all t... | [
"This should work:\nGroup.objects.exclude(~Q(person__position=\"worker\"))\n\nEdit: \nThe above wasn't correct so here's my second try:\nGroup.objects.filter(\n Q(person__position=\"worker\") \n & ~Q(person__position__gt=\"worker\")\n & ~Q(person__position__lt=\"worker\")\n)\n\nI am unsure if this can be u... | [
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004894577_django_python.txt |
Q:
python urllib2 file send problem
I want to post a file to a server via python, for this I need to name this file as "xmlfile" so that server recognizes the input.
import urllib2
url = "http://somedomain"
to_send = open('test.xml').read()
data = {}
data['xmlfile'] = to_send
f = urllib2.urlopen(url, data)
This doe... | python urllib2 file send problem | I want to post a file to a server via python, for this I need to name this file as "xmlfile" so that server recognizes the input.
import urllib2
url = "http://somedomain"
to_send = open('test.xml').read()
data = {}
data['xmlfile'] = to_send
f = urllib2.urlopen(url, data)
This doesn't work, in addition, how can I retr... | [
"I just read the question nimrodm referred to. One answer mentions the poster module.\nThis module can do the multipart/form-data encoding, so if adding another dependency to your project is not a problem I would go with the poster module.\n\nThis is not as simple as it should be. There is a code snippet floating a... | [
1,
0
] | [] | [] | [
"curl",
"python",
"urllib2"
] | stackoverflow_0004896341_curl_python_urllib2.txt |
Q:
bug or feature: open and io.open are not interchangeable
I always thought open and io.open were interchangeable.
Apparently not, if I believe this snippet:
import ctypes, io
class POINT(ctypes.Structure):
_fields_ = [("x", ctypes.c_int),("y", ctypes.c_int)]
# THIS WORKS
with open("mypoints.bin", "wb") as f:
... | bug or feature: open and io.open are not interchangeable | I always thought open and io.open were interchangeable.
Apparently not, if I believe this snippet:
import ctypes, io
class POINT(ctypes.Structure):
_fields_ = [("x", ctypes.c_int),("y", ctypes.c_int)]
# THIS WORKS
with open("mypoints.bin", "wb") as f:
for i in range(10):
p = POINT(i,10-i)
prin... | [
"Yes, it's a \"bug\", io.open in Python 2.6 is slightly broken. It was supposed to be work like 3.x's open to ease transition, but it doesn't work correctly in some cases. For example, it doesn't support objects with the buffer interface like in your case. This is fixed in Python 2.7 where the builtin open can be u... | [
7
] | [] | [] | [
"api",
"file_io",
"python"
] | stackoverflow_0004896788_api_file_io_python.txt |
Q:
How to detect illicit content in images?
Can you help me in providing a prototype to detect illicit content in images, using python.
A:
Hire someone to do that manually.
Or if you want to be scalable, use a crowdsourced solution like Mechanical Turk.
| How to detect illicit content in images? | Can you help me in providing a prototype to detect illicit content in images, using python.
| [
"Hire someone to do that manually.\nOr if you want to be scalable, use a crowdsourced solution like Mechanical Turk.\n"
] | [
2
] | [] | [] | [
"artificial_intelligence",
"image",
"python"
] | stackoverflow_0004896980_artificial_intelligence_image_python.txt |
Q:
Letter grade function
I'm very new to python, I need to write a function that takes a letter grade (a,b,c,d,f, possibly with a + or -) and returns a number grade. The values are 4,3,2,1,0. So an A would be a 4.0, and B would be 3.0. An A+ would increase the number grade value by 0.3 and A- decreases the number gra... | Letter grade function | I'm very new to python, I need to write a function that takes a letter grade (a,b,c,d,f, possibly with a + or -) and returns a number grade. The values are 4,3,2,1,0. So an A would be a 4.0, and B would be 3.0. An A+ would increase the number grade value by 0.3 and A- decreases the number grade by 0.3. Upper and lowerc... | [
"Python has something called dictionaries. These are able to take a value (called the \"key\") and return a value associated with that key. This is just like looking up the definition of something in a dictionary.\nFor instance:\ntest = { 'a': 4.0, 'b': 3.0 }\n\nThe above creates a dictionary that associates the va... | [
5,
0,
0
] | [] | [] | [
"new_operator",
"python"
] | stackoverflow_0004897027_new_operator_python.txt |
Q:
How to put minorticks on both the sub plots?
I am having two sub plots in the figure. How to add the minor ticks on both x and y axis of both the sub plots?
Also, How can I put the y-label for the right sub plot on the right side of the y axis?
Can you please answer the above questions?
The piece of code is... | How to put minorticks on both the sub plots? | I am having two sub plots in the figure. How to add the minor ticks on both x and y axis of both the sub plots?
Also, How can I put the y-label for the right sub plot on the right side of the y axis?
Can you please answer the above questions?
The piece of code is as follows:
# Open the figure to plot the Gain va... | [
"Just call minorticks_on() on the axes and not on the pyplot object:\nax = plt.subplot(121)\n#....\nax.minorticks_on()\n\nay = plt.subplot(122, ...)\n#...\nay.minorticks_on()\n\n"
] | [
2
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0004896176_matplotlib_python.txt |
Q:
How can I access the view function in a Django template tag?
What it says on the tin: I want to be able to access either:
the view function itself
the view name (although this is less useful, I can probably use it to get back to the function)
attributes of the view function
This needs to be accessed from within ... | How can I access the view function in a Django template tag? | What it says on the tin: I want to be able to access either:
the view function itself
the view name (although this is less useful, I can probably use it to get back to the function)
attributes of the view function
This needs to be accessed from within a template tag.
In short, what I'm trying to do is to mark up view... | [
"Yeah, when first implementing Django you sometimes have to change the way you think about your design, especially if you're coming from a language like PHP, ColdFusion, or another tag-based language where a lot of the functionality comes from within the template.\nIn a nutshell: don't try to implement any complex ... | [
3,
2,
1,
0
] | [] | [] | [
"django",
"django_templates",
"python"
] | stackoverflow_0004891699_django_django_templates_python.txt |
Q:
Python strp csv rows example .Show me how you would go about with this
Imagine if you had thousands of rows of this in CSV .
maps.google.co.ke GET /maps?f=q&source=s_q&hl=en&geocode=&q=Africa&aq=0&sll=1.845384,32.871094&sspn=18.498214,20.786133&ie=UTF8&hq=&hnear=Africa&ll=-8.783195,34.508523&spn=69.476093,83.14... | Python strp csv rows example .Show me how you would go about with this | Imagine if you had thousands of rows of this in CSV .
maps.google.co.ke GET /maps?f=q&source=s_q&hl=en&geocode=&q=Africa&aq=0&sll=1.845384,32.871094&sspn=18.498214,20.786133&ie=UTF8&hq=&hnear=Africa&ll=-8.783195,34.508523&spn=69.476093,83.144531&z=3&output=embed HTTP/1.1 1.29646542461634E+015 168722060 1606370688... | [
"i think this code in enough to do the job. \nimport re\n\npat = re.compile('GET.*?HTTP1.1')\n\nwith open('dremel-columns.csv', 'rb') as f_in, open(\"out.txt\", \"wb\") as g_out:\n g_out.write(u + '\\n' for u in pat.finditer(f_in.read()))\n\nisn't it ?\nEDIT: excuse me, I forgot the '\\n'\n.\nEDIT 2: no, it does... | [
1
] | [] | [] | [
"algorithm",
"csv",
"python"
] | stackoverflow_0004897962_algorithm_csv_python.txt |
Q:
Django: writing a view to delete an item with checkboxes
I need help writing a view that gets the POST data which then finds out which checkboxes have been checked, and then deletes the items from the database matched by id.
Originally, This was a checkbox problem. In a edit order form, there are a list of items. ... | Django: writing a view to delete an item with checkboxes | I need help writing a view that gets the POST data which then finds out which checkboxes have been checked, and then deletes the items from the database matched by id.
Originally, This was a checkbox problem. In a edit order form, there are a list of items. Now I CAN remove the item using a bit of javascript but it doe... | [
"Given your template using checkboxes with name=\"item\"... .delete() should work.\nItems.objects.filter(id__in=request.POST.getlist('items')).delete()\n\nAre you getting an exception? Is the delete() code ever running? Throw in a print statement.\nYou have \"a ton of code\", a lot of conditions we're not familiar ... | [
5
] | [] | [] | [
"checkbox",
"django",
"django_forms",
"html",
"python"
] | stackoverflow_0004897291_checkbox_django_django_forms_html_python.txt |
Q:
Creating a python web server to recieve XML HTTP Requests
I am currently working on a project to create simple file uploader site that will update the user of the progress of an upload.
I've been attempting this in pure python (with CGI) on the server side but to get the progress of the file I obviously need send... | Creating a python web server to recieve XML HTTP Requests | I am currently working on a project to create simple file uploader site that will update the user of the progress of an upload.
I've been attempting this in pure python (with CGI) on the server side but to get the progress of the file I obviously need send requests to the server continually. I was looking to use AJAX ... | [
"I would recommend to use a microframework like Sinatra for Ruby. There seem to be some equivalents for Python. What python equivalent of Sinatra would you recommend?\nSuch a framework allows you to simply map a single method to a route.\n",
"Writing a very basic HTTP server won't be very hard (see http://docs.py... | [
1,
0,
0
] | [] | [] | [
"http",
"python",
"xmlhttprequest"
] | stackoverflow_0004898066_http_python_xmlhttprequest.txt |
Q:
Text Decoration + Python - is there a way?
Is there a way in python to turn text blue or make it bigger or...something?
A:
Have a look at the curses module. Not sure you can change the font size, though.
A:
you can use escape sequences
print "^[[0;31;40mColor"
whereas the ^[ is a single character which can b... | Text Decoration + Python - is there a way? | Is there a way in python to turn text blue or make it bigger or...something?
| [
"Have a look at the curses module. Not sure you can change the font size, though.\n",
"you can use escape sequences\nprint \"^[[0;31;40mColor\"\n\nwhereas the ^[ is a single character which can be produced by pressing first ctrl-v and then ESC.\n",
"For coding the escape sequences I've been using the colorama p... | [
2,
1,
1
] | [] | [] | [
"console",
"python"
] | stackoverflow_0004894811_console_python.txt |
Q:
use batik-rasterizer without GTK
i'm using the Apache Batik SVG Rasterizer Library in python, but when i try to convert a svg into png i get this error Gtk-WARNING **: cannot open display:
How can i do to don't use GTK to convert the SVG file
Thanks and sorry for my english!
my code is this
gij --jar batik/batik-... | use batik-rasterizer without GTK | i'm using the Apache Batik SVG Rasterizer Library in python, but when i try to convert a svg into png i get this error Gtk-WARNING **: cannot open display:
How can i do to don't use GTK to convert the SVG file
Thanks and sorry for my english!
my code is this
gij --jar batik/batik-rasterizer.jar file.svg
I use GIJ cou... | [
"Do you have a code sample. The error indicates that you are performing a plot on a headless/display less system. This may arise not due to an SVG conversion but due to a call to display a plot/window or something similar. The error will go away if you attach monitor or set the DISPLAY variable in the environment.\... | [
3,
0,
0
] | [] | [] | [
"django",
"python",
"rasterizing",
"svg"
] | stackoverflow_0003920911_django_python_rasterizing_svg.txt |
Q:
FileField() Error when trying to upload file using GAE and Django
Hello Stack Overflow community!!
I am attempting to upload a file to GAE and I'm using Django. When I run the following code it returns this error:
Tried upload in module pathway.app.views.
Error was: 'module' object has no attribute 'FileField'
W... | FileField() Error when trying to upload file using GAE and Django | Hello Stack Overflow community!!
I am attempting to upload a file to GAE and I'm using Django. When I run the following code it returns this error:
Tried upload in module pathway.app.views.
Error was: 'module' object has no attribute 'FileField'
When googling for a solution I found this, but this issue should have
b... | [
"You are using the version of Django included with Google App Engine, 0.96.4, which is four years old and comes from before the newforms library included support for file fields (and before it was renamed to simply forms). \nInstall an up-to-date Django version in your GAE project's directory and use that instead.\... | [
0
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0004898450_django_google_app_engine_python.txt |
Q:
Python: Parsing timestamps and calculating time differences in milliseconds
I have a list of timestamps in "%H:%M:%S" format. For example
09:50:08.650000
09:50:08.665000
09:50:08.820000
09:50:08.877000
09:50:09.897000
09:50:09.907000
09:50:09.953000
09:50:10.662000
09:50:10.662000
I need to comp... | Python: Parsing timestamps and calculating time differences in milliseconds | I have a list of timestamps in "%H:%M:%S" format. For example
09:50:08.650000
09:50:08.665000
09:50:08.820000
09:50:08.877000
09:50:09.897000
09:50:09.907000
09:50:09.953000
09:50:10.662000
09:50:10.662000
I need to compute efficiently in python the time difference in milliseconds between each line.
| [
"%H:%M:%S.%f is the format string to be used when parsing the times. See http://docs.python.org/library/datetime.html#strftime-strptime-behavior\nimport datetime\n\ntimes = \"\"\"\n09:50:08.650000\n09:50:08.665000\n09:50:08.820000\n09:50:08.877000\n09:50:09.897000\n09:50:09.907000\n09:50:09.953000\n09:50:10.662000\... | [
7,
2
] | [] | [] | [
"datetime",
"python"
] | stackoverflow_0004898687_datetime_python.txt |
Q:
How to avoid PHP exec() by using WSGI to execute a Python script?
Right now I am launching a Python script from PHP using exec() as I have to pass some dynamic variables from the website/MySQL to the command line. However, I would like to improve both the speed and the security of this operation so I thought of us... | How to avoid PHP exec() by using WSGI to execute a Python script? | Right now I am launching a Python script from PHP using exec() as I have to pass some dynamic variables from the website/MySQL to the command line. However, I would like to improve both the speed and the security of this operation so I thought of using WSGI. I was thinking that it might be possible to embed the Python ... | [
"First off, can you do it all in either Python or PHP? Using multiple languages is normally seen as an anti-pattern. That's not to say it's always a bad idea, but you should be questioning why first, and only then if you're convinced it's a good idea move forward.\nAs far as the specifics of what you want to do, ... | [
1
] | [] | [] | [
"php",
"python",
"wsgi"
] | stackoverflow_0004898614_php_python_wsgi.txt |
Q:
Unable to call a function by using a string
I am trying to call a function in a class based on the string I passed in.
I tried following the steps at this link:
Calling a function of a module from a string with the function's name in Python
Here is my code:
methodNameString = "add" + typeOfShip
methodToCall = geta... | Unable to call a function by using a string | I am trying to call a function in a class based on the string I passed in.
I tried following the steps at this link:
Calling a function of a module from a string with the function's name in Python
Here is my code:
methodNameString = "add" + typeOfShip
methodToCall = getattr(listOfPlayerFleets[currentPlayer], methodName... | [
"Your methodToCall variable is a bound method, meaning you don't need to call it on an object--it knows the object it will be called on. fleet.addFighter, for example, is an unbound method. Printing repr(methodToCall) and repr(fleet.addFighter) should make this clear.\nYou should use this:\nmethodNameString = \"a... | [
3,
2,
1,
0
] | [] | [] | [
"dynamic_function",
"python"
] | stackoverflow_0004899043_dynamic_function_python.txt |
Q:
Problem with Functions which has default parameter(s)
I have some question about functions which have default parameters.
import sys
from random import randint
my_list = [1,2,3]
def Veli(a, b = my_list):
my_list.append(randint(1,1500))
print a + b[-1]
print "Number of Refs:", sys.getrefcount(my_list)
pr... | Problem with Functions which has default parameter(s) | I have some question about functions which have default parameters.
import sys
from random import randint
my_list = [1,2,3]
def Veli(a, b = my_list):
my_list.append(randint(1,1500))
print a + b[-1]
print "Number of Refs:", sys.getrefcount(my_list)
print "Def args:", Veli.func_defaults
Veli(1) # This is 4
Vel... | [
"\nDefaults arguments are bounds at function definition time. The line def Veli(a, b = my_list): puts a reference to the object my_list happens to refer to at that time into func_defaults. Python never uses pass-by-reference - variables hold references and those references are always passed by value. So what's actu... | [
1,
1
] | [] | [] | [
"default_parameters",
"function",
"python"
] | stackoverflow_0004899231_default_parameters_function_python.txt |
Q:
python com component does not register when using libxml2 on win7
i've built a com component which utilizes libxml2 python bindings , the build is successfull but when i try to register the component i get "specified module could not be found , unable to load python dll" this is the error i get when the component ... | python com component does not register when using libxml2 on win7 | i've built a com component which utilizes libxml2 python bindings , the build is successfull but when i try to register the component i get "specified module could not be found , unable to load python dll" this is the error i get when the component is built using the bundle files option set as 1
if i build the componen... | [
"Most likely, regsvr32.exe which registers you COM component couldn't find a DLL that your COM component needs.\nI'm not familiar with Python COM components but is there some way you can run depends.exe on it? This is the usual way to track down binary dependency problems.\n"
] | [
1
] | [] | [] | [
"com",
"python"
] | stackoverflow_0004899158_com_python.txt |
Q:
diff two big files in Python
I have two big text files, near 2GB each. I need something like diff f1.txt f2.txt . Is there any way to do this task fast in python? Standard difflib is too slow. I assume there is faster way, because difflib is fully implemented in Python.
A:
How about using difflib in way that you... | diff two big files in Python | I have two big text files, near 2GB each. I need something like diff f1.txt f2.txt . Is there any way to do this task fast in python? Standard difflib is too slow. I assume there is faster way, because difflib is fully implemented in Python.
| [
"How about using difflib in way that you script can handle big files? Don't load the files in memory, but iterate through the files of the files and diff in chunks. For e.g 100 lines at a time. \nimport difflib\n\nd = difflib.Differ()\n\nf1 = open('bigfile1')\nf2 = open('bigfile2')\n\nb1 = []\nb2 = []\n\nfor n, lin... | [
6
] | [] | [] | [
"diff",
"python"
] | stackoverflow_0004899146_diff_python.txt |
Q:
Python: Loading data from a file into an IRC bot
I'm trying to load a list of regex patterns from a file, and I'd like it to pull each regex entry into an array which can later be used to match incoming text patterns, then trigger an action based on them.
I've already gotten the hang of making re.search() work, bu... | Python: Loading data from a file into an IRC bot | I'm trying to load a list of regex patterns from a file, and I'd like it to pull each regex entry into an array which can later be used to match incoming text patterns, then trigger an action based on them.
I've already gotten the hang of making re.search() work, but how can I load the regex patterns from a file, then ... | [
"If you want to trigger an action when a regex matches an text pattern, you probably need some mapping of regex to the action (let's assume it is a reference to a function defined in the same file as the mappings). Say we define the rules in a python file rules.py like this:\nmappings = [\n # (regex, action_name... | [
2,
1
] | [] | [] | [
"python",
"python_2.6"
] | stackoverflow_0004899443_python_python_2.6.txt |
Q:
Prominent Python projects using Nose for testing
What are some well-known Python projects that use Nose for testing?
A:
Sphinx and Werkzeug, for instance.
| Prominent Python projects using Nose for testing | What are some well-known Python projects that use Nose for testing?
| [
"Sphinx and Werkzeug, for instance.\n"
] | [
4
] | [] | [] | [
"nose",
"python",
"testing"
] | stackoverflow_0004897933_nose_python_testing.txt |
Q:
Trying to sort integers but getting 'invalid literal for int() with base 10' error
I'm trying to sort a list by the 8th column (after splitting the file) BUT I keep getting this error:
ValueError: invalid literal for int() with base 10: '72912,'
Here is my list I'm trying to sort:
UDP outside 192.168.30.33:104... | Trying to sort integers but getting 'invalid literal for int() with base 10' error | I'm trying to sort a list by the 8th column (after splitting the file) BUT I keep getting this error:
ValueError: invalid literal for int() with base 10: '72912,'
Here is my list I'm trying to sort:
UDP outside 192.168.30.33:1046 inside 192.168.84.28:161, idle 0:00:18, bytes 72912, flags
TCP outside 192.168.120.2... | [
"There is a trailing comma in the column you need to remove before trying to convert it to an integer.\nlines.sort(cmp, key=lambda x:int(x[8][:-1]), reverse=True)\n\nThat makes a difference.\nIn [1]: foo = '72912,'\nIn [2]: int(foo)\nValueError: invalid literal for int() with base 10: '72912,'\n\nIn [3]: int(foo[:-... | [
4,
2
] | [] | [] | [
"python",
"sorting"
] | stackoverflow_0004899703_python_sorting.txt |
Q:
Python doesn't detect a closed socket until the second send
When I close the socket on one end of a connection, the other end gets an error the second time it sends data, but not the first time:
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("localhost", 12345))
server.liste... | Python doesn't detect a closed socket until the second send | When I close the socket on one end of a connection, the other end gets an error the second time it sends data, but not the first time:
import socket
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(("localhost", 12345))
server.listen(1)
client = socket.create_connection(("localhost",12345))
sock... | [
"This is expected, and how the TCP/IP APIs are implemented (so it's similar in pretty much all languages and on all operating systems)\nThe short story is, you cannot do anything to guarantee that a send() call returns an error directly if that send() call somehow cannot deliver data to the other end. send/write ca... | [
15,
1
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0004899593_python_sockets.txt |
Q:
How can I transfer a file via XMPP using Python?
I'm using xmpppy library for my jabber remote administration bot, but I can't find how to send/receive a file and save it inside the directory specified. The documentation is poor and there isn't any examples, but I really want to make it. Can anyone show some examp... | How can I transfer a file via XMPP using Python? | I'm using xmpppy library for my jabber remote administration bot, but I can't find how to send/receive a file and save it inside the directory specified. The documentation is poor and there isn't any examples, but I really want to make it. Can anyone show some examples or some links about it? Or maybe I should use an a... | [
"There are two XEP's (XMPP Extensions) that cover file transfer: XEP-0096 http://xmpp.org/extensions/xep-0096.html (called SI (Stream Initiated) File Transfer) and XEP-0234 http://xmpp.org/extensions/xep-0234.html (Jingle File Transfer)\nXEP-0096 is the original one but I have found it is rarely implemented (as you... | [
3,
0
] | [] | [] | [
"file_transfer",
"python",
"xmpp"
] | stackoverflow_0002851992_file_transfer_python_xmpp.txt |
Q:
How to filter all selected options?
I have these 5 options from pull down menues:
<select name="image_style">
<select name="image_background">
<select name="image_activity">
<select name="image_merchandise">
<select name="image_type">
I want all selected ones to be filtered. I try this:
image_background = self.re... | How to filter all selected options? | I have these 5 options from pull down menues:
<select name="image_style">
<select name="image_background">
<select name="image_activity">
<select name="image_merchandise">
<select name="image_type">
I want all selected ones to be filtered. I try this:
image_background = self.request.get("image_background")
image_activ... | [
"Build up a list tags of all the options, filter out all non-selected (see the lambda) and check if the resulting list is empty or not.\nselects = filter(lambda x: x != \"None\", \n [image_style, image_background, image_activity,\n image_merchandise, image_type]\n )\n\nif selects... | [
3
] | [] | [] | [
"conditional",
"google_app_engine",
"python"
] | stackoverflow_0004899669_conditional_google_app_engine_python.txt |
Q:
How to produce an exponentially scaled axis?
Consider the following code:
from numpy import log2
import matplotlib.pyplot as plt
xdata = [log2(x)*(10/log2(10)) for x in range(1,11)]
ydata = range(10)
plt.plot(xdata, ydata)
plt.show()
This produces the following plot: My question is, how can I modify this, so th... | How to produce an exponentially scaled axis? | Consider the following code:
from numpy import log2
import matplotlib.pyplot as plt
xdata = [log2(x)*(10/log2(10)) for x in range(1,11)]
ydata = range(10)
plt.plot(xdata, ydata)
plt.show()
This produces the following plot: My question is, how can I modify this, so that the plot, with the exact same data as input, ap... | [
"Here is how it is done. A good example to follow. You just subclass the ScaleBase class.\nHere's your transform. It's not too complicated when you whittle out all the custom formatters and stuff. Just a little verbose.\nfrom numpy import log2\nimport matplotlib.pyplot as plt\n\nfrom matplotlib import scale as ... | [
7,
2
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0004899516_matplotlib_python.txt |
Q:
Python Superglobal?
Is there is a super global (like PHP) in Python? I have certain variables I want to use throughout my whole project in separate files, classes, and functions, and I don't want to have to keep declaring it throughout each file.
A:
In theory yes, you can start spewing crud into __builtin__:
>>... | Python Superglobal? | Is there is a super global (like PHP) in Python? I have certain variables I want to use throughout my whole project in separate files, classes, and functions, and I don't want to have to keep declaring it throughout each file.
| [
"In theory yes, you can start spewing crud into __builtin__:\n>>> import __builtin__\n>>> __builtin__.rubbish= 3\n>>> rubbish\n3\n\nBut, don't do this; it's horrible evilness that will give your applications programming-cancer.\n\nclasses and functions and i don't want to have to keep declaring\n\nPut them in modul... | [
19,
5,
4,
4,
1
] | [] | [] | [
"python",
"python_3.x"
] | stackoverflow_0000736335_python_python_3.x.txt |
Q:
Downloading wmv from a url in Python 2.6
I have a wmv file at a particular url that I want to grab and save as a file using Python. My script uses urllib2 to authenticate and read the bytes and save them locally in chunks. However, once I open the file, no video player recognizes it. When I download the wmv manual... | Downloading wmv from a url in Python 2.6 | I have a wmv file at a particular url that I want to grab and save as a file using Python. My script uses urllib2 to authenticate and read the bytes and save them locally in chunks. However, once I open the file, no video player recognizes it. When I download the wmv manually from a browser, the file plays fine, but od... | [
"What Transfer-Encoding is the server sending back? I would bet it is sending back Transfer-Encoding: chunked, which is ending up in your data.\nhttp://en.wikipedia.org/wiki/Chunked_transfer_encoding\n",
"From what I understand, urllib works at the HTTP level and should properly remove headers in subsequent chunk... | [
0,
0,
0
] | [] | [] | [
"python",
"python_2.6",
"urllib",
"urllib2",
"wmv"
] | stackoverflow_0004883101_python_python_2.6_urllib_urllib2_wmv.txt |
Q:
Django for some reason doesn't want to import one particular model
I have a Django model where I'm importing a number of items:
from django.db import models
from mcif.models.import_profile import ImportProfile
from mcif.models.import_file import ImportFile
from mcif.models.import_bundle import ImportBundle
from mc... | Django for some reason doesn't want to import one particular model | I have a Django model where I'm importing a number of items:
from django.db import models
from mcif.models.import_profile import ImportProfile
from mcif.models.import_file import ImportFile
from mcif.models.import_bundle import ImportBundle
from mcif.models.customer import Customer
#from mcif.models.account_import impo... | [
"You have a circular import - mcif.models.generic_import and mcif.models.account_import are trying to import each other.\nRemember that Python is not Java, and is quite happy to have multiple classes in a single file, especially if they're closely related like these two seem to be. Put them both in a single mcif.mo... | [
3,
2,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004900227_django_python.txt |
Q:
Print new line in Google app engine
self.response.out.write("\n")
When i upload a data of multiline using text property and then printing it back it prints in a single line....
i upload the ascii hexa code ....
so carriage return is 0x10 but when pringing it in ascii from datastore the new line is not inserted...... | Print new line in Google app engine | self.response.out.write("\n")
When i upload a data of multiline using text property and then printing it back it prints in a single line....
i upload the ascii hexa code ....
so carriage return is 0x10 but when pringing it in ascii from datastore the new line is not inserted...
instead it prints as a single line
impor... | [
"Where are you printing that data back out to? If it's inside of HTML (well, unless it's surrounded by <pre> tags), the newlines will be ignored regardless of whether the EOL is indicated by \\n or \\r\\n.\nIf that's what's going on, you can just do\nself.response.out.write(myString.replace(\"\\n\", \"<br />\"))\n\... | [
9,
3
] | [] | [] | [
"google_app_engine",
"new_operator",
"newline",
"python"
] | stackoverflow_0004900013_google_app_engine_new_operator_newline_python.txt |
Q:
Making a system/program vulnerable to exploits
I have been looking quite a bit into exploiting recently. I have been googling alot and i managed to find DVL (Damn Vulnerable Linux) and Metasploitable but for some reason the exploits i scan them to have (with Nessus) do not really work. So now i have decided to try... | Making a system/program vulnerable to exploits | I have been looking quite a bit into exploiting recently. I have been googling alot and i managed to find DVL (Damn Vulnerable Linux) and Metasploitable but for some reason the exploits i scan them to have (with Nessus) do not really work. So now i have decided to try on a smaller scale.. I was wondering if anyone know... | [
"In Ruby an easy way to make a system vulnerable is by running text input from users in an eval.\nbad_code = \"system('rm -rf /users')\"\neval(bad_code)\n\n",
"One that I like alot:\n%0|%0\n\nIt just hangs up system, and then you need to restart :)\nHere you go an Python code bit for it:\nos.system('%0|%0')\n\nIt... | [
0,
0
] | [] | [] | [
"buffer",
"exploit",
"overflow",
"python",
"ruby"
] | stackoverflow_0004899617_buffer_exploit_overflow_python_ruby.txt |
Q:
Trigonometry sin return negative
I made this code in Python
def hitsin(a):
a = a*57.3
return math.sin(a)
so whenever i put hitsin(x) the x converted to radian. I confuse when I put hitsin(90) the answer is not 1 or any number near 1, but negative (it was -0.9971392129043587). Am I doing it wrong?
p.s: I a... | Trigonometry sin return negative | I made this code in Python
def hitsin(a):
a = a*57.3
return math.sin(a)
so whenever i put hitsin(x) the x converted to radian. I confuse when I put hitsin(90) the answer is not 1 or any number near 1, but negative (it was -0.9971392129043587). Am I doing it wrong?
p.s: I also try to write the same kind of code... | [
"You should divide by 180/pi, not multiply. In Python, you can also use math.radians() for the conversion from degree to radians:\ndef hitsin(a):\n return math.sin(math.radians(a))\nhitsin(90)\n# 1.0\n\nFurthermore, I doubt the C code gives the same result as the Python code, because it uses cos() instead of si... | [
13,
6,
1,
0
] | [] | [] | [
"c",
"python",
"trigonometry"
] | stackoverflow_0004900996_c_python_trigonometry.txt |
Q:
How to change back a line during file read
In my code I have a line length print like this:
line = file.readline()
print("length = ", len(line))
after that I start to scan the lines by doing this:
for i in range(len(line)):
if(file.read(1) == 'b'):
print("letter 'b' found.")
The problem is th... | How to change back a line during file read | In my code I have a line length print like this:
line = file.readline()
print("length = ", len(line))
after that I start to scan the lines by doing this:
for i in range(len(line)):
if(file.read(1) == 'b'):
print("letter 'b' found.")
The problem is that the for loop starts reading on line 2 of the ... | [
"It is possible to use file.seek to move the position of the next read, but that's inefficient. You've already read in the line, so you can just process\nline without having to read it in a second time.\nwith open(filename,'r') as f:\n line = f.readline()\n print(\"length = \", len(line))\n if 'b' in line... | [
2,
1,
0,
0
] | [] | [] | [
"io",
"line",
"python"
] | stackoverflow_0004900952_io_line_python.txt |
Q:
How come Pylons is not recognized when I run 'import pylons' in Windows Vista command prompt?
When I try to import pylons in the virtual python environment I get the error
C:\env\Scripts>python
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (A
MD64)] on win32
Type "help", "copyright", "credits" o... | How come Pylons is not recognized when I run 'import pylons' in Windows Vista command prompt? | When I try to import pylons in the virtual python environment I get the error
C:\env\Scripts>python
Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (A
MD64)] on win32
Type "help", "copyright", "credits" or "license" for more informati
on.
>>> import pylons
Traceback (most recent call last):
File "<st... | [
"You have to activate the virtual environment before you can import pylons.\nC:\\Users\\Josh>env\\scripts\\activate\n(env) C:\\Users\\Josh>python\nActivePython 2.6.2.2 (ActiveState Software Inc.) based on\nPython 2.6.2 (r262:71600, Apr 21 2009, 15:05:37) [MSC v.1500 32 bit (Intel)] on\nwin32\nType \"help\", \"copyr... | [
1
] | [] | [] | [
"installation",
"pylons",
"python",
"windows"
] | stackoverflow_0003827235_installation_pylons_python_windows.txt |
Q:
How to print for loop with 2 lists?
I have 2 lists:
filtered_items_list = [src1, scr2, scr3]
filtered_items_url_list = [url1, url2, url3]
I want to print this as
src1, url1
src2, url2
src3, url3
If I try:
>>> for src, url in filtered_items_list, filtered_items_url_list:
print src, url
I get this error:
V... | How to print for loop with 2 lists? | I have 2 lists:
filtered_items_list = [src1, scr2, scr3]
filtered_items_url_list = [url1, url2, url3]
I want to print this as
src1, url1
src2, url2
src3, url3
If I try:
>>> for src, url in filtered_items_list, filtered_items_url_list:
print src, url
I get this error:
ValueError: too many values to unpack
If ... | [
"You should use zip():\nfor src, url in zip(filtered_items_list, filtered_items_url_list):\n print src, url\n\n"
] | [
9
] | [] | [] | [
"for_loop",
"list",
"python"
] | stackoverflow_0004901220_for_loop_list_python.txt |
Q:
Why can't I call a private method when I'm inside a public method?
I have the following code:
class MyClass:
def __private(self):
print "Hey man! This is private!"
def public(self):
__private()
print "I don't care if you see this!"
if __name__ == '__main__':
x = MyClass()
... | Why can't I call a private method when I'm inside a public method? | I have the following code:
class MyClass:
def __private(self):
print "Hey man! This is private!"
def public(self):
__private()
print "I don't care if you see this!"
if __name__ == '__main__':
x = MyClass()
x.public()
However it gives me the following error:
NameError: global ... | [
"You need self:\nself.__private()\n\nClasses in python take getting used to if you're coming from C#/C++/Java, like it looks like you are. This is probably butchering the \"pythonic\" way of wording things, but you can think about it like this (it helped me out):\nEach class defines a namespace defined from within... | [
22,
3
] | [] | [] | [
"private",
"public",
"python"
] | stackoverflow_0004901209_private_public_python.txt |
Q:
py2exe gtk execute scripts from directory
Hi I am building a simple application that will have a combo box to select python scripts that are in a directory called scripts to create reports on a database. I was going to use py2exe to build the program so that the users don't have to have python and submoduals insta... | py2exe gtk execute scripts from directory | Hi I am building a simple application that will have a combo box to select python scripts that are in a directory called scripts to create reports on a database. I was going to use py2exe to build the program so that the users don't have to have python and submoduals installed.
so how would i go about having the progr... | [
"Micheal Foord has the following example for Embedding Ironpython from within Ironpython\nThe basic steps are to create your shell application. For a real lightweight GUI there is EasyWPF. Use pyc to compile your script to an exe and the standard library into a DLL. Depending on if you need to capture stdout from... | [
0
] | [] | [] | [
"ironpython",
"py2exe",
"python",
"reportlab",
"windows"
] | stackoverflow_0004898806_ironpython_py2exe_python_reportlab_windows.txt |
Q:
Two-way querying in Django without circular reference
Let's say you have two models: Post and Category. Each Post has a category_id.
Getting a post's category is straightforward: post.category. What if you want to get all the posts for a certain category? I suppose you would do
def posts(self):
return Post.fil... | Two-way querying in Django without circular reference | Let's say you have two models: Post and Category. Each Post has a category_id.
Getting a post's category is straightforward: post.category. What if you want to get all the posts for a certain category? I suppose you would do
def posts(self):
return Post.filter(category__pk=self.id)
But what if the Post model and C... | [
"For part 1. of your question:\nDjango automatically sets up the reverse relationship for you. on your Category you have access to a post_set attribute, which is itself a Manager, so you can do:\ndef posts(self):\n return self.post_set.all()\n\nCheck out the docs for more on this.\nFor part 2. I have a less comp... | [
3,
2
] | [] | [] | [
"django",
"python"
] | stackoverflow_0004901069_django_python.txt |
Q:
Event Synchronization Using NTP
I would like to synchronize two events between two (or more) wire networked Linux machines. Can I use NTP to do this?
NTP seems to be mostly focused on synchronizing to a time server, where I need two machines to be synchronized to each other. There is a subtle difference there. ... | Event Synchronization Using NTP | I would like to synchronize two events between two (or more) wire networked Linux machines. Can I use NTP to do this?
NTP seems to be mostly focused on synchronizing to a time server, where I need two machines to be synchronized to each other. There is a subtle difference there. For example, if one machine is locat... | [
"You might try delegating one machine as the master, and the remaining machines as slaves. When the synchronized events should occur, the master triggers the slaves to commence.\nThe synchronization would be limited only by the latency (ping) between the machines, and you wouldn't need to worry about system clocks... | [
2,
0
] | [] | [] | [
"ntp",
"python"
] | stackoverflow_0004876759_ntp_python.txt |
Q:
Pydev relative project path
I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where ... | Pydev relative project path | I installed eclipse with pydev plugin. I need to run my existing project on eclipse. But there are relative paths to the files inside my code. I expect from eclipse to append relative paths to the project's default directory. Instead, it appends the relative path to the directory where Eclipse is installed. I could not... | [
"I finally found out how to do it and I am writing the answer for other people with the same problem. You can find it in Run Configurations or Debug Configurations. Choose \"Python Run\" and your run configuration from the left and then in the \"Arguments\" tab in the right side, set your \"working directory\" as \... | [
7,
1,
0
] | [] | [] | [
"eclipse",
"pydev",
"python",
"relative_path"
] | stackoverflow_0003211690_eclipse_pydev_python_relative_path.txt |
Q:
Module subprocess has no attribute 'STARTF_USESHOWWINDOW'
Hi Stack Overflow users,
I've encountered a frustrating problem, can't find the answer to it.
Yesterday I was trying to find a way to HIDE a subprocess.Popen. So for example, if i was opening the cmd. I would like it to be hidden, permanently.
I found this ... | Module subprocess has no attribute 'STARTF_USESHOWWINDOW' | Hi Stack Overflow users,
I've encountered a frustrating problem, can't find the answer to it.
Yesterday I was trying to find a way to HIDE a subprocess.Popen. So for example, if i was opening the cmd. I would like it to be hidden, permanently.
I found this code:
kwargs = {}
if subprocess.mswindows:
su = subprocess... | [
"You can recreate or check the described problem in your Python installation:\nimport subprocess\nsubprocess.STARTF_USESHOWWINDOW\n\nIf the problem persists you should receive error message ending with line like this:\nAttributeError: 'module' object has no attribute 'STARTF_USESHOWWINDOW'\n\nPossible solution of t... | [
11,
4,
1,
1
] | [] | [] | [
"python",
"python_3.x",
"subprocess"
] | stackoverflow_0004703983_python_python_3.x_subprocess.txt |
Q:
local variable - run time error with local
x=5
def printx()
print x
x=10
running this gives unboundlocal error
but when my function is just print x i get no error..
A:
Simply assigning a value to x in the function is making it a local variable, therefore shadowing the global x = 5 specified on the previ... | local variable - run time error with local | x=5
def printx()
print x
x=10
running this gives unboundlocal error
but when my function is just print x i get no error..
| [
"Simply assigning a value to x in the function is making it a local variable, therefore shadowing the global x = 5 specified on the previous line. And on the line you're trying to print x, the local version of x hasn't been initialized yet. It is curious how doing something on a later line is influencing lines that... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0004901687_python.txt |
Q:
How do I retrieve timedate from the database and display in template?
I'm a complete Python and Django noob so any help is appreciated. This is what my model looks like:
class Matches(models.Model):
id = models.AutoField(primary_key=True)
date = models.DateTimeField()
court = models.ForeignKey(Courts)
... | How do I retrieve timedate from the database and display in template? | I'm a complete Python and Django noob so any help is appreciated. This is what my model looks like:
class Matches(models.Model):
id = models.AutoField(primary_key=True)
date = models.DateTimeField()
court = models.ForeignKey(Courts)
class Participants(models.Model):
id = models.AutoField(primary_key=Tr... | [
"1: how would it know to print id and date out of all fields you might have? \nYou can define what your object returns when printed by defining __unicode__\nhttp://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.unicode\n# ... model class\n\ndef __unicode__(self):\n return \"%s %s\" % ... | [
1
] | [] | [] | [
"database",
"django",
"python"
] | stackoverflow_0004902020_database_django_python.txt |
Q:
Why is mercurial version always 1.3.1 even though I installed 1.6.4?
I ran pip uninstall mercurial Mac OSX 10.6.6, with and without sudo, in my virtualenv, and removed every trace of hg or mercurial on my machine. I tried re-installing like so:
pip install mercurial==1.6.4
http://mercurial.berkwood.com/ where I... | Why is mercurial version always 1.3.1 even though I installed 1.6.4? | I ran pip uninstall mercurial Mac OSX 10.6.6, with and without sudo, in my virtualenv, and removed every trace of hg or mercurial on my machine. I tried re-installing like so:
pip install mercurial==1.6.4
http://mercurial.berkwood.com/ where I downloaded a Mac-specific version of 1.6.4
All efforts yielded the same ... | [
"The hg binary is just a thin wrapper around the mercurial Python module. It sounds like all you did was remove the old hg binary but not the old mercurial Python module, so the new install is picking up the old modules.\nYou can see where the modules are installed with python -c 'import mercurial; print mercurial... | [
4
] | [] | [] | [
"macos",
"mercurial",
"python"
] | stackoverflow_0004902199_macos_mercurial_python.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.