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:
Error handling in Django-Piston
In Django-Piston, is there a good way to do error handling? (Like returning a 400 status code when the caller omits a required GET parameter, or when the parameters are invalid.)
A:
Django-piston respects HTTP status codes and handles common erros by default (auth, etc), but you c... | Error handling in Django-Piston | In Django-Piston, is there a good way to do error handling? (Like returning a 400 status code when the caller omits a required GET parameter, or when the parameters are invalid.)
| [
"Django-piston respects HTTP status codes and handles common erros by default (auth, etc), but you can also throw new exceptions or status using rc from piston.utils.\nFor example: \nfrom django.contrib.auth.models import User\nfrom piston.handler import AnonymousBaseHandler\nfrom piston.utils import rc\n\nclass An... | [
4
] | [] | [] | [
"django",
"django_piston",
"python"
] | stackoverflow_0005059718_django_django_piston_python.txt |
Q:
update an entity in datastore app engine
Possible Duplicate:
Update app engine entity
I need to update entity that I loaded from the datastore. But how?
A:
Here you go
myKey = db.Key.from_path('MyModel', 'mykeyvalue')
rec = db.get(myKey)
rec.MyProperty = 'this is a new value'
rec.put()
Here is a link to the... | update an entity in datastore app engine |
Possible Duplicate:
Update app engine entity
I need to update entity that I loaded from the datastore. But how?
| [
"Here you go \nmyKey = db.Key.from_path('MyModel', 'mykeyvalue')\nrec = db.get(myKey)\n\nrec.MyProperty = 'this is a new value'\nrec.put()\n\nHere is a link to the documentation.\nhttp://code.google.com/appengine/docs/python/datastore/entities.html\n"
] | [
14
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0005067418_google_app_engine_python.txt |
Q:
Performing text processing on flatpage content to include handling of custom tag
I'm using flatpages app in my project to manage some html content. That content will include images, so I've made a ContentImage model allowing user to upload images using admin panel.
The user should then be able to include those ima... | Performing text processing on flatpage content to include handling of custom tag | I'm using flatpages app in my project to manage some html content. That content will include images, so I've made a ContentImage model allowing user to upload images using admin panel.
The user should then be able to include those images in content of the flatpages. He can of course do that by manually typing image url... | [
"I finally imlemented this using regular expressions. I decided, that spaces are not allowed inside the custom tag. Main text processing function looks like this:\nimport re\nfrom django.utils.translation import ugettext as _\n\ndef process_image_tags(text, ImageModel):\n '''image tag usage:\n ... some te... | [
1
] | [] | [] | [
"algorithm",
"django",
"python",
"text_processing"
] | stackoverflow_0005054169_algorithm_django_python_text_processing.txt |
Q:
List of dictionaries
Iam trying to create a list of dictionaries, but seems to me, that i am doing something wrong:
So, I have a list of tuples, something like this:
dict = {}
lst = []
cats = [(u'cat1', u'Matilda'),(u'cat2', u'Mew')]
for line in cats:
dict['cat_num'] = line[0]
dict['name'] = line[1]
ls... | List of dictionaries | Iam trying to create a list of dictionaries, but seems to me, that i am doing something wrong:
So, I have a list of tuples, something like this:
dict = {}
lst = []
cats = [(u'cat1', u'Matilda'),(u'cat2', u'Mew')]
for line in cats:
dict['cat_num'] = line[0]
dict['name'] = line[1]
lst.append(dict)
print lst
... | [
"Move the definition of dct inside the loop (and don't call it dict, since this is the name of the class):\nlst = []\ncats = [(u'cat1', u'Matilda'),(u'cat2', u'Mew')]\nfor line in cats:\n dct = {}\n dct['cat_num'] = line[0]\n dct['name'] = line[1]\n lst.append(dct)\nprint lst\n\n",
"Remember that dict... | [
5,
4,
1,
0
] | [] | [] | [
"dictionary",
"list",
"python"
] | stackoverflow_0005067445_dictionary_list_python.txt |
Q:
Django FilteredSelectMultiple: 'TypeError while rendering: unpack non-sequence'
I'm trying to replace the default ManyToManyField widget in the Admin to use a FilteredSelectMultiple, and I'm having some issues. My error is Caught TypeError while rendering: unpack non-sequence
Here is my model
class Car(models.Mod... | Django FilteredSelectMultiple: 'TypeError while rendering: unpack non-sequence' | I'm trying to replace the default ManyToManyField widget in the Admin to use a FilteredSelectMultiple, and I'm having some issues. My error is Caught TypeError while rendering: unpack non-sequence
Here is my model
class Car(models.Model):
parts = models.ManyToManyField('Part')
class Part(models.Model):
name =... | [
" for option_value, option_label in chain(self.choices, choices):\n\nApparently, choices is a list of tuples, first value being option_value and the second is option_label. \nI'm not sure what the first needs to be, but I'm guessing pk.\nTry:\nparts = [(x.pk, x.name) for x in Part.objects.all()]\n\n"
] | [
3
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005067735_django_python.txt |
Q:
Python: Replace, rstrip() not able to remove newlines
I've got a spreadsheet of information (UTF-8 CSV file being read in by the csv module) that contains information for a large number of products that need to go into an inventory db. I'm trying to setup descriptions from newlined rows of text to a html list tags... | Python: Replace, rstrip() not able to remove newlines | I've got a spreadsheet of information (UTF-8 CSV file being read in by the csv module) that contains information for a large number of products that need to go into an inventory db. I'm trying to setup descriptions from newlined rows of text to a html list tags.
The issue I'm having is that the following lines fail to ... | [
"From python manual\n\nstr.replace(old, new[, count])\nReturn a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced.\n\nAs you can see, it doesn't replace \"in place\", instead, try:\nline[2] = \"<ul><li>\" ... | [
10,
2,
1
] | [] | [] | [
"newline",
"python",
"replace"
] | stackoverflow_0005067856_newline_python_replace.txt |
Q:
Pygtk + Glade self refreshing labels
First of all I am a newcomer to programming languages world and of course very new to Python.
In my job, we are using Linux systems. Time to time I need to check some command and script outputs on the terminal. So, I wanted to code a small application with a very basic GUI and... | Pygtk + Glade self refreshing labels | First of all I am a newcomer to programming languages world and of course very new to Python.
In my job, we are using Linux systems. Time to time I need to check some command and script outputs on the terminal. So, I wanted to code a small application with a very basic GUI and chose Python and Pygtk with Glade. Unfort... | [
"There is a worked example here http://tuxion.com/2010/04/16/periodic-timers-in-pygtk.html \n"
] | [
2
] | [] | [] | [
"pygtk",
"python"
] | stackoverflow_0005066757_pygtk_python.txt |
Q:
Python on Mac: Fink? MacPorts? Builtin? Homebrew? Binary installer?
For the last few days, I have been trying to use Python for some audio development.
The thing is, Mac OSX does not handle uninstalling stuff well. Actually, there is no way to uninstall anything. Once it is on your system, you better pray that it ... | Python on Mac: Fink? MacPorts? Builtin? Homebrew? Binary installer? | For the last few days, I have been trying to use Python for some audio development.
The thing is, Mac OSX does not handle uninstalling stuff well. Actually, there is no way to uninstall anything. Once it is on your system, you better pray that it didn't do any funny stuff. Hence, I don't really want to rely on installe... | [
"Short answer: use virtualenv\nLonger answer:\n1) Leave system Python as is (don't touch at all)\n2) Install different versions of Python via this buildout: https://github.com/collective/buildout.python\n3) Use virtualenv for every project \n"
] | [
6
] | [] | [] | [
"audio",
"macos",
"package_managers",
"pygame",
"python"
] | stackoverflow_0005067707_audio_macos_package_managers_pygame_python.txt |
Q:
Is super() broken in Python-2.x?
It's often stated that super should be avoided in Python 2. I've found in my use of super in Python 2 that it never acts the way I expect unless I provide all arguments such as the example:
super(ThisClass, self).some_func(*args, **kwargs)
It seems to me this defeats the purpose o... | Is super() broken in Python-2.x? | It's often stated that super should be avoided in Python 2. I've found in my use of super in Python 2 that it never acts the way I expect unless I provide all arguments such as the example:
super(ThisClass, self).some_func(*args, **kwargs)
It seems to me this defeats the purpose of using super(), it's neither more con... | [
"super() is not broken -- it just should not be considered the standard way of calling a method of the base class. This did not change with Python 3.x. The only thing that changed is that you don't need to pass the arguments self, cls in the standard case that self is the first parameter of the current function a... | [
46,
33,
6,
3,
1
] | [] | [] | [
"multiple_inheritance",
"python",
"python_2.x",
"python_3.x",
"super"
] | stackoverflow_0005066315_multiple_inheritance_python_python_2.x_python_3.x_super.txt |
Q:
How to factorise python test cases with nosetests
I have several functions on graph f(), g() and h() that implements different algorithms for the same problem. I would like to unit-test these functions using unittest framework.
For each algorithm, several constraints should always be valid (such as empty graph, gr... | How to factorise python test cases with nosetests | I have several functions on graph f(), g() and h() that implements different algorithms for the same problem. I would like to unit-test these functions using unittest framework.
For each algorithm, several constraints should always be valid (such as empty graph, graph with only one node, and so on). The code for those ... | [
"Nose gathers classes that match a regex or are subclasses of unittest.TestCase, so the simplest solution is to do neither of those:\nclass AlgoMixin(object):\n # Does not end in \"Test\"; not a subclass of unittest.TestCase.\n # You may prefer \"AbstractBase\" or something else.\n\n def test_empty(self):\n r... | [
2
] | [] | [] | [
"nosetests",
"oop",
"python",
"refactoring",
"unit_testing"
] | stackoverflow_0005068100_nosetests_oop_python_refactoring_unit_testing.txt |
Q:
Getting started with Django
I want to develop my application using google app engine into which I will use python. Now after wondering I came to know it is good it I use dJango template.
Does anyone can tell me or suggest me what to refer to start with Django because from tutorial on its website, it looks difficul... | Getting started with Django | I want to develop my application using google app engine into which I will use python. Now after wondering I came to know it is good it I use dJango template.
Does anyone can tell me or suggest me what to refer to start with Django because from tutorial on its website, it looks difficult?
| [
"Once more I can recommend a gigantuan.net. For me, nothing works better than video tutorials. On Gigantuan you can find 8 movies which will help you to understand the basics of django by building a blog site. Enjoy.\n",
"I've also recently started with Django, and I would recommend reading \"behind\" the tutoria... | [
0,
0,
0
] | [] | [] | [
"django",
"google_app_engine",
"python"
] | stackoverflow_0005064565_django_google_app_engine_python.txt |
Q:
Extending PloneFormGen
Are there any example add-ons where to look at when one would like to
1) Create custom action adapters for PloneFormGen
2) Add new field types to PloneFormGen
A:
The Plone collective has several examples:
http://svn.plone.org/svn/collective//Products.PloneFormGen has a directory 'adapters... | Extending PloneFormGen | Are there any example add-ons where to look at when one would like to
1) Create custom action adapters for PloneFormGen
2) Add new field types to PloneFormGen
| [
"The Plone collective has several examples:\n\nhttp://svn.plone.org/svn/collective//Products.PloneFormGen has a directory 'adapters' with two example and 'fields' with one example.\nGrepping through an 'svn ls' of the collective gives these results:\n\n\ncollective.civicrm.civicrmpfgadaptor/\ncollective.documentpfg... | [
5,
3,
2
] | [] | [] | [
"forms",
"plone",
"ploneformgen",
"python"
] | stackoverflow_0005065892_forms_plone_ploneformgen_python.txt |
Q:
Python Shared Libraries
As I understand there are two types of modules in python (CPython):
- the .so (C extension)
- the .py
The .so are only loaded once even when there are different processes/interpreters importing them.
The .py are loaded once for each process/interpreter (unless reloading explicitly).
Is t... | Python Shared Libraries | As I understand there are two types of modules in python (CPython):
- the .so (C extension)
- the .py
The .so are only loaded once even when there are different processes/interpreters importing them.
The .py are loaded once for each process/interpreter (unless reloading explicitly).
Is there a way .py can be shared ... | [
"The reason .so (or .pyd) files take up memory space only once (except for their variables segment) is that they are recognized by the OS kernel as object code. .py files are only recognized as text files/data; it's the Python interpreter that grants them \"code\" status. Embedding the Python interpreter in a share... | [
1,
0,
0
] | [] | [] | [
"dynamic",
"dynamic_linking",
"multiprocessing",
"multithreading",
"python"
] | stackoverflow_0005068508_dynamic_dynamic_linking_multiprocessing_multithreading_python.txt |
Q:
How do you step through a Subversion hook script with pdb?
I've Googled for this far & wide and turned up nothing. I've written a pre-commit hook for Subversion in Python. If I insert pdb.setTrace() into my hook script and call it manually from the command-line, I can step through it as normal. However, if I do a ... | How do you step through a Subversion hook script with pdb? | I've Googled for this far & wide and turned up nothing. I've written a pre-commit hook for Subversion in Python. If I insert pdb.setTrace() into my hook script and call it manually from the command-line, I can step through it as normal. However, if I do a commit & allow Subversion to call the script, the call to setTra... | [
"Something like a \"remote pdb\" might be useful here:\nhttp://snippets.dzone.com/posts/show/7248\n"
] | [
1
] | [] | [] | [
"debugging",
"python",
"svn",
"svn_hooks"
] | stackoverflow_0005068667_debugging_python_svn_svn_hooks.txt |
Q:
negatives and positives in lists
I'm trying to write a function that allows me to add only the positive numbers in a list and only the negative numbers in a list. I don't know where to start with my coding though. Any help would be great thanks!
example:
negpos([-5,5,6,-8,9])
should return:
[-13, 20]
A:
Try thi... | negatives and positives in lists | I'm trying to write a function that allows me to add only the positive numbers in a list and only the negative numbers in a list. I don't know where to start with my coding though. Any help would be great thanks!
example:
negpos([-5,5,6,-8,9])
should return:
[-13, 20]
| [
"Try this on for size:\ndef negpos (lst):\n (neg, pos) = (0, 0)\n for elem in lst:\n if elem < 0:\n neg = neg + elem\n else:\n pos = pos + elem\n return [neg, pos]\n\nprint negpos ([-5,5,6,-8,9])\n\nIt simply maintains two accumulators and adds to the relevant one. The o... | [
7,
2,
1,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0005061630_python.txt |
Q:
Problem using f2py
I have some routines written in fortran that I'd like to use in my python code. A quick websearch informed me about f2py, and I gave it a try. Using
f2py -c numericalMethods.f -m numericalMethods
it seems to work for a while until a lot of errors are spawn during the conversion. Any idea of wh... | Problem using f2py | I have some routines written in fortran that I'd like to use in my python code. A quick websearch informed me about f2py, and I gave it a try. Using
f2py -c numericalMethods.f -m numericalMethods
it seems to work for a while until a lot of errors are spawn during the conversion. Any idea of why the following bit of c... | [
"Putting my comment that finally solved the problem into an answer :\nFollowing some advice found on the net https://cd34.com/blog/programming/python/mysql-python-and-snow-leopard --> comment 37, I replaced the 10.4 folder by the 10.5 SDK one. And the stdarg.h error is no more. Not very clean and orthodox, but it s... | [
0
] | [] | [] | [
"f2py",
"fortran",
"python"
] | stackoverflow_0003591539_f2py_fortran_python.txt |
Q:
Restarting a Twisted-python Reactor after an unsuccessful connection
I am writing a server with multiple clients. When a client starts, the server may not yet be working. So a reactor.connectTCP may fail (no receiving end). Currently I'm solving this by looping on a reactor.run, i.e.:
connect to server
reactor.ru... | Restarting a Twisted-python Reactor after an unsuccessful connection | I am writing a server with multiple clients. When a client starts, the server may not yet be working. So a reactor.connectTCP may fail (no receiving end). Currently I'm solving this by looping on a reactor.run, i.e.:
connect to server
reactor.run
if fails, repeat
I understand this is not the way to do it in twisted. ... | [
"You can always try to reconnect within your connectionLost handler, for example:\nfrom twisted.internet.protocol import ClientFactory\n\nclass EchoClientFactory(ClientFactory):\n def clientConnectionLost(self, connector, reason):\n connector.connect()\n\nThere is also even a built-in ReconnectingClientFa... | [
2
] | [] | [] | [
"client",
"python",
"reactor",
"twisted"
] | stackoverflow_0005069120_client_python_reactor_twisted.txt |
Q:
Run command only between certain times, else run other command
What I'm trying to do is change my wallpaper between certain times. For example, I have a wallpaper that I use at home, and a wallpaper that I use at school (this is a laptop). What I'd like to do is have a python script that runs a shell command that ... | Run command only between certain times, else run other command | What I'm trying to do is change my wallpaper between certain times. For example, I have a wallpaper that I use at home, and a wallpaper that I use at school (this is a laptop). What I'd like to do is have a python script that runs a shell command that sets my wallpaper only when it is a weekday and when the time is bet... | [
"import datetime\n\nday_of_week = datetime.date.today().weekday() # 0 is Monday, 6 is Sunday\ntime = datetime.datetime.now().time()\n\nif day_of_week < 5 and (time > datetime.time(8) and time < datetime.time(14,15)):\n do_something()\n\n",
"Wooble's answer is right. If you want a slightly less efficient versio... | [
6,
0
] | [] | [] | [
"python"
] | stackoverflow_0005068731_python.txt |
Q:
Multi-threading and proxy adds 30 seconds delay. What can I do to avoid
I am usign PyQt, QThreads and couchdb-python to talk to a couchDB instance on the local LAN.
To test that the multithreading will work if the networking is slow, I have placed a proxy between the GUI and couch.
The networking is logged. The ... | Multi-threading and proxy adds 30 seconds delay. What can I do to avoid | I am usign PyQt, QThreads and couchdb-python to talk to a couchDB instance on the local LAN.
To test that the multithreading will work if the networking is slow, I have placed a proxy between the GUI and couch.
The networking is logged. The log starts off with
13:52:46.303 (1) send: HEAD /cubic HTTP/1.1CRLFHost: loc... | [
"The HTTP spec states (section 9.4)\n\nThe HEAD method is identical to GET except that the server MUST NOT return a message-body in the response.\n\nThis means that there is nothing following the CRLFCRLF but your proxy is waiting for data rather than reading from the incoming connection. I suspect that the couchdb... | [
0,
0
] | [] | [] | [
"multithreading",
"proxy",
"pyqt",
"python"
] | stackoverflow_0005067636_multithreading_proxy_pyqt_python.txt |
Q:
What algorithm can be used to determine the presence of multiple stripes?
Using python, which may be the best algorithm or the best strategy to detect the presence of colored bands as in image?
The image is scanned and cropped, the problem is that the crop not to be precise and I can not make use of a control that... | What algorithm can be used to determine the presence of multiple stripes? | Using python, which may be the best algorithm or the best strategy to detect the presence of colored bands as in image?
The image is scanned and cropped, the problem is that the crop not to be precise and I can not make use of a control that makes use of Cartesian coordinates to determine if the lines are present.
The ... | [
"You have a number of options at your disposal:\n\nIf the strips are going to be the same size, and their orientation is known, then you can use cross-correlation (with working Python source). Your template image could be a single stripe, or a multiple strip pattern if you know the number of strips and their spaci... | [
2,
1
] | [] | [] | [
"image",
"image_processing",
"python"
] | stackoverflow_0005066481_image_image_processing_python.txt |
Q:
Ajax v. including data in the HTML
I'm using JavaScript with jQuery, talking to a Django back end. There are some UI needs that require Ajax, because we can't know what data to send until the user gives some input. However, there is other data that is known at template time. What are the pros and cons of including... | Ajax v. including data in the HTML | I'm using JavaScript with jQuery, talking to a Django back end. There are some UI needs that require Ajax, because we can't know what data to send until the user gives some input. However, there is other data that is known at template time. What are the pros and cons of including that data in the template directly, ins... | [
"The obvious answer in MOST applications is to include them directly, although I would always recommend treating every usage per its own needs. Remember that 'page load speed' is as much perception as it is a measurable stat, especially when dealing with ajax functionality.\nExample\nYou have loads and loads of da... | [
3,
0
] | [] | [] | [
"ajax",
"django",
"javascript",
"performance",
"python"
] | stackoverflow_0005069495_ajax_django_javascript_performance_python.txt |
Q:
Python command line application migration to web based
Any guidelines on migrating a bunch of command line scripts to web based app? It is mainly a information retrieval application that I'm trying to build and does not really need to have much of user management - something in the lines of upload some documents a... | Python command line application migration to web based | Any guidelines on migrating a bunch of command line scripts to web based app? It is mainly a information retrieval application that I'm trying to build and does not really need to have much of user management - something in the lines of upload some documents and search in them. The motivation for going web based in mai... | [
"You could try using some minimalistic web framework.\nIf what you are trying to do is really simple you could have a look at Bottle\nhttp://bottle.paws.de/docs/dev/index.html\nJust import your scripts, think of some simple url scheme and write a few views.\n"
] | [
6
] | [] | [] | [
"migration",
"python"
] | stackoverflow_0005069637_migration_python.txt |
Q:
Tkinter Listbox not deleting items correctly
I have a method that is suppose to take a search parameter and remove everything from the list that does not meet the parameter. But when it runs it removes list items at almost random. I've debugged it and it correctly determines if an item needs to be removed but it d... | Tkinter Listbox not deleting items correctly | I have a method that is suppose to take a search parameter and remove everything from the list that does not meet the parameter. But when it runs it removes list items at almost random. I've debugged it and it correctly determines if an item needs to be removed but it doesn't remove the right one. I think it has someth... | [
"When you delete an item, everything below it moves up causing the index of all following items to change. The simplest solution to this sort of a problem (it's also common when deleting words from a text widget) is to delete backwards, starting at the end. \n",
"I think you already know the problem. When you del... | [
3,
2
] | [] | [] | [
"listbox",
"python",
"tkinter"
] | stackoverflow_0005068871_listbox_python_tkinter.txt |
Q:
Outputting errors to browser in CherryPy
I am new to cherrypy, and can't seem to figure out how to have cherrypy emit a stacktrace or error message to my browser when an error occurs.
I am running cherrypy on apache with mod_wsgi, so its particularly annoying to dig through the apache error logs during developmen... | Outputting errors to browser in CherryPy | I am new to cherrypy, and can't seem to figure out how to have cherrypy emit a stacktrace or error message to my browser when an error occurs.
I am running cherrypy on apache with mod_wsgi, so its particularly annoying to dig through the apache error logs during development.
I am used to PHP, where errors are nicely ... | [
"The most important config setting which governs tracebacks in the browser is request.show_tracebacks. Set it to True to get tracebacks. Note that using the \"production\" config environment sets this to False. There may be other WSGI components you're using, or some feature of mod_wsgi or Apache which is also gett... | [
10
] | [] | [] | [
"browser",
"cherrypy",
"logging",
"python",
"stack_trace"
] | stackoverflow_0005054957_browser_cherrypy_logging_python_stack_trace.txt |
Q:
Always the same results through ZCatalog? Everything is set by the book!
It is strange, but I can't get the ZCatalog working. Everything is done by the book and still the results are always the same full list.
You can see here:
http://nfp-bg.eionet.eu.int/waste/en/search-results?catalogTextIdx=selection
What I hav... | Always the same results through ZCatalog? Everything is set by the book! | It is strange, but I can't get the ZCatalog working. Everything is done by the book and still the results are always the same full list.
You can see here:
http://nfp-bg.eionet.eu.int/waste/en/search-results?catalogTextIdx=selection
What I have done so far:
Created ZCatalog Object
Created ZCTextIndex Lexicon with the... | [
"The ZCatalog has a quirk which is that if your query includes an index that does not exist in the catalog, it will return all indexed objects. In this case, your query appears to involve a \"meta_type\" index which you did not set up. So the ZCatalog tries to apply that index, but doesn't find it, so it returns al... | [
1
] | [] | [] | [
"full_text_search",
"python",
"zope"
] | stackoverflow_0004092487_full_text_search_python_zope.txt |
Q:
XP with C:\python in path won't run files in C:\python
XP Command Line:
helloworld.py is located in C:\python
C:\python is in the path
xxxxxx is the user environment path
This works:
xxxxx> cd C:\python
C:\python>helloworld.py
Hello World
This doesn't work:
xxxxx> helloworld.py
.....can't find the file ... but t... | XP with C:\python in path won't run files in C:\python | XP Command Line:
helloworld.py is located in C:\python
C:\python is in the path
xxxxxx is the user environment path
This works:
xxxxx> cd C:\python
C:\python>helloworld.py
Hello World
This doesn't work:
xxxxx> helloworld.py
.....can't find the file ... but the folder with the file is in the PATH????
| [
"There's a difference between files with a specific a file extension (e.g. .py) being registered to be opened with a specific executable (e.g. python.exe - Windows doesn't see any difference between this and a .pdf file opened by a PDF viewer, it's just opening it and doing something) and that file extension being ... | [
5,
1,
1
] | [] | [] | [
"mod_python",
"python"
] | stackoverflow_0005069597_mod_python_python.txt |
Q:
Combining multiple csv files together and also adding a column during concatenation
I have a set of files I am trying to import into MySQL.
Each CSV file looks like this:
Header1;Header2;Header3;Header4;Header5
Data1;Data2;Data3;Data4;Data5;
Data1;Data2;Data3;Data4;Data5;
Data1;Data2;Data3;Data4;Data5;
Data1;Data2... | Combining multiple csv files together and also adding a column during concatenation | I have a set of files I am trying to import into MySQL.
Each CSV file looks like this:
Header1;Header2;Header3;Header4;Header5
Data1;Data2;Data3;Data4;Data5;
Data1;Data2;Data3;Data4;Data5;
Data1;Data2;Data3;Data4;Data5;
Data1;Data2;Data3;Data4;Data5;
Data may contain spaces, periods or a full colon. They absolutely wi... | [
"Using Text::CSV:\nProgram\n#!/usr/bin/env perl\n\nuse strict;\nuse warnings;\n\nuse File::Find;\nuse Text::CSV;\n\nmy $semi_colon_csv = Text::CSV->new( { 'sep_char' => ';', } );\nmy $comma_csv = Text::CSV->new( {\n 'sep_char' => ',',\n 'eol' => \"\\n\",\n} );\n\nopen my $fh_output, '>', 'output.csv' or ... | [
3,
2,
1,
0,
0
] | [] | [] | [
"awk",
"perl",
"php",
"powershell",
"python"
] | stackoverflow_0005063020_awk_perl_php_powershell_python.txt |
Q:
Traverse foreign key and pull remote model data into Django admin
Is is possible in the admin to pull a field from a remote model, if you have a local foreign key pointing to that model?
class FirstModel(models.Model):
[...]
value12 = models.CharField()
class SecondModel(models.Model):
[...]
first... | Traverse foreign key and pull remote model data into Django admin | Is is possible in the admin to pull a field from a remote model, if you have a local foreign key pointing to that model?
class FirstModel(models.Model):
[...]
value12 = models.CharField()
class SecondModel(models.Model):
[...]
firstmodel = models.ForeignKey(FirstModel)
And in the Admin I want to pull ... | [
"You should be able to access any field in the first model as: firstmodel__value12\nFor the list view for the SecondModel:\nlist_display = ('firstmodel__value12',)\n\nFor the edit view you can use formfield_overrides. To make it non-editable you specify a read-only widget, e.g. like this one or provide your own.\n"... | [
2
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0005070103_django_django_admin_python.txt |
Q:
Python `YYYY-MM-DD`
In Python, what is the best way to get the
RFC 3339 YYYY-MM-DD text from the output of gtk.Calendar::get_date()?
A:
Thanks to Mark and treeface for the solutions, but it seems I've invented a better one:
year, month, day = cal.get_date()
return '{0:04d}-{1:02d}-{2:02d}'.format(year, month+1, ... | Python `YYYY-MM-DD` | In Python, what is the best way to get the
RFC 3339 YYYY-MM-DD text from the output of gtk.Calendar::get_date()?
| [
"Thanks to Mark and treeface for the solutions, but it seems I've invented a better one:\nyear, month, day = cal.get_date()\nreturn '{0:04d}-{1:02d}-{2:02d}'.format(year, month+1, day)\n\nThis solution is shorter, easier to understand (in my opinion), and I believe takes less processing as it cuts out the stage whe... | [
4,
2,
0
] | [] | [] | [
"calendar",
"gtk",
"pygtk",
"python",
"rfc3339"
] | stackoverflow_0003495309_calendar_gtk_pygtk_python_rfc3339.txt |
Q:
Package only works properly in IDLE or Interpreter, but not independantly?
I have been trying to add audio cues to a program I am working on using Py-Audiere. However, the sounds only play when I use the run command within IDlE (or manually put it into the interpreter), and then only if the calls are done in certa... | Package only works properly in IDLE or Interpreter, but not independantly? | I have been trying to add audio cues to a program I am working on using Py-Audiere. However, the sounds only play when I use the run command within IDlE (or manually put it into the interpreter), and then only if the calls are done in certain ways. This is the code snippet:
import audiere
filename = 'Bell'
d = audiere... | [
"I've experimented a bit with audiere (never heard of this library before) and it looks like it plays the sound in a new thread in the background.\nIn your code snippet you tell audiere to start playing your bell, but you never give it enough time to completely play it. When you run this in Idle or the Python inter... | [
1
] | [] | [] | [
"audio",
"python",
"python_idle"
] | stackoverflow_0005068807_audio_python_python_idle.txt |
Q:
Numpy- weight and sum rows of a matrix
Using Python & Numpy, I would like to:
Consider each row of an (n columns x
m rows) matrix as a vector
Weight each row (scalar
multiplication on each component of
the vector)
Add each row to create a final vector
(vector addition).
The weights are given in a regular numpy a... | Numpy- weight and sum rows of a matrix | Using Python & Numpy, I would like to:
Consider each row of an (n columns x
m rows) matrix as a vector
Weight each row (scalar
multiplication on each component of
the vector)
Add each row to create a final vector
(vector addition).
The weights are given in a regular numpy array, n x 1, so that each vector m in the ma... | [
"Even a 'technically' correct answer has been all ready given, I'll give my straightforward answer:\nfrom numpy import array, dot\ndot(array([0.5, -1]), array([[1, 2, 3], [4, 5, 6]]))\n# array([-3.5 -4. -4.5])\n\nThis one is much more on with the spirit of linear algebra (and as well those three dotted requirements... | [
9,
8
] | [] | [] | [
"matrix",
"numpy",
"python",
"vector"
] | stackoverflow_0005069385_matrix_numpy_python_vector.txt |
Q:
Python: Searching a multi-dimensional dictionary for a key
I'm using Python's JSON decoding library with Google Maps API. I am trying to obtain the zip code of an address but it sometimes resides in different dictionary key. Here are two examples (I've trimmed the JSON to what is relevant):
placemark1 = {
"Addre... | Python: Searching a multi-dimensional dictionary for a key | I'm using Python's JSON decoding library with Google Maps API. I am trying to obtain the zip code of an address but it sometimes resides in different dictionary key. Here are two examples (I've trimmed the JSON to what is relevant):
placemark1 = {
"AddressDetails": {
"Country": {
"AdministrativeArea": {
... | [
"def get_key(key,dct):\n if key in dct:\n return dct[key]\n for k in dct:\n try:\n return get_key(key,dct[k])\n except (TypeError,ValueError):\n pass\n else:\n raise ValueError\n\nplacemark1 = {\n \"AddressDetails\": {\n \"Country\": {\n \"Administ... | [
2,
1
] | [] | [] | [
"algorithm",
"dictionary",
"json",
"python"
] | stackoverflow_0005071212_algorithm_dictionary_json_python.txt |
Q:
Django: What kind of querysets should i look for when deciding on model indexes?
In general, is there a type of Model query you look for to optimize by indexing a field (db_index=True)?
In case it's relevant: I'm using MySQL.
Elaboration:
Although I appreciate the responses already given. I was more looking for ad... | Django: What kind of querysets should i look for when deciding on model indexes? | In general, is there a type of Model query you look for to optimize by indexing a field (db_index=True)?
In case it's relevant: I'm using MySQL.
Elaboration:
Although I appreciate the responses already given. I was more looking for advice such as this one from a colleague:
You should definitely index the fields in you... | [
"\nInstall django-debug-toolbar\nLook at the SQL panel, look for long-running queries\nIndex the columns selected in those queries\nIf you need help with the queries, try the \"EXPLAIN\" MySQL command on the query.\n\n",
"Basically you should index fields that are searched for often. For example if you have a use... | [
2,
0
] | [] | [] | [
"django_models",
"django_orm",
"django_queryset",
"mysql",
"python"
] | stackoverflow_0005069954_django_models_django_orm_django_queryset_mysql_python.txt |
Q:
Cross Reference 2 lists in Python 2.x
I am new to Python (using 2.6 and 2.7), but I have searched docs.Python.org and this site. I have found a similar question:
Comparing lists in Python
...But I want to cross-reference 2 lists of different sizes and unknown orders.
Here is an example of what I want to do:
>>> ma... | Cross Reference 2 lists in Python 2.x | I am new to Python (using 2.6 and 2.7), but I have searched docs.Python.org and this site. I have found a similar question:
Comparing lists in Python
...But I want to cross-reference 2 lists of different sizes and unknown orders.
Here is an example of what I want to do:
>>> mammals = ["gorilla","cat","rat","chimpanzee"... | [
"Use sets:\nmammals = [\"gorilla\",\"cat\",\"rat\",\"chimpanzee\",\"dog\",\"beaver\"]\napes = [\"orangutan\",\"chimpanzee\",\"human\",\"gorilla\"]\nprint set(mammals).intersection(apes)\n\nprints\nset(['gorilla', 'chimpanzee'])\n\n",
"list(set(mammals) & set(apes))\n\nIf you need the result to be a list, if you'... | [
1,
1,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0005071793_list_python.txt |
Q:
Start gnome-terminal with multiple virtualenv tabs and services, pre-titled
I'm working on a server-side project that consists of several services. Each service is run in interactive (i.e. non-daemon) mode, this is handy while active development. The project is in virtualenv. So the typical way to start a service ... | Start gnome-terminal with multiple virtualenv tabs and services, pre-titled | I'm working on a server-side project that consists of several services. Each service is run in interactive (i.e. non-daemon) mode, this is handy while active development. The project is in virtualenv. So the typical way to start a service is:
$ cd ~/to/vitualenv/subdir/where/service/code/located
$ source ../path/to/vir... | [
"The following works for me and do what you requested:\ngnome-terminal --working-directory=/path/to/wd --tab-with-profile=profile1 --title=title1 -e 'bash --rcfile /path/to/rcfile1.sh' --tab-with-profile=profile2 --title=title2 -e 'bash --rcfile /path/to/rcfile2.sh'\n",
"Create a gnome-terminal profile named \"se... | [
2,
0
] | [] | [] | [
"gnome_terminal",
"python",
"terminal",
"virtualenv"
] | stackoverflow_0001700995_gnome_terminal_python_terminal_virtualenv.txt |
Q:
Django decorator generates SiteProfileNotAvailable error
Newbie to Python (2.6) and Django (1.2) here, learning the ropes. Consider the following decorator that I want to use on methods, along with @login_required, that redirects users to a profile completion url if they try and do something that requires a "minim... | Django decorator generates SiteProfileNotAvailable error | Newbie to Python (2.6) and Django (1.2) here, learning the ropes. Consider the following decorator that I want to use on methods, along with @login_required, that redirects users to a profile completion url if they try and do something that requires a "minimum information supplied" profile.
The usage pattern is intende... | [
"For me it seems, that you have wrong profile setting in your settings.py. It should look like this: <app>.<model> and that's exactly what django is complaining about. Check out your settings.\n"
] | [
3
] | [] | [] | [
"decorator",
"django",
"python"
] | stackoverflow_0005071707_decorator_django_python.txt |
Q:
Python code objects - what are they used for?
What are the uses of Python code objects? Besides being used by the interpreter or debugger what other useful usages do they have?
Have you interacted directly with code objects? If yes, in what situation?
A:
The primary use of code objects is to separate the static ... | Python code objects - what are they used for? | What are the uses of Python code objects? Besides being used by the interpreter or debugger what other useful usages do they have?
Have you interacted directly with code objects? If yes, in what situation?
| [
"The primary use of code objects is to separate the static parts of functions (code) from the dynamic parts (functions). Code objects are the things that are stashed in .pyc files, and are created when code is compiled; function objects are created from them at runtime when functions are declared. They're exposed... | [
8,
3,
1
] | [] | [] | [
"internals",
"python",
"types"
] | stackoverflow_0005071117_internals_python_types.txt |
Q:
Django not respond with JQuery $.ajax()
i have a big problem while i try send data to django view, because never does it anything
JQUERY CODE
$(function(){
$("#sumbit_run").click(function(){
$('#run-progress-bar').show('slow');
$.ajax({
type: 'POST',
url: '/execute/run/',
data: $('#form_... | Django not respond with JQuery $.ajax() | i have a big problem while i try send data to django view, because never does it anything
JQUERY CODE
$(function(){
$("#sumbit_run").click(function(){
$('#run-progress-bar').show('slow');
$.ajax({
type: 'POST',
url: '/execute/run/',
data: $('#form_run').serialize()+'&generation='+$('#generati... | [
"OK now i know what is the problem, after think why?, i found the POST request is a String, so when start the statement \"while\" never finish, because \"i\" is a integer and \"GENERATION\" is a String.\nHow to solve the problem.\nfix\nGENERATION=(request.POST['generation'])\n\nto\nGENERATION=(int(request.POST['gen... | [
0
] | [] | [] | [
"django",
"jquery",
"python"
] | stackoverflow_0005071210_django_jquery_python.txt |
Q:
Replace section of text with only knowing the beginning and last word using Python
In Python, it possible to cut out a section of text in a document when you only know the beginning and end words?
For example, using the bill of rights as the sample document, search for "Amendment 3" and remove all the text until y... | Replace section of text with only knowing the beginning and last word using Python | In Python, it possible to cut out a section of text in a document when you only know the beginning and end words?
For example, using the bill of rights as the sample document, search for "Amendment 3" and remove all the text until you hit "Amendment 4" without actually knowing or caring what text exists between the two... | [
"You can use Python's re module.\nI wrote this example script for removing the sections of code in file:\nimport re\n\n# Create regular expression pattern\nchop = re.compile('#chop-begin.*?#chop-end', re.DOTALL)\n\n# Open file\nf = open('data', 'r')\ndata = f.read()\nf.close()\n\n# Chop text between #chop-begin and... | [
4,
0,
0
] | [] | [] | [
"python",
"replace",
"text"
] | stackoverflow_0005071844_python_replace_text.txt |
Q:
Escape html in python?
i have a <img src=__string__> but string might contain ", what should I do to escape it?
Example:
__string__ = test".jpg
<img src="test".jpg">
doesn't work.
A:
In Python 3.2 a new html module was introduced, which is used for escaping reserved characters from HTML markup.
It has one funct... | Escape html in python? | i have a <img src=__string__> but string might contain ", what should I do to escape it?
Example:
__string__ = test".jpg
<img src="test".jpg">
doesn't work.
| [
"In Python 3.2 a new html module was introduced, which is used for escaping reserved characters from HTML markup.\nIt has one function html.escape(s, quote=True).\nIf the optional flag quote is true, the characters (\") and (') are also translated.\nUsage:\n>>> import html\n>>> html.escape('x > 2 && x < 7')\n'x >... | [
15,
13,
4,
2
] | [
"The best way to escape XML or HTML in python is probably with triple quotes. Note that you can also escape carriage returns.\n\"\"\"<foo bar=\"1\" baz=\"2\" bat=\"3\">\n<ack/>\n</foo>\n\"\"\"\n\n"
] | [
-3
] | [
"escaping",
"html",
"python"
] | stackoverflow_0003096948_escaping_html_python.txt |
Q:
Constantly reading from a serial port with a background thread
As serial port communication is asynchronous, I figured out early on into my project involving communication with a RS 232 device that I will have to have a background thread constantly reading the port for data received. Now, I'm using IronPython (.NE... | Constantly reading from a serial port with a background thread | As serial port communication is asynchronous, I figured out early on into my project involving communication with a RS 232 device that I will have to have a background thread constantly reading the port for data received. Now, I'm using IronPython (.NET 4.0) so I have access to the slick SerialPort class built into .NE... | [
"I don't see why you can't use the DataReceived event. As the docs state\n\nThe DataReceived event is not\n guaranteed to be raised for every byte\n received. Use the BytesToRead property\n to determine how much data is left to\n be read in the buffer.\n\nAll that is saying is that you aren't guaranteed to get... | [
4,
3,
2
] | [] | [] | [
".net",
"ironpython",
"python",
"serial_port"
] | stackoverflow_0004169219_.net_ironpython_python_serial_port.txt |
Q:
Django caching for web applications
My question is about best practices for caching database updates in Django.
I'm writing a ticketing system. I have a Ticket model and an Update model. Each time a user adds an update to a ticket, an Update is created and linked as foreign key to the Ticket.
I have a TicketDeta... | Django caching for web applications | My question is about best practices for caching database updates in Django.
I'm writing a ticketing system. I have a Ticket model and an Update model. Each time a user adds an update to a ticket, an Update is created and linked as foreign key to the Ticket.
I have a TicketDetail view, that shows the Ticket descriptio... | [
"There are some issues when using memcached for invalidating/updating stale data due to race conditions, which one of the main Johnny Cache backends relies on. In your particular case, say you have 10 updates in total and then two different users in two separate processes create a ticket update. It's quite possible... | [
1,
0
] | [] | [] | [
"caching",
"django",
"python"
] | stackoverflow_0005071365_caching_django_python.txt |
Q:
RestrictedPython on Google AppEngine (GAE)
I'm looking for a way to execute user submitted python code in GAE in a secure fashion (much stricter then the GAE sandbox).
RestrictedPython would certainly fit the shoe, being used in Zope for the exakt same purpose.
But RestrictedPython relies on modifying the AST (abs... | RestrictedPython on Google AppEngine (GAE) | I'm looking for a way to execute user submitted python code in GAE in a secure fashion (much stricter then the GAE sandbox).
RestrictedPython would certainly fit the shoe, being used in Zope for the exakt same purpose.
But RestrictedPython relies on modifying the AST (abstract syntax tree) which means loading modules f... | [
"Note that even if you could get access to the ast modules on GAE, RestrictedPython might still not be the right solution for your use-case. It's only aimed at securing input from less trusted users, where you don't trust their ability to code. You still need to trust and know them.\nThere's various ways in which a... | [
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0003211723_google_app_engine_python.txt |
Q:
I can't test a Google App using OpenID single sign-on on the AppEngine devserver, locally
I'm starting to develop an application using App Engine (Python) that will be integrated in the Google Apps platform and will be sold in the Marketplace. I've implemented the Single Sign-On openID authentication and it works ... | I can't test a Google App using OpenID single sign-on on the AppEngine devserver, locally | I'm starting to develop an application using App Engine (Python) that will be integrated in the Google Apps platform and will be sold in the Marketplace. I've implemented the Single Sign-On openID authentication and it works fine when deployed, but doesn't work locally at all.
How can i do that locally? user.federated_... | [
"On localhost there's no point in verifying that the email matches the federated_id domain, so you should just add this to check_email:\ndef check_email(self, user):\n if os.environ.get('SERVER_SOFTWARE', '').startswith('Dev'):\n return True\n\nIt looks like if your consumer secret and key are set up correctly ... | [
2
] | [] | [] | [
"google_app_engine",
"google_apps",
"google_openid",
"python"
] | stackoverflow_0005070244_google_app_engine_google_apps_google_openid_python.txt |
Q:
How do you increment file name in Python
I'm trying to save a lot of data that needs to be separated in to different files like so
data_1.dat
data_2.dat
data_3.dat
data_4.dat
how do I implement this in python?
A:
from itertools import count
filename = ("data_%03i.dat" % i for i in count(1))
next(filename)
# 'dat... | How do you increment file name in Python | I'm trying to save a lot of data that needs to be separated in to different files like so
data_1.dat
data_2.dat
data_3.dat
data_4.dat
how do I implement this in python?
| [
"from itertools import count\nfilename = (\"data_%03i.dat\" % i for i in count(1))\nnext(filename)\n# 'data_001.dat'\nnext(filename)\n# 'data_002.dat'\nnext(filename)\n# 'data_003.dat'\n\n",
"for i in range(10):\n filename = 'data_%d.dat'%(i,)\n print filename\n\n",
"Similar to Sven's solution, but upgrad... | [
13,
9,
0,
0
] | [] | [] | [
"file_io",
"python"
] | stackoverflow_0005068461_file_io_python.txt |
Q:
bzr unable to connect to ssh host (because of python?)
Until today, I have been able to use bzr pull server:path/to/trunk, but today I get an error:
Unable to connect to SSH host server; EOF during negotiation
It is not clear why this error occurs, but this is the traceback from ~/.bzr.log
Any ideas about how to ... | bzr unable to connect to ssh host (because of python?) | Until today, I have been able to use bzr pull server:path/to/trunk, but today I get an error:
Unable to connect to SSH host server; EOF during negotiation
It is not clear why this error occurs, but this is the traceback from ~/.bzr.log
Any ideas about how to fix this?
Mon 2011-02-21 16:36:04 -0600
0.022 bazaar versio... | [
"This error was caused because I had added\nalias bzr status='bzr status -V' \n\nto .bashrc, and bzr status is an invalid alias name that presumably confused the server's bzr\nA bug report to bzr indicates that a similar error can be caused by changes to the server's firewall settings\n"
] | [
0
] | [] | [] | [
"bazaar",
"openssh",
"python",
"ssh"
] | stackoverflow_0005072210_bazaar_openssh_python_ssh.txt |
Q:
function that produces a two dimensional list from files containing numbers
Write a function table() that takes a parameter a string representing a file name and a number n. The function should open and read the contents of the corresponding file. The file will contain one line with exactly n*n numbers separated... | function that produces a two dimensional list from files containing numbers | Write a function table() that takes a parameter a string representing a file name and a number n. The function should open and read the contents of the corresponding file. The file will contain one line with exactly n*n numbers separated by blank spaces. The function table() should create and return an n x n two-dim... | [
"I assume when you say \"no answers\", you mean no code.\n\nOpen the file.\nRead the command line argument (n).\nCreate a list (x).\nEnter a loop, executed n times.\n\nRead n entries from the file into another list (y) (probably a sub-loop).\nAdd list y to list x.\n\n\nBreaking things into individual small goals li... | [
2,
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0005072519_python.txt |
Q:
Python - Quick Integer List Creation
Can I make a list of numbers from 1 to 6 in one line without a loop?
goal:
[1,2,3,4,5,6]
A:
Yes, use:
range(1,7)
that should do it.
A:
Use the range builtin.
range(1, 7)
| Python - Quick Integer List Creation | Can I make a list of numbers from 1 to 6 in one line without a loop?
goal:
[1,2,3,4,5,6]
| [
"Yes, use:\nrange(1,7)\n\nthat should do it.\n",
"Use the range builtin.\nrange(1, 7)\n\n"
] | [
3,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0005072628_list_python.txt |
Q:
PyObjC tutorial without Xcode
I'm writing a small cross-platform wxPython app, however on every platform I need to use some platform-specific API. On Mac OS it can be done using PyObjC.
I'm searching for tutorial on how to use PyObjC. However, all I found so far were tutorials with Xcode. I want my app to be able... | PyObjC tutorial without Xcode | I'm writing a small cross-platform wxPython app, however on every platform I need to use some platform-specific API. On Mac OS it can be done using PyObjC.
I'm searching for tutorial on how to use PyObjC. However, all I found so far were tutorials with Xcode. I want my app to be able to run on mac/win/lin, without cha... | [
"You can import the Foundation and AppKit modules, then subclass NSApplication. But maybe this isn't what you're looking for, if your pyobjc code isn't the entry point for your code. Could give more specifics about what you're trying to do with pyobjc?\nHere's a quick example using pyobjc to make a simple status ... | [
11,
0
] | [] | [] | [
"macos",
"pyobjc",
"python",
"wxpython"
] | stackoverflow_0004994058_macos_pyobjc_python_wxpython.txt |
Q:
How should I do full-text searching on App Engine?
What should I do for fast, full-text searching on App Engine with as little work as possible (and as little Java — I’m doing Python.)?
A:
I have used Whoosh with appengine in one of my recent project and it seems to work fine. Have a look at https://github.com/... | How should I do full-text searching on App Engine? | What should I do for fast, full-text searching on App Engine with as little work as possible (and as little Java — I’m doing Python.)?
| [
"I have used Whoosh with appengine in one of my recent project and it seems to work fine. Have a look at https://github.com/tallstreet/Whoosh-AppEngine\n",
"GAE has announced plans to offer full-text searching natively in the Datastore soon.\n"
] | [
1,
0
] | [] | [] | [
"full_text_indexing",
"full_text_search",
"google_app_engine",
"python",
"search"
] | stackoverflow_0004130813_full_text_indexing_full_text_search_google_app_engine_python_search.txt |
Q:
Memory Limit for Jython
How can I set the JVM memory limit (-Xmx option for Java) for my Jython program?
I understand that Jython 2.5 introduces the -J option in order to send options to the JVM:
jython -J-Xmx8000m
However, I have to work with Jython 2.2a0 on java1.6.0_23, which does not have that option.
A:
Yo... | Memory Limit for Jython | How can I set the JVM memory limit (-Xmx option for Java) for my Jython program?
I understand that Jython 2.5 introduces the -J option in order to send options to the JVM:
jython -J-Xmx8000m
However, I have to work with Jython 2.2a0 on java1.6.0_23, which does not have that option.
| [
"You could set environment variables JAVA_OPTIONS (for jython < 2.5) or JAVA_MEM for jython 2.5 e.g.:\nalias jython1G=\"JAVA_OPTIONS=\\\"-Xmx1000m $JAVA_OPTIONS\\\" /usr/bin/jython\"\n\n",
"You could just edit jython.bat(windows) or jython(Linux) and add it.\n\"C:\\...\\java.exe\" -Dpython.home=\"C:\\...\" -class... | [
14,
5
] | [] | [] | [
"jvm",
"jython",
"python"
] | stackoverflow_0005065840_jvm_jython_python.txt |
Q:
PyQT QtCore.SIGNAL
Is there any list of the signals that can be use with PyQT4 or at least there is one that is the opposite of lostFocus()?
A:
There is a QFocusEvent event generated by 'QWidget', but not a signal. There is however a convenient event handler that catches these events: focusInEvent.
You can ad... | PyQT QtCore.SIGNAL | Is there any list of the signals that can be use with PyQT4 or at least there is one that is the opposite of lostFocus()?
| [
"There is a QFocusEvent event generated by 'QWidget', but not a signal. There is however a convenient event handler that catches these events: focusInEvent. \nYou can add your own signal by reimplementing this handler. For example (not tested):\nclass MyWidget(QtGui.QWidget):\n\n focus_in = QtCore.pyqtSignal(... | [
2
] | [] | [] | [
"pyqt4",
"python"
] | stackoverflow_0005073023_pyqt4_python.txt |
Q:
Given a binary boolean formula, how to find primary/root operator?
I have binary boolean functions as input strings and need an efficient way to find the "primary" or "root" operator. Some restrictions on the form of the formula are that there is only "and" and "or" operators and no negation. The input strings den... | Given a binary boolean formula, how to find primary/root operator? | I have binary boolean functions as input strings and need an efficient way to find the "primary" or "root" operator. Some restrictions on the form of the formula are that there is only "and" and "or" operators and no negation. The input strings denote "and" operators as single a's and "or" operators as single o's. The ... | [
"Given a root, both subtree of the root must contain balanced set of parentheses.\nSo If you just iterate from left to right until you find the first operator when parentheses are balanced. \npcount = 0\nfor c in function_str:\n if c == '(': pcount += 1\n if c == ')': pcount -= 1\n if (c == 'a' or c == 'o'... | [
2,
0
] | [] | [] | [
"boolean",
"logic",
"python"
] | stackoverflow_0005073373_boolean_logic_python.txt |
Q:
How do I check if values in a dictionary all have the same value X?
I have a dictionary, and I'm trying to check for the rare occurrence of all values having the same numerical value, say 1. How would I go about doing this in an efficient manner?
A:
I will assume you meant the same value:
d = {'a':1, 'b':1, 'c':... | How do I check if values in a dictionary all have the same value X? | I have a dictionary, and I'm trying to check for the rare occurrence of all values having the same numerical value, say 1. How would I go about doing this in an efficient manner?
| [
"I will assume you meant the same value:\nd = {'a':1, 'b':1, 'c':1}\nlen(set(d.values()))==1 # -> True\n\nIf you want to check for a specific value, how about\ntestval = 1\nall(val==testval for val in d.values()) # -> True\n\nthis code will most often fail early (quickly)\n",
"You cannot have key*s* with the... | [
24,
1,
1,
0
] | [] | [] | [
"dictionary",
"python"
] | stackoverflow_0005073624_dictionary_python.txt |
Q:
Matplotlib/Pyplot: How to zoom subplots together AND x-scroll separately?
I previously asked the question "How to zoom subplots together?", and have been using the excellent answer since then.
I'm now plotting just two sets of time-series data, and I need to continue to zoom as above, but now I need to also pan on... | Matplotlib/Pyplot: How to zoom subplots together AND x-scroll separately? | I previously asked the question "How to zoom subplots together?", and have been using the excellent answer since then.
I'm now plotting just two sets of time-series data, and I need to continue to zoom as above, but now I need to also pan one plot relative to the other (I'm doing eyeball correlation). The data comes f... | [
"I hacked the above solution until it did want I think I want.\n# File: ScrollTest.py\n# coding: ASCII\n\"\"\"\nInteratively zoom plots together, but permit them to scroll independently.\n\"\"\"\nfrom matplotlib import pyplot\nimport sys\n\ndef _get_limits( ax ):\n \"\"\" Return X and Y limits for the passed axi... | [
8,
6
] | [] | [] | [
"matplotlib",
"pan",
"python",
"scroll"
] | stackoverflow_0004999014_matplotlib_pan_python_scroll.txt |
Q:
Is it an Array or a String?
I'm given data that could be either a string or an array. I need to do different operations depending on which one it is, so my question is, how can I tell if an object is an array or a string in Python?
conn = boto.connect_sdb(AWSKey, AWSSecret)
item = conn.get_domain(dName).get_item(i... | Is it an Array or a String? | I'm given data that could be either a string or an array. I need to do different operations depending on which one it is, so my question is, how can I tell if an object is an array or a string in Python?
conn = boto.connect_sdb(AWSKey, AWSSecret)
item = conn.get_domain(dName).get_item(imagekey)
tags = item['tag']
tags... | [
"Admittedly, the fact that strings are sequences is sometimes awkward. If you want to implement different behavior depending on if you are dealing with a \"real\" sequence or a string, you can use a construct like:\nif isinstance(some_obj, basestring):\n # do string processing\nelse:\n # do sequence processin... | [
5,
1,
1,
1
] | [] | [] | [
"arrays",
"python",
"string"
] | stackoverflow_0005072290_arrays_python_string.txt |
Q:
Sharepoint/SOAP - GetListItems ignoring query
Trying to talk from Python to Sharepoint through SOAP.
One of the lists I am trying to query contains 'ID' as primary key field.
(Field){
_RowOrdinal = "0"
_FromBaseType = "TRUE"
_DisplayName = "ID"
_Name = "ID"
_SourceID = "http://schemas.microsoft.com/... | Sharepoint/SOAP - GetListItems ignoring query | Trying to talk from Python to Sharepoint through SOAP.
One of the lists I am trying to query contains 'ID' as primary key field.
(Field){
_RowOrdinal = "0"
_FromBaseType = "TRUE"
_DisplayName = "ID"
_Name = "ID"
_SourceID = "http://schemas.microsoft.com/sharepoint/v3"
_ColName = "tp_ID"
_StaticName... | [
"The actual turned out to be that it is necessary to use\n<ns1:query> \n\nhere (for whatever reason).\n",
"Try Type=\"Number\" instead of Counter. I've just been through a bunch of code I wrote a while back to get list items based on the ID and I have used Number, and it works.\nYou may also need to include the e... | [
2,
0
] | [] | [] | [
"python",
"sharepoint",
"soap"
] | stackoverflow_0005015625_python_sharepoint_soap.txt |
Q:
Can anyone tell me why I'm getting this error in SOAPpy?
server = SOAPpy.WSDL.Proxy(wdf)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
server = SOAPpy.WSDL.Proxy(wdf)
File "C:\Python27\lib\soapy\SOAPpy\WSDL.py", line 62, in __init__
self.wsdl = reader.loadFromStream(strea... | Can anyone tell me why I'm getting this error in SOAPpy? | server = SOAPpy.WSDL.Proxy(wdf)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
server = SOAPpy.WSDL.Proxy(wdf)
File "C:\Python27\lib\soapy\SOAPpy\WSDL.py", line 62, in __init__
self.wsdl = reader.loadFromStream(stream, wsdlsource)
File "C:\Python27\lib\soapy\SOAPpy\wstools\WS... | [
"Use this one \n>>> import SOAPpy\n>>> url = \"your wsdl url\"\n>>> nameSpc= \"your name space\"\n>>> client = SOAPpy.SOAPProxy(url,namespace = nameSpc)\n>>> client.config.buildWithNamespacePrefix = 0 // only for callin .net service\n>>> client.config.dumpSOAPIn = 1 // in case to debug\n>>> client.config.dumpSOA... | [
2,
0
] | [] | [] | [
"python",
"soappy"
] | stackoverflow_0003962167_python_soappy.txt |
Q:
jython connection to csv file
Hi
I have a code to read the csv file
import csv
d = csv.reader(open('C:/Documents and Settings/242481/My Documents/file.csv'))
for row in d:
print row
This code returns all the rows in the csv file
Is there any way i can read one row at a time.
And each time i execute the prin... | jython connection to csv file | Hi
I have a code to read the csv file
import csv
d = csv.reader(open('C:/Documents and Settings/242481/My Documents/file.csv'))
for row in d:
print row
This code returns all the rows in the csv file
Is there any way i can read one row at a time.
And each time i execute the print line i need to get the next row.
... | [
"it should work the way you have it, but maybe the EOL characters are not what is expected for the system you're on. try opening it with 'rU': open('file.csv', 'rU')\nto verify that it's printing one row at a time, you could print a blank line between rows:\n\nfor row in d:\n print row\n print\n\nor pause it:\n\nfo... | [
0
] | [] | [] | [
"csv",
"jython",
"python"
] | stackoverflow_0005074199_csv_jython_python.txt |
Q:
Match first instance of Python regex search
I'm looking to the first instance of a match two square brackets using regular expressions. Currently, I am doing
regex = re.compile("(?<=(\[\[)).*(?=\]\])")
r = regex.search(line)
which works for lines like
[[string]]
returns string
but when I try it on a separate l... | Match first instance of Python regex search | I'm looking to the first instance of a match two square brackets using regular expressions. Currently, I am doing
regex = re.compile("(?<=(\[\[)).*(?=\]\])")
r = regex.search(line)
which works for lines like
[[string]]
returns string
but when I try it on a separate line:
[[string]] ([[string2]], [[string3]])
The r... | [
"Python *, +, ? and {n,m} quantifiers are greedy by default\nPatterns quantified with the above quantifiers will match as much as they can by default. In your case, this means the first set of brackets and the last. In Python, you can make any quantifier non-greedy (or \"lazy\") by adding a ? after it. In your case... | [
50
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0005074331_python_regex.txt |
Q:
Python3 strange list reversal
Hey all, so I'm implementing the simple version of the discrete fourier transform in python for a class, but something strange is happening to my output and I have no idea why. For example if my input is [a,b,c,d] the values are getting scrambled like [a',d',c',b'] with the head of th... | Python3 strange list reversal | Hey all, so I'm implementing the simple version of the discrete fourier transform in python for a class, but something strange is happening to my output and I have no idea why. For example if my input is [a,b,c,d] the values are getting scrambled like [a',d',c',b'] with the head of the list in the same place, but the o... | [
"I believe you're missing a negative sign in the calculation of c (see this link).\nWith your code:\n>>> DFT(4, [1, 2, 3, 4])\n4 point DFT finished in 0.0310370227732s\n[(10+0j), (-2.0000000000000004-1.9999999999999996j), (-2+9.797174393178826e-16j), (-1.9999999999999982+2.000000000000001j)]\n\nWith the missing neg... | [
4
] | [
"In the particular piece of code you have provided, we don't see any list manipulation except for assignment to F. There again you need not use += operator and justing using = is fine.\nApart from that, consider this simple case of list assignment, which may help you to track the problem in your code. \nWhen you as... | [
-1
] | [
"python",
"python_3.x"
] | stackoverflow_0005074124_python_python_3.x.txt |
Q:
removing non-numeric characters from a string
strings = ["1 asdf 2", "25etrth", "2234342 awefiasd"] #and so on
Which is the easiest way to get [1, 25, 2234342]?
How can this be done without a regex module or expression like (^[0-9]+)?
A:
new = []
for item in strings:
new.append(int(''.join(i for i in item i... | removing non-numeric characters from a string | strings = ["1 asdf 2", "25etrth", "2234342 awefiasd"] #and so on
Which is the easiest way to get [1, 25, 2234342]?
How can this be done without a regex module or expression like (^[0-9]+)?
| [
"new = []\nfor item in strings:\n new.append(int(''.join(i for i in item if i.isdigit())))\n\n\nprint new\n[1, 25, 2234342]\n\n",
"One could write a helper function to extract the prefix:\ndef numeric_prefix(s):\n n = 0\n for c in s:\n if not c.isdigit():\n return n\n else:\n ... | [
2,
2,
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0005074426_python.txt |
Q:
Obtaining indexes of changed data between two numpy arrays
I have two 3d numpy arrays a1 and a2 where len(a1) == len(a2) and a1[x, y, z] = id
I'm using this code to find out if there is changed data in any of the z layers
eq = a1 == a2
if eq.any():
#find the indexes of the changed data
as the comment and titl... | Obtaining indexes of changed data between two numpy arrays | I have two 3d numpy arrays a1 and a2 where len(a1) == len(a2) and a1[x, y, z] = id
I'm using this code to find out if there is changed data in any of the z layers
eq = a1 == a2
if eq.any():
#find the indexes of the changed data
as the comment and title says I need to find the indexes of the changed data.
basically... | [
"Two more options:\nnp.argwhere(a1!=a2)\nnp.where(a1!=a2)\n\nThey both do the same thing but produce results in different formats (one suitable for indexing the arrays, the other more readable)\n",
"I didn't understand the specifics of your question (e.g., the size/shape of your array); this solution should be ge... | [
4,
1
] | [] | [] | [
"arrays",
"numpy",
"python"
] | stackoverflow_0005073995_arrays_numpy_python.txt |
Q:
Regex to capture the codes between specific function
I have been experimenting with python re, trying to capture specific variables between specific functions. To illustrate let me give an example of file contents of a php file :-
public function executeSomething ()
{
$this->title = 'Edit something';
... | Regex to capture the codes between specific function | I have been experimenting with python re, trying to capture specific variables between specific functions. To illustrate let me give an example of file contents of a php file :-
public function executeSomething ()
{
$this->title = 'Edit something';
$this->action = 'Edit';
$this->headerTitle = 'Edit... | [
"If the input PHP has no bugs and has consistent indentation, you could check for a non-space character before the closing brace.\nr = re.compile(r'public function execute(.*?)\\(\\).*?{(.*?)[^ ]}', re.DOTALL)\n\n"
] | [
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0005074021_python_regex.txt |
Q:
Problem with Facebook OAuth on Google Appengine
I am using the "Server Side" flow to get a user's permissions to access some information using Python on Google Appengine.
I am able to get the server generated code from Facebook after the user clicks on the "Allow" button.
However when I get the access token, I r... | Problem with Facebook OAuth on Google Appengine | I am using the "Server Side" flow to get a user's permissions to access some information using Python on Google Appengine.
I am able to get the server generated code from Facebook after the user clicks on the "Allow" button.
However when I get the access token, I run into the following error:
Traceback (most recent... | [
"It looks like you are trying to access the access_token as url, which is not quite right.\nHere is an example which illustrates how OAuth authentication via FB is done over GAE.\n\nYou go to the https://graph.facebook.com/oauth/authorize? with your client_id and redirect_uri\nUpon authorization, it gives a code a... | [
1
] | [] | [] | [
"facebook",
"google_app_engine",
"oauth",
"python"
] | stackoverflow_0005075339_facebook_google_app_engine_oauth_python.txt |
Q:
Python Classes in 2 Files [Learn Python the Hard Way]
Hey guys,
I'm currently completing Zed Shaw's "Learn Python the Hard Way" and I've been struggling with Exercise 43, which instructs the learner to make a game. For simplicity, I am attempting to rewrite the previous exercise that has a class Game and some func... | Python Classes in 2 Files [Learn Python the Hard Way] | Hey guys,
I'm currently completing Zed Shaw's "Learn Python the Hard Way" and I've been struggling with Exercise 43, which instructs the learner to make a game. For simplicity, I am attempting to rewrite the previous exercise that has a class Game and some functions:
__init__, play, death, and four more for each "room"... | [
"Note: I'm not familiar with the book and hence with the context of the question, so my answer refers to the displayed code only\nThe problem here isn't splitting the code to two files. As far as I can see, the PrincessRoom class in its own file presents no real problem.\nGame can't find the princess method, and it... | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0005075430_python.txt |
Q:
Python/Django mirror or proxy app
I need to setup a mirror/proxy site using Django/Python. What I need to do
I have a site say abc.com.
If I go to abc.com/stackoverflow.com, I want all content to be served from my server at abc.com. This includes all JS, CSS and images.
So I want a django mirror/proxy app, which t... | Python/Django mirror or proxy app | I need to setup a mirror/proxy site using Django/Python. What I need to do
I have a site say abc.com.
If I go to abc.com/stackoverflow.com, I want all content to be served from my server at abc.com. This includes all JS, CSS and images.
So I want a django mirror/proxy app, which takes a url, rewrites the html, pulls th... | [
"You want a vhost setup. You have to connect multiple domain names so that they are served by the same web server. That is accomplished by pointing the domains to the same server and setting up vhosting there. Django, or other software that serves the pages aren't directly involved in it.\n"
] | [
0
] | [] | [] | [
"django",
"mirror",
"proxy",
"python"
] | stackoverflow_0005075840_django_mirror_proxy_python.txt |
Q:
How do you link with 3rd-party libraries when using scons-qt4 plugin?
I'm using scons-qt plugin to build and link with Qt. I have to build a set of executables that link to my own library. Also, library has to link to some third-party libraries beside Qt. So, in library's SConscript I write:
env.SharedLibrary ('pr... | How do you link with 3rd-party libraries when using scons-qt4 plugin? | I'm using scons-qt plugin to build and link with Qt. I have to build a set of executables that link to my own library. Also, library has to link to some third-party libraries beside Qt. So, in library's SConscript I write:
env.SharedLibrary ('proverim', Glob ('*.cc'), LIBS = Split ('sane quazip'))
And for an executabl... | [
"The behaviour you see is expected. By writing\nenv.Program ('PCorrect', Glob ('*.cc'), LIBS = ['proverim'])\n\nor\nenv['LIBS'] = ['proverim']\n\nyou completely overwrite the LIBS that may have been set by qt4.py in the EnableQt4Modules() method.\nWhat you want to do instead is adding your libraries to the Qt4 stuf... | [
2
] | [] | [] | [
"python",
"qt",
"scons"
] | stackoverflow_0005064100_python_qt_scons.txt |
Q:
Return python unicode instances from UTF-8 encoded char* using boost.python
I'm trying to do something which should be very simple, but I'm not having much luck figuring out how from the existing documentation.
For a python 2 project I am trying to return a list gettext-translated string as a unicode instances to ... | Return python unicode instances from UTF-8 encoded char* using boost.python | I'm trying to do something which should be very simple, but I'm not having much luck figuring out how from the existing documentation.
For a python 2 project I am trying to return a list gettext-translated string as a unicode instances to python. The return value for gettext() is a UTF-8 encoded char*, which should be ... | [
"With some help from the C++-SIG mailinglist I have this working now. There are two extra steps needed:\n\nuse boost::python::handle<> to create a C++ wrapper around the PyObject* which takes care of reference handling\nuse boost::python::object to create a C++ wrapper around the handle, which allows using a PyObje... | [
2
] | [] | [] | [
"boost",
"boost_python",
"c++",
"python"
] | stackoverflow_0005064902_boost_boost_python_c++_python.txt |
Q:
inserting a function into a module's namespace using a decorator
I've got a decorator, but I'd like to store the original function in the namespace for future reference, such that I end up with a decorated and non-decorated version of the function.
I'm inserting that original function into the namespace like that:... | inserting a function into a module's namespace using a decorator | I've got a decorator, but I'd like to store the original function in the namespace for future reference, such that I end up with a decorated and non-decorated version of the function.
I'm inserting that original function into the namespace like that:
def crossover(cross):
def ecspy_crossover(random, candidates, a... | [
"Why not just add the original function as an attribute of the wrapped function? In fact that's exactly what functools.wraps does in Python 3.2, it stores the original function in the __wrapped__ attribute.\nRegarding your question, I would guess that your problem is that you are adding the function into the global... | [
2
] | [] | [] | [
"decorator",
"namespaces",
"python"
] | stackoverflow_0005076560_decorator_namespaces_python.txt |
Q:
Error calling function from dictionary
I just want to create a class with a lot of functions which need to import some variables of the class for there output. To make the use more efficient i wanted to store the functions in a dictionary, but somehow that is not working at all...
class A(object):
var = 'hel... | Error calling function from dictionary | I just want to create a class with a lot of functions which need to import some variables of the class for there output. To make the use more efficient i wanted to store the functions in a dictionary, but somehow that is not working at all...
class A(object):
var = 'hello'
def g(self,x):
return self.v... | [
"When a function is called as a method, it implicitly gets the invocant as first argument. But that's not the case when you pull it out of the dict. You you'd have to call\nprint a.dict['g'](a, 0)\n\nOn a side note, I'd expect the call through dict to be slower, not faster, because you first need to get the dict fr... | [
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0005076386_python.txt |
Q:
Adding a CMD linebreak in Python
How would I add a CMD line break in Python?
I have tried the following, but it still comes out as a paragraph.
print "Welcome to xbrEra's first application";
print
print " using Python 2.7.1. I hope you enjoy";
print
print "-------------------------------------";
print
A:
dependi... | Adding a CMD linebreak in Python | How would I add a CMD line break in Python?
I have tried the following, but it still comes out as a paragraph.
print "Welcome to xbrEra's first application";
print
print " using Python 2.7.1. I hope you enjoy";
print
print "-------------------------------------";
print
| [
"depending on your OS:\nprint \"\\n\" \n\nor \nprint \"\\r\\n\"\n\n",
"Python's print stmt adds a newline (which may be '\\r\\n' or '\\n' depending upon your OS) automatically. If you don't want the newline to be added, you can end the your print stmt with a comma. Like print \"hello,world\", And you can explicit... | [
3,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0005076850_python.txt |
Q:
How to design a memory and computationally intensive program to run on Google App Engine
I have a problem with my code running on google app engine. I dont know how to modify my code to suit GAE. The following is my problem
for j in range(n):
for d in range(j):
for d1 in range(d):
for d2 in range(d1):
# ... | How to design a memory and computationally intensive program to run on Google App Engine | I have a problem with my code running on google app engine. I dont know how to modify my code to suit GAE. The following is my problem
for j in range(n):
for d in range(j):
for d1 in range(d):
for d2 in range(d1):
# block which runs in O(n^2)
Efficiently the entire code block is O(N^6) and it will run for mo... | [
"There may be even more efficient ways to store your data and to iterate over it.\nQuestions:\n\nWhat datatype are you storing, list of list ... of int? \nWhat range of the nested list does your innermost loop O(n^2) portion typically operate over?\nWhen you do the putitem, getitem how many values are you retrievi... | [
1,
0,
0
] | [] | [] | [
"design_patterns",
"google_app_engine",
"python"
] | stackoverflow_0004543377_design_patterns_google_app_engine_python.txt |
Q:
Is it possible to convert a QTabBar inside the QTabWidget into a QComboBox?
Is it possible to convert a QTabBar inside the QTabWidget into a QComboBox?
A:
That might somehow be possible by overwriting QTabWidget, but I think the much cleaner, faster and easier solution would be to combine QComboBox and QStackedW... | Is it possible to convert a QTabBar inside the QTabWidget into a QComboBox? | Is it possible to convert a QTabBar inside the QTabWidget into a QComboBox?
| [
"That might somehow be possible by overwriting QTabWidget, but I think the much cleaner, faster and easier solution would be to combine QComboBox and QStackedWidget to a new widget.\n"
] | [
1
] | [] | [] | [
"pyqt",
"pyqt4",
"python",
"qt"
] | stackoverflow_0005075232_pyqt_pyqt4_python_qt.txt |
Q:
Regular expression to remove line breaks
I am a complete newbie to Python, and I'm stuck with a regex problem. I'm trying to remove the line break character at the end of each line in a text file, but only if it follows a lowercase letter, i.e. [a-z]. If the end of the line ends in a lower case letter, I want to r... | Regular expression to remove line breaks | I am a complete newbie to Python, and I'm stuck with a regex problem. I'm trying to remove the line break character at the end of each line in a text file, but only if it follows a lowercase letter, i.e. [a-z]. If the end of the line ends in a lower case letter, I want to replace the line break/newline character with a... | [
"Try \nre.sub(r\"(?<=[a-z])\\r?\\n\",\" \", textblock)\n\n\\Z only matches at the end of the string, after the last linebreak, so it's definitely not what you need here. \\z is not recognized by the Python regex engine.\n(?<=[a-z]) is a positive lookbehind assertion that checks if the character before the current p... | [
25,
2,
1
] | [] | [] | [
"python",
"python_2.7",
"regex"
] | stackoverflow_0005075247_python_python_2.7_regex.txt |
Q:
How to rewrite deprecated DDL() statement in SQLAlchemy 0.7+
So far I have used the following statements in SQLAlchemy to implement table inheritance via ALTER TABLE:
inherit = "ALTER TABLE %(fullname)s INHERIT parent_table"
DDL(inherit, on='postgresql').execute_at("after-create", child_table)
This is deprecated i... | How to rewrite deprecated DDL() statement in SQLAlchemy 0.7+ | So far I have used the following statements in SQLAlchemy to implement table inheritance via ALTER TABLE:
inherit = "ALTER TABLE %(fullname)s INHERIT parent_table"
DDL(inherit, on='postgresql').execute_at("after-create", child_table)
This is deprecated in SQLAlchemy now, and I am a bit confused about the new method thr... | [
"Look at an example in documentation, your code can be rewritten as:\nevent.listen(child_table, \"after-create\", DDL(inherit).execute_if(dialect='postgresql'))\n\n"
] | [
2
] | [] | [] | [
"python",
"sqlalchemy"
] | stackoverflow_0005076950_python_sqlalchemy.txt |
Q:
how to deal with static files to write app.yaml?
Possible Duplicate:
how to write yaml file
I registered a Google App Engine app and I have some files below:
/index.html
/tabs.css
/tab.js
/temp.py
How should I write the app.yaml file?
A:
application: ***your-app-name***
version: 1
runtime: python
api_version: ... | how to deal with static files to write app.yaml? |
Possible Duplicate:
how to write yaml file
I registered a Google App Engine app and I have some files below:
/index.html
/tabs.css
/tab.js
/temp.py
How should I write the app.yaml file?
| [
"application: ***your-app-name***\nversion: 1\nruntime: python\napi_version: 1\n\nhandlers:\n- url: /(robots\\.txt|favicon\\.ico)\n static_files: public/\\1\n upload: public/(.*)\n\n- url: /public\n static_dir: public\n\n- url: /.*\n script: main.py\n\nCreate a pubic directory under you app's root directory and... | [
1
] | [] | [] | [
"google_app_engine",
"python",
"yaml"
] | stackoverflow_0005077554_google_app_engine_python_yaml.txt |
Q:
Getting another error in Django: Caught NoReverseMatch error in django
I seem to have another problem with passing parameters in Django. I seem to get a Caught NoReverseMatch error.
Caught NoReverseMatch while rendering: Reverse for 'tiptop.views.service_order2' with arguments '('', 17L, 1)' and keyword arguments... | Getting another error in Django: Caught NoReverseMatch error in django | I seem to have another problem with passing parameters in Django. I seem to get a Caught NoReverseMatch error.
Caught NoReverseMatch while rendering: Reverse for 'tiptop.views.service_order2' with arguments '('', 17L, 1)' and keyword arguments '{}' not found
It reaches the client_id and service_type but not the order... | [
"Your order object does not have a pk value, for whatever reason - presumably it's a new unsaved instance. So it's passing an empty string as the first parameter to the URL, and is failing to match your service_order2 url which expects a number in that position.\n"
] | [
0
] | [] | [] | [
"django",
"html",
"python",
"url",
"views"
] | stackoverflow_0005077438_django_html_python_url_views.txt |
Q:
How to write `app.yaml` file for Google App Engine app?
I registered a Google App Engine app and I have some files below:
/index.html
/tabs.css
/tab.js
/temp.py
How should I write the app.yaml file?
A:
you should put your static files into some directory, for example staticdata
then your app.yaml would look li... | How to write `app.yaml` file for Google App Engine app? | I registered a Google App Engine app and I have some files below:
/index.html
/tabs.css
/tab.js
/temp.py
How should I write the app.yaml file?
| [
"you should put your static files into some directory, for example staticdata\nthen your app.yaml would look like:\n\napplication: temp\nversion: 1\nruntime: python\napi_version: 1\n\nhandlers:\n- url: /staticdata\n static_dir: staticdata\n\n- url: /.*\n script: temp.py\n\n"
] | [
1
] | [] | [] | [
"google_app_engine",
"python",
"yaml"
] | stackoverflow_0005077336_google_app_engine_python_yaml.txt |
Q:
Detecting and diagnosing workers silently crashing
I'm running Celery 2 using daemonizing - http://ask.github.com/celery/cookbook/daemonizing.html with RabbitMQ.
From time to time silent crash happens, the only thing i see in celeryd.log:
[2010-12-24 14:14:31,323: INFO/PoolWorker-1414] process shutting down
[2010... | Detecting and diagnosing workers silently crashing | I'm running Celery 2 using daemonizing - http://ask.github.com/celery/cookbook/daemonizing.html with RabbitMQ.
From time to time silent crash happens, the only thing i see in celeryd.log:
[2010-12-24 14:14:31,323: INFO/PoolWorker-1414] process shutting down
[2010-12-24 14:14:31,323: INFO/PoolWorker-1414] process exiti... | [
"Queue workers are stalled, so the main solution to this is to adjust a the task time limit for each task, in a way to restart the worker when the tasks exceed this time.\nAdd to your task the following\nfrom celery.decorators import task\nfrom celery.exceptions import SoftTimeLimitExceeded\n\n\n@task()\ndef mytask... | [
1
] | [] | [] | [
"celery",
"django",
"python"
] | stackoverflow_0004526211_celery_django_python.txt |
Q:
Determine if Python script is being executed locally or as CGI
Let's say I have a basic Python script, test.py:
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "<html>Hello world!</html>"
How would one determine if the script is being executed locally, e.g.:
python test.py
Or being called via a web... | Determine if Python script is being executed locally or as CGI | Let's say I have a basic Python script, test.py:
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "<html>Hello world!</html>"
How would one determine if the script is being executed locally, e.g.:
python test.py
Or being called via a web browser, e.g. visiting:
http://example.com/test.py
This doesn't se... | [
"That looks like the best method. There isn't much difference between being called from the command-line and being started by the web server following a HTTP request, except for the CGI environment variables, like REQUEST_METHOD.\n"
] | [
8
] | [] | [] | [
"cgi",
"python"
] | stackoverflow_0005077980_cgi_python.txt |
Q:
Django development add-ons
I have come across various Django development add ons, particularly,
django-extensions
django-annoying
django-debug-toolbar
django-tools
I haven't exactly used all of these.
I think it is hard to beat the simplicity and power obtained by the combination of Django's pretty error pages ... | Django development add-ons | I have come across various Django development add ons, particularly,
django-extensions
django-annoying
django-debug-toolbar
django-tools
I haven't exactly used all of these.
I think it is hard to beat the simplicity and power obtained by the combination of Django's pretty error pages combined with iPythonEmbed shell... | [
"I for one love django-annoying's render_to method.\n@render_to('template.html')\ndef foo(request):\n bar = Bar.objects.all() \n return {'bar': bar}\n\n# equivalent to\ndef foo(request):\n bar = Bar.objects.all() \n return render_to_response('template.html',\n {'bar': bar},\... | [
3,
3,
1,
1,
1,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0001016980_django_python.txt |
Q:
Over-ride default Satchmo email with custom template
I'm using Satchmo for the shop section of a website. I'm trying to override the default 'order_complete' email with my own, but haven't been able to so far. The docs indicate that it should be done in the same way as overriding any other template. So I've create... | Over-ride default Satchmo email with custom template | I'm using Satchmo for the shop section of a website. I'm trying to override the default 'order_complete' email with my own, but haven't been able to so far. The docs indicate that it should be done in the same way as overriding any other template. So I've created one in my template folder at shop/email/order_complete.h... | [
"Just a guess but, is Satchmo listed in installed_apps before your own app? (If so the order_complete template may be being matched before yours is ever reached.)\nTry moving your app before Satchmo and see if that solves it.\n",
"If you want your template folder to take precedence over the app template folders, ... | [
0,
0
] | [] | [] | [
"django",
"python",
"satchmo"
] | stackoverflow_0005076132_django_python_satchmo.txt |
Q:
python: how to tell socket.gethostbyaddr() which dns server to use
is there any way to specify dns server should be used by socket.gethostbyaddr()?
A:
Please correct me, if I'm wrong, but isn't this operating system's responsibility? gethostbyaddr is just a part of libc and according to man:
The gethostbyna... | python: how to tell socket.gethostbyaddr() which dns server to use | is there any way to specify dns server should be used by socket.gethostbyaddr()?
| [
"Please correct me, if I'm wrong, but isn't this operating system's responsibility? gethostbyaddr is just a part of libc and according to man:\n The gethostbyname(), gethostbyname2() and gethostbyaddr() functions each return a\n pointer to an object with the following structure describing an internet host r... | [
5,
1
] | [] | [] | [
"dns",
"python",
"sockets"
] | stackoverflow_0005078338_dns_python_sockets.txt |
Q:
how to create counter loop in django template?
can any tell me how can I write below code of c in django
for(c=0; c<5; c++)
//do something
i had tried below code but it gives me an error
{% for(c=0; c<5; c++)%}
<div class="tab-content">
<h1 class="tab" title="title for page 1">Page 1</h1>
<p>This i... | how to create counter loop in django template? | can any tell me how can I write below code of c in django
for(c=0; c<5; c++)
//do something
i had tried below code but it gives me an error
{% for(c=0; c<5; c++)%}
<div class="tab-content">
<h1 class="tab" title="title for page 1">Page 1</h1>
<p>This is the content of tab 1 on container 1</p>
</div... | [
"When you render your template, you may pass range\nrender_to_response('template_x.html', {'range5': range(5)})\n\nAnd in html template, probably like this\n{% for i in range5 %}\n <div class=\"tab-content\">\n <h1 class=\"tab\" title=\"title for page {{i}}\">Page {{i}}</h1>\n <p>This is the content of tab... | [
4,
3,
3
] | [] | [] | [
"django",
"django_templates",
"python"
] | stackoverflow_0005077978_django_django_templates_python.txt |
Q:
Can I connect 2 NAT-covered computers using FTP?
I have 2 computers behind diferent NAT's and FTP-server. How can i connect computers to each other without server program?
I read about STUN and UDP hole punching, but as i see, it needs some server side program, isn't it?
It's will be used in python program.
A:
T... | Can I connect 2 NAT-covered computers using FTP? | I have 2 computers behind diferent NAT's and FTP-server. How can i connect computers to each other without server program?
I read about STUN and UDP hole punching, but as i see, it needs some server side program, isn't it?
It's will be used in python program.
| [
"To do this without a server you could setup port forwarding on one of the NAT routers. e.g. machine1 behind nat1, machine2 behind nat2. Setup a port on nat1 forward to the FTP port of machine1. You should then be able to FTP from machine2 using the public IP address of nat1. Use passive mode FTP to avoid having to... | [
0
] | [] | [] | [
"ftp",
"nat",
"python"
] | stackoverflow_0005078749_ftp_nat_python.txt |
Q:
Django/Python version of Premailer?
I'm looking to automate the sending of multi-part emails. Now I need to format the text accordingly for both HTML and plaintext versions. Premailer seems pretty awesome. I especially like how it handles the plaintext version.
Anyone know of anything comparable written for Django... | Django/Python version of Premailer? | I'm looking to automate the sending of multi-part emails. Now I need to format the text accordingly for both HTML and plaintext versions. Premailer seems pretty awesome. I especially like how it handles the plaintext version.
Anyone know of anything comparable written for Django/Python?
| [
"https://pypi.python.org/pypi/premailer\nThere is also a barely-supported Django Premailer app, for ideas.\n"
] | [
8
] | [] | [] | [
"django",
"email",
"python"
] | stackoverflow_0005071654_django_email_python.txt |
Q:
Which is the best approach of this data structure in python?
I have the following situation in python:
I am parsing an ontology and i want to keep track of some properties of the ontology and build a data structure with the below characteristics:
-there will be a single key to access each value
-the value would be... | Which is the best approach of this data structure in python? | I have the following situation in python:
I am parsing an ontology and i want to keep track of some properties of the ontology and build a data structure with the below characteristics:
-there will be a single key to access each value
-the value would be another key-value data structure with the following 3 enties:
'x'... | [
"\"Lines of code\" is probably not the best metric to optimize. This looks like a classic example of outgrowing a \"dictionaries and lists\" solution. I've been there many times. Use a class, it will let you write understandable maintainable code, with named methods for manipulating your data structure.\nThis w... | [
8,
1,
0
] | [] | [] | [
"data_structures",
"python"
] | stackoverflow_0005077941_data_structures_python.txt |
Q:
ImportError: No module named win32api, python, even when location of win32api is appended to path
I'm fairly new to python. (Python 2.6)
I'm trying to list the running processes by importing the wmi module.
import wmi
sys.path.append(r'C:\Python26\Lib\site-packages\isapi\test\build\bdis.win32\winexe\temp')
c = wmi... | ImportError: No module named win32api, python, even when location of win32api is appended to path | I'm fairly new to python. (Python 2.6)
I'm trying to list the running processes by importing the wmi module.
import wmi
sys.path.append(r'C:\Python26\Lib\site-packages\isapi\test\build\bdis.win32\winexe\temp')
c = wmi.WMI ()
for process in c.Win32_Process ():
print process.ProcessId, process.Name
A system search ... | [
"This should have all the information you need:\nhttp://mail.python.org/pipermail/python-win32/2003-December/001482.html\nNo need to for WMI, just use Win32 Extensions.\nfrom win32com.client import GetObject\nWMI = GetObject('winmgmts:')\n\n#List all processes\nprocesses = WMI.InstancesOf('Win32_Process')\nfor proc... | [
2
] | [] | [] | [
"importerror",
"python"
] | stackoverflow_0005078736_importerror_python.txt |
Q:
Python, virtualenv - Is it possible to use a single Pyramid project with multiple virtualenvs on different computers?
I'm really interested in trying out the Pyramid Framework but only half of my programming time is spent on my computer here at home; I spend a considerable amount of time at school and use their co... | Python, virtualenv - Is it possible to use a single Pyramid project with multiple virtualenvs on different computers? | I'm really interested in trying out the Pyramid Framework but only half of my programming time is spent on my computer here at home; I spend a considerable amount of time at school and use their computers as well, and according to the documentation for virtualenv, environments can't be moved around like projects. What... | [
"In your setup.py file at the root of your project, you just have to list all the dependencies you have in requires.\nThen, with your virtualenv activated, you run\npython setup.py develop\n\nThis will install missing dependencies on your current virtualenv.\nExample:\nrequires = ['pyramid',\n 'WebError'... | [
4,
2,
1
] | [] | [] | [
"pylons",
"pyramid",
"python",
"virtualenv"
] | stackoverflow_0005074899_pylons_pyramid_python_virtualenv.txt |
Q:
Retrieving a GoogleDoc via API and generate a PDF replacing with own text
I'm wondering if it's possible to retrieve a simple GoogleDoc (via gdata python client) and render a PDF replacing some custom #[PLACE_HOLDERS] with my own information.
A:
Found what I've looking for. The problem was that I tried to use Do... | Retrieving a GoogleDoc via API and generate a PDF replacing with own text | I'm wondering if it's possible to retrieve a simple GoogleDoc (via gdata python client) and render a PDF replacing some custom #[PLACE_HOLDERS] with my own information.
| [
"Found what I've looking for. The problem was that I tried to use DocsService (v1 API) instead of DocsClient (v2).\nWARNING: The examples of gdata/OAuth in AppEngine are outdated - http://code.google.com/p/gdata-python-client/source/browse/samples/oauth/oauth_on_appengine/main_hmac.py.\nTo get an updated version ch... | [
0
] | [] | [] | [
"google_app_engine",
"google_docs_api",
"pdf_generation",
"python"
] | stackoverflow_0005019628_google_app_engine_google_docs_api_pdf_generation_python.txt |
Q:
PyQt4 - Enter key pressed on item in QListView
Hey.
I've got a QListView, and so far I've only figured out how to use the signals that are already given. I can't find any signals for when the enter key was pressed on an item in the list (QStandardListItem). Can't seem to find any keyPressedEvents either.
Is it pos... | PyQt4 - Enter key pressed on item in QListView | Hey.
I've got a QListView, and so far I've only figured out how to use the signals that are already given. I can't find any signals for when the enter key was pressed on an item in the list (QStandardListItem). Can't seem to find any keyPressedEvents either.
Is it possible to "hook up" QListView to a event just like th... | [
"Use event filtering: e.g. in the list container's setupUi, do\n# the self param passed to installEventFilter indicates the object which\n# defines eventFilter(), see below:\nself.list.installEventFilter(self)\n\nand then define the filter API function in that container:\ndef eventFilter(self, watched, event):\n ... | [
5
] | [] | [] | [
"pyqt4",
"python",
"qt4"
] | stackoverflow_0005079438_pyqt4_python_qt4.txt |
Q:
Writing a Python C extension: how to correctly load a PyListObject?
While attempting to read a Python list filled with float numbers and to populate real channels[7] with their values (I'm using F2C, so real is just a typedef for float), all I am able to retrieve from it are zero values. Can you point out the erro... | Writing a Python C extension: how to correctly load a PyListObject? | While attempting to read a Python list filled with float numbers and to populate real channels[7] with their values (I'm using F2C, so real is just a typedef for float), all I am able to retrieve from it are zero values. Can you point out the error in the code below?
static PyObject *orbital_spectra(PyObject *self, PyO... | [
"PyList_GetItem will return a PyObject*. You need to convert that to a number C understands. Try changing your code to this:\nprintf(\"%f\\n\", PyFloat_AsDouble(PyList_GetItem(input, (Py_ssize_t)i)));\n\n",
"Few things I see in this code.\n\nYou leak a reference, don't create that empty list at the beginning, i... | [
3,
2
] | [] | [] | [
"python",
"python_c_extension"
] | stackoverflow_0005079570_python_python_c_extension.txt |
Q:
Find current time interval in python?
How can I find the nearest 15 (or 10) minute interval in python ?
e.g.
>>> datetime.datetime.now()
datetime.datetime(2011, 2, 22, 15, 43, 18, 424873)
I'd like the current 15 minute interval (15:30-15:44) so I'd like to transform the above datetime to a
datetime.datetime(2011... | Find current time interval in python? | How can I find the nearest 15 (or 10) minute interval in python ?
e.g.
>>> datetime.datetime.now()
datetime.datetime(2011, 2, 22, 15, 43, 18, 424873)
I'd like the current 15 minute interval (15:30-15:44) so I'd like to transform the above datetime to a
datetime.datetime(2011, 2, 22, 15, 30, 00, 00)
| [
"Quite the easiest way to me:\nfrom datetime import datetime, timedelta\nnow = datetime.now()\nnow = now - timedelta(minutes = now.minute % 15, seconds = now.second, microseconds = now.microsecond )\n\nHope that'll help.\n",
"I think for this case using replace is more straightforward than timedelta:\n>>> import ... | [
5,
2,
0,
0
] | [] | [] | [
"date_arithmetic",
"python",
"time"
] | stackoverflow_0005079558_date_arithmetic_python_time.txt |
Q:
repr the call resulting in a stack frame?
Is there a standard method to repr the call that resulted in a given stack frame in Python? Failing that, is there a nice way to do it manually?
As an example:
def some_call(*args, **kwargs):
print('{}({})'.format(
'some_call',
', '.join(itertools.cha... | repr the call resulting in a stack frame? | Is there a standard method to repr the call that resulted in a given stack frame in Python? Failing that, is there a nice way to do it manually?
As an example:
def some_call(*args, **kwargs):
print('{}({})'.format(
'some_call',
', '.join(itertools.chain(
map(repr, args),
... | [
"I'm not quite sure what you're asking, but you can use the inspect module to get all the current stack info.\nf = inspect.currentframe()\nprint(f.f_locals)\nprint(inspect.getframeinfo(f))\n\nYou can regenerate the calling of your current frame using inspect.getargvalues, and format it to your liking\ndef some_call... | [
5
] | [] | [] | [
"decorator",
"python",
"python_3.x",
"repr",
"stack_frame"
] | stackoverflow_0005079779_decorator_python_python_3.x_repr_stack_frame.txt |
Q:
Embedding a scripting engine in C++
I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript. User-defined scripts will need the ability to access the application's data model.
Have any of you had experiences with embedding these scripting e... | Embedding a scripting engine in C++ | I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript. User-defined scripts will need the ability to access the application's data model.
Have any of you had experiences with embedding these scripting engines? What are some potential pitfalls... | [
"Lua is also a great candidate for embedding in programs. Its very self contained, and even the native cross-language call system isn't bad.\nFor JavaScript, your best bet right now is to look at V8 (from Google), which is easy enough to work with.\n",
"It's sure easy to embed Python by using the Boost::Python li... | [
7,
6,
4,
1,
1
] | [] | [] | [
"c++",
"embedding",
"javascript",
"python",
"scripting"
] | stackoverflow_0002907087_c++_embedding_javascript_python_scripting.txt |
Q:
Strange vanishing of CR in strings coming from a copy of a file's content passed to raw_input()
Trying to clear up the reasons of what seemed to be a bug, I finally bumped into a weird behaviour of the raw_input() function in Python 2.7:
it removes the CR characters of pairs CR LF from only the strings that resul... | Strange vanishing of CR in strings coming from a copy of a file's content passed to raw_input() | Trying to clear up the reasons of what seemed to be a bug, I finally bumped into a weird behaviour of the raw_input() function in Python 2.7:
it removes the CR characters of pairs CR LF from only the strings that result from a manual copy (via the clipboard) of a file's content. The strings passed to raw_input() that ... | [
"sys.stdin is opened in text mode (you can check this by displaying sys.stdin.mode and seeing that it is 'r'). If you open any file in text mode in Python, then the platform native line ending (\\r\\n for Windows) will be converted to a simple line feed (\\n) in the Python string.\nYou can see this in operation by ... | [
2,
0
] | [] | [] | [
"carriage_return",
"copy_paste",
"python",
"raw_input"
] | stackoverflow_0005060220_carriage_return_copy_paste_python_raw_input.txt |
Q:
python How to watch for Win32_Processor LoadPercentage change in wmi?
How do I watch for a LoadPercentage change event using the Win32_Processor class?
import wmi
c= wmi.WMI()
x = [cpu.LoadPercentage for cpu in c.Win32_Processor()]
Where should the watch for() method be applied so that I can know if the CPU usage... | python How to watch for Win32_Processor LoadPercentage change in wmi? | How do I watch for a LoadPercentage change event using the Win32_Processor class?
import wmi
c= wmi.WMI()
x = [cpu.LoadPercentage for cpu in c.Win32_Processor()]
Where should the watch for() method be applied so that I can know if the CPU usage has dropped to less than say 80%?
Thanks.
Siva
| [
"I don't use that library, but here is an example query:\nfrom win32com.client import Moniker\n\nwmi = Moniker('winmgmts:')\nevents = wmi.ExecNotificationQuery(\"Select * From __InstanceModificationEvent \"\n \"Within 1 \"\n \"Where TargetInstance ... | [
1,
1
] | [] | [] | [
"cpu_usage",
"python",
"watchdog",
"wmi"
] | stackoverflow_0005078960_cpu_usage_python_watchdog_wmi.txt |
Q:
python object AttributeError: type object 'Track' has no attribute 'title'
I apologize if this is a noob question, but I can't seem to figure this one out.
I have defined an object that defines a music track
(NOTE: originally had the just ATTRIBUTE vs self.ATTRIBUTE. I edited those values in to help remove confus... | python object AttributeError: type object 'Track' has no attribute 'title' | I apologize if this is a noob question, but I can't seem to figure this one out.
I have defined an object that defines a music track
(NOTE: originally had the just ATTRIBUTE vs self.ATTRIBUTE. I edited those values in to help remove confusion. They had no affect on the problem)
class Track(object):
def __init__(sel... | [
"You didn't include the bug:\n....other code....\nself.aTrack = [Track(sTitle,sArtist,sAlbum,sSource, sDestDir)]\nself.TrackOlv.AddObjects(self.aTrack)\n....other code....\n\nIt's somewhere in the first \"....other code....\", probably on the line where you first create the self.TrackOlv.\nLook at your error messag... | [
5,
1,
0,
0,
0
] | [] | [] | [
"objectlistview",
"python",
"wxpython"
] | stackoverflow_0005079500_objectlistview_python_wxpython.txt |
Q:
win32api: temporarily block mouse clicks?
Is there any way to disable regular windows mouse clicks using the win API? I can disable clicks anywhere besides a particular point by doing ClipCursor, but the clicks still register.
Alternatively I also want to disable mouse clicks conditionally... for example, I want t... | win32api: temporarily block mouse clicks? | Is there any way to disable regular windows mouse clicks using the win API? I can disable clicks anywhere besides a particular point by doing ClipCursor, but the clicks still register.
Alternatively I also want to disable mouse clicks conditionally... for example, I want to make it impossible to close a window of an ap... | [
"You can, and it's very dangerous. Here's how, in c++\nLRESULT __stdcall LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam)\n{\n if ((nCode < 0) || false)\n {\n result = CallNextHookEx(myLowLevelMouseHookHandle, nCode, wParam, lParam);\n }\n\n return result;\n}\n\nChange the false in the ... | [
2
] | [] | [] | [
"python",
"pywin32",
"winapi",
"windows"
] | stackoverflow_0005081012_python_pywin32_winapi_windows.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.