Title
stringlengths 15
150
| A_Id
int64 2.98k
72.4M
| Users Score
int64 -17
470
| Q_Score
int64 0
5.69k
| ViewCount
int64 18
4.06M
| Database and SQL
int64 0
1
| Tags
stringlengths 6
105
| Answer
stringlengths 11
6.38k
| GUI and Desktop Applications
int64 0
1
| System Administration and DevOps
int64 1
1
| Networking and APIs
int64 0
1
| Other
int64 0
1
| CreationDate
stringlengths 23
23
| AnswerCount
int64 1
64
| Score
float64 -1
1.2
| is_accepted
bool 2
classes | Q_Id
int64 1.85k
44.1M
| Python Basics and Environment
int64 0
1
| Data Science and Machine Learning
int64 0
1
| Web Development
int64 0
1
| Available Count
int64 1
17
| Question
stringlengths 41
29k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Google app engine parsing xml more then 1 mb | 3,334,425 | 2 | 1 | 485 | 0 | python,google-app-engine,parsing | The 1MB limit doesn't apply to parsing; however, you can't fetch more than 1MB from URLfetch; you'll only get the first 1MB from the API.
It's probably not going to be possible to get the XML into your application using the URLfetch API. If the data is smaller than 10MB, you can arrange for an external process to POST it to your application and then process it. If it's between 10MB and 2GB, you'd need to use the Blobstore API to upload it, read it in to your application in 1MB chunks, and process the concatenation of those chunks. | 0 | 1 | 1 | 0 | 2010-07-26T07:14:00.000 | 1 | 0.379949 | false | 3,332,897 | 0 | 0 | 1 | 1 | Hi i need to parse xml file which is more then 1 mb in size, i know GAE can handle request and response up to 10 MB but as we need to use SAX parser API and API GAE has limit of 1 MB so is there way we can parse file more then 1 mb any ways. |
Should I use Pylon's Paste to host my Pylons website? Or can I use Apache? | 3,358,288 | 0 | 5 | 511 | 0 | python,web-services,pylons | I'm using Nginx (with fastcgi) or Apache for hosting Pylons sites, mostly because lack of some "production" features in Paste, but for development Paste is very usefull and handy. | 0 | 1 | 0 | 1 | 2010-07-26T07:57:00.000 | 2 | 0 | false | 3,333,113 | 0 | 0 | 0 | 1 | I'm looking into Pylons and was wondering, should I use Paste as the webserver or can I use Apache?
Are there advantages to using Paste?
Would you recommend against using Apache?
How should I host the sites? |
Python - When Is It Ok to Use os.system() to issue common Linux commands | 3,338,914 | 5 | 12 | 3,734 | 0 | python,linux,centos | One of the problems with system() is that it implies knowledge of the shell's syntax and language for parsing and executing your command line. This creates potential for a bug where you didn't validate input properly, and the shell might interpet something like variable substitution or determining where an argument begins or ends in a way you don't expect. Also, another OS's shell might have divergent syntax from your own, including very subtle divergence that you won't notice right away. For reasons like these I prefer to use execve() instead of system() -- you can pass argv tokens directly and not have to worry about something in the middle (mis-)parsing your input.
Another problem with system() (this also applies to using execve()) is that when you code that, you are saying, "look for this program, and pass it these args". This makes a couple of assumptions which may lead to bugs. First is that the program exists and can be found in $PATH. Maybe on some system it won't. Second, maybe on some system, or even a future version of your own OS, it will support a different set of options. In this sense, I would avoid doing this unless you are absolutely certain the system you will run on will have the program. (Like maybe you put the callee program on the system to begin with, or the way you invoke it is mandated by something like POSIX.)
Lastly... There's also a performance hit associated with looking for the right program, creating a new process, loading the program, etc. If you are doing something simple like a mv, it's much more efficient to use the system call directly.
These are just a few of the reasons to avoid system(). Surely there are more. | 0 | 1 | 0 | 0 | 2010-07-26T20:13:00.000 | 7 | 0.141893 | false | 3,338,616 | 1 | 0 | 0 | 6 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. |
Python - When Is It Ok to Use os.system() to issue common Linux commands | 3,338,752 | 3 | 12 | 3,734 | 0 | python,linux,centos | The only time that os.system might be appropriate is for a quick-and-dirty solution for a non-production script or some kind of testing. Otherwise, it is best to use built-in functions. | 0 | 1 | 0 | 0 | 2010-07-26T20:13:00.000 | 7 | 0.085505 | false | 3,338,616 | 1 | 0 | 0 | 6 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. |
Python - When Is It Ok to Use os.system() to issue common Linux commands | 3,338,632 | 18 | 12 | 3,734 | 0 | python,linux,centos | Rule of thumb: if there's a built-in Python function to achieve this functionality use this function. Why? It makes your code portable across different systems, more secure and probably faster as there will be no need to spawn an additional process. | 0 | 1 | 0 | 0 | 2010-07-26T20:13:00.000 | 7 | 1.2 | true | 3,338,616 | 1 | 0 | 0 | 6 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. |
Python - When Is It Ok to Use os.system() to issue common Linux commands | 3,338,678 | 4 | 12 | 3,734 | 0 | python,linux,centos | Darin's answer is a good start.
Beyond that, it's a matter of how portable you plan to be. If your program is only ever going to run on a reasonably "standard" and "modern" Linux then there's no reason for you to re-invent the wheel; if you tried to re-write make or xterm they'd be sending the men in the white coats for you. If it works and you don't have platform concerns, knock yourself out and simply use Python as glue!
If compatibility across unknown systems was a big deal you could try looking for libraries to do what you need done in a platform independent way. Or you need to look into a way to call on-board utilities with different names, paths and mechanisms depending on which kind of system you're on. | 0 | 1 | 0 | 0 | 2010-07-26T20:13:00.000 | 7 | 0.113791 | false | 3,338,616 | 1 | 0 | 0 | 6 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. |
Python - When Is It Ok to Use os.system() to issue common Linux commands | 3,339,586 | 3 | 12 | 3,734 | 0 | python,linux,centos | Your question seems to have two parts. You mention calling commands like "xterm", "rm -rf", and "cd".
Side Note: you cannot call 'cd' in a sub-shell. I bet that was a trick question ...
As far as other command-level things you might want to do, like "rm -rf SOMETHING", there is already a python equivalent. This answers the first part of your question. But I suspect you are really asking about the second part.
The second part of your question can be rephrased as "should I use system() or something like the subprocess module?".
I have a simple answer for you: just say NO to using "system()", except for prototyping.
It's fine for verifying that something works, or for that "quick and dirty" script, but there are just too many problems with os.system():
It forks a shell for you -- fine if you need one
It expands wild cards for you -- fine unless you don't have any
It handles redirect -- fine if you want that
It dumps output to stderr/stdout and reads from stdin by default
It tries to understand quoting, but it doesn't do very well (try 'Cmd" > "Ofile')
Related to #5, it doesn't always grok argument boundaries (i.e. arguments with spaces in them might get screwed up)
Just say no to "system()"! | 0 | 1 | 0 | 0 | 2010-07-26T20:13:00.000 | 7 | 0.085505 | false | 3,338,616 | 1 | 0 | 0 | 6 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. |
Python - When Is It Ok to Use os.system() to issue common Linux commands | 3,338,709 | 2 | 12 | 3,734 | 0 | python,linux,centos | I would suggest that you only use use os.system for things that there are not already equivalents for within the os module. Why make your life harder? | 0 | 1 | 0 | 0 | 2010-07-26T20:13:00.000 | 7 | 0.057081 | false | 3,338,616 | 1 | 0 | 0 | 6 | Spinning off from another thread, when is it appropriate to use os.system() to issue commands like rm -rf, cd, make, xterm, ls ?
Considering there are analog versions of the above commands (except make and xterm), I'm assuming it's safer to use these built-in python commands instead of using os.system()
Any thoughts? I'd love to hear them. |
python receiving from a socket | 8,259,497 | 0 | 0 | 2,058 | 0 | java,python,android,sockets | The Android code is reading lines, so you need probably to send a \n or possibly \r\n at the end of your Python send string. | 0 | 1 | 1 | 0 | 2010-07-27T00:39:00.000 | 4 | 0 | false | 3,339,971 | 0 | 0 | 0 | 1 | So I have a simple socket server on an android emulator. When I'm only sending data to it, it works just fine. But then if I want to echo that data back to the python script, it doesn't work at all. Here's the code that works:
android:
try {
serverSocket = new ServerSocket(port);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
while (checkingForClients) {
try {
clientSocket = serverSocket.accept();
out = new PrintWriter(clientSocket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(
clientSocket.getInputStream()));
line = null;
while ((line = in.readLine()) != null) {
Log.d("ServerActivity", line);
/* THIS IS THE LINE THAT DOESN'T WORK*/
//out.println(line);
handler.post(new Runnable() {
@Override
public void run() {
if(incomingData == null){
Log.e("Socket Thingey", "Null Error");
}
//out.println(line);
incomingData.setText("Testing");
incomingData.setText(line);
}
});
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
python:
import socket
host = 'localhost'
port = 5000
size = 1024
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port))
s.send('Hello, World!')
# data = s.recv(size) THIS LINE CAUSES PROBLEMS
s.close()
print 'Received:' , data
So there are 2 commented lines. Without those lines, it works perfectly. But if I add in s.recv(size) in python it just freezes and I assume waits for the received data. But the problem is that the android code never gets the sent data. So I have no idea what to do.
Keep in mind I'm new to python and to sockets. |
Starting a GUI process from a Python Windows Service | 3,343,894 | 3 | 0 | 1,456 | 0 | python,user-interface,windows-services | If you give your Service the Allow service to interact with desktop permission it will be able to create windows without the need to launch a subprocess. | 0 | 1 | 0 | 0 | 2010-07-27T12:54:00.000 | 2 | 1.2 | true | 3,343,793 | 1 | 0 | 0 | 1 | I am creating Windows service class in Python that will eventually display a Window when certain conditions are met. Since (as I understand it) services cannot have GUIs, I'm trying to start up a GUI in a seperate process (using subprocess.Popen) when the conditions are right. This isn't working, presumably because the child process has the same privileges as the service.
So how do I start a process from a Python Windows Service that has the ability to display GUIs on the screen? |
On the google app engine, why do updates not reflect in a transaction? | 3,350,082 | 0 | 2 | 215 | 1 | python,google-app-engine | Looks like you are not doing a commit on the transaction before querying
start a db transaction
update entityX by setting entityX.flag = True
save entityX
COMMIT TRANSACTION
query for entity where flag == True. BUT, here is the problem. This query does NOT return any results. It should have returned entityX, but it did not.
In a transaction, entities will not be persisted until the transaction is commited | 0 | 1 | 0 | 0 | 2010-07-28T05:06:00.000 | 2 | 0 | false | 3,350,068 | 0 | 0 | 1 | 1 | I store groups of entities in the google app engine Data Store with the same ancestor/parent/entityGroup. This is so that the entities can be updated in one atomic datastore transaction.
The problem is as follows:
I start a db transaction
I update entityX by setting entityX.flag = True
I save entityX
I query for entity where flag == True. BUT, here is the problem. This query does NOT return any results. It should have returned entityX, but it did not.
When I remove the transaction, my code works perfectly, so it must be the transaction that is causing this strange behavior.
Should updates to entities in the entity group not be visible elsewhere in the same transaction?
PS: I am using Python. And GAE tells me I can't use nested transactions :( |
Fastest way to produce UDP packets | 3,350,509 | 1 | 1 | 371 | 0 | python,twisted,stackless | Multiple NICs, the hardware or the kernel interface is the limit. I can only reach 69,000 packets per second with a Broadcom Corporation NetXtreme BCM5704S Gigabit Ethernet adapter. Try a quad Intel Gigabit Server Adapter with all four NICs on the same subnet. | 0 | 1 | 0 | 0 | 2010-07-28T06:02:00.000 | 2 | 0.099668 | false | 3,350,282 | 0 | 0 | 0 | 2 | We're building a test harness to push binary messages out on a UDP multicast.
The prototype is using the Twisted reactor loop to push out messages, which is achieving just about the level of traffic we require - about 120000 messages per second.
We have a 16 cores on our test machine, and obviously I'd like to spread this over those cores to really make the harness fly.
Does anyone have any ideas about how we might architect the application (either using an event loop approach or a CSP style approach) to up this output.
Also most of the time in the prototype is spent writing to UDP - as IO I shouldn't be surprised, but am I missing anything?
Any ideas welcome. |
Fastest way to produce UDP packets | 3,352,556 | 1 | 1 | 371 | 0 | python,twisted,stackless | The obvious answer when the question of exploiting multiple cores in a Python application comes up is to use multiple processes. With Twisted, you can use reactor.spawnProcess to launch a child process. You could also just start 16 instances of your application some other way (like a shell script). This requires that your application can operate sensibly with multiple instances running at once, of course. Exactly how you might divide the work so that each process can take on some of it depends on the nature of the work.
I would expect a single GigE link to be saturated long before you have all 16 cores running full tilt though. Make sure you're focusing on the bottleneck in the system. As Steve-o said, you may want multiple NICs in the machine as well. | 0 | 1 | 0 | 0 | 2010-07-28T06:02:00.000 | 2 | 0.099668 | false | 3,350,282 | 0 | 0 | 0 | 2 | We're building a test harness to push binary messages out on a UDP multicast.
The prototype is using the Twisted reactor loop to push out messages, which is achieving just about the level of traffic we require - about 120000 messages per second.
We have a 16 cores on our test machine, and obviously I'd like to spread this over those cores to really make the harness fly.
Does anyone have any ideas about how we might architect the application (either using an event loop approach or a CSP style approach) to up this output.
Also most of the time in the prototype is spent writing to UDP - as IO I shouldn't be surprised, but am I missing anything?
Any ideas welcome. |
How do I delay a task using Celery? | 3,358,271 | 1 | 7 | 4,358 | 0 | python,django,celery | You should store some 'pause' value outside of celery/task queue. I do this with a mailer using celery. I can pause parts of the system by setting values in either memcache or mysql. The tasks then make sure to query the outside resource before executing the task. If it's meant to be paused it sets it does a task.retry() that causes it to go through the retry delay time and such. | 0 | 1 | 0 | 0 | 2010-07-28T21:03:00.000 | 2 | 0.099668 | false | 3,357,472 | 0 | 0 | 0 | 1 | Not talking about the delay method.
I want to be able to get a task, given it's task_id and change it's ETA on the fly, before it is executed.
For now I have to cancel it, and re-schedule one. Troublesome if the scheduled process involve a lot of stuff. |
How do I choose a task_id using celery? | 3,379,809 | 4 | 4 | 604 | 0 | python,django,celery | You can certainly use "natural ids", but then to be really useful they would have to
be reverseable, which doesn't work if you add that timestamp. Also the ids are unique, so two tasks can't have the same id (the behavior then is undefined)
If you have a task to refresh the timeline of a twitter user, then you know that you
only want one task running for each user id at any time, so you could use a natural id like:
"update-twitter-timeline-%s" % (user_id)
then always be able to get the result for that task, or revoke the task using that id, no need to manually store it somewhere and look it up. | 0 | 1 | 0 | 0 | 2010-07-28T21:06:00.000 | 1 | 1.2 | true | 3,357,489 | 0 | 0 | 1 | 1 | For now I get a task_id from the async_result and have to save it the get it back later.
Would be better if I knew what the task_id what made of so I can calculate it back instead of pulling from the DB. E.G: set a task with task_id=("%s-%s" % (user_id, datetime)). |
win32api vs Python | 3,358,136 | 4 | 1 | 390 | 0 | python,winapi,io | The most obvious thing seems to be losing cross-platform compatibilty. Python runs on a number of different platforms, none of which has a win32 API except MS Windows. | 0 | 1 | 0 | 1 | 2010-07-28T22:42:00.000 | 2 | 0.379949 | false | 3,358,126 | 0 | 0 | 0 | 2 | What are the Pro's and Con's of using win32api for I/O and other things instead of simply Python, if both have a specific function for it
I mean, using PyWin32 vs Win32Api |
win32api vs Python | 3,358,143 | 5 | 1 | 390 | 0 | python,winapi,io | con
(lack of) portability
harder/more error prone
pro
performance (potentially, it must be measured, as will depend on more than just the api calls) | 0 | 1 | 0 | 1 | 2010-07-28T22:42:00.000 | 2 | 1.2 | true | 3,358,126 | 0 | 0 | 0 | 2 | What are the Pro's and Con's of using win32api for I/O and other things instead of simply Python, if both have a specific function for it
I mean, using PyWin32 vs Win32Api |
communication between python programs | 3,363,869 | 1 | 5 | 4,184 | 0 | python,process | The daemon could have an open (network) socket, where it accepts commands.
It could monitor changes in a file.
Any other kind of signalling is possible, but these would probably be the most common. | 0 | 1 | 0 | 0 | 2010-07-29T14:55:00.000 | 4 | 0.049958 | false | 3,363,831 | 0 | 0 | 0 | 1 | I have a python program that is running as a daemon on Linux.
How to send this daemon a signal from another python program? |
How do I setup python to always include my directory of utility files | 3,368,490 | 0 | 1 | 147 | 0 | python | If it's not in site-packages then you can add a file with the extension .pth to your site-packages directory.
The file should have one path per line, that you want included in sys.path | 0 | 1 | 0 | 0 | 2010-07-30T03:02:00.000 | 3 | 0 | false | 3,368,459 | 1 | 0 | 0 | 1 | I have been programming in Python for a while now, and have created some utilities that I use a lot. Whenever I start a new project, I start writing, and as I need these utilities I copy them from where ever I think the latest version of the particular utility is. I have enough projects now that I am losing track of where the latest version is. And, I will upgrade one of these scripts to fix a problem in a specific situation, and then wish it had propagated back to all of the other projects that use that script.
I am thinking the best way to solve this problem is to create a directory in the site-packages directory, and put all of my utility modules in there. And then add this directory to the sys.path directory list.
Is this the best way to solve this problem?
How do modify my installation of Python so that this directory is always added to sys.path, and I don't have to explicitly modify sys.path at the beginning of each module that needs to use these utilities?
I'm using Python 2.5 on Windows XP, and Wing IDE. |
Running a .py file on LAMP (CentOS) server - from a PHP developer's perspective | 3,369,157 | 1 | 0 | 5,711 | 0 | python,centos | you can use cgi, but that will not have great performance as it starts a new process for each request.
More efficient alternatives are to use fastcgi or wsgi
A third option is to run a mini Python webserver and proxy the requests from apache using rewrite rules | 0 | 1 | 0 | 1 | 2010-07-30T06:17:00.000 | 3 | 0.066568 | false | 3,369,080 | 0 | 0 | 0 | 1 | I'm a LAMP developer trying out Python for the first time.. I'm okay with picking up the syntax, but I can't figure out how to run it on the server! I've tried the following
uploading filename.py to a regular web/public directory. chmod 777, 711, 733, 773... (variations of execute)
putting the filename.py in cgi-bin, chmod same as above..
Typing up example.com/filename.py simply loads a textfile - nothing appears to have been compiled/parsed/etc!
(I believe python is installed, as
whereis python on my server shows /usr/bin/python among several other directories)
Many words for a simple question - how do you run a python file on a CentOS server? |
Need to restart python in Terminal every time a change is made to script | 3,374,587 | 1 | 10 | 16,071 | 0 | python | Do you mean that you enter script directly into the interactive python shall, or are you executing your .py file from the terminal by running something like python myscript.py? | 0 | 1 | 0 | 0 | 2010-07-30T18:59:00.000 | 5 | 0.039979 | false | 3,374,542 | 1 | 0 | 0 | 1 | Every time I make a change to a python script I have to reload python and re-import the module. Please advise how I can modify my scripts and run then without having to relaunch python in the terminal.
Thanks. |
A scalable solution for server side push? | 3,378,244 | 2 | 3 | 651 | 0 | php,python,linux,server-push,publish-subscribe | If you know in advance you'll have a lot of subscribers (people/applications) that want notifications on a certain subject while on other hand you'll have few different subjects consider a pull technology anyway.
RSS, Atom are quite successful even though they use pull. The reason: no need to have an administration on the server of people who are subscribed, to detect who is no longer interested (client offline for a long time) or having a mechanism to get all the data out to the subscribers.
Using push, you need to do very little on the server, while the clients will only pull a small amount of data everytime.
Pull costs slightly more bandwidth that's cheap anyway while it saves you a lot on CPU and software maintanance which is quite expensive. | 0 | 1 | 0 | 0 | 2010-07-31T11:50:00.000 | 3 | 0.132549 | false | 3,377,951 | 0 | 0 | 1 | 1 | I would like to implement a mechanism which will provide a RESTful API that allows a client to register interest in a subject with a sever, and receive asynchronous notifications from the server after the interest is registered. In enterprise (messaging) architecture, this is known as publish/subscribe 'pattern'.
With desktop applications, this is readily acheivable - however with web applications, it is proving to be more difficult.
is there a (preferably open source) framework or library out there that allows the publish/subscribe pattern to be applied to web applications?.
Server side technology may be in any of the following languages: C, C++, PHP, Python, Ruby.
I am running on Linux Ubuntu 10.0.4 |
Deploying python app to Mac and Windows users | 3,379,058 | 0 | 2 | 523 | 0 | python,deployment | How do people usually deploy such apps?
2 choices.
With instructions.
All bundled up.
You write simple instructions like this. Folks can follow these pretty reliably, unless they don't have enough privileges. Sometimes they need to sudo in linux environments.
Download easy_install (or pip)
easy_install this, easy_install that (or pip this, pip that)
easy_install whatever package you wrote.
It works really well. If you download some Python packages you'll see this in action.
Sphinx requires docutils. Django requires docutils and PIL. It works out really well to simply document the dependencies. Other folks seem to do it without serious problems. Follow their lead.
Bundling things up means you have to
(a) provide the entire original distribution (as required by most open source licenses)
(b) provide a compatible open source license with the licenses of the things you bundled. This can be easy if you depend on things that all of the same license. Otherwise, you basically can't redistribute them and have to resort to installation instructions. | 0 | 1 | 0 | 0 | 2010-07-31T17:03:00.000 | 2 | 0 | false | 3,379,032 | 0 | 0 | 0 | 1 | I've written an app in python that depends on wxPython and some other python libraries. I know about pyexe for making python scripts executable on Windows, but what would be the easiest way to share this with my Mac using friends who wouldn't know how to install the required dependencies? One option would be to bundle my dependencies in the same package, but that seems kind of clunky. How do people usually deploy such apps? For once I miss Java... |
logout from command prompt to uploading application on google app | 3,388,313 | 3 | 1 | 556 | 0 | python,google-app-engine,command-prompt | You can run appcfg.py with --no_cookies to tell it not to store authentication cookies, or -e EMAIL to specify an email address that differs from the one in the current cookie. | 0 | 1 | 0 | 0 | 2010-08-02T12:15:00.000 | 1 | 0.53705 | false | 3,387,605 | 0 | 0 | 1 | 1 | I am uploading google app engine application with the help of appcfg.py command from command prompt in windows.
But after one login I want to upload another application from the same command prompt but i cannot because this second application has no rights with the current login so i want to logout from this session on command prompt so for that what to do? It is a python application
Is there any command to logout from command prompt? |
Installing setuptools in a private version of python | 13,340,272 | 0 | 7 | 12,097 | 0 | python | I had the same error due to the fact that Python2.7 was not on the path used by sudo.
I just added:
alias sudo='sudo env PATH=$PATH'
before running the installer. | 0 | 1 | 0 | 0 | 2010-08-02T18:15:00.000 | 5 | 0 | false | 3,390,558 | 1 | 0 | 0 | 1 | A newbie question but.....
I've installed python2.7 on a host where the system version is 2.3 (2.7 at ~/python2.7/bin/python). I'd like to add a few packages such as MySQLdb but need setuptools.
The directions say that you can use --prefix as an argument. However, if I do the following:
sh setuptools-0.6c11-py2.7.egg --prefix=~/python2.7/bin/python
I get the error msg:
-bash-3.00$ sh setuptools-0.6c11-py2.7.egg --prefix=~/python2.7/bin/python
setuptools-0.6c11-py2.7.egg: line 3: exec: python2.7: not found
Am I not using the --prefix command correctly? Naturally, typing sh setuptools-0.6c11-py2.7.egg --help can't find python either.
How do I tell setuptools where to find python explicitly? Any other issues I need to be aware of? |
if I run a .py script, can I open a new terminal, modify the file and run it also? | 3,391,956 | 2 | 2 | 146 | 0 | python | Yes you can. Is this a hard thing to test yourself? | 0 | 1 | 0 | 0 | 2010-08-02T21:28:00.000 | 2 | 0.197375 | false | 3,391,920 | 1 | 0 | 0 | 1 | if I run a .py script, can I open a new terminal, modify the file and run it also?
i.e. does the file that I run get loaded in memory, such that I can modify the file and run it at the same time in a different terminal? |
Linux kernel that runs python file for init | 3,392,306 | 2 | 3 | 1,752 | 0 | linux,kernel,init,python | I don't think init needs to be a C binary; it can be a script with a #! at the beginning; if that is the case, then you can have it be a python program with little effort.
Having said that, it is pretty trivial to write an inittab where init just runs a single program once (Although it's usually more useful to do other stuff too).
Given that you will probably want to do some things on your system which can't easily be done with python (for example, try mounting filesystems without a "mount" binary), you will probably need a busybox (for example) anyway; adding "init" to a busybox binary increases its size very little. | 0 | 1 | 0 | 0 | 2010-08-02T22:10:00.000 | 2 | 0.197375 | false | 3,392,203 | 1 | 0 | 0 | 1 | Would it be possible and not incredibly difficult to build a linux kernel, with a python interpreter built in or accessible from the kernel, that could run a python file as it's init process? |
Disconnecting from host with Python Fabric when using the API | 5,531,404 | 4 | 6 | 4,881 | 0 | python,fabric | If you don't want to have to iterate through all open connections, fabric.network.disconnect_all() is what you're looking for. The docstring reads
"""
Disconnect from all currently connected servers.
Used at the end of fab's main loop, and also intended for use by library users.
""" | 0 | 1 | 0 | 0 | 2010-08-02T22:34:00.000 | 4 | 1.2 | true | 3,392,333 | 0 | 0 | 0 | 1 | The website says:
Closing connections: Fabric’s
connection cache never closes
connections itself – it leaves this up
to whatever is using it. The fab tool
does this bookkeeping for you: it
iterates over all open connections and
closes them just before it exits
(regardless of whether the tasks
failed or not.)
Library users will need to ensure they
explicitly close all open connections
before their program exits, though we
plan to makes this easier in the
future.
I have searched everywhere, but I can't find out how to disconnect or close the connections. I am looping through my hosts and setting env.host_string. It is working, but hangs when exiting. Any help on how to close? Just to reiterate, I am using the library, not a fabfile. |
Python Fuse calling 'readlink' 6 times in a row | 7,897,314 | 1 | 3 | 510 | 0 | python,linux,fuse | Did you set st_size properly in getattr? ls will first try with a buffer size of the returned st_size and double it until the the readlink buffer fits. | 0 | 1 | 0 | 0 | 2010-08-03T12:38:00.000 | 2 | 0.099668 | false | 3,396,503 | 0 | 0 | 0 | 1 | I am implementing a filesystem using Python Fuse. A directory contains only symlinks and as such I return S_IFLNK | 0777 on the getattr method.
Now, when I do an ls on the directory, I notice that Linux calls readlink method 6 times in a row for each entry in the directory.
Is it a bug on my side or a normal behavior? |
Calling a python script from command line without typing "python" first | 3,400,402 | 5 | 12 | 14,699 | 0 | python,linux,shell,command-line | You want a shebang. #!/path/to/python. Put that on the first line of your python script. The #! is actually a magic number that tells the operating system to interpret the file as a script for the program named. You can supply /usr/bin/python or, to be more portable, /usr/bin/env python which calls the /usr/bin/env program and tells it you want the system's installed Python interpreter.
You'll also have to put your script in your path, unless you're okay with typing ./SQLsap args. | 0 | 1 | 0 | 0 | 2010-08-03T20:08:00.000 | 6 | 0.16514 | false | 3,400,381 | 0 | 0 | 0 | 2 | Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible?
Info:
I wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type "python SQLsap args" and would rather just type "SQLsap args". I don't know if this is even possible, but it would be good to know if it is. For more than just this program. |
Calling a python script from command line without typing "python" first | 3,400,404 | 4 | 12 | 14,699 | 0 | python,linux,shell,command-line | Assuming this is on a unix system, you can add a "shebang" on the top of the file like this:
#!/usr/bin/env python
And then set the executable flag like this:
chmod +x SQLsap | 0 | 1 | 0 | 0 | 2010-08-03T20:08:00.000 | 6 | 0.132549 | false | 3,400,381 | 0 | 0 | 0 | 2 | Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible?
Info:
I wrote a handy script for accessing sqlite databases from command line, but I kind of don't like having to type "python SQLsap args" and would rather just type "SQLsap args". I don't know if this is even possible, but it would be good to know if it is. For more than just this program. |
How do you get Intellisense for Python in Eclipse/Aptana/Pydev? | 3,409,335 | 2 | 0 | 3,548 | 0 | python,eclipse,intellisense,pydev | I'm using eclipse 3.6 and pydev with python 2.6 and it's the best one I've tested up to now. I didn't try 3.5 so not sure if it's the same as yours but I think it autocompletes well compared to others I tried but I didn't try any of the paid ones. | 0 | 1 | 0 | 1 | 2010-08-04T19:41:00.000 | 3 | 0.132549 | false | 3,409,226 | 0 | 0 | 0 | 3 | Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2 |
How do you get Intellisense for Python in Eclipse/Aptana/Pydev? | 3,409,439 | 3 | 0 | 3,548 | 0 | python,eclipse,intellisense,pydev | You are probably never going to get something as good as intellisense for python. Due to the dynamic nature of python, it is often impossible to be able to know the type of some variables.
And if you don't know their types, you can't do auto-complete on things like class members.
Personally, I think the auto-complete in PyDev is pretty good, given the nature of python. It isn't as good as for Java and probably won't be, but it sure beats not having anything.
Having said that, I haven't tried if PyDev is able to use the parameter types you can specify in python 3.x. Otherwise, that might be an improvement that could make life a little easier.
Update: Got curious and did a quick test, Looks like optional type information in python 3 is not used by PyDev. | 0 | 1 | 0 | 1 | 2010-08-04T19:41:00.000 | 3 | 0.197375 | false | 3,409,226 | 0 | 0 | 0 | 3 | Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2 |
How do you get Intellisense for Python in Eclipse/Aptana/Pydev? | 9,141,159 | 0 | 0 | 3,548 | 0 | python,eclipse,intellisense,pydev | In Aptana I added the reference to the .egg file to the system PYTHONPATH in Preferences menu. I am not sure if this works for every library out there.
Preferences --> PyDev --> Interpreter Python --> Libraries tab on the right. | 0 | 1 | 0 | 1 | 2010-08-04T19:41:00.000 | 3 | 0 | false | 3,409,226 | 0 | 0 | 0 | 3 | Does anyone know how to get an intellisense like functionality (better than default) in eclipse for python development? I am using Eclipse 3.5 with aptana and pydev and the interpreter is python 2.5.2 |
Appengine Blobstore - Video Streaming | 3,409,743 | 5 | 6 | 1,334 | 0 | python,google-app-engine | I would say the blobstore is suitable for this. While datastore entities are limited to 1MB and standard HTTP responses are limited to 10MB, with the blobstore you can upload, store, and serve files up to 2GB. The 30 second limit refers to how long your handler can execute; time spent downloading (or uploading) doesn't count towards this limit.
The blobstore also supports byte ranges, so if your flash component supports it, you can seek to random positions in the video without downloading everything first. | 0 | 1 | 0 | 0 | 2010-08-04T20:27:00.000 | 1 | 0.761594 | false | 3,409,549 | 0 | 0 | 1 | 1 | I'm trying to setup a video streaming app via the Google Appengine Blobstore. Just wanted to know if this was possible, as there isn't too much regarding this in the Appengine Documentation. Basically I want to serve these videos through a flash player.
Thanks |
py-appscript is starting a new Finder instance | 3,426,504 | 1 | 0 | 266 | 0 | python,applescript | Seeing as how py-appscript is a layer between python and the application you are scripting via Applescript, I would suggest porting the statement to pure Applescript and see if it works there. There are a lot of things that can go wrong with Applescript (and your statement alone) to begin with and it's not obvious what is the expected before with py-appscript when an error occurs. | 0 | 1 | 0 | 0 | 2010-08-06T16:12:00.000 | 1 | 1.2 | true | 3,425,643 | 1 | 0 | 0 | 1 | i have a py2app application, which runs an appscript using py-appscript. the Applescript code is this one line:
app('Finder').update(<file alias of a certain file>)
What this normally does is update a file's preview in Finder. It works most of the time, except for Leopard. In Leopard, everytime that script is executed, instead of updating the file, it starts a new instance of Finder. What am I doing wrong? The app was built on the same machine (the Leopard). |
What language (Java or Python) + framework for mid sized web project? | 3,428,411 | 2 | 2 | 492 | 0 | java,python,google-app-engine,web-applications,stripes | As many things in life, this depends on what your goals are. If you intend to learn a web framework that is used in corporate environments, then choose a Java solution. If not, don't. Python is certainly more elegant and generally more fun in pretty much every way.
As to which framework to use, django has the most mindshare, as evidenced by the number of questions asked about it here. My understanding is that it's also pretty good. It's best suited for CMS-like web sites, though - at least that's what it's coming from and what it's optimized for. You might also have a look at one of the simpler, nimbler ones, such as the relatively new flask. All of these are enjoyable, though they may not all have all features on AppEngine. | 0 | 1 | 0 | 0 | 2010-08-06T21:31:00.000 | 9 | 0.044415 | false | 3,427,946 | 0 | 0 | 1 | 5 | I plan to start a mid sized web project, what language + framework would you recommend?
I know Java and Python. I am looking for something simple.
Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standard SQL solution? + I need fulltext search + I need to filter objects by several parameters).
What about Java with Stripes? Should I use another framework in addition to Stripes (e.g. for database).
UPDATE:
Thanks for the advice, I finally decided to use Django with Eclipse/PyDev as an IDE.
Python/Django is simple and elegant, it's widely used and there is a great documentation. A small disadvantage is that perhaps I'll have to buy a VPS, but it shouldn't be very hard to port the project to App Engine, which is free to some extent. |
What language (Java or Python) + framework for mid sized web project? | 3,428,479 | 0 | 2 | 492 | 0 | java,python,google-app-engine,web-applications,stripes | It depends on your personality. There's no right answer to this question any more than there's a right answer to "what kind of car should I drive?"
If you're artistic and believe code should be beautiful, use Rails.
If you're a real hacker type, I think you'll find a full-stack framework such as Rails or Django to be unsatisfying. These frameworks are "opinionated" software, which means you have to really embrace the author's vision to be most productive.
The wonderful thing about web development in the Python world is there's several great minimal frameworks. I've used several, including web.py, GAE's webapp, and cherrypy. These frameworks are like "here's a request, give me a string to serve up." It's raw. Don't think you'll be stuck in Python concatenating strings though, God no. There's also several excellent templating libraries for Python. I can personally recommend Cheetah but Mako also looks good. | 0 | 1 | 0 | 0 | 2010-08-06T21:31:00.000 | 9 | 0 | false | 3,427,946 | 0 | 0 | 1 | 5 | I plan to start a mid sized web project, what language + framework would you recommend?
I know Java and Python. I am looking for something simple.
Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standard SQL solution? + I need fulltext search + I need to filter objects by several parameters).
What about Java with Stripes? Should I use another framework in addition to Stripes (e.g. for database).
UPDATE:
Thanks for the advice, I finally decided to use Django with Eclipse/PyDev as an IDE.
Python/Django is simple and elegant, it's widely used and there is a great documentation. A small disadvantage is that perhaps I'll have to buy a VPS, but it shouldn't be very hard to port the project to App Engine, which is free to some extent. |
What language (Java or Python) + framework for mid sized web project? | 3,428,497 | 0 | 2 | 492 | 0 | java,python,google-app-engine,web-applications,stripes | Google App Engine + GWT and you have a pretty powerful combination for developing web applications. The datastore is quite fast, and it has so far done the job quite nicely for me.
In my project I had to do a lot of redesigning of my database model, because it was made for a traditional relational database, and some things were not (directly) possible with the datastore.
GWT has a fairly moderate learning curve, but it gets the job done very well. The gui code is really easy to get started with, but it's the asynchronous way of thinking that's the hardest part.
As for search I don't think it's supported in the framework. Filtering is possible on parameters.
There are some limitations to GAE, and you should consider them before putting all your eggs in that basket. The fact that GAE uses J2EE distribution standards makes the application very easy to move to a dedicated server, should the limitations of GAE become a problem. In fact I only think you would have to refactor the part of your code that makes the queries and stores the data (which shouldn't be much more than 100 lines). | 0 | 1 | 0 | 0 | 2010-08-06T21:31:00.000 | 9 | 0 | false | 3,427,946 | 0 | 0 | 1 | 5 | I plan to start a mid sized web project, what language + framework would you recommend?
I know Java and Python. I am looking for something simple.
Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standard SQL solution? + I need fulltext search + I need to filter objects by several parameters).
What about Java with Stripes? Should I use another framework in addition to Stripes (e.g. for database).
UPDATE:
Thanks for the advice, I finally decided to use Django with Eclipse/PyDev as an IDE.
Python/Django is simple and elegant, it's widely used and there is a great documentation. A small disadvantage is that perhaps I'll have to buy a VPS, but it shouldn't be very hard to port the project to App Engine, which is free to some extent. |
What language (Java or Python) + framework for mid sized web project? | 3,428,141 | 0 | 2 | 492 | 0 | java,python,google-app-engine,web-applications,stripes | I don't think the datastore is a problem. Many people will reject it out of hand because they want a standard relational database; if you are willing to consider a datastore in general then I doubt you will have any problems with the GAE datastore. Personally, I quite like it.
The thing that might trip you up is the operational limitations. For example, did you know that an HTTP request must complete within 10 seconds?
What if you get 50% of the way through a project and then find that a web service you are using sometimes take 15 seconds to respond? Now you are toast. You can't pay extra to get the limit raised or anything like that.
So, my point is that you must approach GAE with great care. Learn about the limitations and make sure that they will not be a problem before you start using it. | 0 | 1 | 0 | 0 | 2010-08-06T21:31:00.000 | 9 | 0 | false | 3,427,946 | 0 | 0 | 1 | 5 | I plan to start a mid sized web project, what language + framework would you recommend?
I know Java and Python. I am looking for something simple.
Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standard SQL solution? + I need fulltext search + I need to filter objects by several parameters).
What about Java with Stripes? Should I use another framework in addition to Stripes (e.g. for database).
UPDATE:
Thanks for the advice, I finally decided to use Django with Eclipse/PyDev as an IDE.
Python/Django is simple and elegant, it's widely used and there is a great documentation. A small disadvantage is that perhaps I'll have to buy a VPS, but it shouldn't be very hard to port the project to App Engine, which is free to some extent. |
What language (Java or Python) + framework for mid sized web project? | 3,430,891 | 0 | 2 | 492 | 0 | java,python,google-app-engine,web-applications,stripes | I've built several apps on GAE (with Python) over the last year. It's hard to beat the ease with which you can get an app up and running quickly. Don't discount the value in that alone.
While you may not understand the datastore yet, it is extremely well documented and there are great resources - including this one - to help you get past any problem you might have. | 0 | 1 | 0 | 0 | 2010-08-06T21:31:00.000 | 9 | 0 | false | 3,427,946 | 0 | 0 | 1 | 5 | I plan to start a mid sized web project, what language + framework would you recommend?
I know Java and Python. I am looking for something simple.
Is App Engine a good option? I like the overall simplicity and free hosting, but I am worried about the datastore (how difficult is it to make it similarly fast as a standard SQL solution? + I need fulltext search + I need to filter objects by several parameters).
What about Java with Stripes? Should I use another framework in addition to Stripes (e.g. for database).
UPDATE:
Thanks for the advice, I finally decided to use Django with Eclipse/PyDev as an IDE.
Python/Django is simple and elegant, it's widely used and there is a great documentation. A small disadvantage is that perhaps I'll have to buy a VPS, but it shouldn't be very hard to port the project to App Engine, which is free to some extent. |
Get big TAR(gz)-file contents by dir levels | 3,431,918 | 1 | 0 | 247 | 0 | python,tar | You can't scan the contents of a tar without scanning the entire file; it has no central index. You need something like a ZIP. | 0 | 1 | 0 | 0 | 2010-08-07T19:55:00.000 | 1 | 1.2 | true | 3,431,844 | 1 | 0 | 0 | 1 | I use python tarfile module.
I have a system backup in tar.gz file.
I need to get first level dirs and files list without getting ALL the list of files in the archive because it's TOO LONG.
For example: I need to get ['bin/', 'etc/', ... 'var/'] and that's all.
How can I do it? May be not even with a tar-file? Then how? |
IPython workflow (edit, run) | 11,456,303 | 5 | 51 | 33,816 | 0 | python,user-interface,ipython,python-idle | Try Spyder, I have spent all day trying to find an IDE which has the functionality of ipython and Spyder just kicks it out of the park..
Autocomplete is top notch right from install, no config files and all that crap, and it has an Ipython terminal in the corner for you to instantly run your code.
big thumbs up | 0 | 1 | 0 | 0 | 2010-08-09T08:50:00.000 | 14 | 0.071307 | false | 3,438,531 | 1 | 0 | 0 | 1 | Is there a GUI for IPython that allows me to open/run/edit Python files? My way of working in IDLE is to have two windows open: the shell and a .py file. I edit the .py file, run it, and interact with the results in the shell.
Is it possible to use IPython like this? Or is there an alternative way of working? |
Tasks queue process in python | 3,439,041 | 1 | 0 | 883 | 0 | python,queue,task | This is a bit of a vague question. One thing you should remember is that it is very difficult to leak memory in Python, because of the automatic garbage collection. croning a Python script to handle the queue isn't very nice, although it would work fine.
I would use method 1; if you need more power you could make a small Python process that monitors the DB queue and starts new processes to handle the tasks. | 0 | 1 | 0 | 0 | 2010-08-09T10:14:00.000 | 3 | 0.066568 | false | 3,439,020 | 0 | 0 | 0 | 1 | Task is:
I have task queue stored in db. It grows. I need to solve tasks by python script when I have resources for it. I see two ways:
python script working all the time. But i don't like it (reason posible memory leak).
python script called by cron and do a little part of task. But i need to solve the problem of one working active script in memory (To prevent active scripts count grow). What is the best solution to implement it in python?
Any ideas to solve this problem at all? |
How to strip source from distutils binary distributions? | 39,629,278 | 0 | 8 | 2,952 | 0 | python,bytecode,distutils | "the standard commands don't have such an option"?
Do you have the latest version of setuptools installed? And did you write a setup.py file?
If so, this should work: python setup.py bdist_egg --exclude-source-files. | 0 | 1 | 0 | 0 | 2010-08-09T12:35:00.000 | 4 | 0 | false | 3,440,016 | 0 | 0 | 0 | 1 | I want to create a bytecode-only distribution from distutils (no really, I do; I know what I'm doing). Using setuptools and the bdist_egg command, you can simply provide the --exclude-source parameter. Unfortunately the standard commands don't have such an option.
Is there an easy way to strip the source files just before the tar.gz, zip, rpm or deb is created.
Is there a relatively clean per-command way to do this (eg just for tar.gz or zip). |
Calling a Python module from Perl | 3,446,205 | 9 | 9 | 9,275 | 0 | python,perl,interop | In the short run the easiest solution is to use Inline::Python. Closely followed by calling a command-line script.
In the long run, using a server to provide RPC functionality or simply calling a command-line script will give you the most future proof solution.
Why?
Becuase that way you aren't tied to Perl or Python as the language used to build the systems that consume the services provided by your library. Either method creates a clear, language independent interface that you can use with whatever development environment you adopt.
Depending on your needs any of the presented options may be the "best choice". Depending on how your needs evolve over time, a different choice may be revealed as "best".
My approach to this would be to ask a couple of questions:
How often do you change development tools. You've switched to Python from Perl. Did you start with Tcl and go to Perl? Are you going to switch to the exciting new language X in 1, 5 or 10 years? If you change tools 'often' (whatever that means) emphasize cross tool compatibility.
How fast is fast enough? Is the start up time for command line solutions ok? Does Inline::Python slow things down too much (you are still initializing a Python interpreter, it's just embedded in your Perl interpreter)?
Based on the answers to these questions, I would do the simplest thing that is likely to work.
My guess is that means in order:
Inline::Python
Command line scripts
Build an RPC server | 0 | 1 | 0 | 1 | 2010-08-09T15:50:00.000 | 3 | 1 | false | 3,441,766 | 0 | 0 | 0 | 2 | I created a module in Python which provides about a dozen functionalities. While it will be mostly used from within Python, there is a good fraction of legacy users which will be calling it from Perl.
What is the best way to make a plug in to this module? My thoughts are:
Provide the functionalities as command line utilities and make system calls
Create some sort of server and handle RPC calls (say, via JSON RPC)
Any advise? |
Calling a Python module from Perl | 3,441,920 | 3 | 9 | 9,275 | 0 | python,perl,interop | Provide the functionalities as command line utilities and make system calls
Works really nicely. This is the way programs like Python (and Perl) are meant to use used. | 0 | 1 | 0 | 1 | 2010-08-09T15:50:00.000 | 3 | 0.197375 | false | 3,441,766 | 0 | 0 | 0 | 2 | I created a module in Python which provides about a dozen functionalities. While it will be mostly used from within Python, there is a good fraction of legacy users which will be calling it from Perl.
What is the best way to make a plug in to this module? My thoughts are:
Provide the functionalities as command line utilities and make system calls
Create some sort of server and handle RPC calls (say, via JSON RPC)
Any advise? |
How can I tell where my python script is hanging? | 3,443,835 | 24 | 80 | 82,971 | 0 | python,debugging | Wow! 5 answers already and nobody has suggested the most obvious and simple:
Try to find a reproducible test case that causes the hanging behavior.
Add logging to your code. This can be as basic as print "**010", print "**020", etc. peppered through major areas.
Run code. See where it hangs. Can't understand why? Add more logging. (I.e. if between **020 and **030, go and add **023, **025, **027, etc.)
Goto 3. | 0 | 1 | 0 | 0 | 2010-08-09T19:46:00.000 | 14 | 1 | false | 3,443,607 | 1 | 0 | 0 | 2 | So I'm debugging my python program and have encountered a bug that makes the program hang, as if in an infinite loop. Now, I had a problem with an infinite loop before, but when it hung up I could kill the program and python spat out a helpful exception that told me where the program terminated when I sent it the kill command. Now, however, when the program hangs up and I ctrl-c it, it does not abort but continues running. Is there any tool I can use to locate the hang up? I'm new to profiling but from what I know a profiler can only provide you with information about a program that has successfully completed. Or can you use a profiler to debug such hang ups? |
How can I tell where my python script is hanging? | 3,443,669 | 2 | 80 | 82,971 | 0 | python,debugging | It's easier to prevent these hang-ups than it is to debug them.
First: for loops are very, very hard to get stuck in a situation where the loop won't terminate. Very hard.
Second: while loops are relatively easy to get stuck in a loop.
The first pass is to check every while loop to see if it must be a while loop. Often you can replace while constructs with for, and you'll correct your problem by rethinking your loop.
If you cannot replace a while loop with for, then you simply have to prove that the expression in the while statement must change every time through the loop. This isn't that hard to prove.
Look at all the condition in the loop. Call this T.
Look at all the logic branches in the body of the loop. Is there any way to get through the loop without making a change to the condition, T?
Yes? That's your bug. That logic path is wrong.
No? Excellent, that loop must terminate. | 0 | 1 | 0 | 0 | 2010-08-09T19:46:00.000 | 14 | 0.028564 | false | 3,443,607 | 1 | 0 | 0 | 2 | So I'm debugging my python program and have encountered a bug that makes the program hang, as if in an infinite loop. Now, I had a problem with an infinite loop before, but when it hung up I could kill the program and python spat out a helpful exception that told me where the program terminated when I sent it the kill command. Now, however, when the program hangs up and I ctrl-c it, it does not abort but continues running. Is there any tool I can use to locate the hang up? I'm new to profiling but from what I know a profiler can only provide you with information about a program that has successfully completed. Or can you use a profiler to debug such hang ups? |
As a software developer what is your SNMP suite that easy to integrate into your software | 3,447,496 | 0 | 3 | 597 | 0 | c++,python,c,linux,snmp | I am still searching for that easy to use suite of SNMP tools/API myself.
I build OA&M and I've tried NET-SNMP, Windows SNMP and lately agentpp (www.agentpp.com).
Personally, I preferred the agentpp.
Good luck to you. | 0 | 1 | 0 | 0 | 2010-08-10T04:41:00.000 | 4 | 0 | false | 3,446,087 | 0 | 0 | 0 | 2 | Well, altough the S of the SNMP stands for Simple, yet, so far I haven't experienced it that way. And now that I am about to deploy my software on around around 180 remote Linux servers and wants to monitor the servers and configure my daemons all from a centralized point.
I simply want you to recommend me the library which you'll confidently describe as "SNMP Made Easy".
I am looking for a suite of software which not standing in the developer's way, easy to work with (install, configure).
Speaking from the NOC perspective, the ideal would be such one which requires no maintenance once installed.
Note: Open Source is mandatory. |
As a software developer what is your SNMP suite that easy to integrate into your software | 3,918,718 | 0 | 3 | 597 | 0 | c++,python,c,linux,snmp | The "S" in SNMP is actually for "simple" not because using it is simple, but rather because the protocol (on the wire) is designed to be simple and easy to implement. And it is. Now... actually implementing it and then using it is where the S completely drops away. | 0 | 1 | 0 | 0 | 2010-08-10T04:41:00.000 | 4 | 0 | false | 3,446,087 | 0 | 0 | 0 | 2 | Well, altough the S of the SNMP stands for Simple, yet, so far I haven't experienced it that way. And now that I am about to deploy my software on around around 180 remote Linux servers and wants to monitor the servers and configure my daemons all from a centralized point.
I simply want you to recommend me the library which you'll confidently describe as "SNMP Made Easy".
I am looking for a suite of software which not standing in the developer's way, easy to work with (install, configure).
Speaking from the NOC perspective, the ideal would be such one which requires no maintenance once installed.
Note: Open Source is mandatory. |
Can Cherokee serve a fallback/default page when a reverse proxy is unavailable? | 3,452,793 | 0 | 0 | 218 | 0 | python,web-services,reverse-proxy,cherokee | You could set a custom 504 error page. | 0 | 1 | 0 | 0 | 2010-08-10T13:54:00.000 | 1 | 1.2 | true | 3,449,673 | 0 | 0 | 1 | 1 | I have a Cherokee installation that I'm using to serve a few web applications - one blog/calendar/etc. and two CPU-intensive web applications (1 stable version and 1 development version). All of them are Django or Pylons webservices served with CherryPy. I'm using the reverse-proxy handler in Cherokee to handle the mappings.
Occasionally I have to take the development version down to make changes. Is there a way to set up Cherokee so that it will automatically serve (or redirect to) another page (e.g. indicating an under-construction status) when the reverse-proxy target is unfindable or unresponsive?
I'd prefer an automated solution in Cherokee but if someone knows a simple point-and-click method I'll take that too. |
Viewing Contents Of a DLL File | 3,454,709 | 0 | 4 | 3,117 | 0 | c#,python,c,dll,import | I've done some work with ctypes, and loading dlls in windows, but I don't think DLL have any sort of introspection. This really isn't a big deal, because all of the function calls in DLLs are static. If your trying to use a undocumented DLL, you would not only need to know the names of the functions, but also the parameters of the functions. You would have to reverse engineer the DLL, no small task.
So, in my opinion, I would say no. | 0 | 1 | 0 | 1 | 2010-08-11T01:17:00.000 | 4 | 0 | false | 3,454,647 | 0 | 0 | 0 | 1 | is this possible to view contents and Functions of a DLL file...
few times ago i was playing with OlyDBG then i found there is option for viewing contents of dll...
so suggest me any good tool or soft for this...
and suppose i have a DLL named "Python27.dll"...
now i need to view the content of this DLL so what do i do...
thanx... |
How to depends of a system command with python/distutils? | 3,466,094 | 4 | 3 | 629 | 0 | python,command,packaging,distutils | I wouldn't have any check at all. Document that your library requires this command, and if the user tries to use whatever part of your library needs it, an exception will be raised by whatever runs the command. It should still be possible to import your library and use it, even if only a subset of functionality is offered.
(PS: commands is old and broken and shouldn't be used in new code. subprocess is the hot new stuff.) | 0 | 1 | 0 | 1 | 2010-08-12T06:41:00.000 | 2 | 1.2 | true | 3,465,295 | 0 | 0 | 0 | 1 | I'm looking for the most elegant way to notify users of my library that they need a specific unix command to ensure that it will works...
When is the bet time for my lib to raise an error:
Installation ?
When my app call the command ?
At the import of my lib ?
both?
And also how should you detect that the command is missing (if not commands.getoutput("which CommandIDependsOn"): raise Exception("you need CommandIDependsOn")).
I need advices. |
What are the differences between the two Python 2.7 Mac OS X disk image installers? | 3,472,387 | 0 | 3 | 2,127 | 0 | python,installation,diskimage | Looks like all the other versions only have a 32 bit port? So a "new feature" of 2.7 is a 64 bit port. If you aren't running a 64 bit OS and don't need programs that can use > 4 GB of ram, you can stick with the 32 bit. | 0 | 1 | 0 | 0 | 2010-08-12T21:52:00.000 | 4 | 0 | false | 3,472,349 | 1 | 0 | 0 | 3 | Python 2.7 has two different disk image installers for Mac OS X. My questions are:
What are the differences between the two Python 2.7 disk image installers?
Python 2.7 32-bit Mac OS X Installer Disk Image for Mac OS X 10.3 through 10.6
Python 2.7 PPC/i386/x86-64 Mac OS X Installer Disk Image for Mac OS X 10.5 or later
If running Mac OS X 10.6 Snow Leopard without the 64-bit kernel and extensions, which is the more appropriate version of Python 2.7 to install?
Why are there two different Mac OS X disk image installers for Python 2.7 when Python 2.6.5 and Python 3.2 each only have one?
Does the first listed installer support PPC? Strange that it wouldn't if it support back to Mac OS X 10.3, but unlike the second installer PPC isn't listed. |
What are the differences between the two Python 2.7 Mac OS X disk image installers? | 3,472,470 | 0 | 3 | 2,127 | 0 | python,installation,diskimage | 1) You almost certainly want "Python 2.7 PPC/i386/x86-64 Mac OS X Installer Disk Image". It's also a close analogue of the 2.6.x version that comes with 10.6 by default.
2) Unless you know you need 32-bit versions for some reason, default to 64-bit for everything on Snow Leopard. It's what will most closely match the rest of the the apps/libraries/userland. The kernel is irrelevant in this regard. The 32-bit OS X kernel can and will still run 64-bit userland.
3) 64-bit versions weren't available before 10.6. | 0 | 1 | 0 | 0 | 2010-08-12T21:52:00.000 | 4 | 0 | false | 3,472,349 | 1 | 0 | 0 | 3 | Python 2.7 has two different disk image installers for Mac OS X. My questions are:
What are the differences between the two Python 2.7 disk image installers?
Python 2.7 32-bit Mac OS X Installer Disk Image for Mac OS X 10.3 through 10.6
Python 2.7 PPC/i386/x86-64 Mac OS X Installer Disk Image for Mac OS X 10.5 or later
If running Mac OS X 10.6 Snow Leopard without the 64-bit kernel and extensions, which is the more appropriate version of Python 2.7 to install?
Why are there two different Mac OS X disk image installers for Python 2.7 when Python 2.6.5 and Python 3.2 each only have one?
Does the first listed installer support PPC? Strange that it wouldn't if it support back to Mac OS X 10.3, but unlike the second installer PPC isn't listed. |
What are the differences between the two Python 2.7 Mac OS X disk image installers? | 3,472,625 | 3 | 3 | 2,127 | 0 | python,installation,diskimage | As others have pointed out, the second (64-bit) installer variant is new on python.org starting with 2.7 and future releases of 2.7 and 3.2 will have both 32-bit-only and a 32-/64-bit variants. The newer variant is an attempt to add out-of-the-box support from python.org for Intel 64-bit (x86_64) processes which is the default for new applications in OS X 10.6.
However, the python.org installer goes a bit further and tries to support x86_64 on OS X 10.5 as well and that has caused some serious problems. In particular, the installer was linked with Tk 8.4 for which Apple does not supply a native 64-bit version on either 10.5 or 10.6. This means that IDLE and any other Python program that uses Tkinter fails on 10.6 in the default 64-bit mode (and for various reasons it is not straightforward to run IDLE in 32-bit mode on 10.6). And, of course, they will fail on 10.5 if 64-bit mode is forced. Apple does supply a 64-bit version of Tk 8.5 but only on OS X 10.6. For this and other reasons, the current plan is to change the 32-bit/64-bit variant in future releases to only support 10.6 or higher and only include 32-bit (i386) and 64-bit (x86_64) support, no PPC.
So if you anticipate needing IDLE or Tkinter on 10.6, you should consider sticking to the traditional 32-bit-only 2.7 installer for now until a newer 10.6-only installer is available (which might not be until the next maintenance release of 2.7).
As to question 4, at the moment, both installers support PPC 32-bit: the first on 10.3 through 10.6, the second on 10.5 & 10.6. But the second will disappear in the future. And, although OS X 10.6 will not boot on PPC machines, it is possible to run Python (and most other programs) in PPC mode if the Rosetta emulation package is installed in OS X. | 0 | 1 | 0 | 0 | 2010-08-12T21:52:00.000 | 4 | 1.2 | true | 3,472,349 | 1 | 0 | 0 | 3 | Python 2.7 has two different disk image installers for Mac OS X. My questions are:
What are the differences between the two Python 2.7 disk image installers?
Python 2.7 32-bit Mac OS X Installer Disk Image for Mac OS X 10.3 through 10.6
Python 2.7 PPC/i386/x86-64 Mac OS X Installer Disk Image for Mac OS X 10.5 or later
If running Mac OS X 10.6 Snow Leopard without the 64-bit kernel and extensions, which is the more appropriate version of Python 2.7 to install?
Why are there two different Mac OS X disk image installers for Python 2.7 when Python 2.6.5 and Python 3.2 each only have one?
Does the first listed installer support PPC? Strange that it wouldn't if it support back to Mac OS X 10.3, but unlike the second installer PPC isn't listed. |
Popen gives "File not found" Error (windows/python) | 3,472,949 | 4 | 2 | 4,657 | 0 | python,windows,popen | Instead ofD:\Program Files\Steam\steamapps\terabytest\sourcesdk\bin\orangebox\bin\vbsp.exe, useD:/Program Files/Steam/steamapps/terabytest/sourcesdk/bin/orangebox/bin/vbsp.exe
This eliminates any complications with backslashes inside quotes. | 0 | 1 | 0 | 0 | 2010-08-12T23:40:00.000 | 2 | 1.2 | true | 3,472,862 | 1 | 0 | 0 | 2 | I'm trying to run console commands via subprocess.Popen, and whenever I run it I get the windows "File not found" error, even when running the echo command.
I am also using Popen inside a thread made with the thread module. Is that the problem? |
Popen gives "File not found" Error (windows/python) | 3,472,903 | 3 | 2 | 4,657 | 0 | python,windows,popen | echo is not an executable, it's an internal command inside cmd.exe. If you want to use Popen with internal commands, add a keyword parameter shell=True | 0 | 1 | 0 | 0 | 2010-08-12T23:40:00.000 | 2 | 0.291313 | false | 3,472,862 | 1 | 0 | 0 | 2 | I'm trying to run console commands via subprocess.Popen, and whenever I run it I get the windows "File not found" error, even when running the echo command.
I am also using Popen inside a thread made with the thread module. Is that the problem? |
Is it good style to call bash commands within a Python script using os.system("bash code")? | 3,479,760 | 3 | 8 | 3,091 | 0 | python,security,bash,scripting,embedding | It always better and better style to use Python functions to do this kind of stuff. With Python it's not that hard to write a script in an OS-independent way instead of using bash. | 0 | 1 | 0 | 0 | 2010-08-13T18:35:00.000 | 7 | 0.085505 | false | 3,479,728 | 0 | 0 | 0 | 3 | I was wondering whether or not it is considered a good style to call bash commands within a Python script using os.system(). I was also wondering whether or not it is safe to do so as well.
I know how to implement some of the functionality I need in Bash and in Python, but it is much simpler and more intuitive to implement it in Bash. However, I feel like it is very hackish to write os.system("bash code").
Specifically, I want to move all files that end with a certain extension to a directory.
In bash: *mv .ext /path/to/destination
In Python (Pseudocode):
for file in directory:
if file.endswith("ext"):
move file to destination
In this case, what should I do? |
Is it good style to call bash commands within a Python script using os.system("bash code")? | 3,479,763 | 1 | 8 | 3,091 | 0 | python,security,bash,scripting,embedding | It's not idea, since it makes your script a lot less portable. A native python script can run on any unix or windows machine that has the proper python libraries installed. When you add shell commands into the mix, you break that, and suddenly are locked down to a much narrower subset.
Sometimes you don't have a choice, but if it's something as simple as that, writing the code natively in python would make a lot more sense, and also be faster to boot (since the python process won't have to spawn a new shell just to execute the one command). | 0 | 1 | 0 | 0 | 2010-08-13T18:35:00.000 | 7 | 0.028564 | false | 3,479,728 | 0 | 0 | 0 | 3 | I was wondering whether or not it is considered a good style to call bash commands within a Python script using os.system(). I was also wondering whether or not it is safe to do so as well.
I know how to implement some of the functionality I need in Bash and in Python, but it is much simpler and more intuitive to implement it in Bash. However, I feel like it is very hackish to write os.system("bash code").
Specifically, I want to move all files that end with a certain extension to a directory.
In bash: *mv .ext /path/to/destination
In Python (Pseudocode):
for file in directory:
if file.endswith("ext"):
move file to destination
In this case, what should I do? |
Is it good style to call bash commands within a Python script using os.system("bash code")? | 3,479,838 | 1 | 8 | 3,091 | 0 | python,security,bash,scripting,embedding | The quoting issues alone suggest that a pure Python solution is preferable. | 0 | 1 | 0 | 0 | 2010-08-13T18:35:00.000 | 7 | 0.028564 | false | 3,479,728 | 0 | 0 | 0 | 3 | I was wondering whether or not it is considered a good style to call bash commands within a Python script using os.system(). I was also wondering whether or not it is safe to do so as well.
I know how to implement some of the functionality I need in Bash and in Python, but it is much simpler and more intuitive to implement it in Bash. However, I feel like it is very hackish to write os.system("bash code").
Specifically, I want to move all files that end with a certain extension to a directory.
In bash: *mv .ext /path/to/destination
In Python (Pseudocode):
for file in directory:
if file.endswith("ext"):
move file to destination
In this case, what should I do? |
Twisted vs Google App Engine in serving mobile clients | 3,480,585 | 6 | 1 | 617 | 0 | python,google-app-engine,twisted | Certainly. App Engine will scale your application up as the load increases automatically and will be spread over many machines. The web api they have is pretty nice too. You don't have to worry about deferreds either because it scales by bringing more instances up instead of making things asynchronous.
BTW: I have web services hosted on app engine that are consumed by iPhone. | 0 | 1 | 0 | 0 | 2010-08-13T20:41:00.000 | 1 | 1.2 | true | 3,480,524 | 0 | 0 | 1 | 1 | So far I have been using Twisted to simultaneously serve a lot of mobile clients (Android, iPhone) with their HTTP requests exchanging JSON messages.
For my next project I'd like to try out Google App Engine, but I'm wondering if it is capable of doing the same or if I should rather go with a custom built solution again. |
Google App Engine - Naked Domain Path Redirect in Python | 3,483,631 | 0 | 4 | 830 | 0 | python,google-app-engine,redirect | 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 broken. | 0 | 1 | 1 | 0 | 2010-08-14T05:27:00.000 | 2 | 0 | false | 3,482,152 | 0 | 0 | 1 | 1 | 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, and then redirect the user to where they meant to go (With the www. added?)
EDIT:
Clarification: In my webhost's configuration I have colorurl.com forward to www.colorurl.com. They do not support keeping the path (1and1). I have to detect the previous path and redirect users to it.
User goes to colorurl.com/path
User is redirected to www.colorurl.com
App needs to detect what the path was.
App sends user to www.colorurl.com/path |
Autocompletion in dynamic language IDEs, specifically Python in PyDev | 9,430,038 | 5 | 5 | 3,018 | 0 | python,ide,autocomplete,duck-typing,built-in | 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) | 0 | 1 | 0 | 1 | 2010-08-14T08:38:00.000 | 7 | 0.141893 | false | 3,482,622 | 0 | 0 | 0 | 1 | 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 = open(directory+"/"+account, 'r')
datafile.
No useful methods are suggested (e.g. realines). Only things like call.
I am used to learning a language by jumping into class definitions and using lots of auto-complete to quickly view what a class will do. My PyDev 'interpreter' is set up fine with 'forced builtins'.
Is it possible to get auto-complete for builtins with PyDev? Am I approaching the IDE wrong, i.e. should have an interpreter running on the side and test stuff with it? So far the IDEs have seemed weak, e.g. IDLE segfaulted on my new mac after 2 minutes. I'd love to know what experienced Python developers do when exploring unfamiliar (builtin) modules, as this is making me reconsider my initial attraction to Python. I like a language you can learn by easy exploration!
Thanks, |
wxPython -- Bash shell | 3,506,700 | 0 | 0 | 330 | 0 | bash,shell,wxpython | Maybe pyCrust plus the Python debugger? | 0 | 1 | 0 | 0 | 2010-08-15T08:28:00.000 | 2 | 0 | false | 3,486,708 | 0 | 0 | 0 | 1 | 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 |
App Engine - Output Response Time | 3,490,013 | 3 | 4 | 165 | 0 | python,performance,google-app-engine | 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 -- 0.96 by default, though you can explicitly ask for newer and better ones;-), or jinja2, mako, ...), it's important to be able to use in those templates a tag or filter to request and format such an expression. (You don't want to compute it at the time you call the template's render method, and pass it as part of that method's context, or else you'll fail to account for all the template rendering time in your estimate of "response time"!-). You may have to code and inject such a tag or filter into the "templating language" if your chosen templating language and version doesn't already supply one but is at least minimally extensible;-).
` | 0 | 1 | 0 | 0 | 2010-08-16T01:02:00.000 | 1 | 1.2 | true | 3,489,968 | 0 | 0 | 1 | 1 | Say I wanted to print the response time on my pages like Google do.
How would I go about doing this? |
Remembering to run tests before commit | 3,494,671 | 4 | 6 | 2,165 | 0 | python,unit-testing,build-automation,teamcity | 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. | 0 | 1 | 0 | 1 | 2010-08-16T15:22:00.000 | 5 | 0.158649 | false | 3,494,585 | 0 | 0 | 0 | 2 | 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 done at 6PM may stay broken over night.
"Forgets" is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as.
-> A developer only checks in some of the modified files in his/her workspace.
-> A file was modified outside of eclipse such that eclipse's team synchronize perspective does not detect it as dirty.
How do you deal with this in your organization?
We are thinking of introducing "check in procedure" for developers which will be an automated tool that will automatically run all unit tests and then commit all of the "dirty" files in your workspace. Have you had any experience with such process? Are you aware of any tools which may facilitate this process? Our dev environment is Python using Eclipse's PyDev plugin. |
Remembering to run tests before commit | 3,494,863 | 7 | 6 | 2,165 | 0 | python,unit-testing,build-automation,teamcity | 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! | 0 | 1 | 0 | 1 | 2010-08-16T15:22:00.000 | 5 | 1 | false | 3,494,585 | 0 | 0 | 0 | 2 | 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 done at 6PM may stay broken over night.
"Forgets" is a generic term, there a couple other common reasons why even remembering to run the tests could result in TeamCity failure. Such as.
-> A developer only checks in some of the modified files in his/her workspace.
-> A file was modified outside of eclipse such that eclipse's team synchronize perspective does not detect it as dirty.
How do you deal with this in your organization?
We are thinking of introducing "check in procedure" for developers which will be an automated tool that will automatically run all unit tests and then commit all of the "dirty" files in your workspace. Have you had any experience with such process? Are you aware of any tools which may facilitate this process? Our dev environment is Python using Eclipse's PyDev plugin. |
How do you find the filename that you pass to open()? | 3,498,742 | 2 | 2 | 965 | 0 | python,file | 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 current working directory of your process. If you don't know that working directory, an absolute path is usually simplest to find and specify.
So, find out where the file lives (e.g. c:/wher/ever) and use that absolute path (with "rightside up slashes", instead of windows-style backslashes, as I just explained in another answer) to open the file in question. | 0 | 1 | 0 | 0 | 2010-08-17T01:00:00.000 | 2 | 1.2 | true | 3,498,587 | 1 | 0 | 0 | 1 | I'm trying to open a file with Python, but I'm unsure how to find the correct filename to use. |
How can I know if the user is connected to the local machine via ssh in my python script? | 3,508,010 | 0 | 1 | 416 | 0 | python,ssh | 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 to the machine. | 0 | 1 | 0 | 1 | 2010-08-18T00:13:00.000 | 3 | 0 | false | 3,507,980 | 0 | 0 | 0 | 2 | 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? | 3,508,136 | 0 | 1 | 416 | 0 | python,ssh | 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 system id. | 0 | 1 | 0 | 1 | 2010-08-18T00:13:00.000 | 3 | 0 | false | 3,507,980 | 0 | 0 | 0 | 2 | How can I know if the user is connected to the local machine via ssh in my python script? |
How to completely remove Python from a Windows machine? | 60,318,668 | 26 | 123 | 600,614 | 0 | python,installation,uninstallation | 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 to Environment Variables -> Path) you will find that very python you just installed | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 1 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 38,920,189 | 8 | 123 | 600,614 | 0 | python,installation,uninstallation | 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 some files there. | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 1 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 18,430,403 | 56 | 123 | 600,614 | 0 | python,installation,uninstallation | 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 Windows 7 out of the box, no additional programs or scripts required. | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 1 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 68,139,862 | 3 | 123 | 600,614 | 0 | python,installation,uninstallation | 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 (from UI) | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 0.042831 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 53,206,032 | 3 | 123 | 600,614 | 0 | python,installation,uninstallation | It's actually quite simple.
When you installed it, you must have done it using some .exe file (I am assuming). Just run that .exe again, and then there will be options to modify Python. Just select the "Complete Uninstall" option, and the EXE will completely wipe out python for you.
Also, you might have to checkbox the "Remove Python from PATH". By default it is selected, but you may as well check it to be sure :) | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 0.042831 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 71,832,157 | 3 | 123 | 600,614 | 0 | python,installation,uninstallation | First, uninstall Python, then remove the pip packages you installed.
Uninstall Python: "Add or Remove Programs", search for Python and uninstall it.
Remove Pip packages: type in File Explorer %LOCALAPPDATA%\Programs\Python, and remove the folders you want.
This will clean up any pip package you installed. Otherwise, if you were to reinstall Python, you will find yourself with the same pip packages that you had. | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 0.042831 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 69,742,157 | 3 | 123 | 600,614 | 0 | python,installation,uninstallation | If you still have the python installer on your PC, you can double-click on it (run it, it will open the installer window), and select the "Uninstall" option. It will uninstall that python version (if the installer is for Python3.9, then Python3.9 will be uninstalled, if it is for Python3.10, then that version...) | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 0.042831 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 51,663,703 | 2 | 123 | 600,614 | 0 | python,installation,uninstallation | Uninstall the python program using the windows GUI.
Delete the containing folder e.g if it was stored in C:\python36\ make sure to delete that folder | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 0.028564 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 36,202,297 | 1 | 123 | 600,614 | 0 | python,installation,uninstallation | I know it is an old question, but I ran into this problem with 2.7 and 3.5. Though 2.7 would not show up in my default windows uninstall list, it showed up fine in the ccleaner tools tab under uninstall. Uninstalled and reinstalled afterwards and it has been smooth coding ever since. | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 0.014285 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 35,889,457 | 0 | 123 | 600,614 | 0 | python,installation,uninstallation | Windows 7 64-bit, with both Python3.4 and Python2.7 installed at some point :)
I'm using Py.exe to route to Py2 or Py3 depending on the script's needs - but I previously improperly uninstalled Python27 before.
Py27 was removed manually from C:\python\Python27 (the folder Python27 was deleted by me previously)
Upon re-installing Python27, it gave the above error you specify.
It would always back out while trying to 'remove shortcuts' during the installation process.
I placed a copy of Python27 back in that original folder, at C:\Python\Python27, and re-ran the same failing Python27 installer. It was happy locating those items and removing them, and proceeded with the install.
This is not the answer that addresses registry key issues (others mention that) but it is somewhat of a workaround if you know of previous installations that were improperly removed.
You could have some insight to this by opening "regedit" and searching for "Python27" - a registry key appeared in my command-shell Cache pointing at c:\python\python27\ (which had been removed and was not present when searching in the registry upon finding it).
That may help point to previously improperly removed installations.
Good luck! | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 0 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 3,515,850 | 1 | 123 | 600,614 | 0 | python,installation,uninstallation | Almost all of the python files should live in their respective folders (C:\Python26 and C:\Python27). Some installers (ActiveState) will also associate .py* files and add the python path to %PATH% with an install if you tick the "use this as the default installation" box. | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | 0.014285 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
How to completely remove Python from a Windows machine? | 66,791,174 | -1 | 123 | 600,614 | 0 | python,installation,uninstallation | Windows Start Menu > Settings > Apps > Apps & features > Select the app and click the Uninstall button | 0 | 1 | 0 | 0 | 2010-08-18T18:59:00.000 | 14 | -0.014285 | false | 3,515,673 | 1 | 0 | 0 | 12 | 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.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... |
Extending python with C module | 3,517,141 | 1 | 1 | 471 | 0 | python,c,python-module,i2c | Don't use the Python C API, there are much easier alternatives, most notably cython.
cython is a Python-like language, which compiles into C code for the Python c library. Basically it's C with Python syntax and features (e.g. nice for loops, exceptions, etc.). cython is clearly the most recommendable way to write C extensions for python.
You might also want to take a look at ctypes, a module to dynamically load C libraries and call functions from them. If your i2c-code is available as shared library, you can get away with no native binding at all, which eases development and distribution. | 0 | 1 | 0 | 1 | 2010-08-18T21:49:00.000 | 5 | 0.039979 | false | 3,517,011 | 0 | 0 | 0 | 3 | So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.
Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo. |
Extending python with C module | 3,517,152 | 0 | 1 | 471 | 0 | python,c,python-module,i2c | I've had good luck using ctypes. Whatever you choose, though, you may not gain any time this time but the next time around your effort will be much faster than doing the whole thing in C. | 0 | 1 | 0 | 1 | 2010-08-18T21:49:00.000 | 5 | 0 | false | 3,517,011 | 0 | 0 | 0 | 3 | So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.
Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo. |
Extending python with C module | 3,517,190 | 2 | 1 | 471 | 0 | python,c,python-module,i2c | One of the first Python programs I wrote was a script that called functions from a C library, which sounds close to what you're doing. I used ctypes, and I was impressed as to how easy it was: I could access each library function from python by writing just a few lines of python (no C at all!). I'd tried the Python C API before, and it required a lot more boilerplate. I havent tried SWIG or Cython. | 0 | 1 | 0 | 1 | 2010-08-18T21:49:00.000 | 5 | 0.07983 | false | 3,517,011 | 0 | 0 | 0 | 3 | So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.
Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo. |
Why do some Django ORM queries end abruptly with the message "Killed"? | 3,529,637 | 6 | 7 | 1,944 | 1 | python,django,postgresql | Only one thing I could think of that will kill automatically a process on Linux - the OOM killer. What's in the system logs? | 0 | 1 | 0 | 0 | 2010-08-19T22:19:00.000 | 2 | 1.2 | true | 3,526,748 | 0 | 0 | 1 | 1 | Sometimes, when fetching data from the database either through the python shell or through a python script, the python process dies, and one single word is printed to the terminal: Killed
That's literally all it says. It only happens with certain scripts, but it always happens for those scripts. It consistently happens with this one single query that takes a while to run, and also with a south migration that adds a bunch of rows one-by-one to the database.
My initial hunch was that a single transaction was taking too long, so I turned on autocommit for Postgres. Didn't solve the problem.
I checked the Postgres logs, and this is the only thing in there:
2010-08-19 22:06:34 UTC LOG: could not receive data from client: Connection reset by peer
2010-08-19 22:06:34 UTC LOG: unexpected EOF on client connection
I've tried googling, but as you might expect, a one-word error message is tough to google for.
I'm using Django 1.2 with Postgres 8.4 on a single Ubuntu 10.4 rackspace cloud VPS, stock config for everything. |
Store python classes as pickles in GAE? | 5,152,644 | 0 | 2 | 366 | 0 | python,google-app-engine,pickle | The key advantages of using Django are its ORM and template system. The ORM is not very useful with datastore because of its non-relational nature and the template system is available as part of the app engine to be used with webapp.
I have had good success with using webapp and django templates for our project. | 0 | 1 | 0 | 0 | 2010-08-20T15:34:00.000 | 2 | 0 | false | 3,532,417 | 0 | 0 | 1 | 2 | I am porting a Python investing application to Google App Engine. Every market that you can trade in is a plugin: for example the stocks trading and FOREX trading are all plugins.
The application stores the portfolio (which is a Portfolio class instance containing the active investments (class instances) and history) as a pickle. However you can't write to the disk, and it seems a bit crude to use pickles in the Datastore as a blob, and pickles are also slow and CPU intensive (no cPickle).
Does anyone have any ideas how I can store all the current investments, and the history to the datastore without using large and intensive pickles?
Thank you
Ps. webapp or Django? |
Store python classes as pickles in GAE? | 3,532,598 | 1 | 2 | 366 | 0 | python,google-app-engine,pickle | The best solution would be to use the Datastore data models, but you'll have to rewrite parts of your app. Using Pickle for data persistance, especially involving much data, is not a good pratice. | 0 | 1 | 0 | 0 | 2010-08-20T15:34:00.000 | 2 | 0.099668 | false | 3,532,417 | 0 | 0 | 1 | 2 | I am porting a Python investing application to Google App Engine. Every market that you can trade in is a plugin: for example the stocks trading and FOREX trading are all plugins.
The application stores the portfolio (which is a Portfolio class instance containing the active investments (class instances) and history) as a pickle. However you can't write to the disk, and it seems a bit crude to use pickles in the Datastore as a blob, and pickles are also slow and CPU intensive (no cPickle).
Does anyone have any ideas how I can store all the current investments, and the history to the datastore without using large and intensive pickles?
Thank you
Ps. webapp or Django? |
Do you use data mappers with MongoDB? | 3,553,262 | 1 | 2 | 366 | 1 | python,orm,mongodb,mongoengine,mongokit | We are running a production site using Mongodb for the backend (no direct queries to Mongo, we have a search layer in between). We wrote our own business / object layer, i suppose it just seemed natural enough for the programmers to write in the custom logic. We did separate the database and business layers, but they just didn't see a need to go for a separate library. As the software keeps evolving I think it makes sense. We have 15 million records. | 0 | 1 | 0 | 0 | 2010-08-20T16:54:00.000 | 1 | 1.2 | true | 3,533,064 | 0 | 0 | 0 | 1 | I've been diving into MongoDB with kind help of MongoKit and MongoEngine, but then I started thinking whether the data mappers are necessary here. Both mappers I mentioned enable one to do simple things without any effort. But is any effort required to do simple CRUD? It appears to me that in case of NoSQL the mappers just substitute one api with another (but of course there is data validation, more strict schema, automatic referencing/dereferencing)
Do you use Data Mappers in your applications? How big are they (apps)? Why yes, why no?
Thanks |
Performance differences between Python and C | 3,533,838 | 7 | 13 | 14,463 | 0 | python,c,performance | Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
Yes.
The noticeable differences are these
There's much less Python code.
The Python code is much easier to read.
Python supports really nice unit testing, so the Python code tends to be higher quality.
You can write the Python code more quickly, since there are fewer quirky language features. No preprocessor, for example, really saves a lot of hacking around. Super-experience C programmers hardly notice it. But all that #include sandwich stuff and making the .h files correct is remarkably time-consuming.
Python can be easier to package and deploy, since you don't need a big fancy make script to do a build. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | 1 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Performance differences between Python and C | 15,903,255 | 0 | 13 | 14,463 | 0 | python,c,performance | C is definitely faster than Python because Python is written in C.
C is middle level language and hence faster but there not much a great difference between C & Python regarding executable time it takes.
but it is really very easy to write code in Python than C and it take much shorter time to write code and learn Python than C.
Because its easy to write its easy to test also. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | 0 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Performance differences between Python and C | 3,539,538 | -1 | 13 | 14,463 | 0 | python,c,performance | The excess time to write the code in C compared to Python will be exponentially greater than the difference between C and Python execution speed. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | -0.014285 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Performance differences between Python and C | 3,536,830 | -1 | 13 | 14,463 | 0 | python,c,performance | You will find C is much slower. Your developers will have to keep track of memory allocation, and use libraries (such as glib) to handle simple things such as dictionaries, or lists, which python has built-in.
Moreover, when an error occurs, your C program will typically just crash, which means you'll need to get the error to happen in a debugger. Python would give you a stack trace (typically).
Your code will be bigger, which means it will contain more bugs. So not only will it take longer to write, it will take longer to debug, and will ship with more bugs. This means that customers will notice the bugs more often.
So your developers will spend longer fixing old bugs and thus new features will get done more slowly.
In the mean-time, your competitors will be using a sensible programming language and their products will be increasing in features and usability, rapidly yours will look bad. Your customers will leave and you'll go out of business. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | -0.014285 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Performance differences between Python and C | 3,534,845 | 0 | 13 | 14,463 | 0 | python,c,performance | Across all programs, it isn't really possible to say whether things will be quicker or slower on average in Python or C.
For the programs that I've implemented in both languages, using similar algorithms, I've seen no improvement (and sometimes a performance degradation) for string- and IO-heavy code, when reimplementing python code in C. The execution time is dominated by allocation and manipulation of strings (which functionality python implements very efficiently) and waiting for IO operations (which incurs the same overhead in either language), so the extra overhead of python makes very little difference.
But for programs that do even simple operations on image files, say (images being large enough for processing time to be noticeable compared to IO), C is enormously quicker. For this sort of task the bulk of the time running the python code is spent doing Python Stuff, and this dwarfs the time spent on the underlying operations (multiply, add, compare, etc.). When reimplemented as C, the bureaucracy goes away, the computer spends its time doing real honest work, and for that reason the thing runs much quicker.
It's not uncommon for the python code to run in (say) 5 seconds where the C code runs in (say) 0.05. So that's a 100x increase -- but in absolute terms, this is not so big a deal. It takes so much less longer to write python code than it does to write C code that your program would have to be run some huge number of times to turn a time profit. I often reimplement in C, for various reasons, but if you don't have this requirement then it's probably not worth bothering. You won't get that part of your life back, and next year computers will be quicker. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | 0 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Performance differences between Python and C | 3,534,210 | 1 | 13 | 14,463 | 0 | python,c,performance | It really depends a lot on what your doing and if the algorithm in question is available in Python via a natively compiled library. If it is, then I believe you'll be looking at performance numbers close enough that Python is most likely your answer -- assuming it's your preferred language. If you must implement the algorithm yourself, depending on the amount of logic required and the size of your data set, C/C++ may be the better option. It's hard to provide a less nebulous answer without more information. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | 0.014285 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Performance differences between Python and C | 3,534,052 | 4 | 13 | 14,463 | 0 | python,c,performance | If your text files that you are sorting and parsing are large, use C. If they aren't, it doesn't matter. You can write poor code in any language though. I have seen simple code in C for calculating areas of triangles run 10x slower than other C code, because of poor memory management, use of structures, pointers, etc.
Your I/O algorithm should be independent of your compute algorithm. If this is the case, then using C for the compute algorithm can be much faster. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | 0.057081 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Performance differences between Python and C | 3,533,974 | 4 | 13 | 14,463 | 0 | python,c,performance | The first rule of computer performance questions: Your mileage will vary. If small performance differences are important to you, the only way you will get valid information is to test with your configuration, your data, and your benchmark. "Small" here is, say, a factor of two or so.
The second rule of computer performance questions: For most applications, performance doesn't matter -- the easiest way to write the app gives adequate performance, even when the problem scales. If that is the case (and it is usually the case) don't worry about performance.
That said:
C compiles down to machine executable and thus has the potential to execute as at least as fast as any other language
Python is generally interpreted and thus may take more CPU than a compiled language
Very few applications are "CPU bound." I/O (to disk, display, or memory) is not greatly affected by compiled vs interpreted considerations and frequently is a major part of computer time spent on an application
Python works at a higher level of abstraction than C, so your development and debugging time may be shorter
My advice: Develop in the language you find the easiest with which to work. Get your program working, then check for adequate performance. If, as usual, performance is adequate, you're done. If not, profile your specific app to find out what is taking longer than expected or tolerable. See if and how you can fix that part of the app, and repeat as necessary.
Yes, sometimes you might need to abandon work and start over to get the performance you need. But having a working (albeit slow) version of the app will be a big help in making progress. When you do reach and conquer that performance goal you'll be answering performance questions in SO rather than asking them. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | 0.057081 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Performance differences between Python and C | 3,533,800 | 10 | 13 | 14,463 | 0 | python,c,performance | In general IO bound work will depend more on the algorithm then the language. In this case I would go with Python because it will have first class strings and lots of easy to use libraries for manipulating files, etc. | 0 | 1 | 0 | 1 | 2010-08-20T18:27:00.000 | 14 | 1 | false | 3,533,759 | 1 | 0 | 0 | 11 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.