Q_Id int64 337 49.3M | CreationDate stringlengths 23 23 | Users Score int64 -42 1.15k | Other int64 0 1 | Python Basics and Environment int64 0 1 | System Administration and DevOps int64 0 1 | Tags stringlengths 6 105 | A_Id int64 518 72.5M | AnswerCount int64 1 64 | is_accepted bool 2
classes | Web Development int64 0 1 | GUI and Desktop Applications int64 0 1 | Answer stringlengths 6 11.6k | Available Count int64 1 31 | Q_Score int64 0 6.79k | Data Science and Machine Learning int64 0 1 | Question stringlengths 15 29k | Title stringlengths 11 150 | Score float64 -1 1.2 | Database and SQL int64 0 1 | Networking and APIs int64 0 1 | ViewCount int64 8 6.81M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6,539,267 | 2011-06-30T18:17:00.000 | 0 | 1 | 0 | 0 | python | 6,539,682 | 2 | false | 0 | 0 | You might have a look at pygame, it's pretty common for this sort of thing. | 1 | 0 | 0 | I started coding an RPG engine in python and I want it to be very scripted(buffs, events). I am experimenting with events and hooking. I would appreciate if you could tell me some matured opensource projects(so i can inspect the code) to learn from. Not necessarily python, but it would be ideal.
Thanks in advance. | Python rpg adivce? | 0 | 0 | 0 | 730 |
6,539,687 | 2011-06-30T18:54:00.000 | 0 | 0 | 0 | 0 | python,django | 6,539,716 | 2 | false | 1 | 0 | You can use cursor.fetchall() instead of cursor.fetchone() to retrieve all rows.
And then extract nessesary field:
raw_items = cursor.fetchall()
items = [ item.field for item in raw_items ] | 2 | 0 | 0 | I've used a raw SQL Query to access them, and it seems to have worked. However, I can't figure out a way to actually print the results to an array. The only thing that I can find is the cursor.fetchone() command, which gives me a single row.
Is there any way that I can return an entire column in a django query set? | How do I use django db API to save all the elements of a given column in a dictionary? | 0 | 1 | 0 | 223 |
6,539,687 | 2011-06-30T18:54:00.000 | 1 | 0 | 0 | 0 | python,django | 6,539,798 | 2 | true | 1 | 0 | dict(MyModel.objects.values_list('id', 'my_column')) will return a dictionary with all elements of my_column with the row's id as the key. But probably you're just looking for a list of all the values, which you should receive via MyModel.objects.values_list('my_column', flat=True)! | 2 | 0 | 0 | I've used a raw SQL Query to access them, and it seems to have worked. However, I can't figure out a way to actually print the results to an array. The only thing that I can find is the cursor.fetchone() command, which gives me a single row.
Is there any way that I can return an entire column in a django query set? | How do I use django db API to save all the elements of a given column in a dictionary? | 1.2 | 1 | 0 | 223 |
6,539,891 | 2011-06-30T19:13:00.000 | -1 | 0 | 0 | 0 | python,xml,dom | 6,540,130 | 2 | false | 0 | 0 | How many and what kind of changes do you need to make? It sounds to me like you may be better served simply using a standalone XML editor (just Google for them, there are lots). Frankly, I'm kind of surprised your IDE doesn't have adequate search-and-replace for your needs. (Most of the ones I've seen even have rege... | 1 | 7 | 0 | I need to make a few changes to existing XML files, while preserving formatting and comments - everything except the minor changes I do should be untouched. I've tried xml.etree and lxml.etree with no success.
The XML is generated by my IDE, but its editor is lacking in functionality, so I have to make a few manual cha... | Python library for editing XML preserving formatting and comments | -0.099668 | 0 | 1 | 539 |
6,540,330 | 2011-06-30T19:52:00.000 | 5 | 0 | 1 | 0 | python,time,plone,race-condition,collision | 6,540,543 | 1 | true | 1 | 0 | You'll be perfectly safe doing this, even in the unlikely event two requests are processed at exactly the same time, in event of a conflict the ZODB will raise a ConflictError and retry your request.
Responding to the discussion below:
On a single computer then by defition both transactions must overlap (you got the sa... | 1 | 1 | 0 | I have to use _createObjectByType on Plone. I have as an argument the id of the object. Is it going to be safe, in this scenario, to create an id based on time.time() to avoid collisions? Can two requests have exactly the same timestamp as shown by time.time()? | Is it time.time() a safe approach when creating content types on plone programatically? | 1.2 | 0 | 0 | 112 |
6,541,771 | 2011-06-30T22:22:00.000 | 47 | 0 | 0 | 0 | python,pyqt,fullscreen | 6,541,995 | 1 | true | 0 | 1 | use showFullScreen() on your widget. | 1 | 28 | 0 | I'm new to pyqt and I've been looking for some docs about pyqt and fullscreen mode. but I couldn't find nothing. So here is my question:
is there any way to run a PyQT 4 application on fullscreen? | Fullscreen with pyqt4? | 1.2 | 0 | 0 | 28,015 |
6,541,900 | 2011-06-30T22:41:00.000 | 2 | 0 | 1 | 0 | python,string | 6,541,941 | 5 | false | 0 | 0 | " ".join([my_string for i in range(3)] | 1 | 8 | 0 | I want to join strings
my_string = "I am good." such that it should be printing the same my_string 3 times, as in
my_string*3 with a space in between each full sentence. How do I do it? something like str.join(' ',my_string*3)?
I know this a basic question, but I want to know this.
Thank you in advance,
Sammed | Python - concatenate a string to itself, multiple times | 0.07983 | 0 | 0 | 10,976 |
6,543,413 | 2011-07-01T03:50:00.000 | 0 | 0 | 0 | 0 | python,graphics,tkinter | 32,061,918 | 2 | false | 0 | 1 | tkapp is the highest "master". If you make a widget on the root window, tkapp is the master of that. | 1 | 5 | 0 | I'm using Tkinter in Python, and trying to create code to run when a text box's value is changed. All the code I find online uses a mysterious tk member of Tkinter widgets, and I can't find any documentation on it! I found it's of type tkapp, but there's no documentation on that either.
Where can I find a decent resour... | What is Tkinter's tkapp? | 0 | 0 | 0 | 2,594 |
6,543,599 | 2011-07-01T04:31:00.000 | 0 | 0 | 0 | 0 | python,algorithm,screen-scraping,beautifulsoup,lxml | 6,543,634 | 3 | false | 1 | 0 | Extracting the real content from a content-page can not be done automatically - at least not with the standard tools. You have to define/identify where the real content is stored (by specifying the related CSS ID or class in your own HTML extraction code). | 2 | 0 | 0 | I know there is lxml and BeautifulSoup, but that won't work for my project, because I don't know in advance what the HTML format of the site I am trying to scrape an article off of will be. Is there a python-type module similar to Readability that does a pretty good job at finding the content of an article and returnin... | Python- is there a module that will automatically scrape the content of an article off a webpage? | 0 | 0 | 1 | 323 |
6,543,599 | 2011-07-01T04:31:00.000 | 0 | 0 | 0 | 0 | python,algorithm,screen-scraping,beautifulsoup,lxml | 6,567,206 | 3 | false | 1 | 0 | Using HTQL, the query is:
&html_main_text | 2 | 0 | 0 | I know there is lxml and BeautifulSoup, but that won't work for my project, because I don't know in advance what the HTML format of the site I am trying to scrape an article off of will be. Is there a python-type module similar to Readability that does a pretty good job at finding the content of an article and returnin... | Python- is there a module that will automatically scrape the content of an article off a webpage? | 0 | 0 | 1 | 323 |
6,544,814 | 2011-07-01T07:19:00.000 | 9 | 0 | 1 | 0 | python,pycharm | 6,548,619 | 4 | false | 0 | 0 | Press Ctrl-Shift-Enter to close the missing braces on the current line (if any), add the missing colon (if missing) and put the caret into the correctly indented position on the next line. | 3 | 15 | 0 | I can't get the auto-indentations to work properly unless I use the automatic closing of braces, et al (which I don't like), and I see no option allowing one to skip over/out.
Eclipse has a configuration option for this, and Visual Studio doesn't auto-close everything by default, but rather formats the code block after... | How to skip over closing braces / brackets / parentheses in PyCharm? | 1 | 0 | 0 | 6,548 |
6,544,814 | 2011-07-01T07:19:00.000 | 0 | 0 | 1 | 0 | python,pycharm | 46,707,024 | 4 | false | 0 | 0 | Why do you dislike the auto-closing brackets? They do not disturb anyone, see:
^ specifies the cursor position
method([a, {b: c^}])
behaves as if no brackets were there if you insert new brackets!
insert a '}':
method([a, {b: c}^])
now insert a ']':
method([a, {b: c}]^)
now insert a ')':
method([a, {b: c}])^
et vo... | 3 | 15 | 0 | I can't get the auto-indentations to work properly unless I use the automatic closing of braces, et al (which I don't like), and I see no option allowing one to skip over/out.
Eclipse has a configuration option for this, and Visual Studio doesn't auto-close everything by default, but rather formats the code block after... | How to skip over closing braces / brackets / parentheses in PyCharm? | 0 | 0 | 0 | 6,548 |
6,544,814 | 2011-07-01T07:19:00.000 | 4 | 0 | 1 | 0 | python,pycharm | 53,860,314 | 4 | true | 0 | 0 | Shift + Enter will jump past completions and drop you onto the next line.
Ctrl + ] will jump to the end of the current element.
This seems to work in most cases to skip past auto-completions. I find it the most versatile of the options.
Ctrl + [ will jump you to the start of whatever code block you are in.
As previous... | 3 | 15 | 0 | I can't get the auto-indentations to work properly unless I use the automatic closing of braces, et al (which I don't like), and I see no option allowing one to skip over/out.
Eclipse has a configuration option for this, and Visual Studio doesn't auto-close everything by default, but rather formats the code block after... | How to skip over closing braces / brackets / parentheses in PyCharm? | 1.2 | 0 | 0 | 6,548 |
6,546,310 | 2011-07-01T09:46:00.000 | 2 | 0 | 1 | 0 | python,cython | 6,591,378 | 1 | true | 0 | 1 | I assume you are talking about writing C modules here. If so yes you can. I don't know what the equivalent on Windows is, but in Linux you can use dlopen and friends. There is a man page for it, and several web sites documenting it. Try this link "http://linux.die.net/man/3/dlopen" it provides you with a nice examp... | 1 | 2 | 0 | I'm working with an API which is distributed as a dll/so file that I need to dynamically link with my python program. To accomplish this, I want to use Cython.
I have been able to, in the past, link with the dll statically. This works well, except that the API comes in four different flavors, with theoretically infini... | Cython: Dynamically linking with a dll/so | 1.2 | 0 | 0 | 981 |
6,546,786 | 2011-07-01T10:31:00.000 | 0 | 0 | 0 | 0 | python,inheritance,superclass | 6,546,832 | 1 | true | 1 | 0 | I am not sure I entirely understood your question, but are you sure you need to use inheritance? Couldn't the class you need just be a member instead?
Changing the superclass at runtime does not sound like a very good design, if at all possible.
Just to be sure I got you, what you want to do is have Controller inherit ... | 1 | 0 | 0 | in my webapp I made two different sessionhandler classes inheriting from a class called SessionHandler
Now I'd like to initiate the appropriate handler (dependent on a cookie value.)
Background: My SessionHandler should be the base class of the Controller as it needs to call a Controller backend method otherwise i woul... | class definition dependence on runtime | 1.2 | 0 | 0 | 77 |
6,547,863 | 2011-07-01T12:20:00.000 | 1 | 0 | 0 | 0 | python,django,dependency-management,legacy-code,modularity | 7,359,061 | 1 | true | 1 | 0 | Start by decoupling the components where possible, and convert the legacy code to (portable) apps if not the case already, and the legacy code should not live under the main project tree.
Any new features should be well documented and decoupled apps or generic libraries themselves, even if they override/interact/depend... | 1 | 4 | 0 | I am right now in the situation to plan the internationalization of a django project that contains mainly legacy code. The old project itself has different applications which have a strong dependency to each other, so it is hard to separate them. Looking at the time left it is impossible at all.
The main requirements f... | Dealing with legacy django project in new localized projects | 1.2 | 0 | 0 | 184 |
6,548,496 | 2011-07-01T13:20:00.000 | 6 | 1 | 0 | 0 | python,unit-testing,nose | 6,548,606 | 2 | true | 0 | 0 | I respectfully suggest that changing the meaning of "broken" is a bad idea.
The meaning of a failed/"red" test should never be anything other than "this functionality is broken". To do anything else risks diluting the value of the tests.
If you implement this and then next week a handful of tests fail, would it be an... | 1 | 9 | 0 | I want to my tests to fail if they take longer than a certain time to run (say 500ms) because it sucks when a load of slightly slow tests mount up and suddenly you have this big delay every time you run the test suite. Are there any plugins or anything for Nose that do this already? | Making Nose fail slow tests | 1.2 | 0 | 0 | 1,155 |
6,549,488 | 2011-07-01T14:44:00.000 | 1 | 0 | 0 | 1 | python,linux,zeromq | 6,550,992 | 3 | false | 0 | 0 | I'm pretty sure sending with ZeroMQ will be substantially quicker than saving and loading files.
There are other ways to send information over the network, such as raw sockets (lower level), AMQP implementations like RabbitMQ (more structured/complicated), HTTP requests/replies, and so on. ZeroMQ is a pretty good optio... | 3 | 1 | 1 | Suppose that you have a machine that gets fed with real-time stock prices from the exchange. These prices need to be transferred to 50 other machines in your network in the fastest possible way, so that each of them can run its own processing on the data.
What would be the best / fastest way to send the data over to th... | Distributing Real-Time Market Data Using ZeroMQ / NFS? | 0.066568 | 0 | 0 | 1,280 |
6,549,488 | 2011-07-01T14:44:00.000 | 1 | 0 | 0 | 1 | python,linux,zeromq | 6,552,072 | 3 | true | 0 | 0 | I would go with zeromq with pub/sub sockets..
in your 2 option, your "clients" will have to refresh in order to get your file modifications.. like polling.. if you have some write error, you will have to handle this by hand, which won't be easy as well..
zeromq is simple, reliable and powerful.. i think that perfectly ... | 3 | 1 | 1 | Suppose that you have a machine that gets fed with real-time stock prices from the exchange. These prices need to be transferred to 50 other machines in your network in the fastest possible way, so that each of them can run its own processing on the data.
What would be the best / fastest way to send the data over to th... | Distributing Real-Time Market Data Using ZeroMQ / NFS? | 1.2 | 0 | 0 | 1,280 |
6,549,488 | 2011-07-01T14:44:00.000 | 0 | 0 | 0 | 1 | python,linux,zeromq | 6,643,883 | 3 | false | 0 | 0 | Definatly do NOT use the file system. ZeroMQ is a great solution wiht bindings in Py. I have some examples here: www.coastrd.com. Contact me if you need more help. | 3 | 1 | 1 | Suppose that you have a machine that gets fed with real-time stock prices from the exchange. These prices need to be transferred to 50 other machines in your network in the fastest possible way, so that each of them can run its own processing on the data.
What would be the best / fastest way to send the data over to th... | Distributing Real-Time Market Data Using ZeroMQ / NFS? | 0 | 0 | 0 | 1,280 |
6,549,669 | 2011-07-01T15:00:00.000 | 35 | 0 | 0 | 1 | python | 6,549,740 | 7 | true | 0 | 0 | When you pass a negative PID to kill, it actually sends the signal to the process group by that (absolute) number. You do the equivalent with os.killpg() in Python. | 1 | 27 | 0 | for example from bash:
kill -9 -PID
os.kill(pid, signal.SIGKILL) kill only parent process. | how to kill process and child processes from python? | 1.2 | 0 | 0 | 63,568 |
6,550,003 | 2011-07-01T15:30:00.000 | 0 | 0 | 0 | 0 | python,django,django-models,django-views | 6,553,381 | 1 | true | 1 | 0 | Here is a possible answer for the question i figured out:
Getting the list of albums in a string, in my case separated by commas
You need to import shutil, then:
@login_required
def remove_albums(request):
if request.is_ajax():
if request.method == 'POST':
#if the ajax call for delete what ok ... | 1 | 1 | 0 | I have a photo gallery with an album model (just title and date and stuff) and a photo model with a foriegn key to the album and three imageFields in it (regular, mid and thumb).
When a user delete an album i need to delete all the photos reletaed to the album (from server) then all the DB records that point to the alb... | How to delete an object and all related objects with all imageFields insite them (photo gallery) | 1.2 | 1 | 0 | 80 |
6,550,005 | 2011-07-01T15:30:00.000 | 1 | 0 | 0 | 0 | python,lxml | 6,552,762 | 4 | false | 0 | 0 | For pure python libraries, you can do that. Unfortunately, lxml depends on a bunch of compiled c code, so it's not going to be generally portable in the way you want.
Using virtualenv is a good alternative, since it helps isolate a project and the installed files. For lxml to work, you'll need the libraries necessary ... | 1 | 5 | 0 | I need to perform some xml parsing using a machine that I may not have permission to install libraries in. So is it possible to include a python library like lxml with my source? | Is it possible to include a library like lxml without installing it? | 0.049958 | 0 | 1 | 1,197 |
6,552,097 | 2011-07-01T18:51:00.000 | 1 | 0 | 1 | 0 | python,multithreading | 6,552,616 | 3 | false | 0 | 0 | You can have a reference to parent thread on child thread.. and then get it's ID | 1 | 6 | 0 | I looking for the way to get parent ID or name from child thread.
In example, I have main thread as MainThread. In this thread i create a few new threads. Then I use threading.enumerate() to get references to all running thread, pick one of child threads and somehow get ID or name of MainThread. Is any way to do that? | threading - how to get parent id/name? | 0.066568 | 0 | 0 | 7,432 |
6,554,653 | 2011-07-02T01:52:00.000 | 7 | 0 | 1 | 0 | python,immutability,mutable,language-theory | 6,555,518 | 4 | false | 0 | 0 | If you like the idea of immutability, you should check out a pure functional language. In Haskell all (pure) variables are immutable (yet still referred to as "variables", but there you go). It is a great idea - you and the compiler both know that passing something into a function cannot change it in any way. | 2 | 18 | 0 | One of the things that I admire about Python is its distinction between mutable and immutable types. Having spent a while programming in c before coming to Python, I was astonished at how easily Python does away with all the complexities of pointer dereferencing that drive me mad in c. In Python everything just works t... | What is the theory behind mutable and immutable types? | 1 | 0 | 0 | 2,057 |
6,554,653 | 2011-07-02T01:52:00.000 | 4 | 0 | 1 | 0 | python,immutability,mutable,language-theory | 6,555,012 | 4 | true | 0 | 0 | Objective C is loaded with mutable/immutable distinctions (to the point where there are both NSString and NSMutableString, for example); it predates Python by about 8 years. Smalltalk, from which Objective C inherited much of its OO design, uses the concept to a lesser extent (notably, strings are not immutable; the tr... | 2 | 18 | 0 | One of the things that I admire about Python is its distinction between mutable and immutable types. Having spent a while programming in c before coming to Python, I was astonished at how easily Python does away with all the complexities of pointer dereferencing that drive me mad in c. In Python everything just works t... | What is the theory behind mutable and immutable types? | 1.2 | 0 | 0 | 2,057 |
6,556,035 | 2011-07-02T08:55:00.000 | 1 | 0 | 0 | 0 | python,dns | 6,556,075 | 1 | false | 0 | 0 | Setting up a proxy in your browser tells it where to make TCP connections; it doesn't have anything to do with how it queries DNS, which is determined by your operating system's resolver.
For Linux you'd just shut down bind, e.g. Debian /etc/init.d/bind9 stop; then your Python script would catch the traffic on port 53.... | 1 | 0 | 0 | i am still a novice in these areas so here is my question:
I want to see the dns request sent out by my browser (say chrome).so i set up a udp server in python with host='' and port=21567(can be anything other than the previlaged and reserved ones).i set my server to listen for connections using the udp.recvfrom(1024)
... | Web dev in python | 0.197375 | 0 | 1 | 84 |
6,557,000 | 2011-07-02T12:32:00.000 | 0 | 0 | 0 | 0 | python,function,import,call,web2py | 6,846,235 | 2 | false | 1 | 0 | you can create python files in modules folder and import them just like how you import python libraries in your controllers. But you have to give the path to those files like
from applications.myApp.modules.myModule import *
this is my solution for my wrappers. now you can use your functions by calling their name
myF... | 1 | 1 | 0 | I have split the code into multiple files. I have imported all the functions from all other files into admin.py. Lets say I want to call a function XYZ. If I give path to function as admin/XYZ it gives me error as invalid function and for this I have to give the path as file_with_XYZ_function/XYZ.
Is there a way to ove... | Function call using import in web2py | 0 | 0 | 1 | 3,186 |
6,557,112 | 2011-07-02T12:53:00.000 | 2 | 0 | 1 | 0 | python,persistence,save | 6,557,181 | 2 | false | 0 | 0 | Use the logging module from the standard library. It is designed to provide a flexible framework for logging information from a running application (across modules and source files).
In particular, it supports the notion of handlers, allowing you to send logging information into various sinks: files, sockets, email, s... | 1 | 3 | 0 | I have a program where I want to record the function name, parameters passed to the function and the result. I am currently recording this using a decorator. However I am unsure how to store this. Currently I am just appending to a file each time.
I want to just be able to add my decorators to any function in any pytho... | Storing data on the fly with Python | 0.197375 | 0 | 0 | 269 |
6,558,765 | 2011-07-02T18:15:00.000 | 10 | 0 | 1 | 1 | python,macos | 54,629,284 | 10 | false | 0 | 0 | In IPython %history -g should give you the entire command history. The default configuration also saves your history into a file named .python_history in your user directory. | 2 | 195 | 0 | I'm working on the default python interpreter on Mac OS X, and I Cmd+K (cleared) my earlier commands. I can go through them one by one using the arrow keys. But is there an option like the --history option in bash shell, which shows you all the commands you've entered so far? | How do you see the entire command history in interactive Python? | 1 | 0 | 0 | 137,835 |
6,558,765 | 2011-07-02T18:15:00.000 | 62 | 0 | 1 | 1 | python,macos | 39,063,906 | 10 | false | 0 | 0 | With python 3 interpreter the history is written to
~/.python_history | 2 | 195 | 0 | I'm working on the default python interpreter on Mac OS X, and I Cmd+K (cleared) my earlier commands. I can go through them one by one using the arrow keys. But is there an option like the --history option in bash shell, which shows you all the commands you've entered so far? | How do you see the entire command history in interactive Python? | 1 | 0 | 0 | 137,835 |
6,558,957 | 2011-07-02T18:57:00.000 | 3 | 0 | 1 | 0 | python,python-c-api | 6,558,981 | 1 | true | 0 | 0 | Basically, you use the Python C API to get the module the function is contained in, then query the module dictionary for the function. That's more or less the same what the Python runtime does internally when your Python code invokes a function from somewhere.
Relevant functions from the API to look at are PyImport_Imp... | 1 | 2 | 0 | From the c-api, I would like to call a python function by name. I would then be calling the function with a list of python objects as arguments.
It is not clear to me in the Python documentation how I would get a "Callable" object from the main python interpreter.
Any help appreciated in:
Getting the address from the... | How to call a python function by name from the C-API? | 1.2 | 0 | 0 | 1,070 |
6,559,656 | 2011-07-02T21:17:00.000 | 4 | 0 | 1 | 0 | python | 6,559,698 | 1 | true | 0 | 0 | Why not just modify sys.path to include the directory one level down? Then the same imports will work in both places. | 1 | 0 | 0 | I have dev and production systems.
My production system is different from my dev system in that that it adds one directory to the beginning path.
for eg. on dev system:
main->module1->module2
becomes on production:
project_name->main->module1->module2.
Because of that I have to change all my imports to accommodate for ... | Importing modules with variable paths? | 1.2 | 0 | 0 | 53 |
6,561,896 | 2011-07-03T08:32:00.000 | 7 | 0 | 1 | 0 | python,file-io | 6,561,905 | 1 | false | 0 | 0 | Use fileobject.seek(offset). | 1 | 0 | 0 | I'm writing a file reader for my (binary) format and I sometimes need to skip some portion of the file.
I could do fileobject.read(howmuchtoskip) for that, but I guess that will load the unneeded part to memory and will be slow.
Can I just set the "index" of the "pointer" or whatever that's called? | Skipping data in a binary file in Python | 1 | 0 | 0 | 572 |
6,562,148 | 2011-07-03T09:45:00.000 | 0 | 0 | 1 | 0 | python,string,date | 6,675,013 | 5 | false | 0 | 0 | I found the following very useful for converting the time to a uniform format and then searching for this format pattern:
from datetime import datetime
date_object = datetime.strptime('March-1-05', '%B-%d-%y')
print date_object.strftime("%B %d, %Y") | 1 | 10 | 0 | I want to be able to read a string and return the first date appears in it. Is there a ready module that I can use? I tried to write regexs for all possible date format, but it is quite long. Is there a better way to do it? | Python - finding date in a string | 0 | 0 | 0 | 7,917 |
6,565,728 | 2011-07-03T21:41:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,blackberry,attachment,vcf-vcard | 6,602,467 | 2 | true | 1 | 0 | Obviously as I mentioned on my comment above:
- it has nothing to do with Google App Engine
- some devices are just not able to read vcards in format 3.0
But I haven't found a good parser/ converter so far (from vcard 3.0 to vcard 2.1 in python) so if anyone knows one, please let me know. Otherwise, I'll have to build... | 1 | 2 | 0 | I'm using App Engine with Python. My application basically sends vcards (.vcf) by email when users request it.
Indeed, files with .vcf extension are supported by App Engine. I use the mail API to send them as attachment. Before, I stored them as db.Blob().
Problem:
Most of the time, Blackberry users cannot read the vc... | Attachments in mails sent via App Engine not readable on every mail client/ device | 1.2 | 0 | 0 | 391 |
6,566,264 | 2011-07-03T23:52:00.000 | 0 | 0 | 0 | 0 | python,user-interface | 6,566,268 | 3 | false | 0 | 1 | The best GUI's for Python are tkinter, Qt (PyQt), and wx (wxPython). Search any of those terms to learn more. | 2 | 0 | 0 | I'm attempting to convert a Python application I coded using the cmd module into a gui. Initially, I came across EasyGui. But after giving it a try, I find that it is very limited, the gui screens are not consistent, and overall not easy on the eyes. I read about IronPython (Python + .NET), but cannot find adequate doc... | Is there a preferred Python gui to use | 0 | 0 | 0 | 1,559 |
6,566,264 | 2011-07-03T23:52:00.000 | 5 | 0 | 0 | 0 | python,user-interface | 6,566,327 | 3 | true | 0 | 1 | Tkinter is in the standard library, works on all platforms, and is fairly simple and lightweight, but it looks a bit clunky.
WxPython tries to use platform widgets, so it looks a bit better, but it's a separate library. On Linux, I still find it doesn't look quite right.
PyQt is a large, powerful framework - it looks g... | 2 | 0 | 0 | I'm attempting to convert a Python application I coded using the cmd module into a gui. Initially, I came across EasyGui. But after giving it a try, I find that it is very limited, the gui screens are not consistent, and overall not easy on the eyes. I read about IronPython (Python + .NET), but cannot find adequate doc... | Is there a preferred Python gui to use | 1.2 | 0 | 0 | 1,559 |
6,566,880 | 2011-07-04T02:48:00.000 | 5 | 0 | 1 | 0 | python,multiprocessing,zeromq | 6,577,473 | 2 | false | 0 | 0 | You can't compare apples and oranges.
multiprocessing is a library to fork many processes.
zmq is a library that allows processes to use messages to communicate.
They do different jobs. | 1 | 4 | 0 | I'd like to write python code that loads a data set as input and analyzes it.
There will be 5 parallel processes that will analyze the data -- each process will be processing the data differently -- in a unique way.
Before any processing will begin, the master script (the one that will 'start' all the different sub-pr... | Multi-Core Python: multiprocessing Vs. zeroMQ? | 0.462117 | 0 | 0 | 3,748 |
6,567,511 | 2011-07-04T05:11:00.000 | 2 | 0 | 1 | 0 | python,mongodb | 6,567,552 | 1 | false | 0 | 0 | (1) Create a unique index on the related columns and catch the error upon insertion time | 1 | 0 | 0 | (1) What's the fastest way to check if an item I'm about to "insert" into a MongoDB collection is unique (and if so not insert it)
(2) For an existing database, what's the fastest way to look at all the entries and remove duplicates but keep one copy i.e. like a "set" function: {a,b,c,a,a,b} -> {a,b,c}
I am aware that... | Fastest Way to (1) not insert duplicate entry (2) consolidate duplicates in Mongo DB? | 0.379949 | 1 | 0 | 824 |
6,569,721 | 2011-07-04T09:41:00.000 | 0 | 0 | 0 | 0 | python,django,django-models,loading | 6,569,873 | 2 | false | 1 | 0 | First, this is a Python question, not a Django one as modules are a Python concept.
Secondly, there is no such thing as static loading in Python because it's an dynamic language by essence.
Therefor, loading a module in Python is always dynamic.
The only thing you should know are:
once a module is imported, the code i... | 1 | 0 | 0 | Is any difference between the dynamically loading and static loading modules in Django?
How about its efficiency? Who can tell me the principles about the mechanism of dynamically loading and static loading modules in Django? | Dynamically loading and static loading modules in Django | 0 | 0 | 0 | 910 |
6,570,635 | 2011-07-04T11:07:00.000 | 0 | 0 | 1 | 0 | python,pip | 72,422,110 | 4 | false | 0 | 0 | Another "workaround" is to use IPC/RPC and run isolated packages in services. If the dependencies are on the different libraries, maybe can separate by the usage of the packages. | 1 | 115 | 0 | In my application I would like to use:
packageA, which requires packageX==1.3
packageB, which requires packageX==1.4
packageX==1.5
How can I install multiple versions of packageX with pip to handle this situation? | Installing multiple versions of a package with pip | 0 | 0 | 0 | 54,635 |
6,570,892 | 2011-07-04T11:33:00.000 | 1 | 0 | 1 | 1 | python,perl,date,calendar | 6,571,157 | 2 | false | 0 | 0 | Did you think about scheduling the invoke of your script?
For me, the best approach is this:
1.Have two options to run the script:
run_script
run_script --update
2.Schedule the update run in some task scheduler (for example Cron) to be executed daily.
3.When you would want to check the image for current day, simply r... | 1 | 3 | 0 | I would like to write a tiny calendar-like application for someone as a birthday present (to be run on Ubuntu). All it should do is display a separate picture each day, so whenever it's invoked it should check the date and select the appropriate picture from the collection I would provide, but also, in case it just kee... | How to periodically check for the current date from within a program? | 0.099668 | 0 | 0 | 328 |
6,572,203 | 2011-07-04T13:31:00.000 | 1 | 0 | 0 | 0 | python,django,deployment,architecture,amazon-web-services | 6,574,660 | 1 | false | 1 | 0 | This isn't really a Django question. It is more a Python Question.
However to answer your question Django is going to have to be able to import these files one way or another. If they are on seperate machines you really should refactor the code out into it's own app and then install this app on each of the machines.
Th... | 1 | 2 | 0 | Our site has two separate projects connected to the same database. This is implemented by importing the models from project1 into project2 and using it to access and manipulate data.
This works fine on our test server, but we are planning deployment and we decided we would rather have the projects on two separate machi... | separate django projects on different machines using a common database | 0.197375 | 1 | 0 | 253 |
6,573,646 | 2011-07-04T15:52:00.000 | 1 | 0 | 1 | 1 | python,macos,multiprocessing | 6,580,433 | 2 | true | 0 | 0 | The problem is that multiprocessing uses os.fork on unix. So the sub-process becomes a copy of the main process. Dont know what's going on with Fedora, but it shouldn't work on linux either.
There doesn't seem to be any easy way to get around it. | 1 | 2 | 0 | modules exists inside new processes before import, using python-multiprocessing on osx.
Here's an example:
import multiprocessing
import sys
import os
print 'importing module'
def main():
import uuid
print 'setting var'
uuid.some_variable = True
def process(name):
print 'uuid module loaded:', 'uu... | multiprocessing import modules on mac | 1.2 | 0 | 0 | 848 |
6,574,274 | 2011-07-04T17:04:00.000 | 11 | 0 | 1 | 0 | python,coroutine | 6,574,545 | 2 | true | 0 | 0 | Coroutines don't really improve performance except in a very limited sense: multi-threaded programs have a certain overhead and coroutines provide some of the benefit of threading without incurring those overheads. However, most multi-threaded applications (even in C-Python with its GIL) benefit from the overlap when o... | 1 | 16 | 0 | I've been seeing a lot of talks and articles on coroutines in python. They are considered to be "microthreads" and I've heard they improve performance.
How do coroutines improve performance? From what I've seen so far, they are single threaded and execute in sequence. I agree that from a design perspective they are qui... | How do coroutines improve performance | 1.2 | 0 | 0 | 4,078 |
6,574,701 | 2011-07-04T17:57:00.000 | 1 | 0 | 1 | 0 | python,import | 6,574,748 | 1 | true | 0 | 0 | I use this sort of approach in some of my testing code. I want to test output from one version of a module against a different versions of the same module. Being able to iterate over different module instances makes the code cleaner.
But this sort of code is the exception to the rule. It's very infrequently that this... | 1 | 1 | 0 | I recently learned of the __ import__ function and found that I could store a module in a variable, so I was thinking of making a list of modules and then calling the appropriate one when necessary.
So I might have three modules test1, test2, test3, each containing a single function "print_hello" that simply prints "he... | Storing a list of modules | 1.2 | 0 | 0 | 78 |
6,574,740 | 2011-07-04T18:04:00.000 | 0 | 1 | 0 | 0 | java,c++,python,math,matlab | 6,574,755 | 5 | false | 1 | 0 | I think you can use PHP or Java Web. | 2 | 3 | 0 | I am very new to programming. I am familiar with HTML, C++ and learning PHP to start a database.
I want to make a website which tracks a stock price. I have written various algorithms in Matlab however, MATLAB only has a to-Java conversion.
I was wondering what language would be the best to do a lot of calculations. ... | Math Intensive, Calculation Based Website - Which Language Should I Use? | 0 | 0 | 0 | 1,004 |
6,574,740 | 2011-07-04T18:04:00.000 | 0 | 1 | 0 | 0 | java,c++,python,math,matlab | 6,574,803 | 5 | false | 1 | 0 | I would do C++ and write them to a database, then using php you can grab them from the same database and show them online, otherwise then java can do all that but make sure all calculations aren't done on the fly since that will kill your server, especially with stocks that can turn into a lot of data. | 2 | 3 | 0 | I am very new to programming. I am familiar with HTML, C++ and learning PHP to start a database.
I want to make a website which tracks a stock price. I have written various algorithms in Matlab however, MATLAB only has a to-Java conversion.
I was wondering what language would be the best to do a lot of calculations. ... | Math Intensive, Calculation Based Website - Which Language Should I Use? | 0 | 0 | 0 | 1,004 |
6,575,280 | 2011-07-04T19:12:00.000 | 0 | 0 | 0 | 0 | python,django,django-authentication | 8,865,656 | 1 | false | 1 | 0 | I don't profess to be a web security expert, but I've done something similar in the past. As long as you properly set the cookie domain (which you claim to be doing) I don't really see any security issues, especially since both sites are on the same domain.
If you really want to be safe I suppose you could set up your ... | 1 | 3 | 0 | I'm trying to implement single sign-on using only django auth.
Let's assume two django projects, on different sub-domains: site.com(auth) and app1.site.com(app1)
The auth table in site.com is master. site.com handles: login, logout, account registration, etc.
site.com sets SESSION_COOKIE_DOMAIN to .site.com to allow it... | Implementation of sso with django auth. Is this safe? | 0 | 0 | 0 | 530 |
6,576,909 | 2011-07-04T23:45:00.000 | 0 | 0 | 0 | 0 | python,django,web-services,authentication | 6,576,961 | 1 | false | 1 | 0 | Not really sure what you're looking to do as it doesn't make much sense. But you need to validate data provided by users on your site against data available in another database that isn't accessible to your app.
This means you need to send the data your users are providing to you to the other service that is providi... | 1 | 1 | 0 | I'm trying to make a website that requires users to enter information about themselves. In order to check to see if this information is correct, it needs to enter the information on another website (that has an entire database of these types of users). It will then return the results found. How do I do such a thing? Wh... | Accessing forms from one website to another, python/django | 0 | 0 | 0 | 88 |
6,577,657 | 2011-07-05T03:04:00.000 | 1 | 0 | 0 | 0 | python,arrays,performance,numpy | 6,581,184 | 1 | true | 0 | 0 | As I see it, if you were doing this in C or Fortran, you'd have to have an idea of the size of the array so that you can allocate the correct amount of memory (ignoring realloc!). So assuming you do know this, why do you need to append to the array?
In any case, numpy arrays have the resize method, which you can use to... | 1 | 1 | 1 | I'm still confused whether to use list or numpy array.
I started with the latter, but since I have to do a lot of append
I ended up with many vstacks slowing my code down.
Using list would solve this problem, but I also need to delete elements
which again works well with delete on numpy array.
As it looks now I'll hav... | Efficient Datatype Python (list or numpy array?) | 1.2 | 0 | 0 | 762 |
6,577,807 | 2011-07-05T03:49:00.000 | 0 | 0 | 1 | 0 | python,matplotlib | 6,580,497 | 2 | false | 0 | 0 | You may use plt.annotate or plt.text.
And, as an aside, 1) you probably want to use different variables for the file names and numpy arrays you're loading your data into (what is data in data=plb.loadtxt(data)),
2) you probably want to move the label positioning into the loop (in your code, what is data in the plt.cl... | 1 | 0 | 1 | How can I use pyplot.clabel to attach the file names to the lines being plotted?
plt.clabel(data) line gives the error | matplotlib.pyplot how to add labels with .clabel? | 0 | 0 | 0 | 1,086 |
6,578,452 | 2011-07-05T05:59:00.000 | 13 | 0 | 1 | 0 | python,obfuscation | 6,578,598 | 3 | false | 0 | 0 | I would suggest you go back into thinking about this, considering:
Use the right tool for the job
Obfuscation is hard
Other means to achieve your goals
Firstly, Python was not designed to be obfuscated. Every aspect of the language is free and accessible to anybody who wants to inspect or modify it. Being a bytecode ... | 3 | 7 | 0 | we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but ... | how to encrypt python source code? | 1 | 0 | 0 | 13,175 |
6,578,452 | 2011-07-05T05:59:00.000 | 3 | 0 | 1 | 0 | python,obfuscation | 6,579,423 | 3 | false | 0 | 0 | Anything can be reverse engineered. It is not possible to give a user's machine information without the possibility for the user to examine that information. All you can do is make it take more effort.
Python is particularly bad if you have this requirement, because Python bytecode is much easier to read than fully ass... | 3 | 7 | 0 | we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but ... | how to encrypt python source code? | 0.197375 | 0 | 0 | 13,175 |
6,578,452 | 2011-07-05T05:59:00.000 | 4 | 0 | 1 | 0 | python,obfuscation | 6,578,518 | 3 | false | 0 | 0 | separate confidential functionality in C functions and develop SWIG wrappers. If you are using C++, you can consider boost python. | 3 | 7 | 0 | we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but ... | how to encrypt python source code? | 0.26052 | 0 | 0 | 13,175 |
6,579,467 | 2011-07-05T07:53:00.000 | 13 | 0 | 0 | 1 | python,django,multithreading,wsgi,flask | 6,587,335 | 2 | false | 1 | 0 | WSGI does not specify the lifetime of an application process (as WSGI application is a Python callable object). You can run it in a way that is completely independent of the web server, in which case, only you control the lifetime.
There is also nothing in the WSGI that would prohibit you from spawning threads, or proc... | 1 | 14 | 0 | To achieve something similar to google app engines 'deferred calls' (i.e., the request is handled, and afterwards the deferred task is handled), i experimented a little and came up with the solution to spawn a thread in which my deferred call is handled.
I am now trying to determine if this is an acceptable way.
Is it ... | Is it ok to spawn threads in a wsgi-application? | 1 | 0 | 0 | 3,562 |
6,579,723 | 2011-07-05T08:20:00.000 | 7 | 1 | 1 | 0 | python,vim | 57,220,317 | 8 | false | 0 | 0 | The way I do it is not specific to functions. It will just select a continuous block of Python code:
v]] if what you want to select is below the cursor
v[[ if it is above the cursor.
Just remove one bracket if the cursor is on the first line of the code block you want to select. | 5 | 18 | 0 | Is it possible without any plugins?
Or what's the best plugin for edit python file? | what's the fastest way to select a function of Python via VIM? | 1 | 0 | 0 | 5,089 |
6,579,723 | 2011-07-05T08:20:00.000 | 0 | 1 | 1 | 0 | python,vim | 64,190,015 | 8 | false | 0 | 0 | I try to avoid visual, hence for actions like yank, I tend to go to the beginning of the paragraph [[, yank till the end y]] and come back ^o.
All in one, it is [[y]]^o (With ^ standing for control).
For visual you might use [[v]] or some variations like [[v][, [[v]m, or [[v]M. | 5 | 18 | 0 | Is it possible without any plugins?
Or what's the best plugin for edit python file? | what's the fastest way to select a function of Python via VIM? | 0 | 0 | 0 | 5,089 |
6,579,723 | 2011-07-05T08:20:00.000 | 2 | 1 | 1 | 0 | python,vim | 59,506,958 | 8 | false | 0 | 0 | I normally use vip or any of the above depending on the need, do not forget that you can always select up (i.e., down =)) to the next occurrence using v/match (followed by Enter to confirm, and possibly n for next). For python, you could look for the next def or for the return (ret is normally enough).
This isn't the... | 5 | 18 | 0 | Is it possible without any plugins?
Or what's the best plugin for edit python file? | what's the fastest way to select a function of Python via VIM? | 0.049958 | 0 | 0 | 5,089 |
6,579,723 | 2011-07-05T08:20:00.000 | 0 | 1 | 1 | 0 | python,vim | 68,185,960 | 8 | false | 0 | 0 | If your function is long or has many blank lines, using v}}...}}d is pretty slow.
The quickest way I've found (without plug-ins) is zc2dd. The command zc closes the fold under the cursor, so if you are at the function declaration or any line at the outermost indent level, the whole function will fold. Then 2dd (or 3dd ... | 5 | 18 | 0 | Is it possible without any plugins?
Or what's the best plugin for edit python file? | what's the fastest way to select a function of Python via VIM? | 0 | 0 | 0 | 5,089 |
6,579,723 | 2011-07-05T08:20:00.000 | 14 | 1 | 1 | 0 | python,vim | 6,597,250 | 8 | false | 0 | 0 | try vis to visualy select and o to jump edges | 5 | 18 | 0 | Is it possible without any plugins?
Or what's the best plugin for edit python file? | what's the fastest way to select a function of Python via VIM? | 1 | 0 | 0 | 5,089 |
6,580,723 | 2011-07-05T09:47:00.000 | 2 | 0 | 0 | 0 | python,sql,database | 6,580,794 | 2 | false | 0 | 0 | I think both will work, and both are equally bad ideas. :) My point is that implementing user authentication in python/pg has been done so many times in the past that there's hardly justification for writing it yourself. Have you had a look at Django, for example? It will take care of this for you, and much more, and l... | 2 | 0 | 0 | I'm writing my first web site, and am dealing with user registration.
One common problem to me like to everyone else is to detect user already exist.
I am writing the app with python, and postgres as database.
I have currently come up with 2 ideas:
1)
lock(mutex)
u = select from db where name = input_name
if u == null... | Detect users already exist in database on user registration | 0.197375 | 1 | 0 | 235 |
6,580,723 | 2011-07-05T09:47:00.000 | 0 | 0 | 0 | 0 | python,sql,database | 6,580,784 | 2 | false | 0 | 0 | Slightly different, I usually do a select query via AJAX to determine if a username already exists, that way I can display a message on the UI explaining that the name is already taken and suggest another before the submit the registration form. | 2 | 0 | 0 | I'm writing my first web site, and am dealing with user registration.
One common problem to me like to everyone else is to detect user already exist.
I am writing the app with python, and postgres as database.
I have currently come up with 2 ideas:
1)
lock(mutex)
u = select from db where name = input_name
if u == null... | Detect users already exist in database on user registration | 0 | 1 | 0 | 235 |
6,581,744 | 2011-07-05T11:13:00.000 | 1 | 0 | 0 | 0 | python,wxpython | 6,584,095 | 1 | true | 0 | 1 | I would use the SetItems() method, which according to the docs does the following: "Clear and set the strings in the control from a list".
Edit: myListCtrl.SetItems(ListOfStrings)
That will replace all the items in the control with whatever is in the list. | 1 | 0 | 0 | i have a wxlistbox in a class and i want to update the data inside the listbox from a different class.Is i possible to reload the class while leave the control from another class?if yes ,how?
eg:
i have two classes,Class A and Class B.In class A there is a wxlistbox.while starting the program class A initilise the wxli... | how to update a wxlistbox from a different class? | 1.2 | 0 | 0 | 169 |
6,582,404 | 2011-07-05T12:07:00.000 | 0 | 0 | 0 | 0 | python,pyqt4,spyder | 6,644,662 | 2 | false | 0 | 0 | Have you considered using PyQt's built-in MySQL support? This could make it a bit easier to display DB info, depending on what you want the interface to look like. | 1 | 0 | 0 | Im trying to use Spyder with pyodbc to connect mysql using a PyQT4 gui framework.
I have pyodbc in Spyder figure out.
How do I use PyQt4 to get info into gui's? I'm looking to use gui on Fedora and winx64.
Edit: I figured out the fedora driver. Can anyone help me with QMYSQL driver. | How connect Spyder to mysql on Winx64 and Fedora? | 0 | 1 | 0 | 842 |
6,582,741 | 2011-07-05T12:34:00.000 | 1 | 0 | 1 | 0 | python | 6,583,140 | 4 | false | 0 | 0 | You can return a tuple of (httplib.HTTPResponse, str) with the str being optionally None.
Definitely raise an exception for 1).
If you don't like returning a tuple, you can also create a "response object" i.e. an instance of a new class ( lets say SomethingResponse ) that encapsulates the HTTPResponse with optional mes... | 1 | 4 | 0 | This one's a structure design problem, I guess. Back for some advice.
To start: I'm writing a module. Hence the effort of making it as usable to potential developers as possible.
Inside an object (let's call it Swoosh) I have a method which, when called, may result in either success (a new object is returned -- for ins... | Multiple 'endings' to a function - return an object, return a string, raise an exception? | 0.049958 | 0 | 0 | 157 |
6,583,593 | 2011-07-05T13:41:00.000 | 0 | 0 | 0 | 0 | python,django | 6,584,353 | 1 | false | 1 | 0 | If you can, it's better to include the packages as an svn external / git module / etc. That way they're always available, even to others that checkout your project.
Short of that, virtualenv is the better solution. You still "install" the packages, but they are added to the virtual environment (hence the name). You get... | 1 | 0 | 0 | Is it possible to "install" third party django packages by sym linking them into your site directory?
For example, I'd like to use the django-registration package. However, I don't want to install django-registration into my site-packages directory. I'd rather just link django-registration/registration into my project... | Django installing packages via symlinking | 0 | 0 | 0 | 138 |
6,585,176 | 2011-07-05T15:29:00.000 | 4 | 0 | 1 | 0 | python,numpy | 6,585,193 | 2 | true | 0 | 0 | NumPy has been used on 64-bit systems of all types for years now. I doubt you will find anything new that doesn't show up elsewhere as well. | 1 | 1 | 1 | I am currently working with numpy on a 32bit system (Ubuntu 10.04 LTS).
Can I expect my code to work fluently, in the same manner, on a 64bit (Ubuntu) system?
Does numpy have an compatibility issues with 64bit python? | Python: 64bit Numpy? | 1.2 | 0 | 0 | 2,531 |
6,585,680 | 2011-07-05T16:11:00.000 | 3 | 0 | 1 | 0 | python,pydoc | 6,585,780 | 3 | false | 0 | 0 | help() is a Python function.
pydoc is a command-line interface to the same thing.
If you want to see more what pydoc does, take a look in pydoc.py (import pydoc; pydoc.__file__) and see what's in the cli function. It does do some extra importing magic, but I don't think it really needs to - help() accepts a string whic... | 1 | 1 | 0 | Are these two things different? The results that the two give in Python are similar. | Difference between pydoc and help()? | 0.197375 | 0 | 0 | 1,178 |
6,586,106 | 2011-07-05T16:51:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,login | 6,590,472 | 2 | false | 1 | 0 | No - the User API only provides the user's email address, an app-specific unique ID, and their nickname (Which, as you observe, is derived from the email address). | 1 | 0 | 0 | Currently the method nickname() in the Users class seem to return either the initial way you entered your username when you signed up for gmail (IE. "UseRnAme" if thats how you chose to type it, rather then "username" as it would show up when you log in on a google service) or the entire email if you signed up for a go... | Is it possible to fetch a google profile nickname and use in app engine apps? | 0 | 0 | 0 | 246 |
6,586,552 | 2011-07-05T17:31:00.000 | 11 | 0 | 0 | 0 | python,database,django,concurrency,thread-safety | 6,586,594 | 4 | true | 1 | 0 | This must be a very common situation. How do I handle it in a threadsafe way?
Yes.
The "standard" solution in SQL is to simply attempt to create the record. If it works, that's good. Keep going.
If an attempt to create a record gets a "duplicate" exception from the RDBMS, then do a SELECT and keep going.
Django, how... | 1 | 24 | 0 | In my Django app very often I need to do something similar to get_or_create(). E.g.,
User submits a tag. Need to see if
that tag already is in the database.
If not, create a new record for it. If
it is, just update the existing
record.
But looking into the doc for get_or_create() it looks like it's not thread... | Django: how to do get_or_create() in a threadsafe way? | 1.2 | 0 | 0 | 9,325 |
6,586,793 | 2011-07-05T17:53:00.000 | 2 | 1 | 1 | 1 | python,git | 6,587,062 | 1 | true | 0 | 0 | Have you tried running python setup.py install in the emesene directory? | 1 | 0 | 0 | Anyone knows how to build and run emesene - the chat client in Python - on OS X once you get the code from GitHub?
I have searched online and I cannot find a source that is working. I did find some documents on sidhosting website. But that did not work for me completely. Hence I need help here.
Thanks
Sumod | How to build and run emesene on OS X using Git | 1.2 | 0 | 0 | 73 |
6,587,095 | 2011-07-05T18:22:00.000 | 6 | 0 | 1 | 0 | python,haskell,multicore | 6,587,378 | 2 | false | 0 | 0 | The Python multiprocessing module has nothing to do with threads. It tries to provide an API similar to threading (which does expose threads) with processes underneath.
Python threads are mapped to OS threads, and if you create more threads than cores the exact same thing happens as if you'd do it in C (pthreads, Win A... | 1 | 6 | 0 | Maybe there's someone out there with the right interests that will know how to answer this. Basically the question is: What are the differences between the multiprocessing module in Python, and the parallelism in Haskell. For instance: are threads created in Python mapped to OS threads? If so, what if there are more th... | Haskell vs. Python threading model | 1 | 0 | 0 | 926 |
6,588,041 | 2011-07-05T19:46:00.000 | 3 | 1 | 1 | 0 | python,unicode-string,python-2.7 | 6,588,072 | 4 | true | 0 | 0 | Python natively supports Unicode. If you directly read and write from the first file to the second, then no data is lost as it copies the bytes verbatim. However, if you decode the string and then re-encode it, you'll need to make sure you use the right encoding. | 2 | 0 | 0 | I wrote a simple file parser and writer, but then I came across an article talking about the importance of unicode and then it occurred to me that I'm assuming the input file is ascii encoded, which may not be the case all the time, though it would be rare in my situation.
In those rare cases, I would expect UTF-8 enco... | Writing UTF-8 friendly parsers in python | 1.2 | 0 | 0 | 669 |
6,588,041 | 2011-07-05T19:46:00.000 | 2 | 1 | 1 | 0 | python,unicode-string,python-2.7 | 6,588,187 | 4 | false | 0 | 0 | If you are using Python 2.6 or later, you can use the io library and its io.open method to open the files you want. It has an encoding argument which should be set to 'utf-8' in your case. When you read or write the returned file objects, string are automatically en-/decoded.
Anyway, you don't need to do something spec... | 2 | 0 | 0 | I wrote a simple file parser and writer, but then I came across an article talking about the importance of unicode and then it occurred to me that I'm assuming the input file is ascii encoded, which may not be the case all the time, though it would be rare in my situation.
In those rare cases, I would expect UTF-8 enco... | Writing UTF-8 friendly parsers in python | 0.099668 | 0 | 0 | 669 |
6,589,499 | 2011-07-05T22:19:00.000 | 1 | 0 | 1 | 1 | python,directory | 6,589,637 | 3 | false | 0 | 0 | In general you cannot obtain this information. You should use argv to switch behaviour of your script. | 2 | 5 | 0 | How does one acquire the directory of the Windows Shortcut calling a python script. I'd like to have multiple shortcuts in various places pointing to one script that I could edit if I wanted, but where the directory from which the script is called is accessible. Is this possible?
This script would likely then be compi... | Get the directory of a Shortcut calling a Python Script | 0.066568 | 0 | 0 | 1,900 |
6,589,499 | 2011-07-05T22:19:00.000 | 5 | 0 | 1 | 1 | python,directory | 6,589,628 | 3 | true | 0 | 0 | The easiest solution is to just use a batch script instead of a shortcut.
All it needs is python C:\path\to\script\script.py, and the script will have the correct CWD.
The default when creating a shortcut on windows is for the Start in: property to be set to the folder the linked file resides in.
The script has no know... | 2 | 5 | 0 | How does one acquire the directory of the Windows Shortcut calling a python script. I'd like to have multiple shortcuts in various places pointing to one script that I could edit if I wanted, but where the directory from which the script is called is accessible. Is this possible?
This script would likely then be compi... | Get the directory of a Shortcut calling a Python Script | 1.2 | 0 | 0 | 1,900 |
6,589,684 | 2011-07-05T22:44:00.000 | 1 | 0 | 1 | 0 | python,django,macos,python-imaging-library | 6,590,829 | 5 | false | 1 | 0 | Second, would it be easier to set up
the entire environment on Ubuntu than
it is on a Mac?
To answer this question (though I never used Mac though): I never had problems setting up a python environment for Django development on Ubuntu. Though in any case you should go with the built-in Python version if possible. ... | 2 | 2 | 0 | I was trying to setup Django dev environment on Mac and arrived into a hell. It all started when trying to install PIL, which failed after trying 15 or so different recipes I found on blogs. So I wanted to install the Python, this time 2.7, and reinstall setuptools, easy_install, pip from scratch.
After just installin... | Django - Mac development, environment hell | 0.039979 | 0 | 0 | 2,030 |
6,589,684 | 2011-07-05T22:44:00.000 | 0 | 0 | 1 | 0 | python,django,macos,python-imaging-library | 6,599,875 | 5 | false | 1 | 0 | Yes I have had problems with MacOS. I think rather than trying to figure it out I just switched to Ubuntu. I use a mac with Ubuntu installed in VMware Fusion. I have developed on both and prefer the Ubuntu because I'm just more comfortable with installing packages and the file structure.
I love using the VM because I'm... | 2 | 2 | 0 | I was trying to setup Django dev environment on Mac and arrived into a hell. It all started when trying to install PIL, which failed after trying 15 or so different recipes I found on blogs. So I wanted to install the Python, this time 2.7, and reinstall setuptools, easy_install, pip from scratch.
After just installin... | Django - Mac development, environment hell | 0 | 0 | 0 | 2,030 |
6,590,343 | 2011-07-06T00:24:00.000 | 0 | 1 | 0 | 1 | python,mpi,mpich,mpiexec | 6,590,376 | 2 | false | 0 | 0 | Is mpdboot compatible with such a version of python? That's downright ancient, I didn't know there was even any distribution left that still shipped 2.3. Have you tried with 2.7? | 1 | 0 | 0 | I am trying to use the mpdboot command to start 4 processors on which to run my MPI program. I created a mpd.hosts file with 4 nodes (75, 77, 79 and 80). Each of them run python 2.3.4. I also modified the bashrc and cshrc files to ensure that the variables contain the path to the directory of the compiler libraries. I ... | Mpdboot: Deprecation Warning | 0 | 0 | 0 | 2,152 |
6,590,400 | 2011-07-06T00:33:00.000 | 0 | 0 | 0 | 1 | python,sockets,serversocket | 6,602,114 | 2 | true | 0 | 0 | It turns out that all I needed to do was to set the socket timeout to something lower, like 1 minute, the recv call will throw and exception after 1 minute. | 2 | 2 | 0 | I'm trying to determine if a server socket was shut down gracefully or not in python.
The program received files and if some error occurs during the send the file should be removed.
I know your first suggestion will be to let the client send either the length of the file or some terminating data to let the server know ... | Detecting graceful shut downs of sockets in python | 1.2 | 0 | 1 | 481 |
6,590,400 | 2011-07-06T00:33:00.000 | 1 | 0 | 0 | 1 | python,sockets,serversocket | 6,590,500 | 2 | false | 0 | 0 | If the other end has finished sending data, they should shutdown (2) the socket for writing. Then in your multiplexing loop you would be able to check if the socket has been shutdown for writing or has just be closed (writing & reading) by the remote end. This is a graceful shutdown and you can use select/poll/kqueue o... | 2 | 2 | 0 | I'm trying to determine if a server socket was shut down gracefully or not in python.
The program received files and if some error occurs during the send the file should be removed.
I know your first suggestion will be to let the client send either the length of the file or some terminating data to let the server know ... | Detecting graceful shut downs of sockets in python | 0.099668 | 0 | 1 | 481 |
6,590,688 | 2011-07-06T01:42:00.000 | 39 | 0 | 1 | 0 | python,django,virtualenv | 6,591,061 | 8 | false | 1 | 0 | I used to do the same until I started using libraries that are compiled differently depending on the environment such as PyCrypto. My PyCrypto mac wouldn't work on Cygwin wouldn't work on Ubuntu.
It becomes an utter nightmare to manage the repository.
Either way I found it easier to manage the pip freeze & a requiremen... | 4 | 367 | 0 | I'm thinking about putting the virtualenv for a Django web app I am making inside my git repository for the app. It seems like an easy way to keep deploy's simple and easy. Is there any reason why I shouldn't do this? | Is it bad to have my virtualenv directory inside my git repository? | 1 | 0 | 0 | 149,954 |
6,590,688 | 2011-07-06T01:42:00.000 | 24 | 0 | 1 | 0 | python,django,virtualenv | 6,590,779 | 8 | false | 1 | 0 | I think one of the main problems which occur is that the virtualenv might not be usable by other people. Reason is that it always uses absolute paths. So if you virtualenv was for example in /home/lyle/myenv/ it will assume the same for all other people using this repository (it must be exactly the same absolute path).... | 4 | 367 | 0 | I'm thinking about putting the virtualenv for a Django web app I am making inside my git repository for the app. It seems like an easy way to keep deploy's simple and easy. Is there any reason why I shouldn't do this? | Is it bad to have my virtualenv directory inside my git repository? | 1 | 0 | 0 | 149,954 |
6,590,688 | 2011-07-06T01:42:00.000 | 0 | 0 | 1 | 0 | python,django,virtualenv | 42,731,272 | 8 | false | 1 | 0 | If you just setting up development env, then use pip freeze file, caz that makes the git repo clean.
Then if doing production deployment, then checkin the whole venv folder. That will make your deployment more reproducible, not need those libxxx-dev packages, and avoid the internet issues.
So there are two repos. One f... | 4 | 367 | 0 | I'm thinking about putting the virtualenv for a Django web app I am making inside my git repository for the app. It seems like an easy way to keep deploy's simple and easy. Is there any reason why I shouldn't do this? | Is it bad to have my virtualenv directory inside my git repository? | 0 | 0 | 0 | 149,954 |
6,590,688 | 2011-07-06T01:42:00.000 | 0 | 0 | 1 | 0 | python,django,virtualenv | 59,330,598 | 8 | false | 1 | 0 | I think is that the best is to install the virtual environment in a path inside the repository folder, maybe is better inclusive to use a subdirectory dedicated to the environment (I have deleted accidentally my entire project when force installing a virtual environment in the repository root folder, good that I had th... | 4 | 367 | 0 | I'm thinking about putting the virtualenv for a Django web app I am making inside my git repository for the app. It seems like an easy way to keep deploy's simple and easy. Is there any reason why I shouldn't do this? | Is it bad to have my virtualenv directory inside my git repository? | 0 | 0 | 0 | 149,954 |
6,591,238 | 2011-07-06T03:25:00.000 | 2 | 0 | 0 | 0 | python,libcurl,pycurl | 6,691,232 | 1 | true | 0 | 0 | As with most bindings made for C libraries, it is clever to make a very thin layer on top of it to offer the most of it.
This said, it generally makes sense to wrap that binding itself then to offer more higher level features and more language-specific ways to do things, rather than to write yet another binding.
So no,... | 1 | 5 | 0 | PycURL is a thin wrapper around the C libcurl API, I wonder if there's any more pythonic wrapper for libcurl which supports CurlMulti ? | PyCurl alternative, a pythonic wrapper for libcurl? | 1.2 | 0 | 1 | 785 |
6,591,255 | 2011-07-06T03:27:00.000 | 1 | 0 | 0 | 0 | python,web-crawler,scrapy | 6,591,511 | 2 | false | 1 | 0 | If you want selective crawling, like fetching "Next" links for pagination etc., it's better to write your own crawler. But for general crawling, you should use crawlspider and filter out the links that you don't need to follow using Rules & process_links function.
Take a look at the crawlspider code in \scrapy\contrib\... | 1 | 9 | 0 | After several readings to Scrapy docs I'm still not catching the diferrence between using CrawlSpider rules and implementing my own link extraction mechanism on the callback method.
I'm about to write a new web crawler using the latter approach, but just becuase I had a bad experience in a past project using rules. I'd... | Following links, Scrapy web crawler framework | 0.099668 | 0 | 1 | 6,599 |
6,596,568 | 2011-07-06T12:44:00.000 | 1 | 0 | 0 | 0 | android,python,embed,android-ndk,sl4a | 15,260,692 | 1 | false | 0 | 1 | I recommend putting the NLP code into web services on a Linux server and calling those from android.
This is quite straight forward in a framework like django. | 1 | 7 | 0 | I am building an application for Android. It will interface with some C++ libraries using Android NDK through JNI. There are also some libraries that are written in Python that I want to call from my Android application (e.g. NTLK). How can I do that?
Please note that SL4A (Scripting Layer for Android) is something dif... | Want to use Python Libraries in Android | 0.197375 | 0 | 0 | 5,930 |
6,596,974 | 2011-07-06T13:14:00.000 | -2 | 0 | 0 | 0 | python,labview | 29,132,316 | 9 | false | 0 | 0 | Here is a good quick solution but kind of unelegant. Just use a text file that both labview and python can read/write from. Labview writes commands to text file and python waits until a command is read or vice versa. you can have a read text file and a write text file at the same time. However this is a slower solution... | 1 | 5 | 0 | How do I send data from LabView to Python and get a result back? | send data from LabView to Python and get back | -0.044415 | 0 | 0 | 18,951 |
6,598,835 | 2011-07-06T15:19:00.000 | -1 | 0 | 1 | 0 | python,overloading | 6,598,926 | 3 | false | 0 | 0 | I would leave it as two separate methods for the sake of code readabilty and maintainabilty. | 1 | 1 | 0 | I think the concept is called overloading.
Right now I'm writing a class that will provide getter and setter methods, and am stuck on a design issue.
Both methods are one-liners that simply set a value, or return a value.
def set_number(self, num):
self.count = num
def get_number(self):
return self.count
Wou... | "Method overloading" in python | -0.066568 | 0 | 0 | 325 |
6,599,686 | 2011-07-06T16:18:00.000 | 1 | 0 | 1 | 1 | python,packaging,setuptools | 6,599,711 | 3 | false | 0 | 0 | Run the script with /opt/bin/python script.py, or
edit the first line to read #!/opt/bin/python, or
put /opt/bin in your path before /usr/bin. | 1 | 4 | 0 | I have created a package that I will be distributing throughout the company that replaces a legacy bash script with the same name. It is referenced many places so it needs to execute like the current script does. This has worked fine until I encountered some servers that do not have a current version of Python as the d... | How do you specify the shebang line of a command script created by setuptools | 0.066568 | 0 | 0 | 4,584 |
6,599,716 | 2011-07-06T16:20:00.000 | 3 | 0 | 0 | 0 | python,database,django,sqlite,in-memory-database | 6,600,219 | 3 | true | 1 | 0 | Disconnect django.contrib.auth.management.create_superuser from the post_syncdb signal, and instead connect your own function that creates and saves a new superuser User with the desired password. | 1 | 1 | 0 | I'm trying to have a purely in-memory SQLite database in Django, and I think I have it working, except for an annoying problem:
I need to run syncdb before using the database, which isn't too much of a problem. The problem is that it needs to create a superuser (in the auth_user table, I think) which requires interacti... | Django In-Memory SQLite3 Database | 1.2 | 1 | 0 | 1,200 |
6,600,878 | 2011-07-06T18:00:00.000 | 2 | 0 | 1 | 0 | python,pip,easy-install,pypi | 20,098,161 | 18 | false | 0 | 0 | pip freeze lists all installed packages even if not by pip/easy_install.
On CentOs/Redhat a package installed through rpm is found. | 3 | 424 | 0 | Is there a way to find all Python PyPI packages that were installed with easy_install or pip? I mean, excluding everything that was/is installed with the distributions tools (in this case apt-get on Debian). | Find all packages installed with easy_install/pip? | 0.022219 | 0 | 0 | 479,337 |
6,600,878 | 2011-07-06T18:00:00.000 | 1 | 0 | 1 | 0 | python,pip,easy-install,pypi | 6,600,913 | 18 | false | 0 | 0 | Get all file/folder names in site-packages/ (and dist-packages/ if it exists), and use your package manager to strip the ones that were installed via package. | 3 | 424 | 0 | Is there a way to find all Python PyPI packages that were installed with easy_install or pip? I mean, excluding everything that was/is installed with the distributions tools (in this case apt-get on Debian). | Find all packages installed with easy_install/pip? | 0.011111 | 0 | 0 | 479,337 |
6,600,878 | 2011-07-06T18:00:00.000 | 9 | 0 | 1 | 0 | python,pip,easy-install,pypi | 43,012,269 | 18 | false | 0 | 0 | Newer versions of pip have the ability to do what the OP wants via pip list -l or pip freeze -l (--list).
On Debian (at least) the man page doesn't make this clear, and I only discovered it - under the assumption that the feature must exist - with pip list --help.
There are recent comments that suggest this feature is ... | 3 | 424 | 0 | Is there a way to find all Python PyPI packages that were installed with easy_install or pip? I mean, excluding everything that was/is installed with the distributions tools (in this case apt-get on Debian). | Find all packages installed with easy_install/pip? | 1 | 0 | 0 | 479,337 |
6,601,626 | 2011-07-06T19:08:00.000 | 4 | 0 | 0 | 0 | python,django | 6,601,656 | 1 | true | 1 | 0 | The _set suffix indicates that the attribute is a manager rather than a model, and should be retained in order to minimize confusion. | 1 | 1 | 0 | I am hoping to hear from some people with experience developing Django sites as part of some sort of team.
What is the naming convention most commonly seen for many-to-many relationships? Do most people stick with the entry_set default, or is it more common and easier to use a more symmetrical related_name='entries' a... | Django many-to-many relationships: prevailing naming convention | 1.2 | 0 | 0 | 336 |
6,601,812 | 2011-07-06T19:26:00.000 | 68 | 0 | 1 | 0 | python,json,serialization,nan | 6,602,204 | 3 | true | 0 | 0 | json.dumps has an allow_nan parameter, which defaults to True.
NaN, Infinity and -Infinity are not part of JSON, but they are standard in Javascript, so they're commonly used extensions. If the recipient can't handle them, set allow_nan=False. But then you'll get ValueError when you try to serialise NaN. | 1 | 89 | 0 | I am trying to encode an array which contains floats and NaN into JSON string from Python using json.dumps().
But the encoded JSON string is not being decoded successfully in PHP. Is the NaN causing this problem? How can I work around this situation? | sending NaN in json | 1.2 | 0 | 0 | 61,089 |
6,602,151 | 2011-07-06T19:57:00.000 | 1 | 0 | 0 | 0 | python,selenium,webdriver | 6,603,609 | 3 | false | 0 | 0 | I've tried the selenium-2 rc3 python bindings for chrome. My experience was the opposite of what you're describing - after clicking, the driver didn't know that the page was ready for it to continue. So instead of speeding up the tests, they turned out very slow (because the driver was waiting for ages). However, the f... | 3 | 4 | 0 | First off, sorry for the cryptic question.
My team is currently using Selenium 2.0rc3 (with python) for testing our web app with chrome. When we used the 2.02b version of Selenium, our test passed (it was a little slow and we had small hacks that we added to webdriver). After we upgraded, the test became extremely fast... | Selenium 2.0rc3 click function too fast? | 0.066568 | 0 | 1 | 2,381 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.