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
3,481,554
2010-08-14T01:00:00.000
0
0
1
0
python,operators
3,481,558
5
false
0
0
It just personal preference. You could also compare if x != 3 and if not x == 3. There's no difference between the two expressions you've shown.
2
67
0
I've noticed that both of these work the same: if x not in list and if not x in list. Is there some sort of difference between the two in certain cases? Is there a reason for having both, or is it just because it's more natural for some people to write one or the other? Which one am I more likely to see in other people...
"x not in" vs. "not x in"
0
0
0
32,712
3,481,554
2010-08-14T01:00:00.000
3
0
1
0
python,operators
3,481,565
5
false
0
0
not x in L isn't explicitly disallowed because that would be silly. x not in L is explicitly allowed (though it compiles to the same bytecode) because it's more readable. x not in L is what everyone uses, though.
2
67
0
I've noticed that both of these work the same: if x not in list and if not x in list. Is there some sort of difference between the two in certain cases? Is there a reason for having both, or is it just because it's more natural for some people to write one or the other? Which one am I more likely to see in other people...
"x not in" vs. "not x in"
0.119427
0
0
32,712
3,481,949
2010-08-14T04:01:00.000
2
1
1
0
python,komodo,komodoedit
3,482,353
1
true
0
0
Problem solved itself when I closed Komodo, saving the project, and reopened it. Sounds like Komodo's internal representation was out-of-date or corrupted. I'll leave the question here for the next person who stumbles over it.
1
2
0
I am using Komodo edit on a Python file on Windows. When I type import s it successfully lists all the importable files starting with s, including one of my modules in one of my directories. When I type import t it lists all the importable files starting with t, EXCLUDING one of my modules in the same directory. Even t...
Komodo Edit auto-complete won't find a Python module
1.2
0
0
1,865
3,482,112
2010-08-14T05:13:00.000
1
0
1
0
python,event-handling,wxpython
3,482,120
3
false
0
0
If communicating by stdin/stdout is what you need, you should use the subprocess module.
1
3
0
I'm working on one GUI program, and was gonna add a long running task into one event, but I found this would make the whole program freeze a lot, so considering other people's advice I would make the GUI only responsible for starting, stopping and monitoring and make the long running task run as a separate script. The ...
How to control/call another python script within one python script? (Communicate between scripts)
0.066568
0
0
2,081
3,482,152
2010-08-14T05:27:00.000
0
0
0
1
python,google-app-engine,redirect
3,483,631
2
false
1
0
You need to use a third-party site to do the redirection to www.*; many registrars offer this service. Godaddy's service (which is even free with domain registration) forwards foo.com/bar to www.foo.com/bar; I can't speak to the capabilities of the others but it seems to me that any one that doesn't behave this way is...
1
4
0
I'm working on a site, colorurl.com, and I need users to be able to type in colorurl.com/00ff00 (or some variation of that), and see the correct page. However, with the naked domain issue, users who type in colorurl.com/somepath will instead be redirected to www.colorurl.com/. Is there a way to detect this in python, a...
Google App Engine - Naked Domain Path Redirect in Python
0
0
1
830
3,482,622
2010-08-14T08:38:00.000
5
1
0
1
python,ide,autocomplete,duck-typing,built-in
9,430,038
7
false
0
0
Just to keep it up to date so that new readers are not confused about the current state of Pydev - the example you gave now works in Pydev. (btw, one should avoid operating on paths manualy - use os.path.join instead)
1
5
0
I'm new to Python, with a background in statically typed languages including lots and lots of Java. I decided on PyDev in eclipse as an IDE after checking features/popularity etc. I was stunned that auto-complete doesn't seem to work properly for builtins. For example if I try automcomplete on datafile after: datafile ...
Autocompletion in dynamic language IDEs, specifically Python in PyDev
0.141893
0
0
3,018
3,483,179
2010-08-14T12:03:00.000
1
0
0
0
python,listbox,wxpython,center,alignment
3,506,756
1
true
0
1
No, the default ListBox won't work for that. Try the VListBox instead.
1
0
0
I want the text of the ListBox to be centered, is that possible?
How to align the text in a wx.ListBox using wxPython?
1.2
0
0
434
3,483,492
2010-08-14T13:25:00.000
2
0
0
0
ironpython,pyqt
3,490,601
3
false
0
1
Hope someone else who spent more time messing around with this comes by and gives you qualified, ambiguous answer, but here is some questionable insight from my personal experience: PyQt relates to cPython in a way that is very different than .Net relates to IronPython. While IronPython is built on TOP of .Net, PyQt is...
1
2
0
Is it possible to use PyQt from IronPython? From what I've read IronPython should work with CPython compatible libraries but out of the box it doesn't seem to work. If it is possible, will code completion work?
Using PyQt from IronPython
0.132549
0
0
2,411
3,483,520
2010-08-14T13:32:00.000
9
0
1
0
python,dictionary,setdefault
6,287,888
18
false
0
0
As Muhammad said, there are situations in which you only sometimes wish to set a default value. A great example of this is a data structure which is first populated, then queried. Consider a trie. When adding a word, if a subnode is needed but not present, it must be created to extend the trie. When querying for the pr...
2
217
0
The addition of collections.defaultdict in Python 2.5 greatly reduced the need for dict's setdefault method. This question is for our collective education: What is setdefault still useful for, today in Python 2.6/2.7? What popular use cases of setdefault were superseded with collections.defaultdict?
Use cases for the 'setdefault' dict method
1
0
0
117,147
3,483,520
2010-08-14T13:32:00.000
3
0
1
0
python,dictionary,setdefault
40,944,406
18
false
0
0
One drawback of defaultdict over dict (dict.setdefault) is that a defaultdict object creates a new item EVERYTIME non existing key is given (eg with ==, print). Also the defaultdict class is generally way less common then the dict class, its more difficult to serialize it IME. P.S. IMO functions|methods not meant to mu...
2
217
0
The addition of collections.defaultdict in Python 2.5 greatly reduced the need for dict's setdefault method. This question is for our collective education: What is setdefault still useful for, today in Python 2.6/2.7? What popular use cases of setdefault were superseded with collections.defaultdict?
Use cases for the 'setdefault' dict method
0.033321
0
0
117,147
3,483,675
2010-08-14T14:11:00.000
0
0
0
0
python,event-handling,wxpython
41,389,878
2
false
0
1
In the __init__( ) for your main frame put this: wx.CallAfter( func_name )
2
0
0
I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being "clicked" once the program ...
How to make a event run immediately after a GUI program starts in wxpython?
0
0
0
205
3,483,675
2010-08-14T14:11:00.000
1
0
0
0
python,event-handling,wxpython
3,483,688
2
true
0
1
In the main frame constructor set a one-shot timer with interval 0 that fires the event.
2
0
0
I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being "clicked" once the program ...
How to make a event run immediately after a GUI program starts in wxpython?
1.2
0
0
205
3,483,723
2010-08-14T14:24:00.000
0
0
1
0
python,macos
69,496,412
5
false
0
0
The command brew install readline worked for me.
2
27
0
I was wondering if anyone can explain why all of a sudden in Python interactive mode all arrow keys are failing? When I press up button for example to go through command history I get "^[[A". Same with any other arrow keys. I have no idea why this happened and it was working before (on OS X Snow Leopard). Does anyone k...
Python interactive mode history and arrow keys
0
0
0
10,940
3,483,723
2010-08-14T14:24:00.000
15
0
1
0
python,macos
26,222,005
5
false
0
0
If you are using homebrew, this is an easy fix: brew uninstall python brew uninstall readline brew install readline --universal brew install python That fixed it for me (running OS X Mavericks 10.9.5)
2
27
0
I was wondering if anyone can explain why all of a sudden in Python interactive mode all arrow keys are failing? When I press up button for example to go through command history I get "^[[A". Same with any other arrow keys. I have no idea why this happened and it was working before (on OS X Snow Leopard). Does anyone k...
Python interactive mode history and arrow keys
1
0
0
10,940
3,484,232
2010-08-14T16:47:00.000
7
1
0
0
c#,powershell,ironpython,ironruby,dynamic-language-runtime
3,484,368
3
false
0
0
number 2 is true (the dynamic lang teams have been losing headcount for awhile now) and an excellent reason. Ruby and Python aren't MS languages, and as such Iron * is just 'get it working on .NET'. PowerShell is a Microsoft creation, Microsoft-controlled, and Microsoft-supported. More importantly, multiple Microsoft...
3
12
0
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!): 1) It's simple to create a runspace with classes in...
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
1
0
0
3,780
3,484,232
2010-08-14T16:47:00.000
12
1
0
0
c#,powershell,ironpython,ironruby,dynamic-language-runtime
3,496,609
3
false
0
0
I'm not convinced PowerShell has "being a scripting language for applications" anywhere in it's long-term goals. It's first a shell, second an integration & automation engine, and third a shell scripting language ... since it's not redistributable at all, I'm not sure where embedded scripting fits in. It's certainly ...
3
12
0
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!): 1) It's simple to create a runspace with classes in...
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
1
0
0
3,780
3,484,232
2010-08-14T16:47:00.000
2
1
0
0
c#,powershell,ironpython,ironruby,dynamic-language-runtime
3,504,982
3
false
0
0
I'm in a similar position. I decided to use IronPython scripting but ever since I saw Anders Hejlsberg's talk "The Future of C#", I've had a feeling IronPython was doomed. It was in Microsoft's interest to get the DLR developed but they ultimately want us to use tools and languages they control. After all, aren't yo...
3
12
0
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!): 1) It's simple to create a runspace with classes in...
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?
0.132549
0
0
3,780
3,485,203
2010-08-14T21:34:00.000
0
0
0
0
python,networking,snmp
3,486,005
3
false
0
0
You might try running nmap against the ports you want to check, but that won't necessarily give you an indication that the server process on the other side of an open port is alive.
2
3
0
Is there a way to monitor server ports using SNMP (I'm using net-snmp-python to check this with python). So far I've checked pretty simple with "nc" command, however I want to see if I can do this with SNMP. Thank you for your answers and patience.
Check ports with SNMP (net-snmp)
0
0
1
9,078
3,485,203
2010-08-14T21:34:00.000
0
0
0
0
python,networking,snmp
3,485,524
3
false
0
0
It's hard to see where SNMP might fit in. The best way to monitor would be to use a protocol specific client (i.e., run a simple query v.s. MySQL, retrieve a test file using FTP, etc.) If that doesn't work, you can open a TCP or UDP socket to the ports and see if anyone is listening.
2
3
0
Is there a way to monitor server ports using SNMP (I'm using net-snmp-python to check this with python). So far I've checked pretty simple with "nc" command, however I want to see if I can do this with SNMP. Thank you for your answers and patience.
Check ports with SNMP (net-snmp)
0
0
1
9,078
3,485,369
2010-08-14T22:28:00.000
3
0
0
0
python,django,django-admin
3,485,462
3
true
1
0
Stripping the junk and such should be done with a custom formfield. Downloading the images... there are multiple ways to fix that problem. If you choose to store the image location and original location in the database, than you should do it with a pre-save signal. If you choose to store the images locally directly, t...
1
3
0
I have a Django model with a text field. I'm using a rich text editor (nicEdit) on the admin site to allow the client to easily enter markup into the field. I'd like to process the contents of the field and perform a few actions before anything is inserted into the database. For example, I want to strip junk generated ...
Process field before database insert / update
1.2
0
0
2,000
3,486,372
2010-08-15T05:49:00.000
1
0
1
0
python,http
3,486,383
3
false
0
0
You are going to have to implement that asynchronously as HTTP protocol states you have a request and a reply. Another option would be to work directly with the socket, bypassing any pre-built module. This would allow you to violate protocol and write your own bit that ignores any responses, in essence dropping the co...
2
6
0
I want to send it and forget it. The http rest service call I'm making takes a few seconds to respond. The goal is to avoid waiting those few seconds before more code can execute. I'd rather not use python threads I'll use twisted async calls if I must and ignore the response.
How can I make an http request without getting back an http response in Python?
0.066568
0
1
2,585
3,486,372
2010-08-15T05:49:00.000
0
0
1
0
python,http
3,486,378
3
false
0
0
HTTP implies a request and a reply for that request. Go with an async approach.
2
6
0
I want to send it and forget it. The http rest service call I'm making takes a few seconds to respond. The goal is to avoid waiting those few seconds before more code can execute. I'd rather not use python threads I'll use twisted async calls if I must and ignore the response.
How can I make an http request without getting back an http response in Python?
0
0
1
2,585
3,486,384
2010-08-15T05:54:00.000
3
0
1
0
python
46,546,045
8
false
0
0
Most of previous examples will raise an exception in case your string is not long enough. Another approach is to use 'yourstring'.ljust(100)[:100].strip(). This will give you first 100 chars. You might get a shorter string in case your string last chars are spaces.
1
121
0
Can seem to find a substring function in python. Say I want to output the first 100 characters in a string, how can I do this? I want to do it safely also, meaning if the string is 50 characters it shouldn't fail.
Output first 100 characters in a string
0.07486
0
0
174,305
3,486,708
2010-08-15T08:28:00.000
0
0
0
1
bash,shell,wxpython
3,506,700
2
false
0
0
Maybe pyCrust plus the Python debugger?
1
0
0
Hey I want to create a bash-shell in wxPython, the only thing it should be able to do is run a python file and be able to offer user_input on the fly. (I know there is a Python Shell, but that is something different) Can someone help me with this? thanks in advance
wxPython -- Bash shell
0
0
0
330
3,487,447
2010-08-15T12:59:00.000
0
1
0
0
python,scripting,sms,libgmail
3,487,491
1
true
0
0
As far as I know libgmail is not compatible with the current Gmail interface. If I am not mistaken libgmail is not actively maintained either. You might want to look at alternative options.
1
1
0
i'm new to python , and trying to write a script in order to send SMS's , after quick googling i found this lib: libgmail, and successfully installed it , this is the code i use to send SMS: !/usr/bin/env python import libgmail ga = libgmail.GmailAccount("username@gmail.com", "password") myCellEmail = "phonenumber@mes...
cant send SMS vla libgmail - python
1.2
0
0
571
3,487,456
2010-08-15T13:00:00.000
10
0
0
0
python,sqlite,mongodb
3,491,117
5
false
0
0
As others have said, MongoDB does not have single-server durability right now. Fortunately, it's dead easy to set up multi-node replication. You can even set up a second machine in another data center and have data automatically replicated to it live! If a write must succeed, you can cause Mongo to not return from an i...
3
12
0
I have a couple of sqlite dbs (i'd say about 15GBs), with about 1m rows in total - so not super big. I was looking at mongodb, and it looks pretty easy to work with, especially if I want to try and do some basic natural language processing on the documents which make up the databases. I've never worked with Mongo in t...
Mongodb - are reliability issues significant still?
1
1
0
3,302
3,487,456
2010-08-15T13:00:00.000
3
0
0
0
python,sqlite,mongodb
3,488,244
5
false
0
0
Mongo does not have ACID properties, specifically durability. So you can face issues if the process does not shut down cleanly or the machine loses power. You are supposed to implement backups and redundancy to handle that.
3
12
0
I have a couple of sqlite dbs (i'd say about 15GBs), with about 1m rows in total - so not super big. I was looking at mongodb, and it looks pretty easy to work with, especially if I want to try and do some basic natural language processing on the documents which make up the databases. I've never worked with Mongo in t...
Mongodb - are reliability issues significant still?
0.119427
1
0
3,302
3,487,456
2010-08-15T13:00:00.000
2
0
0
0
python,sqlite,mongodb
3,490,547
5
false
0
0
I don't see the problem if you have the same data also in the sqlite backups. You can always refill your MongoDb databases. Refilling will only take a few minutes.
3
12
0
I have a couple of sqlite dbs (i'd say about 15GBs), with about 1m rows in total - so not super big. I was looking at mongodb, and it looks pretty easy to work with, especially if I want to try and do some basic natural language processing on the documents which make up the databases. I've never worked with Mongo in t...
Mongodb - are reliability issues significant still?
0.07983
1
0
3,302
3,487,507
2010-08-15T13:16:00.000
0
1
1
0
python,unit-testing,readability
3,488,720
3
false
0
0
It feels like there maybe some room for breaking your method into smaller pieces. Ones focused on dealing with parsing input and formatting output, could be separate from the actual clustering logic. This way tests around your clustering methods would be fewer and dealing with easily understood and testable data stru...
2
4
0
I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things: Does each cluster contain the correct elements (and maybe other properties as well)? Does each ...
Writing unittests for a function that returns a hierarchy of objects
0
0
0
72
3,487,507
2010-08-15T13:16:00.000
2
1
1
0
python,unit-testing,readability
3,487,617
3
true
0
0
If there are isomorphic results, you should probably have a predicate that can test for logical equivalence. This would likely be good for your code unit as well as helping to implement the unit test. This is the core of Manoj Govindan's answer without the string intermediates and since you aren't interested in string ...
2
4
0
I have a function that performs a hierarchical clustering on a list of input vectors. The return value is the root element of an object hierarchy, where each object represents a cluster. I want to test the following things: Does each cluster contain the correct elements (and maybe other properties as well)? Does each ...
Writing unittests for a function that returns a hierarchy of objects
1.2
0
0
72
3,488,256
2010-08-15T16:41:00.000
2
0
1
0
python,windows-7,python-idle
16,830,685
10
false
0
0
I ran into this weird situation also, and did a bit of troubleshooting. As a rigorous task, uninstalling, and re-installing the versions of python(2.6, 2.7, 3.1) and all my associated extensions and other site packages: in addition to the subsequent options that others have provided, that may have, or may not have, hel...
7
7
0
I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1. Right now Idle cannot launch. What should i do to get it running? NOTE: I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py i uninstalled 3.1 and installed back 2.7, not working neither...
Python IDLE is not starting on Windows 7
0.039979
0
0
62,164
3,488,256
2010-08-15T16:41:00.000
10
0
1
0
python,windows-7,python-idle
29,646,059
10
false
0
0
I got the same problem on window 10. Steps to solve the problem: Locate the .idlerc folder in your profile directory (e.g. C:\Users\{your-username} without the braces). Delete the .idlerc directory. It worked for me...
7
7
0
I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1. Right now Idle cannot launch. What should i do to get it running? NOTE: I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py i uninstalled 3.1 and installed back 2.7, not working neither...
Python IDLE is not starting on Windows 7
1
0
0
62,164
3,488,256
2010-08-15T16:41:00.000
6
0
1
0
python,windows-7,python-idle
10,644,585
10
false
0
0
I too faced the same problem. But at last solved like this --> Run Python\Lib\idlelib\idle.py as admin, i got the error that the file "recent-files.lst" can't be opened. So go to your home folder, show hidden files, click on .idlerc and delete the file named "recent-files". Now IDLE is working...
7
7
0
I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1. Right now Idle cannot launch. What should i do to get it running? NOTE: I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py i uninstalled 3.1 and installed back 2.7, not working neither...
Python IDLE is not starting on Windows 7
1
0
0
62,164
3,488,256
2010-08-15T16:41:00.000
0
0
1
0
python,windows-7,python-idle
27,628,227
10
false
0
0
Run python setup program, change python 2x, choose to entirely remove tcl/tk, proceed, then run setup again, change python again, on the tcl\tk choose entire feature will be installed, proceed. It worked for me.
7
7
0
I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1. Right now Idle cannot launch. What should i do to get it running? NOTE: I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py i uninstalled 3.1 and installed back 2.7, not working neither...
Python IDLE is not starting on Windows 7
0
0
0
62,164
3,488,256
2010-08-15T16:41:00.000
0
0
1
0
python,windows-7,python-idle
40,044,077
10
false
0
0
Even I was facing same issue with my code, But It is resolved now. I was using 2.6 which was having old version of Xlrd, so I updated xlrd in 2.7 using pip and I opened my file with 2.7 and it works.
7
7
0
I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1. Right now Idle cannot launch. What should i do to get it running? NOTE: I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py i uninstalled 3.1 and installed back 2.7, not working neither...
Python IDLE is not starting on Windows 7
0
0
0
62,164
3,488,256
2010-08-15T16:41:00.000
1
0
1
0
python,windows-7,python-idle
35,168,182
10
false
0
0
Once I copied the C:\Python27\tcl\tcl8.5 folder to C:\Python27\Lib as suggested in Bogdan's answer the error message "This probably means that Tcl wasn't installed properly" went away. Instead I started seeing "This probably means that tk wasn't installed properly". I had to copy the C:\Python27\tcl\tk8.5 folder to C...
7
7
0
I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1. Right now Idle cannot launch. What should i do to get it running? NOTE: I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py i uninstalled 3.1 and installed back 2.7, not working neither...
Python IDLE is not starting on Windows 7
0.019997
0
0
62,164
3,488,256
2010-08-15T16:41:00.000
0
0
1
0
python,windows-7,python-idle
52,254,251
10
false
0
0
Delete the .idlerc directory as suggested above, run the python installer again and choose repair. If needed associate the .py files with the python.exe executable in Python27 folder. This worked for me after removing python 3.7.
7
7
0
I used to use Python 2.7 and then IDLE was working. I uninstalled it and installed Python 3.1. Right now Idle cannot launch. What should i do to get it running? NOTE: I tried c:\Python31\pythonw.exe c:\Python31\Lib\idlelib\idle.py i uninstalled 3.1 and installed back 2.7, not working neither...
Python IDLE is not starting on Windows 7
0
0
0
62,164
3,488,548
2010-08-15T18:00:00.000
0
0
1
0
python,module,directory,importerror
20,068,252
5
false
0
0
Where are you storing the module you created? When I create a module, I do the following: Create a folder in the lib\sitepackages folder in your python folder ex: myModules Save a blank python file named init.py in this folder. The file does not have to contain any syntax. Later on, you can set module requirements in ...
2
4
0
I run Windows 7, and I can import built-in modules, but when I save my own script and try to import it in IDLE, I get an error saying that the module doesn't exist. I use the Python text editor found by clicking "File" and "New Window" from the Python Shell. I save it as a .py file within a Module folder I created with...
Python Module Importing Issues
0
0
0
18,759
3,488,548
2010-08-15T18:00:00.000
4
0
1
0
python,module,directory,importerror
3,488,565
5
true
0
0
Python uses PYTHONPATH environment variable to define a list of folders which should be looked at when importing modules. Most likely your folder is not PYTHONPATH
2
4
0
I run Windows 7, and I can import built-in modules, but when I save my own script and try to import it in IDLE, I get an error saying that the module doesn't exist. I use the Python text editor found by clicking "File" and "New Window" from the Python Shell. I save it as a .py file within a Module folder I created with...
Python Module Importing Issues
1.2
0
0
18,759
3,489,071
2010-08-15T20:22:00.000
1
0
1
0
python,list,dictionary,data-structures,set
59,817,607
13
false
0
0
Dictionary: A python dictionary is used like a hash table with key as index and object as value. List: A list is used for holding objects in an array indexed by position of that object in the array. Set: A set is a collection with functions that can tell if an object is present or not present in the set.
6
331
0
When should I use a dictionary, list or set? Are there scenarios that are more suited for each data type?
In Python, when to use a Dictionary, List or Set?
0.015383
0
0
207,368
3,489,071
2010-08-15T20:22:00.000
1
0
1
0
python,list,dictionary,data-structures,set
44,613,023
13
false
0
0
Lists are what they seem - a list of values. Each one of them is numbered, starting from zero - the first one is numbered zero, the second 1, the third 2, etc. You can remove values from the list, and add new values to the end. Example: Your many cats' names. Tuples are just like lists, but you can't change their value...
6
331
0
When should I use a dictionary, list or set? Are there scenarios that are more suited for each data type?
In Python, when to use a Dictionary, List or Set?
0.015383
0
0
207,368
3,489,071
2010-08-15T20:22:00.000
634
0
1
0
python,list,dictionary,data-structures,set
3,489,100
13
true
0
0
A list keeps order, dict and set don't: when you care about order, therefore, you must use list (if your choice of containers is limited to these three, of course ;-) ). dict associates each key with a value, while list and set just contain values: very different use cases, obviously. set requires items to be hashable,...
6
331
0
When should I use a dictionary, list or set? Are there scenarios that are more suited for each data type?
In Python, when to use a Dictionary, List or Set?
1.2
0
0
207,368
3,489,071
2010-08-15T20:22:00.000
201
0
1
0
python,list,dictionary,data-structures,set
3,489,078
13
false
0
0
Do you just need an ordered sequence of items? Go for a list. Do you just need to know whether or not you've already got a particular value, but without ordering (and you don't need to store duplicates)? Use a set. Do you need to associate values with keys, so you can look them up efficiently (by key) later on? Use a d...
6
331
0
When should I use a dictionary, list or set? Are there scenarios that are more suited for each data type?
In Python, when to use a Dictionary, List or Set?
1
0
0
207,368
3,489,071
2010-08-15T20:22:00.000
20
0
1
0
python,list,dictionary,data-structures,set
3,489,082
13
false
0
0
Use a dictionary when you have a set of unique keys that map to values. Use a list if you have an ordered collection of items. Use a set to store an unordered set of items.
6
331
0
When should I use a dictionary, list or set? Are there scenarios that are more suited for each data type?
In Python, when to use a Dictionary, List or Set?
1
0
0
207,368
3,489,071
2010-08-15T20:22:00.000
25
0
1
0
python,list,dictionary,data-structures,set
3,489,081
13
false
0
0
When you want an unordered collection of unique elements, use a set. (For example, when you want the set of all the words used in a document). When you want to collect an immutable ordered list of elements, use a tuple. (For example, when you want a (name, phone_number) pair that you wish to use as an element in a set,...
6
331
0
When should I use a dictionary, list or set? Are there scenarios that are more suited for each data type?
In Python, when to use a Dictionary, List or Set?
1
0
0
207,368
3,489,183
2010-08-15T20:47:00.000
0
0
1
0
python,timezone
71,177,623
8
false
0
0
Working with the latest version of tzlocal which is 4.1 as of today, tzlocal.get_localzone().key produces the following error: AttributeError: '_PytzShimTimezone' object has no attribute 'key'. But tzlocal.get_localzone().zone works lovely.
1
24
0
In a Python project I'm working on, I'd like to be able to get a "human-readable" timezone name of the form America/New_York, corresponding to the system local timezone, to display to the user. Every piece of code I've seen that accesses timezone information only returns either a numeric offset (-0400) or a letter code...
How can I get a human-readable timezone name in Python?
0
0
0
22,635
3,489,520
2010-08-15T22:25:00.000
0
0
0
0
python,gtk
3,489,566
3
false
0
1
Given the widget w, what does w.get_name() return? If None, that means the widget has no name property. Maybe you want gtk.glade.get_widget_name(w) instead? (I'm not sure if the name property of the widget and the name for it in the Glade XML from which it was created are the same thing...).
1
10
0
How do I get a widget's "name"? When I define a GUI using Glade, I can "name" the widgets of the window but how do I recover that property when I have a widget object instance? I've tried get_property(), get_name() and $widget.name to no avail. Update: I am using GtkBuilder file format (i.e. XML format). Resolution: a ...
Python GTK+ widget name
0
0
0
4,906
3,489,968
2010-08-16T01:02:00.000
3
0
0
1
python,performance,google-app-engine
3,490,013
1
true
1
0
Call start = time.time() as the very first operation in your handling scripts, and, when you're just about done with everything, as the very last thing you output use (a properly formatted version of) time.time() - start. If you're using templates for your output (e.g., the Django templates that come with app engine --...
1
4
0
Say I wanted to print the response time on my pages like Google do. How would I go about doing this?
App Engine - Output Response Time
1.2
0
0
165
3,490,543
2010-08-16T04:09:00.000
4
1
1
0
python,rubygems
3,490,551
2
false
1
0
no it does not have a ruby installer that I know of. It does have easy_install and pip though. Your google-fu is lacking.
1
3
0
With Ruby you can do gem install from the command line to install a module...even if it is not on your machine. Can you do that with python. Does someone know of a module? Seth
Does python have a ruby installer like gem that lets you install modules from the command line even if they are not on your machine?
0.379949
0
0
1,036
3,493,092
2010-08-16T12:29:00.000
33
0
1
0
python,image-processing,numpy,python-imaging-library
3,494,982
6
true
0
0
scipy.misc.imread() will return a Numpy array, which is handy for lots of things.
2
31
1
I want to do some image processing using Python. Is there a simple way to import .png image as a matrix of greyscale/RGB values (possibly using PIL)?
Convert image to a matrix in python
1.2
0
0
77,563
3,493,092
2010-08-16T12:29:00.000
7
0
1
0
python,image-processing,numpy,python-imaging-library
50,263,426
6
false
0
0
scipy.misc.imread() is deprecated now. We can use imageio.imread instead of that to read it as a Numpy array
2
31
1
I want to do some image processing using Python. Is there a simple way to import .png image as a matrix of greyscale/RGB values (possibly using PIL)?
Convert image to a matrix in python
1
0
0
77,563
3,493,244
2010-08-16T12:51:00.000
0
0
0
0
python,mobile-website,turbogears
3,562,868
4
false
1
0
The simplest version of a "mobile site" is simply CSS. Display a simplified version of the site to USERAGENTS that are identified as mobile.
1
1
0
Is it possible to develop mobile versions of webpages using Turbogears? Can someone please show me an example and how it is done?
Can I use Turbogears to develop mobile sites?
0
0
0
254
3,494,020
2010-08-16T14:22:00.000
0
1
0
0
python,tar,bzip2,tarfile
3,494,091
2
false
0
0
Bzip2 compresses in large blocks (900 KiB by default, I believe). One method that would speed up the scanning of the tar file dramatically, but would reduce compression performance, would be to compress each file individually and then tar the results together. This is essentially what Zip-format files are (though using...
1
3
0
I have about 200,000 text files that are placed in a bz2 file. The issue I have is that when I scan the bz2 file to extract the data I need, it goes extremely slow. It has to look through the entire bz2 file to fine the single file I am looking for. Is there anyway to speed this up? Also, I thought about possibly organ...
Organizing files in tar bz2 file with python
0
0
0
965
3,494,585
2010-08-16T15:22:00.000
4
1
0
1
python,unit-testing,build-automation,teamcity
3,494,671
5
false
0
0
I think it is more of a social problem rather than a deficiency of the automated systems. Yes, you can improve the systems in place, but they will be no match for someone thinking of the implications of their commit, and testing it before they hit commit.
2
6
0
We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer "forgets" to run all the tests before a commit resulting in TeamCity failure which if this check in was don...
Remembering to run tests before commit
0.158649
0
0
2,165
3,494,585
2010-08-16T15:22:00.000
7
1
0
1
python,unit-testing,build-automation,teamcity
3,494,863
5
false
0
0
In one of the teams I was working before we had an agreement that anyone who breaks the tests buys bacon sandwiches for the whole team the next morning. Its extreme, but it works perfectly!
2
6
0
We have a decent set of unit tests on our code and those unit tests run in under 2 minutes. We also use TeamCity to do a build and to run tests after each check in. However, we still get issues where a developer "forgets" to run all the tests before a commit resulting in TeamCity failure which if this check in was don...
Remembering to run tests before commit
1
0
0
2,165
3,494,587
2010-08-16T15:22:00.000
1
0
0
0
python,gtk
3,495,112
2
true
0
1
I found out I can use gtk.get_current_event_time() to get a reasonable timestamp matching what Gtk looks like it expects.
1
0
0
What is the format of the parameter activate_time in Python GTK+ when using Gtk.Menu.popup() method? I have tried using int(time.time()) but I get a traceback saying an integer is required...
Format of activate_time in Gtk.Menu
1.2
0
0
132
3,497,883
2010-08-16T22:20:00.000
7
0
1
0
python
3,497,914
3
false
0
0
I do this frequently for classes that abstract database tables where there is often a field called id because there is no reasonable chance of a name conflict. Be advised that some synatax highlighters will mark it as a builtin function.
2
37
0
I know that there's a function called id so I wouldn't create a function or a variable called id, but what about an attribute on an object?
In Python is it bad to create an attribute called 'id'?
1
0
0
5,692
3,497,883
2010-08-16T22:20:00.000
36
0
1
0
python
3,497,915
3
true
0
0
That's ok, and is pretty common. For example, objects mapped to a database record will often have an "id" attribute mapped to the database "id" column value. Attributes are always "namespaced" so you have to refer to them via self.id or obj.id so there's no conflict with the built-in function.
2
37
0
I know that there's a function called id so I wouldn't create a function or a variable called id, but what about an attribute on an object?
In Python is it bad to create an attribute called 'id'?
1.2
0
0
5,692
3,498,587
2010-08-17T01:00:00.000
2
0
1
1
python,file
3,498,742
2
true
0
0
You can specify the path to the file in either a complete way (e.g. 'c:/wher/ever/the.txt'), also known as "absolute" because it's taken exactly as you specify it, or a partial one (e.g., just "the.txt", or "ever/the.txt", or "../ever/the.txt", and so on), also known as "relative" because it's taken relatively to the c...
1
2
0
I'm trying to open a file with Python, but I'm unsure how to find the correct filename to use.
How do you find the filename that you pass to open()?
1.2
0
0
965
3,498,904
2010-08-17T02:28:00.000
0
0
1
0
python,windows,validation
3,498,920
2
false
0
0
I would really urge you not to do this. As you said, whatever you do will be broken, and you may actually cause more copies of your software to be pirated by including this barrier. Asking your users nicely not to steal may do better... That said, implementing this in a way that discourages the most casual piracy is ...
2
0
0
I have been working on a huge project for work for a while now, and it is almost done. However, in an effort to prevent the program was being pirated (I already know there is pretty much no method that can't be cracked ), the software needs to be able to validate. I'm not exactly sure how to do this. Could some sort of...
Software Validation Server in Python?
0
0
0
228
3,498,904
2010-08-17T02:28:00.000
2
0
1
0
python,windows,validation
3,498,935
2
true
0
0
The software, when starting, should launch an https (so it can't just be sniffed easily;-) request to your server, identifying itself (however it is that you choose to identify, e.g. a serial number or whatever), and the server's response will tell it what to do (run normally, or terminate, or ask the user to register ...
2
0
0
I have been working on a huge project for work for a while now, and it is almost done. However, in an effort to prevent the program was being pirated (I already know there is pretty much no method that can't be cracked ), the software needs to be able to validate. I'm not exactly sure how to do this. Could some sort of...
Software Validation Server in Python?
1.2
0
0
228
3,501,068
2010-08-17T09:28:00.000
1
0
0
0
python,rtf
3,501,153
2
false
0
0
PyRTF is abandonware and doesn't realy have anything in the way of documentation other than the examples. I don't know about columns, but it does support tables so you might be able to achieve the layout you want that way.
1
0
0
Can anybody reccomend a way of generating a multi column RTF document with python, i was going to use PyRTF but i cant find any documentation on how to set up columns. i think i might need to edit the modules source any reccomendations?
Python RTF Multi Column layout
0.099668
0
0
548
3,501,215
2010-08-17T09:51:00.000
0
0
0
0
python,opengl,svg,cairo,rsvg
37,703,846
3
false
0
1
I had to do the same (changing element color for instance), and had to modify rsvg library because all those nice features exist but they are hidden. You have to make a new interface to link to the nice features.
1
3
0
I render a huge SVG file with a lot of elements with Cairo, OpenGL and rsvg. I draw svg on cairo surface via rsvg and create an OpenGL texture to draw it. Everything is fine. And now I have to interact with elements from SVG. For example, I want to guess an element by coordinates. And I want to change the background of...
SVG interaction in python with cairo, opengl and rsvg
0
0
0
3,978
3,501,382
2010-08-17T10:15:00.000
3
0
1
0
python,integer
17,510,248
41
false
0
0
If you just need the value, operator.index (__index__ special method) is the way to go in my opinion. Since it should work for all types that can be safely cast to an integer. I.e. floats fail, integers, even fancy integer classes that do not implement the Integral abstract class work by duck typing. operator.index is ...
1
1,068
0
How do I check whether a variable is an integer?
Checking whether a variable is an integer or not
0.014633
0
0
1,713,701
3,503,970
2010-08-17T15:11:00.000
0
0
1
0
python,pyc
3,504,112
6
false
0
0
Well, I don't think Python ever interprets code directly if you're loading the code from a file. Even when using the interactive shell, Python will compile the imported module into a .pyc. That said, you could write a shell script to go ahead and delete all the .pyc files before launching your scripts. That would c...
3
24
0
Is there a way to make Python ignore any .pyc files that are present and always interpret all the code (including imported modules) directly? Google hasn't turned up any answers, so I suspect not, but it seemed worth asking just in case. (Why do I want to do this? I have a large pipeline of Python scripts which are ru...
Make Python ignore .pyc files
0
0
0
7,661
3,503,970
2010-08-17T15:11:00.000
0
0
1
0
python,pyc
3,503,998
6
false
0
0
Perhaps you could work around this by, for example, scheduling a job to periodically shut down the scripts and delete the .pyc files.
3
24
0
Is there a way to make Python ignore any .pyc files that are present and always interpret all the code (including imported modules) directly? Google hasn't turned up any answers, so I suspect not, but it seemed worth asking just in case. (Why do I want to do this? I have a large pipeline of Python scripts which are ru...
Make Python ignore .pyc files
0
0
0
7,661
3,503,970
2010-08-17T15:11:00.000
6
0
1
0
python,pyc
24,909,688
6
false
0
0
In case anyone is using python 2.6 or above with the same question, the simplest thing to do is: Delete all .pyc files Run all your python interpreters with the -B option, so they won't generate .pyc files. From the docs: -B If given, Python won’t try to write .pyc or .pyo files on the import of source modules. Se...
3
24
0
Is there a way to make Python ignore any .pyc files that are present and always interpret all the code (including imported modules) directly? Google hasn't turned up any answers, so I suspect not, but it seemed worth asking just in case. (Why do I want to do this? I have a large pipeline of Python scripts which are ru...
Make Python ignore .pyc files
1
0
0
7,661
3,504,383
2010-08-17T15:52:00.000
0
0
0
0
python,wxpython,resolution-independence
3,526,358
2
false
0
1
Did you try calling the GetNumberOfLines() method? According to Robin Dunn, that should work, although it doesn't take wrapped lines into account.
1
2
0
I'm writing an e-book reader in Python + wxPython, and I'd like to find out how many lines of text can be displayed in a given RichTextCtrl with the current formatting without scrolling. I thought of using and dividing the control's height by RichTextCtrl.GetFont().GetPixelSize(), but it appears that the pixel size pa...
Finding out how many lines can be displayed in wx.richtext.RichTextCtrl without scrolling
0
0
0
445
3,504,405
2010-08-17T15:54:00.000
1
0
0
0
python,django,architecture,code-organization
3,504,714
2
true
1
0
I would create subdirectory named rules in the app with game logic and there create module named after each game, that you would like serve. Then create a common interface for those modules, that will be utilized by your games and import proper rules module by name (if your game is called adom, then simply __import__('...
2
4
0
I'm designing (and ultimately writing) a system in Django that consists of two major components: A Game Manager: this is essentially a data-entry piece. Trusted (non-public) users will enter information on a gaming system, such as options that a player may have. The interface for this is solely the Django admin cons...
How to best organize the rules component of a Django system?
1.2
0
0
177
3,504,405
2010-08-17T15:54:00.000
1
0
0
0
python,django,architecture,code-organization
3,504,959
2
false
1
0
the "rules" that are associated with each game. for each game put into the first app, there are a sets of prerequisites, limitations, and other business logic specific to that game. That's part of the game app, then. There's also similarly-structured logic that will be common to all games. That's part of the game ap...
2
4
0
I'm designing (and ultimately writing) a system in Django that consists of two major components: A Game Manager: this is essentially a data-entry piece. Trusted (non-public) users will enter information on a gaming system, such as options that a player may have. The interface for this is solely the Django admin cons...
How to best organize the rules component of a Django system?
0.099668
0
0
177
3,504,522
2010-08-17T16:05:00.000
2
0
0
0
python,image,pyqt,selection,pixel
3,543,483
3
false
0
1
First you have to draw the image. You can do this my making a QLabel widget and call setPixmap. You need to convert your QImage to QPixmap before doing this (you can use QPixmap.fromImage(img)). You can get mouse clicks by subclassing the QImage and intercepting mousePressEvent. Look up the pixel value with QImage.pixe...
1
9
0
I would like to know how i can select a pixel with a mouse click in an image (QImge) and get pixel position and value. Thanks
Pyqt get pixel position and value when mouse click on the image
0.132549
0
0
19,296
3,506,105
2010-08-17T19:20:00.000
3
1
0
0
python,emacs
6,899,728
2
true
0
0
Ropemacs does the job : Use the function rope-show-doc over the symbol or use the keybinding C-c d. Simple :)
2
7
0
I am using Emacs 23.1.1 on GNU/Linux with autocomplete.el 1.3 and Ropemacs 0.6. In Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possib...
Quickhelp for Python in Emacs autocomplete.el?
1.2
0
0
607
3,506,105
2010-08-17T19:20:00.000
1
1
0
0
python,emacs
6,889,131
2
false
0
0
I stopped using all the autocomplete stuff in all my developing environments. They rarely do what I want. Either the lists is too long, or too short, or not sorted well. Therefore I use dabbrev-expand in all my modes global-set-key to tab. This works even quote well for text. Usually it is enough to get a good expansio...
2
7
0
I am using Emacs 23.1.1 on GNU/Linux with autocomplete.el 1.3 and Ropemacs 0.6. In Lisp programming, autocomplete.el shows the documentation (known as 'QuickHelp' in autocomplete.el) of the suggested completions. Python completion with ropemacs works, but does not show quick help for the Python completion. Is it possib...
Quickhelp for Python in Emacs autocomplete.el?
0.099668
0
0
607
3,506,252
2010-08-17T19:35:00.000
6
1
0
0
java,python,qt,programming-languages,replace
3,506,325
10
false
1
0
Might be worth loking at the other JVM languages - Clojure and Scala are the two I personally think are most promising. Yes you are on the JVM, but you're pretty independent from Java the langauage and don't have to use any Sun/Oracle implementations if you don't want to. Having said that - I think that you are worryin...
3
3
0
I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement. I am fluent in C...
What languages would be a good replacement for Java?
1
0
0
3,718
3,506,252
2010-08-17T19:35:00.000
0
1
0
0
java,python,qt,programming-languages,replace
3,509,044
10
false
1
0
C# is the only thing that will meet your needs and not feel hopelessly archaic, or frustrate with limited library. For open source/non-windows, use mono. It's a good, mature implementation of most of what's important in the CLR. Some things (WPF, WCF, etc) are "missing" from mono, but these aren't so much part of the ...
3
3
0
I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement. I am fluent in C...
What languages would be a good replacement for Java?
0
0
0
3,718
3,506,252
2010-08-17T19:35:00.000
1
1
0
0
java,python,qt,programming-languages,replace
3,506,402
10
false
1
0
I too would like another Java-like technology to come along. Lately I've been doing Flex/Actionscript. While I really enjoy it, Actionscript technology seriously lacks the elegance that Java has. Adobe can write some good cross platform APIs, but they just don't have the head capital to build elegant languages and c...
3
3
0
I may be posting a premature question, and maybe I'm just freaking out for no reason, but the way Oracle is handling Java is not very promising. I am a nerd who fell in love with Java from the first sight, and use it all the time in my personal/freelance projects but now I am thinking of a replacement. I am fluent in C...
What languages would be a good replacement for Java?
0.019997
0
0
3,718
3,507,451
2010-08-17T22:22:00.000
0
0
1
0
python,multithreading,r
3,507,504
6
false
0
0
If I remember correctly (but I might be wrong here) one of the main purposes of Ada95 was parallel processing. Funny language, that was. Jokes aside I'm not quite sure how good performance wise it would be (but seeing you are using Python now then it shouldn't be that bad) but I'd suggest Java since the basics of multi...
2
6
0
Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be...
Recommended language for multithreaded data work
0
0
0
657
3,507,451
2010-08-17T22:22:00.000
1
0
1
0
python,multithreading,r
3,507,522
6
false
0
0
On the Python side, your best bet is probably to separate the two steps in two different processes. There are a couple of modules that help you to achieve that. You would couple the two processes through pipes. In order to pass arbitrary data through the pipe, you need to serialize and deserialize it. The pickle module...
2
6
0
Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be...
Recommended language for multithreaded data work
0.033321
0
0
657
3,507,543
2010-08-17T22:39:00.000
1
0
0
0
python,postgresql,sqlalchemy,rsa,pycrypto
3,507,558
2
false
0
0
By "same key" you mean "the other key", right? RSA gives you a keypair, if you encrypt with one you decrypt with the other ... Other than that, it sounds like a encoding problem. Try storing the data as binary or encode the string with your databases collation. Basically encryption gives you bytes but you store them as...
1
1
0
I want to encrypt a string using RSA algorithm and then store that string into postgres database using SQLAlchemy in python. Then Retrieve the encrypted string and decrypt it using the same key. My problem is that the value gets stored in the database is not same as the actual encrypted string. The datatype of column w...
Inserting Encrypted Data in Postgres via SQLALchemy
0.099668
1
0
3,897
3,507,732
2010-08-17T23:20:00.000
3
1
0
0
python,arduino
3,507,854
3
false
0
0
Encode them into binary strings with Python's struct module. I don't know if arduino wants them little-endian or big-endian, but, if its docs aren't clear about this, a little experiment should easily settle the question;-).
1
1
0
I need to send integers greater than 255? Does anyone know how to do this?
Sending integer values to Arduino from PySerial
0.197375
0
0
14,924
3,507,925
2010-08-18T00:00:00.000
1
0
1
0
python
3,507,956
3
false
0
0
Quick-and-dirty solution is to use s[::2] where s is the 80-characters byte string of which you want to consider only alternate bytes. The "clean: solution, per @fadden's comment, might be to read in the data as UTF-16 (then .encode it to ASCII, etc), but if the Q&D one suffices for your purposes, it might be simpler ...
1
3
0
I have some binary data, in hex editor it looks like: s.o.m.e.d.a.t.a with all these dots in between each letter when I read with filehandle.read(40) it shows these dots I know that the dots aren't supposed to be there, is there a way to unpack some ascii data that is 40 bytes long with struct? I tried '40s' and 's' b...
Read 40 bytes of binary data as ascii text
0.066568
0
0
3,727
3,507,980
2010-08-18T00:13:00.000
0
1
0
1
python,ssh
3,508,010
3
false
0
0
Am I correct in assuming you're running your script on some sort of UNIX/Linux system? If so, you can just type "users" on the command-line, and it will show you the currently logged in users. Also, if you call the "lastlog" command, that will show you all the users on the system and the last time they all logged in t...
2
1
0
How can I know if the user is connected to the local machine via ssh in my python script?
How can I know if the user is connected to the local machine via ssh in my python script?
0
0
0
416
3,507,980
2010-08-18T00:13:00.000
0
1
0
1
python,ssh
3,508,136
3
false
0
0
Check any of the SSH variables SSH_CONNECTION, SSH_CLIENT, or SSH_TTY. However, these can be unset by the user. Check the output of who am i. It will end with the remote system identification in brackets if you are connected remotely. Make sure to handle x-term sessions which will have a colon (:) in the remote sy...
2
1
0
How can I know if the user is connected to the local machine via ssh in my python script?
How can I know if the user is connected to the local machine via ssh in my python script?
0
0
0
416
3,509,275
2010-08-18T05:44:00.000
2
0
0
0
python,django,django-models,many-to-many
3,509,354
1
true
1
0
If I have two classes A and B with a many to many relationship and I want to delete an instance of A, do I need to remove all of its related Bs first or will Django sort that out for me? Short answer: Django will sort that out for you. Does it make any difference if the ManyToMany field is declared on class A or B? ...
1
0
0
If I have two classes A and B with a many to many relationship and I want to delete an instance of A, do I need to remove all of its related Bs first or will Django sort that out for me? I obviously don't want to leave orphaned rows in the join table. Does it make any difference if the ManyToMany field is declared on c...
Can deleting a django Model with a ManyToManyField create orphaned database rows?
1.2
0
0
334
3,509,471
2010-08-18T06:28:00.000
1
0
1
0
python,windows-7,registry,editing,access-denied
3,509,560
1
false
0
0
If you want to edit something that is writable only with administrative privileges, you just have to run under admin privileges. Everything else would be a giant security hole.
1
1
0
I have run into another problem with my current project. The program needs to values and keys periodically while running. Each time I attempt to edit the value, I get a code 5, Access Denied. How would I go about doing this so the values can be editied, but the user doesn't have to enter admin credentials to run the ap...
Edit Windows 7 Registry in Python?
0.197375
0
0
1,429
3,510,374
2010-08-18T08:51:00.000
1
0
0
0
python,django,tinymce,django-filebrowser,django-grappelli
7,351,831
3
false
1
0
I managed to get the admin site to look like the django simple admin interface by not setting my admin media prefix to '/media/grappelli/'. Just left it as '/static/admin/' and it didn't break anything seemingly, I've not been able to get the 'choose' to work either way though.
1
1
0
So, I found django admin interface called 'grappelli'. Looked at the screenshots and decided that I like it. Went to sources page and checked out trunk. Set it up and noticed that it looks nothing like screenshots. No dashboard, no side panel, different colors of the elements and model item lists are very narrow. From ...
django grappelli, filebrowser and Tiny MCE insert image dialog
0.066568
0
0
2,709
3,510,747
2010-08-18T09:41:00.000
6
1
1
0
python,logging
3,510,824
1
true
0
0
imaplib is much older (it was in Python1.5.2) than the logging module (Python2.3), so perhaps noone has needed to update it to use logging yet
1
1
0
I'm not sure if it's because sys.stderr.write is faster.
Why does python libs (eg imaplib) does not use logging but use sys.stderr.write?
1.2
0
0
72
3,511,027
2010-08-18T10:19:00.000
23
0
1
0
python,design-patterns,factory,factory-pattern
3,511,165
3
false
0
0
Be Pythonic. Don't overcomplicate your code with "enterprise" language (like Java) solutions that add unnecessary levels of abstraction. Your code should be simple, and intuitive. You shouldn't need to delegate to another class to instantiate another.
2
23
0
I'm currently implementing the Factory design pattern in Python and I have a few questions. Is there any way to prevent the direct instantiation of the actual concrete classes? For example, if I have a VehicleFactory that spawns Vehicles, I want users to just use that factory, and prevent anyone from accidentally inst...
Factory pattern in Python
1
0
0
16,908
3,511,027
2010-08-18T10:19:00.000
6
0
1
0
python,design-patterns,factory,factory-pattern
3,511,337
3
false
0
0
Is there any way to prevent the direct instantiation of the actual concrete classes? Why? Are your programmers evil sociopaths who refuse to follow the rules? If you provide a factory -- and the factory does what people need -- then they'll use the factory. You can't "prevent" anything. Remember. This is Python...
2
23
0
I'm currently implementing the Factory design pattern in Python and I have a few questions. Is there any way to prevent the direct instantiation of the actual concrete classes? For example, if I have a VehicleFactory that spawns Vehicles, I want users to just use that factory, and prevent anyone from accidentally inst...
Factory pattern in Python
1
0
0
16,908
3,511,922
2010-08-18T12:15:00.000
2
1
1
0
java,python,gil
3,512,342
5
false
0
0
After reading your updated spec: I need explicit+strong typing to write safer code in the expense of development speed. GIL is important as the code is going to be quite computing extensive and will run on multicore servers, so it has to effectively use multiple CPU What exactly does "computing extensive" mean? What ...
2
4
0
Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL? I belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad. Java is nice, but I need something more 'embedable' without bulky JR...
Looking for strong/explicit-typed language without GIL
0.07983
0
0
887
3,511,922
2010-08-18T12:15:00.000
4
1
1
0
java,python,gil
3,512,157
5
false
0
0
Anything in the ML family might work for you. Ocaml is a great place to start, but it does have a stop-the-world GC last I looked. Haskell is famous as a lab for innovative concurrency models. Python's comprehensions came from Haskell, where they'rr a convenient syntax for some very fundamental ideas. And Erlang is st...
2
4
0
Are there any languages which feature static type checking like in C++ with modern syntax like in Python, and does not have GIL? I belive, Python 3 with ability to explicitly declare type of each variable would be 'almost there', but GIL makes me sad. Java is nice, but I need something more 'embedable' without bulky JR...
Looking for strong/explicit-typed language without GIL
0.158649
0
0
887
3,513,433
2010-08-18T14:57:00.000
0
0
0
0
python,sqlalchemy
3,513,490
1
false
1
0
You must load the parent object again.
1
0
0
I'd like to query the database and get read-only objects with session object. I need to save the objects in my server and use them through the user session. If I use a object outside of the function that calls the database, I get this error: "DetachedInstanceError: Parent instance is not bound to a Session; lazy load o...
How to get read-only objects from database?
0
1
0
244
3,514,444
2010-08-18T16:41:00.000
2
0
1
0
python,windows,version,uninstallation
3,514,562
1
true
0
0
Most python installations come with an uninstaller that shows up in Add/Remove programs on Windows. It is certainly possible to have several versions installed. On my windows machine, I have Python 2.5, 2.6, 2.7 and 3.1. The "default" python is the one which occurs first in your system path. Also (depending on which in...
1
1
0
After a fresh installation of my Windows dev machine, I installed Python 2.7. Quickly I learnt that this was a mistake as many of the packages I use only work on Python 2.6. So I installed 2.6 also and now I have both installations. How can I make everything work with Python 2.6 instead of Python 2.7? Every time I inst...
How to work with a new Python installation while having an old one installed?
1.2
0
0
1,546
3,514,495
2010-08-18T16:46:00.000
-2
1
1
0
python,python-c-extension
3,514,728
5
false
0
0
multiprocessing is easy. if thats not fast enough, your question is complicated.
1
12
0
I want to run a cpu intensive program in Python across multiple cores and am trying to figure out how to write C extensions to do this. Are there any code samples or tutorials on this?
How to use C extensions in python to get around GIL
-0.07983
0
0
6,155
3,515,043
2010-08-18T17:51:00.000
3
0
1
0
python
3,516,882
5
false
0
0
If you can't install anything on the computer, the you might be best off outputting an HTML file with the data in a <table> that the user could view/search/print in IE.
2
1
0
I have an executable (converted to exe from python using py2exe) that outputs lists of numbers that could be from 0-50K lines long or a little bit more. While developing, I just saved them to a TXT file using simple f.write. The person wants to print this output on paper! (don't ask why lol) So, I'm wondering if I can...
Which format should I save my python script output?
0.119427
0
0
648
3,515,043
2010-08-18T17:51:00.000
1
0
1
0
python
3,515,070
5
false
0
0
You could use LaTeX to produce a PDF, maybe? But why exactly isn't a text file good enough?
2
1
0
I have an executable (converted to exe from python using py2exe) that outputs lists of numbers that could be from 0-50K lines long or a little bit more. While developing, I just saved them to a TXT file using simple f.write. The person wants to print this output on paper! (don't ask why lol) So, I'm wondering if I can...
Which format should I save my python script output?
0.039979
0
0
648
3,515,673
2010-08-18T18:59:00.000
26
0
1
1
python,installation,uninstallation
60,318,668
14
false
0
0
you can delete it manually. open Command Prompt cd C:\Users\<you name>\AppData\Local\Microsoft\WindowsApps del python.exe del python3.exe Now the command prompt won't be showing it anymore where python --> yields nothing, and you are free to install another version from source / anaconda and (after adding its address...
12
123
0
I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena... I would like to completely remove Python from my system. I tried running the 2...
How to completely remove Python from a Windows machine?
1
0
0
600,614
3,515,673
2010-08-18T18:59:00.000
8
0
1
1
python,installation,uninstallation
38,920,189
14
false
0
0
I had window 7 (64 bit) and Python 2.7.12, I uninstalled it by clicking the python installer from the "download" directory then I selected remove python then I clicked “ finish”. I also removed the remaining python associated directory & files from the c: drive and also from “my documents” folder, since I created som...
12
123
0
I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena... I would like to completely remove Python from my system. I tried running the 2...
How to completely remove Python from a Windows machine?
1
0
0
600,614
3,515,673
2010-08-18T18:59:00.000
56
0
1
1
python,installation,uninstallation
18,430,403
14
false
0
0
Here's the steps (my non-computer-savvy girlfriend had to figure this one out for me, but unlike all the far more complicated processes one can find online, this one works) Open Control Panel Click "Uninstall a Program" Scroll down to Python and click uninstall for each version you don't want anymore. This works on W...
12
123
0
I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena... I would like to completely remove Python from my system. I tried running the 2...
How to completely remove Python from a Windows machine?
1
0
0
600,614
3,515,673
2010-08-18T18:59:00.000
3
0
1
1
python,installation,uninstallation
68,139,862
14
false
0
0
Open CMD To show all packages installed - pip list To copy the packages name to a file - pip freeze > requirements.txt To delete all packages - pip uninstall -r requirements.txt -y Check all packages are removed - pip list Uninstall pip and other remaining packages Control panel > Uninstall > Python uninstall (fr...
12
123
0
I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena... I would like to completely remove Python from my system. I tried running the 2...
How to completely remove Python from a Windows machine?
0.042831
0
0
600,614