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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,415,649 | 2010-12-11T07:05:00.000 | 1 | 0 | 0 | 0 | python | 4,415,722 | 2 | false | 0 | 1 | If you're looking for a way to do it with just the standard Python library, the answer is probably "no" - or at the very least, "not in any straightforward manner". There are many things in the standard library, but gaming hardware support is not one of them. | 1 | 1 | 0 | Is there anyway I could register button pushes on a joystick without using any function from pygame? | Detecting an arbittrary button press on a USB joystick WITHOUT pygame | 0.099668 | 0 | 0 | 916 |
4,416,570 | 2010-12-11T11:50:00.000 | 3 | 0 | 0 | 0 | python,webkit,gtk | 4,421,093 | 2 | true | 1 | 1 | You can't. webview.load_uri() takes a string containing a URI. 'file.html' isn't a URI, 'file://file.html' is. | 2 | 2 | 0 | Every time I need to load a local file using webkit in python I need to start with "file://" which I need to include in all files I am working with. How can I eliminate the need to do that? I want to load files like webview.load_uri('file.html') instead of webview.load_uri('file://file.html')? | Problem loading local files with webkit in python | 1.2 | 0 | 0 | 2,182 |
4,416,570 | 2010-12-11T11:50:00.000 | 1 | 0 | 0 | 0 | python,webkit,gtk | 7,470,386 | 2 | false | 1 | 1 | webview.load_string() takes the text of an html file. you can load the file into a file object without the file:// and read it into the load_string function. | 2 | 2 | 0 | Every time I need to load a local file using webkit in python I need to start with "file://" which I need to include in all files I am working with. How can I eliminate the need to do that? I want to load files like webview.load_uri('file.html') instead of webview.load_uri('file://file.html')? | Problem loading local files with webkit in python | 0.099668 | 0 | 0 | 2,182 |
4,416,642 | 2010-12-11T12:17:00.000 | -1 | 0 | 1 | 0 | python,shell | 67,948,618 | 5 | false | 0 | 0 | You can,,go to options then configure IDE, then on the settings window select highlights, on the rightside press the button below a builtin theme, then choose your choice theme | 3 | 4 | 0 | Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions? | Change background color of python shell | -0.039979 | 0 | 0 | 86,168 |
4,416,642 | 2010-12-11T12:17:00.000 | 2 | 0 | 1 | 0 | python,shell | 4,417,082 | 5 | false | 0 | 0 | If you are reffering to the window idle for example for version 2.6 there is now way to change the background color from withe to another one. But you can change the background color of your text if you go to options.
Another thing you can do is to use other gui for python which could be more elaborated such as eclipse... | 3 | 4 | 0 | Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions? | Change background color of python shell | 0.07983 | 0 | 0 | 86,168 |
4,416,642 | 2010-12-11T12:17:00.000 | 2 | 0 | 1 | 0 | python,shell | 17,314,925 | 5 | false | 0 | 0 | just go through simple steps
- go to options
- configure IDLE
- highlighting
- then select background and click on choose color for:
- you can change the color to any color but becareful if u change only the background color the foreground color may not be visible because they both might be black
Enjoy | 3 | 4 | 0 | Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions? | Change background color of python shell | 0.07983 | 0 | 0 | 86,168 |
4,416,984 | 2010-12-11T13:40:00.000 | 3 | 0 | 0 | 1 | python,macos,installation,easy-install | 4,416,999 | 4 | false | 0 | 0 | You should use sudo . You will need to enter your password. | 2 | 17 | 0 | I'm trying to install easy_install and, well... see for yourself:
sh setuptools-0.6c11-py2.6.egg
Processing setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /Library/Python/2.6/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/local/bin
error: /usr... | Permission denied when trying to install easy_install on OSX | 0.148885 | 0 | 0 | 17,459 |
4,416,984 | 2010-12-11T13:40:00.000 | 3 | 0 | 0 | 1 | python,macos,installation,easy-install | 4,417,579 | 4 | false | 0 | 0 | Judging from the paths displayed, you are likely using the Apple-supplied Python 2.6 in OS X 10.6. If so, be aware that Apple has already easily installed easy_install for you in /usr/bin. Just try typing easy_install; you may need to use sudo easy_install if the package tries to install a script. If you are using a... | 2 | 17 | 0 | I'm trying to install easy_install and, well... see for yourself:
sh setuptools-0.6c11-py2.6.egg
Processing setuptools-0.6c11-py2.6.egg
Copying setuptools-0.6c11-py2.6.egg to /Library/Python/2.6/site-packages
Adding setuptools 0.6c11 to easy-install.pth file
Installing easy_install script to /usr/local/bin
error: /usr... | Permission denied when trying to install easy_install on OSX | 0.148885 | 0 | 0 | 17,459 |
4,417,127 | 2010-12-11T14:13:00.000 | 7 | 0 | 0 | 0 | python,django,django-templates,django-template-filters | 4,417,129 | 1 | true | 1 | 0 | The answer is maddeningly simple: split the custom tag and custom filter into two separate python files and it will work.
I suspect the problem is this: the custom tag is using template.loader.get_template() to load another template. That template file contains a {% load %} tag which tries to load the same file in whi... | 1 | 1 | 0 | I have a python file in my Django project which contains a custom template tag and a custom template filter.
My custom tag uses template.loader.get_template() to load another template file. This worked great... until I added my custom filter to the loaded template.
Now I get a Django "Invalid Filter" TemplateSyntaxErr... | "Invalid Filter" error for my custom Django template filters but not any other filters | 1.2 | 0 | 0 | 6,013 |
4,417,316 | 2010-12-11T15:02:00.000 | 1 | 0 | 1 | 0 | python,compiler-construction | 4,417,403 | 6 | false | 0 | 0 | py2exe - Python to Windows EXE
py2exe converts your Python programs to standalone Windows executables that can run without your users needing to install Python. Note that this is not a native code compiler - your code is still interpreted. py2exe merely provides all the necessary pieces so that when your end users doub... | 3 | 0 | 0 | Ok so i am in need of a python compiler (from .py or .pyw to .exe).
the only ones i have come across are:
- cx_freeze (doesnt work)
- py2exe (way too complicated)
EDIT:
both of the programs above are complicated (to me) because you have to make all these setup files, and type in a bunch of parameters and commands to g... | I need a stand alone python interpreter/compiler! | 0.033321 | 0 | 0 | 4,305 |
4,417,316 | 2010-12-11T15:02:00.000 | 0 | 0 | 1 | 0 | python,compiler-construction | 4,419,301 | 6 | false | 0 | 0 | You could also simply provide your friend a ZIP file containing python.exe, the python libs, and your python application (in pyc) along with a batch to start python.exe with your script. Python is fairly easy to run without it being 'installed'. | 3 | 0 | 0 | Ok so i am in need of a python compiler (from .py or .pyw to .exe).
the only ones i have come across are:
- cx_freeze (doesnt work)
- py2exe (way too complicated)
EDIT:
both of the programs above are complicated (to me) because you have to make all these setup files, and type in a bunch of parameters and commands to g... | I need a stand alone python interpreter/compiler! | 0 | 0 | 0 | 4,305 |
4,417,316 | 2010-12-11T15:02:00.000 | 2 | 0 | 1 | 0 | python,compiler-construction | 4,417,435 | 6 | false | 0 | 0 | One option might be to use IronPython. IronPython is another dialect of python that targets .NET, and works quite easily with MS Visual Studio. | 3 | 0 | 0 | Ok so i am in need of a python compiler (from .py or .pyw to .exe).
the only ones i have come across are:
- cx_freeze (doesnt work)
- py2exe (way too complicated)
EDIT:
both of the programs above are complicated (to me) because you have to make all these setup files, and type in a bunch of parameters and commands to g... | I need a stand alone python interpreter/compiler! | 0.066568 | 0 | 0 | 4,305 |
4,418,252 | 2010-12-11T18:30:00.000 | 1 | 0 | 0 | 1 | python,syntax,batch-file,equivalent | 4,418,349 | 5 | false | 0 | 0 | Python is not a system shell, Python is a multi-paradigm programming language.
If you want to compare .bat with anything, compare it with sh or bash. (You can have those on various platforms too - for example, sh for windows is in the MinGW package). | 2 | 1 | 0 | Ok i have these commands used in batch and i wanted to know the commands in python that would have a similar affect, just to be clear i dont want to just use os.system("command here") for each of them. For example in batch if you wanted a list of commands you would type help but in python you would type help() and then... | comparing batch to python commands? | 0.039979 | 0 | 0 | 2,645 |
4,418,252 | 2010-12-11T18:30:00.000 | 0 | 0 | 0 | 1 | python,syntax,batch-file,equivalent | 17,412,938 | 5 | false | 0 | 0 | I am pretty much facing the same problem as you, daniel11. As a solution, I am learning BATCH commands and their meaning. After I understand those, I am going to write a program in Python that does the same or accomplishes the same task.
Thanks to Adam V. and katrielatex for their insight and suggestions. | 2 | 1 | 0 | Ok i have these commands used in batch and i wanted to know the commands in python that would have a similar affect, just to be clear i dont want to just use os.system("command here") for each of them. For example in batch if you wanted a list of commands you would type help but in python you would type help() and then... | comparing batch to python commands? | 0 | 0 | 0 | 2,645 |
4,418,378 | 2010-12-11T19:00:00.000 | -2 | 1 | 1 | 1 | python,linux,bash | 4,420,885 | 4 | false | 0 | 0 | There is no direct way you can do it .
But you can make a python script to emulate a bash terminal and you can use the beautiful "Subprocess" module in python to execute commnands the way you like | 1 | 12 | 0 | What i'd like to have is a mechanism that all commands i enter on a Bash-Terminal are wrapped by a Python-script. The Python-script executes the entered command, but it adds some additional magic (for example setting "dynamic" environment variables).
Is that possible somehow?
I'm running Ubuntu and Debian Squeezy.
Ad... | Wrap all commands entered within a Bash-Shell with a Python script | -0.099668 | 0 | 0 | 3,793 |
4,418,461 | 2010-12-11T19:17:00.000 | 2 | 0 | 0 | 0 | python,django,database-design | 4,418,851 | 2 | true | 1 | 0 | Editors often solve this problem with a Piece Table. The table is a list of objects that point to spans of characters that are a) contiguous in memory, and b) share common attributes. The order of the pieces in the table is used for mapping character-in-document addresses to memory and vice versa. By reordering the pie... | 1 | 1 | 0 | I'm having trouble figuring out how to best implement a document (paragraph-) revision system in Django.
I want to save a revision history of a document, paragraph-by-paragraph. In other words, there will be a class Document, which has a ManyToManyField to Paragraph. To maintain the order of the paragraphs, a third cla... | How to maintain order of paragraphs in a Django document revision system? | 1.2 | 0 | 0 | 304 |
4,418,839 | 2010-12-11T20:40:00.000 | 1 | 0 | 0 | 0 | python,wing-ide | 4,431,943 | 1 | true | 0 | 1 | I've contacted Wingware support and they have confirmed that there is no way to set the brace matching colour. | 1 | 3 | 0 | Has anyone figured out a way to change the brace matching colours in WingIDE? I have managed to manually port my favourite colour scheme across from my text editor and the default green just doesn't do it for me. I've been unable to find instructions on how to do this in the UI, user manual and mailing lists. | WingIDE brace matching colours | 1.2 | 0 | 0 | 135 |
4,418,931 | 2010-12-11T21:03:00.000 | 0 | 0 | 1 | 0 | python,unicode,encoding,utf-8 | 4,418,961 | 4 | false | 0 | 0 | Well, if you have a stream of bytes that are UTF-8-encoded text and you interpret them as a string encoded in something else and then re-encoding it as UTF-8, then you have a problem.
If you read it as UTF-8 again (since you cannot treat bytes as text without an encoding, certainly), then you have Unicode, which, when ... | 2 | 1 | 0 | Is there any harm to encoding a string multiple times in python, with the same encoding format? (i.e, UTF-8)?
I have a function that uses another function to get a string from a document, and then serialize the string. Currently, the only user of the second function(the one which gets the string from the document) is t... | Is there any harm to encoding (with the same encoding format) a string multiple times? (in Python) | 0 | 0 | 0 | 618 |
4,418,931 | 2010-12-11T21:03:00.000 | 1 | 0 | 1 | 0 | python,unicode,encoding,utf-8 | 4,419,163 | 4 | false | 0 | 0 | In general, you should only call encode on unicode objects and only call decode on string objects.
encode encodes a Unicode object into a given encoding (stored as a string). decode decodes a given encoding back into a Unicode object.
The existance of string.encode and unicode.decode in 2.x should be treated as a hist... | 2 | 1 | 0 | Is there any harm to encoding a string multiple times in python, with the same encoding format? (i.e, UTF-8)?
I have a function that uses another function to get a string from a document, and then serialize the string. Currently, the only user of the second function(the one which gets the string from the document) is t... | Is there any harm to encoding (with the same encoding format) a string multiple times? (in Python) | 0.049958 | 0 | 0 | 618 |
4,420,706 | 2010-12-12T07:29:00.000 | 4 | 0 | 1 | 0 | python,pip,virtualenv,requirements.txt | 4,424,968 | 1 | true | 0 | 0 | I figured out what the cause of my pip problems was. Long story short, source left over in the virtualenv's build directory was causing an error that made packages upgrades fail. What I actually should have been doing was clearing out that directory (which pip doesn't always do I guess) before running the pip install a... | 1 | 2 | 0 | I feel like there must be a way to do this, but for the life of me I can't figure out how: I want to run pip against a requirements file in a virtualenv so that no matter what packages are in the virtualenv before I run pip, the requirements file is totally fulfilled (including specific versions) after I run it.
The pr... | How can I get pip install's -I flag to work with a requirements file? | 1.2 | 0 | 0 | 3,818 |
4,422,754 | 2010-12-12T16:52:00.000 | 1 | 0 | 0 | 1 | python,django,google-app-engine,templates,adsense | 4,426,058 | 2 | false | 1 | 0 | adsense is javascript, if your django is returning nothing check your HttpResponse and how you are generating the template. it looks like you need to specify in settings.py the location of the template file.
you may want add the following (in settings.py):
import os
ROOT_PATH = os.path.dirname(__file__)
TEMPLATE_DIRS... | 2 | 0 | 0 | I have a problem with Django on Google App Engine. I finished to design html templet for my web application and I imported them on django using django template system.
The problem is google ad-sense. I can say ad-sense banner on the html version of my pages if i try to open them in my browser. But nothing appear if I ... | Django + Adsense on Google App Engine | 0.099668 | 0 | 0 | 1,724 |
4,422,754 | 2010-12-12T16:52:00.000 | 0 | 0 | 0 | 1 | python,django,google-app-engine,templates,adsense | 4,448,211 | 2 | false | 1 | 0 | I solved the problem! Sorry, I accidentally added some character with erroneous codeing. | 2 | 0 | 0 | I have a problem with Django on Google App Engine. I finished to design html templet for my web application and I imported them on django using django template system.
The problem is google ad-sense. I can say ad-sense banner on the html version of my pages if i try to open them in my browser. But nothing appear if I ... | Django + Adsense on Google App Engine | 0 | 0 | 0 | 1,724 |
4,422,948 | 2010-12-12T17:35:00.000 | -1 | 0 | 1 | 0 | python,irc | 4,422,957 | 5 | false | 0 | 0 | if "Greg" in greet:
doSomething("Hi Greg")
the key is that strings take the in operator | 1 | 2 | 0 | I was wondering how to go about finding a string you don't know what is, in a string. I am writing an IRC bot and i need this function. I want to be able to write:
!greet Greg
and then my bot is supposed to say "Hi, Greg!". So what comes after greet is variable. And if i wrote !greet Matthew it would say "Hi, Matthew!"... | How to find x in a string in Python | -0.039979 | 0 | 1 | 361 |
4,425,137 | 2010-12-13T01:18:00.000 | 0 | 0 | 0 | 0 | python,pylons | 4,464,437 | 2 | false | 0 | 0 | a __before__ method is a right place to do it. | 2 | 2 | 0 | I'm writing a pylons application, and I'm wondering if there is a best practice for where to set some application specific values of the template context object (tmpl_context)?
Currently, I've added a __before__() method to the BaseController and am setting up the tmpl_context object with values there but am wondering ... | Best practice for pylons app global tmpl_context settings? | 0 | 0 | 0 | 423 |
4,425,137 | 2010-12-13T01:18:00.000 | 0 | 0 | 0 | 0 | python,pylons | 4,444,729 | 2 | false | 0 | 0 | I think the BaseController is a good place to put that, either in __call__() or in __before__(). | 2 | 2 | 0 | I'm writing a pylons application, and I'm wondering if there is a best practice for where to set some application specific values of the template context object (tmpl_context)?
Currently, I've added a __before__() method to the BaseController and am setting up the tmpl_context object with values there but am wondering ... | Best practice for pylons app global tmpl_context settings? | 0 | 0 | 0 | 423 |
4,426,002 | 2010-12-13T05:17:00.000 | 3 | 0 | 1 | 0 | python,conventions | 4,426,033 | 2 | true | 0 | 0 | No, there's no convention for organization of functions and classes. However, there are some basic guidelines that will make your source flow better and make more sense to readers:
Document. Whatever you do, make sure that the uses (and in some cases, implementation) of classes and functions is described in plain engl... | 1 | 6 | 0 | I'm starting a new Python project, and want to follow standard conventions as closely as possible. I've read that import statements should come first, for example. But I haven't found any conventions for things like putting all function definitions before or after all class definitions. Are there any conventions for th... | Python source file organization | 1.2 | 0 | 0 | 2,189 |
4,426,397 | 2010-12-13T06:47:00.000 | 4 | 0 | 1 | 0 | python,string | 4,426,424 | 6 | false | 0 | 0 | "hello"[:-3] - first length - 3 characters.
"hello"[:2] - first 2 characters. | 4 | 4 | 0 | I have a string in python and I'd like to take off the last three characters. How do I go about this?
So turn something like 'hello' to 'he'. | String Manipulation in Python | 0.132549 | 0 | 0 | 17,814 |
4,426,397 | 2010-12-13T06:47:00.000 | 1 | 0 | 1 | 0 | python,string | 4,426,420 | 6 | false | 0 | 0 | type "hello"[:2]
or "hello"[:-3] which is the answer for removing the last three letters
hope this helps | 4 | 4 | 0 | I have a string in python and I'd like to take off the last three characters. How do I go about this?
So turn something like 'hello' to 'he'. | String Manipulation in Python | 0.033321 | 0 | 0 | 17,814 |
4,426,397 | 2010-12-13T06:47:00.000 | 0 | 0 | 1 | 0 | python,string | 7,232,632 | 6 | false | 0 | 0 | "hello"[:2] is the easiest way to do this however the accurate answer for the problem
would be as Saif al Harthi stated. "hello"[:-3] | 4 | 4 | 0 | I have a string in python and I'd like to take off the last three characters. How do I go about this?
So turn something like 'hello' to 'he'. | String Manipulation in Python | 0 | 0 | 0 | 17,814 |
4,426,397 | 2010-12-13T06:47:00.000 | -2 | 0 | 1 | 0 | python,string | 25,325,614 | 6 | false | 0 | 0 | if x is your string then you can use x[:len(x)-3:+1] to get the desired result | 4 | 4 | 0 | I have a string in python and I'd like to take off the last three characters. How do I go about this?
So turn something like 'hello' to 'he'. | String Manipulation in Python | -0.066568 | 0 | 0 | 17,814 |
4,426,808 | 2010-12-13T07:57:00.000 | 0 | 0 | 0 | 0 | python,django,ant,intellij-idea | 4,428,911 | 1 | false | 1 | 0 | Which module type have you created? Please try to create a regular Java module with a Java SDK, and to add a Python facet to it. | 1 | 0 | 0 | Greetings! Intellij IDEA 10 + Python plugin when creating a project using Django, does not run Apache Ant-scripts. When I try to add an Ant-script error occurs «Cannot Add Files». I can’t understand reason of problem. | Intellij IDEA 10 + Python + Django does not run Apache Ant-scripts | 0 | 0 | 0 | 679 |
4,427,623 | 2010-12-13T09:56:00.000 | 0 | 0 | 1 | 0 | python,symbian,s60,pys60 | 5,888,625 | 1 | false | 1 | 0 | I don't thinks those libraries will run on PyS60 if they are not designed for that platform. | 1 | 0 | 0 | I have Python installed on my S60 phone...but I require some addtional libraries like pyaudio and lightblue to be installed on my phone...is there a way I can do this?
Also where are the Python libraries installed on my phone? | Extra Python libraries on phone | 0 | 0 | 0 | 157 |
4,427,936 | 2010-12-13T10:36:00.000 | 0 | 0 | 0 | 0 | python,logging,file-locking | 4,427,958 | 2 | false | 0 | 0 | As far as I know, Windows does not support file locking. In other words, applications that don't know about your file being locked can't be prevented from reading a file.
But the remaining question is: how can Excel accomplish this?
You might want to try to write to a temporary file first (one that Excel does not know ... | 1 | 1 | 0 | I am writing a Python logger script which writes to a CSV file in the following manner:
Open the file
Append data
Close the file (I think this is necessary to save the changes, to be safe after every logging routine.)
PROBLEM:
The file is very much accessible through Windows Explorer (I'm using XP). If the file is op... | Prevent a file from being opened | 0 | 1 | 0 | 2,562 |
4,427,981 | 2010-12-13T10:42:00.000 | 5 | 0 | 1 | 0 | python,dictionary | 4,428,010 | 5 | false | 0 | 0 | A dictionary has no order. So your wording "b's key is smaller than d's" is the right one.
Now, it looks like you could swap keys and values... | 2 | 0 | 0 | There is a dictionary that may include keys starting from 0 and values: a, b, c, d, e. Each time the values may be assigned to different keys keys. Size of the dictionary may change as well.
I am interested in two values. Let's call them b and d.
Is there any algorithm that determine situations when b appears earlier t... | Determine position of values in dictionary, Python | 0.197375 | 0 | 0 | 5,837 |
4,427,981 | 2010-12-13T10:42:00.000 | 0 | 0 | 1 | 0 | python,dictionary | 4,428,033 | 5 | false | 0 | 0 | Dictionaries are unordered sets of key-value pairs. dict.keys() need not produce the same output always. Can't you do what you want with lists? | 2 | 0 | 0 | There is a dictionary that may include keys starting from 0 and values: a, b, c, d, e. Each time the values may be assigned to different keys keys. Size of the dictionary may change as well.
I am interested in two values. Let's call them b and d.
Is there any algorithm that determine situations when b appears earlier t... | Determine position of values in dictionary, Python | 0 | 0 | 0 | 5,837 |
4,428,613 | 2010-12-13T12:04:00.000 | 1 | 0 | 0 | 0 | python,mysql | 4,428,933 | 5 | false | 0 | 0 | I agree with Mchi, there is no problem storing "pickled" data if you don't need to search or do relational type operations.
Denormalisation is also an important tool that can scale up database performance when applied correctly.
It's probably a better idea to use JSON instead of pickles. It only uses a little more spac... | 4 | 2 | 0 | Many times while creating database structure, I get stuck at the question, what would be more effective, storing data in pickled format in a column in the same table or create additional table and then use JOIN.
Which path should be followed, any advice ?
For example:
There is a table of Customers, containing fields li... | Is it a good practice to use pickled data instead of additional tables? | 0.039979 | 1 | 0 | 159 |
4,428,613 | 2010-12-13T12:04:00.000 | 2 | 0 | 0 | 0 | python,mysql | 4,429,509 | 5 | true | 0 | 0 | Mixing SQL databases and pickling seems to ask for trouble. I'd go with either sticking all data in the SQL databases or using only pickling, in the form of the ZODB, which is a Python only OO database that is pretty damn awesome.
Mixing makes case sometimes, but is usually just more trouble than it's worth. | 4 | 2 | 0 | Many times while creating database structure, I get stuck at the question, what would be more effective, storing data in pickled format in a column in the same table or create additional table and then use JOIN.
Which path should be followed, any advice ?
For example:
There is a table of Customers, containing fields li... | Is it a good practice to use pickled data instead of additional tables? | 1.2 | 1 | 0 | 159 |
4,428,613 | 2010-12-13T12:04:00.000 | 0 | 0 | 0 | 0 | python,mysql | 4,432,349 | 5 | false | 0 | 0 | I agree with @Lennart Regebro. You should probably see whether you need a Relational DB or an OODB. If RDBMS is your choice, I would suggest you stick with more tables. IMHO, pickling may have issues with scalability. If thats what you want, you should look at ZODB. It is pretty good and supports caching etc for better... | 4 | 2 | 0 | Many times while creating database structure, I get stuck at the question, what would be more effective, storing data in pickled format in a column in the same table or create additional table and then use JOIN.
Which path should be followed, any advice ?
For example:
There is a table of Customers, containing fields li... | Is it a good practice to use pickled data instead of additional tables? | 0 | 1 | 0 | 159 |
4,428,613 | 2010-12-13T12:04:00.000 | 3 | 0 | 0 | 0 | python,mysql | 4,428,635 | 5 | false | 0 | 0 | Usually it's best to keep your data normalized (i.e. create more tables). Storing data 'pickled' as you say, is acceptable, when you don't need to perform relational operations on them. | 4 | 2 | 0 | Many times while creating database structure, I get stuck at the question, what would be more effective, storing data in pickled format in a column in the same table or create additional table and then use JOIN.
Which path should be followed, any advice ?
For example:
There is a table of Customers, containing fields li... | Is it a good practice to use pickled data instead of additional tables? | 0.119427 | 1 | 0 | 159 |
4,429,462 | 2010-12-13T13:51:00.000 | 1 | 0 | 1 | 0 | python | 4,429,666 | 9 | false | 0 | 0 | Think about what it will do, at present, if you give it, say a=32 and b=2. b*b will give you 4, 16, 256...
So, you have to keep track of the original b as you're calling your function recursively. You could have a third variable with a default value (original_b), but there's a way to do it without replacing b at all. | 2 | 1 | 0 | I am doing exercise on Singpath and I am stuck at this question. This question is under recursion exercises but I have no idea what the question means.
A number, a, is a power of b if it is
divisible by b and a/b is a power of
b.
Write a function called is_power
that takes parameters a and b and
returns True... | Python Recursion Exercise | 0.022219 | 0 | 0 | 4,300 |
4,429,462 | 2010-12-13T13:51:00.000 | 0 | 0 | 1 | 0 | python | 4,429,802 | 9 | false | 0 | 0 | You should start with the trivial cases, there are two in fact: is_power(x,x) and is_power(1,x).
Once you have the edge case you just need to write down the definition correctly. It mentions a/b and b, but you wrote return is_power(a,b*b). Maybe you think that is the same, just scaled both arguments with b, but it is ... | 2 | 1 | 0 | I am doing exercise on Singpath and I am stuck at this question. This question is under recursion exercises but I have no idea what the question means.
A number, a, is a power of b if it is
divisible by b and a/b is a power of
b.
Write a function called is_power
that takes parameters a and b and
returns True... | Python Recursion Exercise | 0 | 0 | 0 | 4,300 |
4,430,227 | 2010-12-13T15:10:00.000 | 0 | 1 | 0 | 1 | python,winapi,api,performancecounter | 4,430,461 | 2 | false | 0 | 0 | You could just call the C# StopWatch class directly from Python couldn't you? Maybe a small wrapper is needed (don't know Python/C# interop details - sorry) - if you are already using C# for data acquisition, doing the same for timings via Stopwatch should be simpler than anything else you can do. | 1 | 4 | 0 | I have a python script that calls a USB-based data-acquisition C# dotnet executable. The main python script does many other things, e.g. it controls a stepper motor. We would like to check the relative timing of various operations, for that purpose the dotnet exe generates a log with timestamps from C# Stopwatch.GetTi... | python on win32: how to get absolute timing / CPU cycle-count | 0 | 0 | 0 | 1,794 |
4,430,408 | 2010-12-13T15:26:00.000 | 1 | 1 | 0 | 1 | python,linux,ubuntu,ssh | 4,430,456 | 2 | false | 0 | 0 | A very quick alternative is to pipe the output of your python program to a file, and then simply using tail with the second user to see the output as it's being written to the file. However, with a program like you have there, the file will very quickly become massive. | 1 | 2 | 0 | I have a script, called test.py, that does the following:
while (1):
....print "hello world"
(this script simply prints 'hello world' continuously).
Now, I am using two machines (machine A and machine B). Same user is used for both machines. I would like to do the following:
(1) [working with machine A] run test.p... | View Script Output Over SSH? | 0.099668 | 0 | 0 | 1,034 |
4,432,208 | 2010-12-13T18:31:00.000 | -1 | 0 | 1 | 0 | python,python-2.7,syntax,operators,modulo | 68,943,352 | 20 | false | 0 | 0 | def absolute(c):
if c>=0:
return c
else:
return c*-1
x=int(input("Enter the value:"))
a=absolute(x)
print(a) | 3 | 262 | 0 | What does the % in a calculation? I can't seem to work out what it does.
Does it work out a percent of the calculation for example: 4 % 2 is apparently equal to 0. How? | What is the result of % in Python? | -0.01 | 0 | 0 | 1,214,655 |
4,432,208 | 2010-12-13T18:31:00.000 | 1 | 0 | 1 | 0 | python,python-2.7,syntax,operators,modulo | 4,432,250 | 20 | false | 0 | 0 | The % (modulo) operator yields the remainder from the division of the first argument by the second. The numeric arguments are first converted to a common type.
3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 = 7
This is based on operator precedence. | 3 | 262 | 0 | What does the % in a calculation? I can't seem to work out what it does.
Does it work out a percent of the calculation for example: 4 % 2 is apparently equal to 0. How? | What is the result of % in Python? | 0.01 | 0 | 0 | 1,214,655 |
4,432,208 | 2010-12-13T18:31:00.000 | 49 | 0 | 1 | 0 | python,python-2.7,syntax,operators,modulo | 19,524,230 | 20 | false | 0 | 0 | The modulus is a mathematical operation, sometimes described as "clock arithmetic." I find that describing it as simply a remainder is misleading and confusing because it masks the real reason it is used so much in computer science. It really is used to wrap around cycles.
Think of a clock: Suppose you look at a clock... | 3 | 262 | 0 | What does the % in a calculation? I can't seem to work out what it does.
Does it work out a percent of the calculation for example: 4 % 2 is apparently equal to 0. How? | What is the result of % in Python? | 1 | 0 | 0 | 1,214,655 |
4,432,606 | 2010-12-13T19:19:00.000 | 2 | 0 | 1 | 0 | visual-studio-2010,ironpython,ironpython-studio | 7,561,040 | 2 | false | 1 | 0 | I had a similar issue with IronPython 2.7 RTM on VS 2010 SP1. I had the python tools for VS 1.0 installed before I installed IronPython. I did the following to resolve the issue
Uninstalled IronPython
Uninstalled Python tools for VS
Installed IronPython 2.7 RTM without the "Tools for VS" feature, this is provided by t... | 1 | 1 | 0 | I installed IronPython yesterday. After running Visual Studio the IronPython project template showed up but later it was gone. I've tried repairing, uninstalling, and reinstalling without fixing the issue. How can I make the templates show up? | How can I fix missing IronPython project templates in Visual Studio 2010? | 0.197375 | 0 | 0 | 1,945 |
4,434,959 | 2010-12-14T00:55:00.000 | 3 | 1 | 1 | 0 | python,barcode,barcode-scanner | 4,435,008 | 2 | false | 0 | 0 | Are you making a python web-app or a client application? Unless you're looking for specialized bar code scanning functionality it doesn't really matter since the input from the scanner appears like keyboard entry (sometimes prefixed with a special input character), so you just have to have a way of listening to the key... | 1 | 11 | 0 | I'm doing some feasibility research with regards to a (large) book cataloging project. Any help would w/r/t good sources of information would be appreciated but the things I would specifically like to know are:
1.)does python have any modules for use with barcode readers (preferably USB)? What other programs are availa... | USB Barcode scanner research | 0.291313 | 0 | 0 | 4,396 |
4,435,882 | 2010-12-14T04:31:00.000 | 0 | 0 | 0 | 0 | python,html,url,printing | 4,435,929 | 2 | false | 1 | 0 | Fetch it (using mechanize, urllib or whatever else you want), parse what you get (using elementtree, BeautifulSoup, lxml or whatever else you want) and you have what you want. | 1 | 1 | 0 | How would you get all the HTML tags from a URL and print them? | How to get html tags from url? | 0 | 0 | 1 | 646 |
4,437,307 | 2010-12-14T08:42:00.000 | 8 | 0 | 0 | 1 | python,google-app-engine,forms,submit,datastore | 4,437,354 | 3 | false | 1 | 0 | Sounds like you want to look into AJAX. The simplest way to do this is probably to use the ajax functions in one of the popular Javascript libraries, like jQuery. | 2 | 0 | 0 | As a newbie to app engine and python I can follow the examples given by Google and have created a python application with a template HTML page where I can enter data, submit it to the datastore and by reading back the data, just sent, recreate the sending page so I can continue adding data and store again. However wha... | How do you submit a form to an app engine python application without refreshing the sending page? | 1 | 0 | 0 | 514 |
4,437,307 | 2010-12-14T08:42:00.000 | -1 | 0 | 0 | 1 | python,google-app-engine,forms,submit,datastore | 4,439,461 | 3 | false | 1 | 0 | Have a look at Pyjamas pyjs.org
It's a Python Compiler for web browsers. Write your client side in Python and Pyjamas will compile it into JavaScript. | 2 | 0 | 0 | As a newbie to app engine and python I can follow the examples given by Google and have created a python application with a template HTML page where I can enter data, submit it to the datastore and by reading back the data, just sent, recreate the sending page so I can continue adding data and store again. However wha... | How do you submit a form to an app engine python application without refreshing the sending page? | -0.066568 | 0 | 0 | 514 |
4,437,331 | 2010-12-14T08:47:00.000 | 18 | 1 | 0 | 1 | python,ssh | 4,441,673 | 2 | true | 0 | 0 | Try pssh -O StrictHostKeyChecking=no. This works for me.
By default ssh uses the value of "ask", which causes it to ask the user whether to continue connecting to unknown host. By setting the value to "no", you avoid the question, but are no longer protected against certain attacks. E.g. if you are connecting to hostA,... | 1 | 5 | 0 | when I use pssh, trying to access a remote machine which is not inside the UNIX
known hosts file, pssh freeze after giving the password.
After having added the host using a direct ssh command, pssh works.
So is there an option to give to the pssh command in order to avoid this problem ?
Thanks for your help,
Regards | pssh and known_hosts file | 1.2 | 0 | 0 | 12,459 |
4,438,020 | 2010-12-14T10:12:00.000 | 0 | 0 | 1 | 1 | python,windows | 61,368,121 | 11 | false | 0 | 0 | Above mentioned all the methods did not worked I tried them all , I will tell you more simpler solution and alternative of windows task scheduler
Create a .bat file with content
"ADDRESS OF YOUR PROJECT INTERPRETER" "ADDRESS OF YOUR PYTHON SCRIPT WITH SCRIPT NAME"
Store this bat file into the window startup folder(by ... | 4 | 80 | 0 | I have a python file and I am running the file.
If Windows is shutdown and booted up again, how I can run that file every time Windows starts? | How to start a python file while Windows starts? | 0 | 0 | 0 | 132,882 |
4,438,020 | 2010-12-14T10:12:00.000 | 1 | 0 | 1 | 1 | python,windows | 22,035,422 | 11 | false | 0 | 0 | try adding an entry to "HKLM/SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" .
Right click ->new -> string value -> add file path | 4 | 80 | 0 | I have a python file and I am running the file.
If Windows is shutdown and booted up again, how I can run that file every time Windows starts? | How to start a python file while Windows starts? | 0.01818 | 0 | 0 | 132,882 |
4,438,020 | 2010-12-14T10:12:00.000 | 9 | 0 | 1 | 1 | python,windows | 66,016,922 | 11 | false | 0 | 0 | click Win+R
type shell:startup
drag and drop your python file my_script.py
if you don't need the console:
change extension from my_script.py to my_script.pyw
else:
create run_my_script.cmd with content: python path\to\your\my_script.py | 4 | 80 | 0 | I have a python file and I am running the file.
If Windows is shutdown and booted up again, how I can run that file every time Windows starts? | How to start a python file while Windows starts? | 1 | 0 | 0 | 132,882 |
4,438,020 | 2010-12-14T10:12:00.000 | 70 | 0 | 1 | 1 | python,windows | 4,439,204 | 11 | false | 0 | 0 | Depending on what the script is doing, you may:
package it into a service, that should then be installed
add it to the windows registry (HKCU\Software\Microsoft\Windows\CurrentVersion\Run)
add a shortcut to it to the startup folder of start menu - its location may change with OS version, but installers always have som... | 4 | 80 | 0 | I have a python file and I am running the file.
If Windows is shutdown and booted up again, how I can run that file every time Windows starts? | How to start a python file while Windows starts? | 1 | 0 | 0 | 132,882 |
4,438,516 | 2010-12-14T11:11:00.000 | 2 | 0 | 1 | 0 | python,conditional-statements,goto | 4,438,582 | 5 | false | 0 | 0 | Python is designed to support good coding practices and GOTO is not one of them. It may lead to unreadable program logic, if not used properly.
I suggest to learn code your program in a Python way, do not stick with (sometimes bad) habits from other programming languages. See Python documentation, real mature Python pr... | 1 | 5 | 0 | Since there is no goto operator in Python, what technique can be used instead?
Condition
If it is true, go to thread 1, if is false, go to thread 2
In thread we do something small and after that we go to thread 2 where all other actions take place. | Equivalent to GOTO in conditions, Python | 0.07983 | 0 | 0 | 38,829 |
4,438,644 | 2010-12-14T11:29:00.000 | 1 | 0 | 1 | 1 | windows-7,curl,python-3.x | 4,439,344 | 1 | false | 0 | 0 | There is no module called "curl", so it's unclear what you mean?
PycURL?
friendly_curl?
pylibcurl?
curlwrapper?
pyparallelcurl?
In any case, as far as I can gather, none of them are ported to Python 3, so the answer on how to install them on Python 3 is: Talk to the authors and help port them! It's fun! | 1 | 0 | 0 | Can you please tell how to install curl for python 3.x to Windows 7. Ease_install only for the 2 version of the sort. | How to install curl on python 3.x in Windows 7? | 0.197375 | 0 | 0 | 907 |
4,440,341 | 2010-12-14T14:44:00.000 | 0 | 0 | 1 | 0 | python,computer-science,computer-science-theory | 5,954,608 | 5 | true | 0 | 0 | I finally decided to use a mixture of online resources. I am teaching him basics of CS and basic Python myself. Then I will cherry pick topics for him from various free python books and official documentations.
Let's see how this experiment goes. | 1 | 2 | 0 | In our office, we have an office boy(completed high school(10+2 years)) with average academic record so far). He wants to learn programming. I have started coaching him in Computer Science basics (history of computer science, number systems, etc.), but I am not able to put in enough time with him(because I have very li... | Online resources for Introduction to computer and computer sciences for absolute beginner | 1.2 | 0 | 0 | 321 |
4,441,209 | 2010-12-14T16:05:00.000 | 1 | 0 | 0 | 0 | python,django,nosql,scaling,partitioning | 4,441,374 | 1 | false | 1 | 0 | Problem A: how to keep the query for items added by people you are following working well with growing datasets?
starting with a dataset of (who are my followers / who am i following); one could save these values as tuples and segmentate them across several SQL databases (though I doubt real segmentation is really need... | 1 | 1 | 0 | The problem is somewhat similar to twitter/facebook's:
followers and following
users add items
Subsequently you see the items added by all the people you are following.
Problem A: how to keep the query for items added by people you are following working well with growing datasets?
Problem B: we are seeing geographica... | Scaling a follower model | 0.197375 | 0 | 0 | 185 |
4,441,933 | 2010-12-14T17:06:00.000 | 0 | 1 | 0 | 0 | php,python,design-patterns,cron,screen-scraping | 4,441,983 | 3 | false | 1 | 0 | Do you need to run the script 50 times per user, or only when the user has logged into your service to check on things? | 2 | 0 | 0 | On the front-end, I have a PHP webapp that allows users to create a list of their websites (5 max).
On the back-end, a Python script runs daily (and has ~10 iterations) for each website that the user registers. Each script per website takes about 10 seconds to run through all iterations and finish its scraping. It then... | Best practice for running a daily Python screen-scraping script 50 times (8.3 minutes total) per user? | 0 | 0 | 0 | 772 |
4,441,933 | 2010-12-14T17:06:00.000 | 0 | 1 | 0 | 0 | php,python,design-patterns,cron,screen-scraping | 4,441,994 | 3 | false | 1 | 0 | Assuming you're using a database to store the users' web sites, you can have just 1 script that runs as a daily cron job and queries the database for the list of sites to process. | 2 | 0 | 0 | On the front-end, I have a PHP webapp that allows users to create a list of their websites (5 max).
On the back-end, a Python script runs daily (and has ~10 iterations) for each website that the user registers. Each script per website takes about 10 seconds to run through all iterations and finish its scraping. It then... | Best practice for running a daily Python screen-scraping script 50 times (8.3 minutes total) per user? | 0 | 0 | 0 | 772 |
4,441,947 | 2010-12-14T17:07:00.000 | 4 | 0 | 1 | 0 | python,list,memory | 6,846,141 | 5 | false | 0 | 0 | I had a similar problem using a 32-bit version of python in a 64-bit windows environment. I tried the 64-bit windows version of python and very quickly ran into troubles with the Scipy libraries compiled for 64-bit windows.
The totally free solution that I implemented was
1) Install VirtualBox
2) Install CentOS 5.6 on... | 2 | 23 | 0 | I am building a large data dictionary from a set of text files. As I read in the lines and process them, I append(dataline) to a list.
At some point the append() generates a Memory Error exception. However, watching the program run in the Windows Task Manager, at the point of the crash I see 4.3 GB available and 1.1 ... | Why Python `Memory Error` with list `append()` lots of RAM left | 0.158649 | 0 | 0 | 51,737 |
4,441,947 | 2010-12-14T17:07:00.000 | 3 | 0 | 1 | 0 | python,list,memory | 26,113,468 | 5 | false | 0 | 0 | I had a similar problem happening when evaluating an expression containing large numpy arrays (actually, one was sparse). I was doing this on a machine with 64GB of memory, of which only about 8GB was in use, so was surprised to get the MemoryError.
It turned out that my problem was array shape broadcasting: I had inad... | 2 | 23 | 0 | I am building a large data dictionary from a set of text files. As I read in the lines and process them, I append(dataline) to a list.
At some point the append() generates a Memory Error exception. However, watching the program run in the Windows Task Manager, at the point of the crash I see 4.3 GB available and 1.1 ... | Why Python `Memory Error` with list `append()` lots of RAM left | 0.119427 | 0 | 0 | 51,737 |
4,443,509 | 2010-12-14T19:50:00.000 | 0 | 1 | 1 | 0 | python | 4,443,870 | 5 | false | 0 | 0 | If the two modules are unrelated except for that common function, you may wish to consider extracting that function (and maybe other things that are related to that function) into a third module. | 3 | 0 | 0 | I have around 80 lines of a function in a file. I need the same functionality in another file so I am currently importing the other file for the function.
My question is that in terms of running time on a machine which technique would be better :- importing the complete file and running the function or copying the func... | Is importing a file good in Python | 0 | 0 | 0 | 143 |
4,443,509 | 2010-12-14T19:50:00.000 | 1 | 1 | 1 | 0 | python | 4,443,553 | 5 | false | 0 | 0 | Importing is good cause it helps you manage stuff easily. What if you needed the same function again? Instead of making changes at multiple places, there is just one centralized location - your module.
In case the function is small and you won't need it anywhere else, put it in the file itself.
If it is complex and wo... | 3 | 0 | 0 | I have around 80 lines of a function in a file. I need the same functionality in another file so I am currently importing the other file for the function.
My question is that in terms of running time on a machine which technique would be better :- importing the complete file and running the function or copying the func... | Is importing a file good in Python | 0.039979 | 0 | 0 | 143 |
4,443,509 | 2010-12-14T19:50:00.000 | 4 | 1 | 1 | 0 | python | 4,443,551 | 5 | true | 0 | 0 | Importing is how you're supposed to do it. That's why it's possible. Performance is a complicated question, but in general it really doesn't matter. People who really, really need performance, and can't be satisfied by just fixing the basic algorithm, are not using Python in the first place. :) (At least not for the ti... | 3 | 0 | 0 | I have around 80 lines of a function in a file. I need the same functionality in another file so I am currently importing the other file for the function.
My question is that in terms of running time on a machine which technique would be better :- importing the complete file and running the function or copying the func... | Is importing a file good in Python | 1.2 | 0 | 0 | 143 |
4,445,117 | 2010-12-14T22:54:00.000 | 0 | 0 | 0 | 0 | sql-server-2008,stored-procedures,python-2.6,call-graph | 18,523,367 | 3 | false | 0 | 0 | SQL Negotiator Pro has a free lite version at www.aphilen.com
The full version is the only product out there that will find all dependencies and not stop after finding the first 10 child dependencies. Other products fail when there is a circular reference and just hang, these guys have covered this off. Also a neat fea... | 1 | 8 | 0 | I would like to be able to plot a call graph of a stored procedure. I am not interested in every detail, and I am not concerned with dynamic SQL (although it would be cool to detect it and skip it maybe or mark it as such.)
I would like the tool to generate a tree for me, given the server name, db name, stored proc nam... | Is there a free tool which can help visualize the logic of a stored procedure in SQL Server 2008 R2? | 0 | 1 | 0 | 6,375 |
4,447,658 | 2010-12-15T07:29:00.000 | 1 | 0 | 0 | 0 | networking,graph,wxpython,pygraphviz | 4,493,216 | 1 | false | 0 | 0 | Take a look at the wx.lib.ogl package. It has the basics of what you would need to build diagrams of shapes, labels, lines, arrows, etc. and you can allow the user to interact with them to move them around the window, etc. It is not perfect, but people are using it for this type of thing quite a bit.
Another possibil... | 1 | 1 | 0 | Hi
I would like to create a wxpython application with a window where I can create a network graph. I have heard (never used) of graphviz and NetworkX, but it seems to me that they only creates graph given some input data. I would like to do the opposite - i.e., create drag and drop nodes and links from a pallete menu... | wxPython: Network Graph - clickable with context menu - Any pkgs? | 0.197375 | 0 | 1 | 943 |
4,449,473 | 2010-12-15T11:39:00.000 | 4 | 0 | 1 | 0 | python,linux,file | 4,449,505 | 2 | false | 0 | 0 | Your operating system is caching the file.
What? This means, the first time you read the file, your program had to go look for the information in the hard drive, and hard drives are slooooow.
Now, after having read the whole file for the first time, Linux kept it around in memory just in case, and probably because ther... | 1 | 2 | 0 | SIZE = 1<<16
def justread(file):
with open(file, 'rb') as f:
while f.read(SIZE):
pass
The first time I run this function on a 700MB file it took 19 secs.
When I repeated
reading the same file again the time it took dropped to 0.5secs.
I repeated this with many files and the results were similar... | Why file read is faster on reading again? | 0.379949 | 0 | 0 | 476 |
4,450,144 | 2010-12-15T13:02:00.000 | 8 | 0 | 1 | 0 | python,io | 4,450,277 | 7 | false | 0 | 0 | If it should be human-readable, I'd
also go with JSON. Unless you need to
exchange it with enterprise-type
people, they like XML better. :-)
If it should be human editable and
isn't too complex, I'd probably go
with some sort of INI-like format,
like for example configparser.
If it is complex, and doesn't need to
be ex... | 1 | 14 | 1 | What is the easiest way to save and load data in python, preferably in a human-readable output format?
The data I am saving/loading consists of two vectors of floats. Ideally, these vectors would be named in the file (e.g. X and Y).
My current save() and load() functions use file.readline(), file.write() and string-to-... | easy save/load of data in python | 1 | 0 | 0 | 62,035 |
4,450,752 | 2010-12-15T14:07:00.000 | 3 | 0 | 1 | 0 | python,if-statement | 4,450,795 | 4 | false | 0 | 0 | Note: If you can put the elements as keys of a dict then testing for membership is much quicker thanks to the hashing algorithm. Will only be an issue if your list is very long or your app does a lot of this kind of thing. Otherwise, "X not in Y" as Sven says. | 1 | 11 | 0 | Let's say there is a list a that contains both numbers and letters. Is there quick way to find out that the list doesn't contain some specific element. I plan to use it in conditions. | Python, find out that a list does not have specific item | 0.148885 | 0 | 0 | 32,752 |
4,451,166 | 2010-12-15T14:50:00.000 | 1 | 0 | 0 | 0 | python,windows,wxpython | 4,465,221 | 3 | false | 0 | 1 | The simple answer is that the wx.ListBox doesn't support that. Try using a one column wx.ListCtrl (in Report mode) instead. | 2 | 2 | 0 | I'm using a wxPython listbox on Windows to get a choice from the user, and I would like them to be able to select an item using the ENTER key, as if they had double-clicked. I know how to do this in C or C++ using the Windows API directly, but can't seem to find how to do it using wxPython. Anyone know how? It seems li... | Keyboard interface to wxPython listbox | 0.066568 | 0 | 0 | 721 |
4,451,166 | 2010-12-15T14:50:00.000 | 1 | 0 | 0 | 0 | python,windows,wxpython | 4,451,586 | 3 | false | 0 | 1 | Maybe I'm missing some nuance, there wasn't much info to go on, but it sounds like you could accomplish this by catching the keydown event, matching for enter and then calling your on_doubleclick function. Unless there's an implicit double-click handling you should be good to go. | 2 | 2 | 0 | I'm using a wxPython listbox on Windows to get a choice from the user, and I would like them to be able to select an item using the ENTER key, as if they had double-clicked. I know how to do this in C or C++ using the Windows API directly, but can't seem to find how to do it using wxPython. Anyone know how? It seems li... | Keyboard interface to wxPython listbox | 0.066568 | 0 | 0 | 721 |
4,451,464 | 2010-12-15T15:12:00.000 | 0 | 0 | 0 | 0 | python,pygame | 4,474,154 | 4 | false | 0 | 1 | Depends on the size of the map you want to make, however, with the actual technologies it's very hard to see a tile-map "rendered" to take longer than expected, tiled based games are almost extinguished, however is always a good practice and a starting point to the world of game programming | 3 | 5 | 0 | I am trying to decide if it is better to use a pre-rendered large image for a scrolling map game or to render the tiles individual on screen each frame. I have tried to program the game both ways and don't see any obvious difference in speed, but that might be due to my lack of experiences.
Besides for memory, is the... | Pygame: Tiled Map or Large Image | 0 | 0 | 0 | 2,637 |
4,451,464 | 2010-12-15T15:12:00.000 | 1 | 0 | 0 | 0 | python,pygame | 4,451,504 | 4 | false | 0 | 1 | Memory and speed are closely related. If your tile set fits in video memory, but the pre-rendered map doesn't, speed will suffer. | 3 | 5 | 0 | I am trying to decide if it is better to use a pre-rendered large image for a scrolling map game or to render the tiles individual on screen each frame. I have tried to program the game both ways and don't see any obvious difference in speed, but that might be due to my lack of experiences.
Besides for memory, is the... | Pygame: Tiled Map or Large Image | 0.049958 | 0 | 0 | 2,637 |
4,451,464 | 2010-12-15T15:12:00.000 | 5 | 0 | 0 | 0 | python,pygame | 4,451,490 | 4 | true | 0 | 1 | The only reason I can think of for picking one over the other on modern hardware (anything as fast and with as much ram as, say, an iPhone), would be technical ones that make the game code itself easier to follow. There's not much performance wise to distinguish them.
One exception I can think of, is if you are using ... | 3 | 5 | 0 | I am trying to decide if it is better to use a pre-rendered large image for a scrolling map game or to render the tiles individual on screen each frame. I have tried to program the game both ways and don't see any obvious difference in speed, but that might be due to my lack of experiences.
Besides for memory, is the... | Pygame: Tiled Map or Large Image | 1.2 | 0 | 0 | 2,637 |
4,452,208 | 2010-12-15T16:19:00.000 | 2 | 0 | 0 | 0 | python,django,packaging | 4,452,849 | 6 | true | 1 | 0 | Yes, you can package it. Django may not be the easiest to do this with, but the principles are the same for other frameworks. You need to make an installer that installs everything you need. And that installer needs to be different for different platforms. such as Windows, Ubuntu, OS X etc. That also means that the ans... | 1 | 21 | 0 | I've made a small little "application" utilizing Django as a framework. This is an application that is not ment to be deployed to a server but run locally on a machine. Thus the runserver.py works just nice.
I, as an developer is comfortable with fireing up the terminal, running python manage.py runserver and using it.... | Package a django project and its dependencies for a standalone "product" | 1.2 | 0 | 0 | 9,313 |
4,452,735 | 2010-12-15T17:07:00.000 | 6 | 0 | 1 | 0 | c#,python | 4,452,792 | 3 | true | 0 | 0 | You can put a Main method in as many classes as you like, although only one can be an entry point for an application. (For talks, I often have a main method in every class, and use a helper library to present all of those pseudo-entry-points when I run the project.)
Likewise you can definitely add a reference to a .exe... | 2 | 0 | 0 | With python, I can use if __name__ == "__main__": for using the module both as a library and a program.
Can I mimic this feature in C#?
I see a class in C# can have a 'static void Main()', but I'm not sure if every class can have a Main() without a problem.
ADDED
/m:CLASS_NAME is a way to specify the class to run the... | if __name__ == "__main__": equivalent in C# | 1.2 | 0 | 0 | 901 |
4,452,735 | 2010-12-15T17:07:00.000 | 6 | 0 | 1 | 0 | c#,python | 4,452,790 | 3 | false | 0 | 0 | You can compile a C# project as a program (executable) with a Main() method, and you'd still be able to use it as a library. No special syntax required.
You could add a Main() method to every class, but I doubt it's useful.
.NET applications usually have different structures than Python ones; trying to fit the same pro... | 2 | 0 | 0 | With python, I can use if __name__ == "__main__": for using the module both as a library and a program.
Can I mimic this feature in C#?
I see a class in C# can have a 'static void Main()', but I'm not sure if every class can have a Main() without a problem.
ADDED
/m:CLASS_NAME is a way to specify the class to run the... | if __name__ == "__main__": equivalent in C# | 1 | 0 | 0 | 901 |
4,453,724 | 2010-12-15T18:57:00.000 | 2 | 1 | 1 | 0 | python,encryption,aes | 4,453,804 | 3 | false | 0 | 0 | Ideally, you would not be at a cipher level in order to secure your data. If nothing else, use an existing, proven secure, framework such as GPG to handle file encryption. This is driven home by your question regarding AES: you haven't even mentioned what cipher modes you were considering (CBC, XTR, CTR, CFB, EBC, etc)... | 1 | 3 | 0 | I am looking to implement a simple project that backs up files and encrypts them using AES.
The normal backing up part is done thanks to how Python handles everything ... however I need to encrypt the data also.
So my questions are:
Is AES the best encryption algorithm for encrypting the files or I can do better?
What... | AES encryption of files with Python | 0.132549 | 0 | 0 | 2,086 |
4,455,197 | 2010-12-15T21:38:00.000 | 0 | 0 | 0 | 0 | python,authentication,authorization,web-frameworks | 4,638,281 | 2 | false | 1 | 0 | I have an answer, after a bit of fiddling.
The answer is that the only reason to use the authentication schema suggested in the repoze.what documentation is that if you do, you can use their predicates for free. Fortunately, writing & using your own predicates is a piece of cake. It seems to me that the only hard requ... | 1 | 0 | 0 | I'm writing a web app, and I'd like to use repoze.what & repoze.who to handle my authorisation & authentication. The problem is that repoze.what seems to be hard-coded to accept a certain permissions model, that is:
Visitors to the site are either a logged in user, or anonymous.
User accounts belong to 0 or more group... | alternative permissions model with repoze.what | 0 | 0 | 0 | 225 |
4,455,845 | 2010-12-15T23:01:00.000 | 6 | 0 | 0 | 0 | python,django,http,ios,csrf | 4,457,172 | 2 | true | 1 | 0 | Is your goal to re-use an existing form? if so, iPhone app should GET the page with the form and then POST using the CSRF token. The whole point of CSRF tokens is that the server has to generate them.
Is your goal to authenticate the iPhone app so that other apps can't POST to your API? That is a can of worms, since an... | 1 | 3 | 0 | Here's the thing:
Right now, on my website template, there is {% csrf_token %} that allows my website to send a POST request of a form.
But what if my iPhone app (a client) wants to send a POST request to my web service? How do I give my iPhone app a CSRF token that it can temporarily use? | How do I generate a Django CSRF key for my iPhone and Android apps that want to send a POST request? | 1.2 | 0 | 0 | 1,747 |
4,455,973 | 2010-12-15T23:21:00.000 | 1 | 1 | 0 | 1 | python,root | 4,456,065 | 2 | false | 0 | 0 | you could copy python binary to python-suid,
chown it to user you want to run scripts as and chown u+s python-suid
then in script #!/usr/bin/python-suid | 2 | 1 | 0 | I have a python script which I would like to launch from inittab, shown below
s1:respawn:/home/a_user/app/script.py
I believe initab executes as root, so the a_user's envrinment is not available
The script needs to know "a_user" home directory for ini file settings and log file storage. I would like to avoid hard codi... | Executing a python script from inittab not as root | 0.099668 | 0 | 0 | 1,378 |
4,455,973 | 2010-12-15T23:21:00.000 | 1 | 1 | 0 | 1 | python,root | 4,456,006 | 2 | false | 0 | 0 | Use runuser (or the distro's equvalent) to run it as a different user. runuser does change $HOME, but other similar commands may not. | 2 | 1 | 0 | I have a python script which I would like to launch from inittab, shown below
s1:respawn:/home/a_user/app/script.py
I believe initab executes as root, so the a_user's envrinment is not available
The script needs to know "a_user" home directory for ini file settings and log file storage. I would like to avoid hard codi... | Executing a python script from inittab not as root | 0.099668 | 0 | 0 | 1,378 |
4,455,999 | 2010-12-15T23:25:00.000 | 3 | 1 | 1 | 0 | python,powershell | 4,456,153 | 1 | true | 0 | 0 | I am not sure why you got downvoted as this is a legitimate question. I think the best integration you are going to get trying to integrate PowerShell into CPython will be through spawning a new process and passing in the PowerShell script you want run. Unfortunately this will also mean parsing any output that is gener... | 1 | 11 | 0 | I know it is possible to use Powershell from within IronPython, but is this possible using CPython beyond using Popen() and other similar calls? I'm trying to do some very basic NET framework programming (windows Forms, etc.) like you can do inside of IronPython using CPython.
Thanks!
Any help appreciated. | Powershell integration with Python (not IronPython) | 1.2 | 0 | 0 | 2,213 |
4,456,444 | 2010-12-16T00:42:00.000 | 1 | 0 | 0 | 0 | python,django,templates,frameworks | 4,456,547 | 1 | true | 1 | 0 | Um... yes?
More seriously - whatever makes you happier. If you're in a hurry, roll your own; if you have a bit more time, by all means get to know the Django system; it'll probably be worthwhile in the longer run. | 1 | 1 | 0 | I'm split between writing my own comments model (pretty easy model, foreign key it to the entry) or using the full-out Django comment framework.
I mean, for right now, I just want a basic box for people to post a comment. That's it. | If I just want a simple comment box below my entry, should I use Django's comment framework or write my own? | 1.2 | 0 | 0 | 477 |
4,456,591 | 2010-12-16T01:14:00.000 | 0 | 0 | 0 | 0 | python,django,django-forms,media | 4,462,233 | 2 | false | 1 | 0 | What happens if you just use {{ form.media }} for each form, and link up the media in the form's Meta? I seem to remember that making sure that it didn't insert anything twice, but it's been a while.
Have you tried that yet? | 1 | 2 | 0 | I send several forms to a template, and I want to put all required media in the <head> tag. Some forms might require the same media (for instance, the same JS file), so I would like to unify all medias before putting them in the <head>. Question is, how do I do that? I know you can unify two medias by doing m1 + m2, bu... | Django: correct way to group a bunch of media's | 0 | 0 | 0 | 135 |
4,458,090 | 2010-12-16T06:34:00.000 | 0 | 1 | 1 | 0 | python,text,encoding,character-encoding,decoding | 14,012,214 | 4 | false | 0 | 0 | Working with xlrd, I have in a line
...xl_data.find(str(cell_value))...
which gives the error:"'ascii' codec can't encode character u'\xdf' in position 3: ordinal not in range(128)".
All suggestions in the forums have been useless for my german words.
But changing into:
...xl_data.find(cell.value)...
gives no error.
S... | 1 | 0 | 0 | I have this text in a file - Recuérdame (notice it's a French word). When I read this file with a python script, I get this text as Recuérdame.
I read it as a unicode string. Do I need to find what the encoding of the text is & decode this? or is my terminal playing tricks on me? | Python Text Encoding | 0 | 0 | 0 | 3,875 |
4,458,701 | 2010-12-16T08:24:00.000 | 8 | 0 | 1 | 0 | python,memory,python-idle | 62,961,863 | 4 | false | 0 | 0 | How about dir() which will output instantiated objects as a list? I just used this just now:
[x for x in dir() if x.lower().startswith('y')] | 1 | 53 | 0 | Say that in the python shell (IDLE) I have defined some classes, functions, variables. Also created objects of the classes. Then I deleted some of the objects and created some others. At a later point in time, how can I get to know what are the currently active objects, variables, and methods definitions active in the ... | How to get the list of all initialized objects and function definitions alive in python? | 1 | 0 | 0 | 51,812 |
4,458,890 | 2010-12-16T08:49:00.000 | 0 | 0 | 1 | 0 | python,database,multithreading,webserver | 4,458,917 | 5 | false | 1 | 0 | If the Web server is single-threaded and DB requests are synchronous (meaning the Web server is blocked while the DB request is being processed) then making it multi-threaded would help.
This would enable you to process multiple requests simultaneously. Your DB engine is probably quite good at that. However, right now ... | 5 | 4 | 0 | We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded.
The problem i... | Multi threaded webserver vs single threaded | 0 | 0 | 0 | 7,079 |
4,458,890 | 2010-12-16T08:49:00.000 | 0 | 0 | 1 | 0 | python,database,multithreading,webserver | 4,458,945 | 5 | false | 1 | 0 | My instinct says you're right, but it also says that using Django or Cherrypy is WAY overkill, even if you did want to make it multithreaded.
I think you're right, though, since if the webserver really isn't doing anything other than working a DB, then any other thread wouldn't be able to do anything other than start a... | 5 | 4 | 0 | We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded.
The problem i... | Multi threaded webserver vs single threaded | 0 | 0 | 0 | 7,079 |
4,458,890 | 2010-12-16T08:49:00.000 | 3 | 0 | 1 | 0 | python,database,multithreading,webserver | 4,458,981 | 5 | false | 1 | 0 | Having several threads or processes will indeed help you (indeed it's in practice required) when you want to handle more than one request at a time.
That doesn't mean that the two requests will be handled faster. Having a pool of processes or threads is very helpful for webserver performance, but that's not really noti... | 5 | 4 | 0 | We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded.
The problem i... | Multi threaded webserver vs single threaded | 0.119427 | 0 | 0 | 7,079 |
4,458,890 | 2010-12-16T08:49:00.000 | 0 | 0 | 1 | 0 | python,database,multithreading,webserver | 4,459,115 | 5 | false | 1 | 0 | You should go for multithreaded or asynchronous webserver, otherwise each request is being blocked. Django is a web framework, you might have to look for scripts which you can transparently replace in your current setup and still have your pure python multithreaded webserver. Otherwise twisted is a good solution too. A... | 5 | 4 | 0 | We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded.
The problem i... | Multi threaded webserver vs single threaded | 0 | 0 | 0 | 7,079 |
4,458,890 | 2010-12-16T08:49:00.000 | 1 | 0 | 1 | 0 | python,database,multithreading,webserver | 4,460,274 | 5 | false | 1 | 0 | Step 1. Use Apache. It may seem like overkill but it's cheap multi-threading with no programming on your part. Apache can be configured to fork off several servers. No programming on your part.
This may be sufficient to make your application run concurrently.
Step 2. Rewrite your application to use the wsgi framew... | 5 | 4 | 0 | We have a simple webserver for internal use that has only one duty: listen for requests, read them, and push the data in a database. The db and webserver are both located on the same machine. The db is a mysql-db and the server is a python webserver (BaseHTTPServer.HTTPServer) which runs single threaded.
The problem i... | Multi threaded webserver vs single threaded | 0.039979 | 0 | 0 | 7,079 |
4,459,352 | 2010-12-16T09:49:00.000 | 2 | 0 | 1 | 0 | python,algorithm,qwerty | 4,469,544 | 4 | false | 0 | 0 | I don't have any algorithms to propose, but a few hints:
I use both hands to type, meaning that the keyboard is roughly split in 2 halves, it is frequent that I have coordination issues between the two hands, meaning that each type the letters in the "right" order but the interleaving is wrong. This is especially true... | 2 | 13 | 0 | I'm looking for a reasonably simple algorithm to determine how difficult it is to type a word on the QWERTY layout.
The words would not necessarily be dictionary words, so a list of commonly mistyped words or the like is not an option. I'm sure there must be an existing, well-tested algorithm, but I can't find anything... | Determining how difficult a word is to type on a QWERTY keyboard | 0.099668 | 0 | 0 | 3,967 |
4,459,352 | 2010-12-16T09:49:00.000 | 1 | 0 | 1 | 0 | python,algorithm,qwerty | 4,459,438 | 4 | false | 0 | 0 | Take out your Scrabble set, note down the scores for each letter, total the scores for a word, hey presto you have your algorithm. Not sure it entirely satisfies your requirements, but it might point you in a useful direction. You might, for instance, want to assign scores not only to individual letters but also to d... | 2 | 13 | 0 | I'm looking for a reasonably simple algorithm to determine how difficult it is to type a word on the QWERTY layout.
The words would not necessarily be dictionary words, so a list of commonly mistyped words or the like is not an option. I'm sure there must be an existing, well-tested algorithm, but I can't find anything... | Determining how difficult a word is to type on a QWERTY keyboard | 0.049958 | 0 | 0 | 3,967 |
4,460,921 | 2010-12-16T12:49:00.000 | 0 | 0 | 1 | 0 | python,wikipedia | 4,460,959 | 10 | false | 0 | 0 | Try a combination of urllib to fetch the site and BeautifulSoup or lxml to parse the data. | 1 | 42 | 1 | How can I extract the first paragraph from a Wikipedia article, using Python?
For example, for Albert Einstein, that would be:
Albert Einstein (pronounced /ˈælbərt
ˈaɪnstaɪn/; German: [ˈalbɐt ˈaɪnʃtaɪn]
( listen); 14 March 1879 – 18 April
1955) was a theoretical physicist,
philosopher and author who is widely
... | Extract the first paragraph from a Wikipedia article (Python) | 0 | 0 | 0 | 49,932 |
4,461,191 | 2010-12-16T13:27:00.000 | 1 | 1 | 1 | 0 | ironpython | 4,467,668 | 1 | false | 0 | 0 | You can get the ExceptionOperations object from scriptEngine.GetService(). You can then call FormatException or GetStackFrames. You can also set the ExceptionDetail option to true to get more verbose stack traces from FormatException. | 1 | 2 | 0 | I have an application written in IronPython which uses classes and methods from imported .NET assembly (compiled with debug support). When a method in assembly throws an exception, it gets caught in IronPython code as Exception (not System.Exception) and the traceback ends at last IronPython method.
What I would like t... | Combine IronPython's and CLI stack trace | 0.197375 | 0 | 0 | 323 |
4,462,068 | 2010-12-16T14:56:00.000 | 0 | 0 | 1 | 0 | python,google-app-engine,printing | 4,462,590 | 4 | false | 0 | 0 | This is just a wild guess, but if item['pubDate'] is a non-string object it might a result of differences between special methods. Perhaps the __str__ method returns nothing, while the __add__ method does something different. | 2 | 2 | 0 | why this does not print anything:
for item in pipe.json["value"]["items"]:
print item["pubDate"]
but this does:
for item in pipe.json["value"]["items"]:
print item["pubDate"] + "\n"
p.s. the loop is running inside another loop.
p.p.s. this is running inside google app engine application.i have looked at http re... | weird python print behaviour | 0 | 0 | 0 | 259 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.