Q_Id int64 337 49.3M | CreationDate stringlengths 23 23 | Users Score int64 -42 1.15k | Other int64 0 1 | Python Basics and Environment int64 0 1 | System Administration and DevOps int64 0 1 | Tags stringlengths 6 105 | A_Id int64 518 72.5M | AnswerCount int64 1 64 | is_accepted bool 2
classes | Web Development int64 0 1 | GUI and Desktop Applications int64 0 1 | Answer stringlengths 6 11.6k | Available Count int64 1 31 | Q_Score int64 0 6.79k | Data Science and Machine Learning int64 0 1 | Question stringlengths 15 29k | Title stringlengths 11 150 | Score float64 -1 1.2 | Database and SQL int64 0 1 | Networking and APIs int64 0 1 | ViewCount int64 8 6.81M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
517,970 | 2009-02-05T21:19:00.000 | 1 | 0 | 1 | 1 | python,windows,console | 29,520,444 | 30 | false | 0 | 0 | I am using Spyder (Python 2.7) and to clean the interpreter console I use either
%clear
that forces the command line to go to the top and I will not see the previous old commands.
or I click "option" on the Console environment and select "Restart kernel" that removes everything. | 7 | 437 | 0 | Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.
Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several... | How to clear the interpreter console? | 0.006667 | 0 | 0 | 824,944 |
517,970 | 2009-02-05T21:19:00.000 | 1 | 0 | 1 | 1 | python,windows,console | 18,846,817 | 30 | false | 0 | 0 | I found the simplest way is just to close the window and run a module/script to reopen the shell. | 7 | 437 | 0 | Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc.
Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several... | How to clear the interpreter console? | 0.006667 | 0 | 0 | 824,944 |
518,162 | 2009-02-05T22:01:00.000 | 6 | 0 | 0 | 0 | python,django,django-models,many-to-many | 518,290 | 3 | false | 1 | 0 | I would add a field which indicates whether the objects are "draft" or "live". That way they are persisted across requests, sessions, etc. and django stops complaining.
You can then filter your objects to only show "live" objects in public views and only show "draft" objects to the user that created them. This can als... | 1 | 8 | 0 | I have a couple of models in django which are connected many-to-many. I want to create instances of these models in memory, present them to the user (via custom method-calls inside the view-templates) and if the user is satisfied, save them to the database.
However, if I try to do anything on the model-instances (call ... | How to work with unsaved many-to-many relations in django? | 1 | 0 | 0 | 4,822 |
519,296 | 2009-02-06T06:15:00.000 | 3 | 0 | 0 | 0 | python,postgresql,psycopg2 | 15,046,529 | 3 | false | 0 | 0 | Make sure your db connection command isn't in any kind of loop. I was getting the same error from my script until I moved my db.database() out of my programs repeating execution loop. | 3 | 22 | 0 | I am getting the error OperationalError: FATAL: sorry, too many clients already when using psycopg2. I am calling the close method on my connection instance after I am done with it. I am not sure what could be causing this, it is my first experience with python and postgresql, but I have a few years experience with php... | Getting OperationalError: FATAL: sorry, too many clients already using psycopg2 | 0.197375 | 1 | 0 | 27,905 |
519,296 | 2009-02-06T06:15:00.000 | 15 | 0 | 0 | 0 | python,postgresql,psycopg2 | 519,304 | 3 | true | 0 | 0 | This error means what it says, there are too many clients connected to postgreSQL.
Questions you should ask yourself:
Are you the only one connected to this database?
Are you running a graphical IDE?
What method are you using to connect?
Are you testing queries at the same time that you running the code?
Any of these... | 3 | 22 | 0 | I am getting the error OperationalError: FATAL: sorry, too many clients already when using psycopg2. I am calling the close method on my connection instance after I am done with it. I am not sure what could be causing this, it is my first experience with python and postgresql, but I have a few years experience with php... | Getting OperationalError: FATAL: sorry, too many clients already using psycopg2 | 1.2 | 1 | 0 | 27,905 |
519,296 | 2009-02-06T06:15:00.000 | 1 | 0 | 0 | 0 | python,postgresql,psycopg2 | 64,746,356 | 3 | false | 0 | 0 | It simple means many clients are making transaction to PostgreSQL at same time.
I was running Postgis container and Django in different docker container. Hence for my case restarting both db and system container solved the problem. | 3 | 22 | 0 | I am getting the error OperationalError: FATAL: sorry, too many clients already when using psycopg2. I am calling the close method on my connection instance after I am done with it. I am not sure what could be causing this, it is my first experience with python and postgresql, but I have a few years experience with php... | Getting OperationalError: FATAL: sorry, too many clients already using psycopg2 | 0.066568 | 1 | 0 | 27,905 |
520,210 | 2009-02-06T13:08:00.000 | 1 | 1 | 1 | 0 | python | 520,369 | 8 | false | 0 | 0 | It's juste one example but I know it is widely used in large scientific institutions with high tech machinery where non-programmers (typically physicists) need quick prototypes or tools to cover their data collection/processing needs. The easy-to access scripting language aspect clearly plays its role here. So I don't ... | 2 | 8 | 0 | I have downloaded the Pyscripter and learning Python. But I have no Idea if it has any job value , especially in India. I am learning Python as a Hobby. But it would be comforting to know if Python programmers are in demand in India. | Where is Python used? I read about it a lot on Reddit | 0.024995 | 0 | 0 | 5,951 |
520,210 | 2009-02-06T13:08:00.000 | 1 | 1 | 1 | 0 | python | 520,257 | 8 | false | 0 | 0 | In 10 years of web development I've had 1 client have me write an email parsing app with it. Not that it doesn't get used, but I've seen Ruby/php/.net way more often in the wild.
Edit:
From the other posts if you plan on working at Google, it sounds like the language to learn - LOL! | 2 | 8 | 0 | I have downloaded the Pyscripter and learning Python. But I have no Idea if it has any job value , especially in India. I am learning Python as a Hobby. But it would be comforting to know if Python programmers are in demand in India. | Where is Python used? I read about it a lot on Reddit | 0.024995 | 0 | 0 | 5,951 |
520,362 | 2009-02-06T13:55:00.000 | 1 | 0 | 0 | 0 | python | 520,423 | 4 | false | 0 | 0 | You cannot get a directory listing on a website.
Pedantically, HTTP has no notion of directory.
Pratically, WebDAV provides a directory listing verb, so you can use that if WebDAV is enabled.
Otherwise, the closest thing you can do is similar to what recursive wget does: get a page, parse the HTML, look for hyperlinks ... | 3 | 0 | 0 | Hi im coding to code a Tool that searchs for Dirs and files.
have done so the tool searchs for dirs, but need help to make it search for files on websites.
Any idea how it can be in python? | Search Files& Dirs on Website | 0.049958 | 0 | 1 | 188 |
520,362 | 2009-02-06T13:55:00.000 | 1 | 0 | 0 | 0 | python | 520,397 | 4 | false | 0 | 0 | You can only do this if you have permission to browse directories on the site and no default page exists. | 3 | 0 | 0 | Hi im coding to code a Tool that searchs for Dirs and files.
have done so the tool searchs for dirs, but need help to make it search for files on websites.
Any idea how it can be in python? | Search Files& Dirs on Website | 0.049958 | 0 | 1 | 188 |
520,362 | 2009-02-06T13:55:00.000 | 1 | 0 | 0 | 0 | python | 520,373 | 4 | false | 0 | 0 | Is this tool scanning the directories of your own website (in which the tool is running), or external sites? | 3 | 0 | 0 | Hi im coding to code a Tool that searchs for Dirs and files.
have done so the tool searchs for dirs, but need help to make it search for files on websites.
Any idea how it can be in python? | Search Files& Dirs on Website | 0.049958 | 0 | 1 | 188 |
521,476 | 2009-02-06T18:13:00.000 | -2 | 0 | 1 | 0 | python,camelcasing | 64,492,274 | 4 | false | 0 | 0 | In python only the 3 keywords True ,False and None are started with capital letters. I think This is to differentiate these 3 keywords from others. These 3 keywords can be used as literals or values where as other keywords not.
For example
a=True is correct
but
a=for is wrong | 1 | 82 | 0 | All members are camel case, right? Why True/False but not true/false, which is more relaxed? | Why True/False is capitalized in Python? | -0.099668 | 0 | 0 | 29,153 |
521,532 | 2009-02-06T18:25:00.000 | 16 | 0 | 1 | 0 | python,pretty-print,pprint | 521,546 | 5 | false | 0 | 0 | Are you looking for pprint.pformat? | 1 | 232 | 0 | In other words, what's the sprintf equivalent to pprint? | How do I get python's pprint to return a string instead of printing? | 1 | 0 | 0 | 80,792 |
522,781 | 2009-02-07T00:27:00.000 | 0 | 1 | 0 | 0 | python,yahoo-api,yahoo-search | 526,491 | 3 | true | 0 | 0 | Thank you.
I found myself that something like this works OK (file type is the first argument, and query is the second):
format = sys.argv[1]
query = " ".join(sys.argv[2:])
srch = create_search("Web", app_id, query=query, format=format) | 1 | 1 | 0 | Does anyone know if there is some parameter available for programmatic search on yahoo allowing to restrict results so only links to files of specific type will be returned (like PDF for example)?
It's possible to do that in GUI, but how to make it happen through API?
I'd very much appreciate a sample code in Python, b... | how to search for specific file type with yahoo search API? | 1.2 | 0 | 1 | 1,551 |
524,068 | 2009-02-07T16:30:00.000 | 3 | 0 | 0 | 1 | python,linux,bash,shell,command | 524,104 | 4 | false | 0 | 0 | You can do this, but only if the shell runs as a subprocess of your Python program; you can't feed content into the stdin of your parent process. (If you could, UNIX would have a host of related security issues when folks run processes with fewer privileges than the calling shell!)
If you're familiar with how Expect al... | 1 | 1 | 0 | Is there any way to inject a command into a bash prompt in Linux? I am working on a command history app - like the Ctrl+R lookup but different. I am using python for this.
I will show a list of commands from history based on the user's search term - if the user presses enter, the app will execute the command and print ... | Insert Command into Bash Shell | 0.148885 | 0 | 0 | 2,348 |
524,214 | 2009-02-07T17:54:00.000 | 2 | 0 | 0 | 0 | python,django,django-models | 524,414 | 4 | false | 1 | 0 | I've used cron to update my DB using both a script and a view. From cron's point of view it doesn't really matter which one you choose. As you've noted, though, it's hard to beat the simplicity of firing up a browser and hitting a URL if you ever want to update at a non-scheduled interval.
If you go the view route, i... | 1 | 8 | 0 | What is the best idea to fill up data into a Django model from an external source?
E.g. I have a model Run, and runs data in an XML file, which changes weekly.
Should I create a view and call that view URL from a curl cronjob (with the advantage that that data can be read anytime, not only when the cronjob runs), or cr... | How to externally populate a Django model? | 0.099668 | 0 | 0 | 7,525 |
524,734 | 2009-02-07T22:39:00.000 | -1 | 0 | 1 | 0 | python,types | 524,739 | 2 | false | 0 | 0 | Use the built-in "type" function, e.g. type(10) -> . | 1 | 1 | 0 | How can i find out if the obj returned by a func is a int or something else (like a sqlite cursor) | python, how to tell what type of obj was returned | -0.099668 | 0 | 0 | 386 |
524,797 | 2009-02-07T23:18:00.000 | 0 | 0 | 0 | 0 | python,multithreading,sqlite | 524,955 | 6 | false | 0 | 0 | Depending on the data rate sqlite could be exactly the correct way to do this. The entire database is locked for each write so you aren't going to scale to 1000s of simultaneous writes per second. But if you only have a few it is the safest way of assuring you don't overwrite each other. | 4 | 9 | 0 | I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas... | Python, SQLite and threading | 0 | 1 | 0 | 13,542 |
524,797 | 2009-02-07T23:18:00.000 | 0 | 0 | 0 | 0 | python,multithreading,sqlite | 524,937 | 6 | false | 0 | 0 | Depending on the application the DB could be a real overhead. If we are talking about volatile data, maybe you could skip the communication via DB completely and share the data between the data gathering process and the data serving process(es) via IPC. This is not an option if the data has to be persisted, of course... | 4 | 9 | 0 | I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas... | Python, SQLite and threading | 0 | 1 | 0 | 13,542 |
524,797 | 2009-02-07T23:18:00.000 | 8 | 0 | 0 | 0 | python,multithreading,sqlite | 524,806 | 6 | true | 0 | 0 | Short answer: Don't use Sqlite3 in a threaded application.
Sqlite3 databases scale well for size, but rather terribly for concurrency. You will be plagued with "Database is locked" errors.
If you do, you will need a connection per thread, and you have to ensure that these connections clean up after themselves. This is ... | 4 | 9 | 0 | I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas... | Python, SQLite and threading | 1.2 | 1 | 0 | 13,542 |
524,797 | 2009-02-07T23:18:00.000 | 1 | 0 | 0 | 0 | python,multithreading,sqlite | 524,901 | 6 | false | 0 | 0 | "...create several threads that will gather data at a specified interval and cache that data locally into a sqlite database.
Then in the main thread start a CherryPy app that will query that sqlite db and serve the data."
Don't waste a lot of time on threads. The things you're describing are simply OS processes. Just... | 4 | 9 | 0 | I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP.
So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas... | Python, SQLite and threading | 0.033321 | 1 | 0 | 13,542 |
525,080 | 2009-02-08T03:14:00.000 | 9 | 0 | 1 | 0 | python | 525,099 | 4 | true | 0 | 0 | "I don't find the error at compile but at run time"
Correct. True for all non-compiled interpreted languages.
"I need to change and run the script again"
Also correct. True for all non-compiled interpreted languages.
"Is there a way to have it break and let me modify and run?"
What?
If it's a run-time error, the scri... | 3 | 0 | 0 | Python is pretty clean, and I can code neat apps quickly.
But I notice I have some minor error someplace and I dont find the error at compile but at run time. Then I need to change and run the script again. Is there a way to have it break and let me modify and run?
Also, I dislike how python has no enums. If I were to ... | python coding speed and cleanest | 1.2 | 0 | 0 | 485 |
525,080 | 2009-02-08T03:14:00.000 | 2 | 0 | 1 | 0 | python | 525,106 | 4 | false | 0 | 0 | Python is an interpreted language, there is no compile stage, at least not that is visible to the user. If you get an error, go back, modify the script, and try again. If your script has long execution time, and you don't want to stop-restart, you can try a debugger like pdb, using which you can fix some of your errors... | 3 | 0 | 0 | Python is pretty clean, and I can code neat apps quickly.
But I notice I have some minor error someplace and I dont find the error at compile but at run time. Then I need to change and run the script again. Is there a way to have it break and let me modify and run?
Also, I dislike how python has no enums. If I were to ... | python coding speed and cleanest | 0.099668 | 0 | 0 | 485 |
525,080 | 2009-02-08T03:14:00.000 | 3 | 0 | 1 | 0 | python | 525,135 | 4 | false | 0 | 0 | With interpreted languages you have a lot of freedom. Freedom isn't free here either. While the interpreter won't torture you into dotting every i and crossing every T before it deems your code worthy of a run, it also won't try to statically analyze your code for all those problems. So you have a few choices.
1) {P... | 3 | 0 | 0 | Python is pretty clean, and I can code neat apps quickly.
But I notice I have some minor error someplace and I dont find the error at compile but at run time. Then I need to change and run the script again. Is there a way to have it break and let me modify and run?
Also, I dislike how python has no enums. If I were to ... | python coding speed and cleanest | 0.148885 | 0 | 0 | 485 |
525,244 | 2009-02-08T06:08:00.000 | 0 | 0 | 0 | 0 | python,pycurl | 9,639,360 | 3 | false | 0 | 0 | We are planning to release new version of pycURL in a month or two. The new version would have all features of libcurl installed on your machine. -:) | 1 | 2 | 0 | curl_unescape doesnt seem to be in pycurl, what do i use instead? | pycurl and unescape | 0 | 0 | 0 | 286 |
525,592 | 2009-02-08T11:57:00.000 | 1 | 1 | 0 | 1 | bash,replace,scripting,ironpython | 70,116,740 | 17 | false | 0 | 0 | For MAC users in case you don't read the comments :)
As mentioned by @Austin, if you get the Invalid command code error
For the in-place replacements BSD sed requires a file extension after the -i flag to save to a backup file with given extension.
sed -i '.bak' 's/find/replace' /file.txt
You can use '' empty string if... | 2 | 687 | 0 | What's the simplest way to do a find and replace for a given input string, say abc, and replace with another string, say XYZ in file /tmp/file.txt?
I am writting an app and using IronPython to execute commands through SSH — but I don't know Unix that well and don't know what to look for.
I have heard that Bash, apart f... | Find and Replace Inside a Text File from a Bash Command | 0.011764 | 0 | 0 | 811,095 |
525,592 | 2009-02-08T11:57:00.000 | 2 | 1 | 0 | 1 | bash,replace,scripting,ironpython | 68,204,228 | 17 | false | 0 | 0 | Simplest way to replace multiple text in a file using sed command
Command -
sed -i 's#a/b/c#D/E#g;s#/x/y/z#D:/X#g;' filename
In the above command s#a/b/c#D/E#g where I am replacing a/b/c with D/E and then after the ; we again doing the same thing | 2 | 687 | 0 | What's the simplest way to do a find and replace for a given input string, say abc, and replace with another string, say XYZ in file /tmp/file.txt?
I am writting an app and using IronPython to execute commands through SSH — but I don't know Unix that well and don't know what to look for.
I have heard that Bash, apart f... | Find and Replace Inside a Text File from a Bash Command | 0.023525 | 0 | 0 | 811,095 |
525,773 | 2009-02-08T14:09:00.000 | 1 | 0 | 0 | 0 | python,cookies | 525,982 | 6 | false | 0 | 0 | There's the cookielib library. You can also implement your own cookie storage and policies, the cookies are found in the set-cookie header of the response (Set-Cookie: name=value), then you send the back to a server in one or more Cookie headers in the request (Cookie: name=value). | 2 | 11 | 0 | How can I accept cookies in a python script? | Accept Cookies in Python | 0.033321 | 0 | 1 | 12,543 |
525,773 | 2009-02-08T14:09:00.000 | 1 | 0 | 0 | 0 | python,cookies | 525,966 | 6 | false | 0 | 0 | I believe you mean having a Python script that tries to speak HTTP.
I suggest you to use a high-level library that handles cookies automatically.
pycurl, mechanize, twill - you choose.
For Nikhil Chelliah:
I don't see what's not clear here.
Accepting a cookie happens client-side. The server can set a cookie. | 2 | 11 | 0 | How can I accept cookies in a python script? | Accept Cookies in Python | 0.033321 | 0 | 1 | 12,543 |
525,807 | 2009-02-08T14:30:00.000 | -1 | 0 | 1 | 1 | windows,performance,python-idle | 525,925 | 3 | false | 0 | 0 | If you "system idle process" is taking up 100% then essentially you machine is bored, nothing is going on. If you add up everything going on in task manager, subtract this number from 100%, then you will have the value of "system idle process." Notice it consumes almost no memory at all and cannot be affecting perfor... | 1 | 1 | 0 | I am doing some performance measurement of my code on a Windows box and I am finding that I am getting dramatically different results between measurements. A quick bit of ad hoc exploration during a slow one shows in the task manager System Idle Processes taking up almost 100% CPU.
Does anyone know what System Idle Pr... | Windows System Idle Processes interfering with performance measurement | -0.066568 | 0 | 0 | 4,707 |
527,314 | 2009-02-09T07:05:00.000 | 1 | 0 | 0 | 0 | python,user-interface,maya,panels,mel | 551,109 | 4 | true | 0 | 1 | Have you tried searching ui item names in MEL files under maya installation directory? It should be one of the MEL scripts included, and from there you can just modify it. | 1 | 1 | 0 | I've been writing tools in Maya for years using MEL and Python. I'd consider myself an expert in custom window/gui design in Maya except for one area; modifying existing panels and editors.
Typically, I'm building tools that need totally custom UIs, so its customary for me to build them from scratch. However, recentl... | How to modify existing panels in Maya using MEL or Python? | 1.2 | 0 | 0 | 5,048 |
527,510 | 2009-02-09T09:20:00.000 | 8 | 0 | 1 | 1 | python,deployment,layout,bootstrapping | 528,064 | 5 | true | 0 | 0 | I sometimes use the approach I describe below, for the exact same reason that @Boris states: I would prefer that the use of some code is as easy as a) svn checkout/update - b) go.
But for the record:
I use virtualenv/easy_install most of the time.
I agree to a certain extent to the critisisms by @Ali A and @S.Lott
An... | 4 | 13 | 0 | Background: I have a small Python application that makes life for developers releasing software in our company a bit easier. I build an executable for Windows using py2exe. The application as well as the binary are checked into Subversion. Distribution happens by people just checking out the directory from SVN. The pro... | How to deploy a Python application with libraries as source with no further dependencies? | 1.2 | 0 | 0 | 7,725 |
527,510 | 2009-02-09T09:20:00.000 | 0 | 0 | 1 | 1 | python,deployment,layout,bootstrapping | 527,934 | 5 | false | 0 | 0 | I agree with the answers by Nosklo and S.Lott. (+1 to both)
Can I just add that what you want to do is actually a terrible idea.
If you genuinely want people to hack on your code, they will need some understanding of the libraries involved, how they work, what they are, where they come from, the documentation for each ... | 4 | 13 | 0 | Background: I have a small Python application that makes life for developers releasing software in our company a bit easier. I build an executable for Windows using py2exe. The application as well as the binary are checked into Subversion. Distribution happens by people just checking out the directory from SVN. The pro... | How to deploy a Python application with libraries as source with no further dependencies? | 0 | 0 | 0 | 7,725 |
527,510 | 2009-02-09T09:20:00.000 | 8 | 0 | 1 | 1 | python,deployment,layout,bootstrapping | 527,872 | 5 | false | 0 | 0 | "I dislike the fact that developers (or me starting on a clean new machine) have to jump through the distutils hoops of having to install the libraries locally before they can get started"
Why?
What -- specifically -- is wrong with this?
You did it to create the project. Your project is so popular others want to do th... | 4 | 13 | 0 | Background: I have a small Python application that makes life for developers releasing software in our company a bit easier. I build an executable for Windows using py2exe. The application as well as the binary are checked into Subversion. Distribution happens by people just checking out the directory from SVN. The pro... | How to deploy a Python application with libraries as source with no further dependencies? | 1 | 0 | 0 | 7,725 |
527,510 | 2009-02-09T09:20:00.000 | 0 | 0 | 1 | 1 | python,deployment,layout,bootstrapping | 530,727 | 5 | false | 0 | 0 | I'm not suggesting that this is a great idea, but usually what I do in situations like these is that I have a Makefile, checked into subversion, which contains make rules to fetch all the dependent libraries and install them. The makefile can be smart enough to only apply the dependent libraries if they aren't present... | 4 | 13 | 0 | Background: I have a small Python application that makes life for developers releasing software in our company a bit easier. I build an executable for Windows using py2exe. The application as well as the binary are checked into Subversion. Distribution happens by people just checking out the directory from SVN. The pro... | How to deploy a Python application with libraries as source with no further dependencies? | 0 | 0 | 0 | 7,725 |
528,817 | 2009-02-09T16:21:00.000 | 7 | 1 | 0 | 0 | python,.net,excel,com | 528,833 | 5 | true | 0 | 0 | There is no way that completely bypasses COM. You can use VSTO (Visual Studio Tools for Office), which has nice .NET wrappers on the COM objects, but it is still COM underneath. | 1 | 1 | 0 | I'm working on a regression-testing tool that will validate a very large number of Excel spreadsheets. At the moment I control them via COM from a Python script using the latest version of the pywin32 product. Unfortunately COM seems to have a number of annoying drawbacks:
For example, the slightest upset seems to be a... | Is there a better way (besides COM) to remote-control Excel? | 1.2 | 0 | 0 | 5,983 |
529,034 | 2009-02-09T17:15:00.000 | 6 | 0 | 1 | 0 | python | 529,048 | 7 | false | 0 | 0 | I've always seen/heard that using sleep is the better way to do it. Using sleep will keep your Python interpreter's CPU usage from going wild. | 1 | 58 | 0 | I am writing an queue processing application which uses threads for waiting on and responding to queue messages to be delivered to the app. For the main part of the application, it just needs to stay active. For a code example like:
while True:
pass
or
while True:
time.sleep(1)
Which one will have the least i... | Python: Pass or Sleep for long running processes? | 1 | 0 | 0 | 49,015 |
529,424 | 2009-02-09T19:04:00.000 | 0 | 0 | 1 | 0 | python,loops,reverse | 72,380,349 | 28 | false | 0 | 0 | As a beginner in python, I found this way more easy to understand and reverses a list.
say numlst = [1, 2, 3, 4]
for i in range(len(numlst)-1,-1,-1):
print( numlst[ i ] )
o/p = 4, 3, 2, 1 | 1 | 941 | 0 | So I can start from collection[len(collection)-1] and end in collection[0].
I also want to be able to access the loop index. | Traverse a list in reverse order in Python | 0 | 0 | 0 | 1,036,458 |
530,127 | 2009-02-09T21:41:00.000 | 0 | 1 | 1 | 0 | python,optimization,profiling,performance | 1,267,504 | 3 | false | 0 | 0 | you want to look for cpu used, not for "total time used" from within that method--that might help. Sorry I don't use python but that's how it is for me in ruby :)
-r | 2 | 7 | 0 | I'm writing a Python program with a lot of file access. It's running surprisingly slowly, so I used cProfile to find out what was taking the time.
It seems there's a lot of time spent in what Python is reporting as "{built-in method acquire}". I have no idea what this method is. What is it, and how can I speed up my... | What is Python's "built-in method acquire"? How can I speed it up? | 0 | 0 | 0 | 2,567 |
530,127 | 2009-02-09T21:41:00.000 | 0 | 1 | 1 | 0 | python,optimization,profiling,performance | 530,233 | 3 | false | 0 | 0 | Using threads for IO is a bad idea. Threading won't make your program wait faster. You can achieve better results by using asynchronous I/O and an event loop; Post more information about your program, and why you are using threads. | 2 | 7 | 0 | I'm writing a Python program with a lot of file access. It's running surprisingly slowly, so I used cProfile to find out what was taking the time.
It seems there's a lot of time spent in what Python is reporting as "{built-in method acquire}". I have no idea what this method is. What is it, and how can I speed up my... | What is Python's "built-in method acquire"? How can I speed it up? | 0 | 0 | 0 | 2,567 |
531,377 | 2009-02-10T07:39:00.000 | 3 | 0 | 1 | 0 | python,flash | 531,401 | 4 | false | 0 | 0 | I don't know of any Python-specific solutions but there are multiple tools to handle this:
You can create a flash file with dummy pictures which you then replace using mtasc, swfmill, SWF Tools or similar. This way means lots of trouble but allows you to create a dynamic flash file.
If you don't need dynamic content, t... | 1 | 1 | 0 | I'm having a set of Python scripts that process the photos. What I would like is to be able to create some kind of flash-presentation out of those images.
Is there any package or 'framework' that would help to do this? | What's a way to create flash animations with Python? | 0.148885 | 0 | 0 | 1,953 |
531,711 | 2009-02-10T09:50:00.000 | 0 | 0 | 0 | 0 | python,sqlite,locking | 6,345,495 | 4 | false | 0 | 0 | I've also seen this error when the db file is on an NFS mounted file system. | 1 | 3 | 0 | I get "database table is locked" error in my sqlite3 db. My script is single threaded, no other app is using the program (i did have it open once in "SQLite Database Browser.exe"). I copied the file, del the original (success) and renamed the copy so i know no process is locking it yet when i run my script everything i... | python, sqlite error? db is locked? but it isnt? | 0 | 1 | 0 | 5,791 |
532,934 | 2009-02-10T16:03:00.000 | 0 | 0 | 1 | 0 | python,serialization,pickle | 532,989 | 7 | false | 0 | 0 | "the byte overhead is significant"
Why does this matter? It does the job. If you're running low on disk space, I'd be glad to sell you a 1Tb for $500.
Have you run it? Is performance a problem? Can you demonstrate that the performance of serialization is the problem?
"I thought of just using repr() and eval(), bu... | 1 | 7 | 0 | All I want to do is serialize and unserialize tuples of strings or ints.
I looked at pickle.dumps() but the byte overhead is significant. Basically it looks like it takes up about 4x as much space as it needs to. Besides, all I need is basic types and have no need to serialize objects.
marshal is a little better in ter... | Lightweight pickle for basic types in python? | 0 | 1 | 0 | 2,674 |
534,375 | 2009-02-10T21:51:00.000 | 4 | 0 | 1 | 0 | python,pass-by-reference,pass-by-value | 534,382 | 8 | false | 0 | 0 | The object is passed. Not a copy, but a reference to the underlying object. | 2 | 79 | 0 | When you pass a collection like list, array to another function in python, does it make a copy of it, or is it just a pointer? | Passing values in Python | 0.099668 | 0 | 0 | 89,634 |
534,375 | 2009-02-10T21:51:00.000 | 8 | 0 | 1 | 0 | python,pass-by-reference,pass-by-value | 534,386 | 8 | false | 0 | 0 | A reference is passed, but if the parameter is an immutable object, modifying it within the method will create a new instance. | 2 | 79 | 0 | When you pass a collection like list, array to another function in python, does it make a copy of it, or is it just a pointer? | Passing values in Python | 1 | 0 | 0 | 89,634 |
536,051 | 2009-02-11T09:19:00.000 | 1 | 0 | 0 | 0 | python,mysql,sqlalchemy | 536,269 | 2 | false | 0 | 0 | Exactly what problems are you running into?
You can simply iterate over the ResultProxy object:
for row in conn_or_sess_or_engine.execute(selectable_obj_or_SQLstring):
do_something_with(row) | 1 | 0 | 0 | I want to fetch data from a mysql database using sqlalchemy and use the data in a different class.. Basically I fetch a row at a time, use the data, fetch another row, use the data and so on.. I am running into some problem doing this..
Basically, how do I output data a row at a time from mysql data?.. I have looked i... | Outputting data a row at a time from mysql using sqlalchemy | 0.099668 | 1 | 0 | 563 |
537,086 | 2009-02-11T14:41:00.000 | 2 | 0 | 1 | 0 | python,performance,arrays,memory-management,list | 537,288 | 7 | false | 0 | 0 | In Python, all objects are allocated on the heap.
But Python uses a special memory allocator so malloc won't be called every time you need a new object.
There are also some optimizations for small integers (and the like) which are cached; however, which types, and how, is implementation dependent. | 1 | 61 | 0 | When programming in Python, is it possible to reserve memory for a list that will be populated with a known number of items, so that the list will not be reallocated several times while building it? I've looked through the docs for a Python list type, and have not found anything that seems to do this. However, this t... | Reserve memory for list in Python? | 0.057081 | 0 | 0 | 43,592 |
537,399 | 2009-02-11T15:46:00.000 | 1 | 0 | 1 | 0 | python,webserver,environment,wsgi | 537,504 | 3 | false | 1 | 0 | I'd recommend Nginx for the web server. Fast and easy to set up.
You'd probably want to have one unix user per vhost - so every home directory holds its own application, python environment and server configuration. This allows you to restart a particular app safely, simply by killing worker processes that your vhost o... | 1 | 1 | 0 | I've been told wsgi is the way to go and not mod_python. But more specifically, how would you set up your multi website server environment? Choice of web server, etc? | How would you set up a python web server with multiple vhosts? | 0.066568 | 0 | 0 | 1,401 |
537,522 | 2009-02-11T16:11:00.000 | 6 | 0 | 1 | 0 | python,vi | 29,808,730 | 4 | false | 0 | 0 | For Mac OS X 10.10.3, python2.7, vi mode can be configured by placing bind -v in ~/.editrc. The last few paragraphs of the man page hint at this. | 1 | 32 | 0 | I was working a bit in the python interpreter (python 2.4 on RHEL 5.3), and suddenly found myself in what seems to be a 'vi command mode'. That is, I can edit previous commands with typical vi key bindings, going left with h, deleting with x...
I love it - the only thing is, I don't know how I got here (perhaps it's th... | Standard python interpreter has a vi command mode? | 1 | 0 | 0 | 10,401 |
537,542 | 2009-02-11T16:17:00.000 | 3 | 0 | 1 | 0 | python,hash | 537,597 | 3 | false | 0 | 0 | I don't know Python but I am familiar w/ hash calculations.
If you handle the reading of files manually, just read in one block (of 256 bytes or 4096 bytes or whatever) at a time, and pass each block of data to update the hash of each algorithm. (you'll have to initialize state at the beginning and finalize the state a... | 1 | 6 | 0 | How can I get a MD5, SHA and other hashes from a file but only doing one pass? I have 100mb files, so I'd hate to process those 100MB files multiple times. | How can I create multiple hashes of a file using only one pass? | 0.197375 | 0 | 0 | 1,081 |
537,774 | 2009-02-11T16:58:00.000 | 1 | 0 | 0 | 0 | wxpython,wxwidgets,xrc | 598,169 | 1 | true | 0 | 1 | XRC doesn't have an include mechanism that I know of, but you can have custom widgets.
So implement your common panel as its own XRC, and set that up as something that you can reference by class name in other xrc files.
You would create an XmlResourceHandler that handles the custom Panel in the XRC, and instantiates yo... | 1 | 0 | 0 | I've got an wx App that has the UI defined in XRC files. Each form is in its own xrc file. There is one panel that is common to many of the forms. Is there a way to have objects defined in one file that are included and referenced in another?
I know there is a object_ref mechanism, but I can't see how that can referenc... | Is there to include elements from one xrc file in another xrc file | 1.2 | 0 | 0 | 260 |
542,289 | 2009-02-12T16:59:00.000 | 2 | 1 | 0 | 0 | python,build-process,build-automation | 3,838,805 | 5 | false | 1 | 0 | My Rapid Throughts:
SCons is quite mature and oriented also to other languages (es C++)
Waf is very simlar to ant/maven, so you will prefer it if you are used to ant/maven
Paver is very pythonic oriented, and seems a good option if you do not know how to start. | 1 | 16 | 0 | I switched from NAnt to using Python to write build automation scripts. I am curious if whether any build frameworks worth using that are similar to Make, Ant, and NAnt, but, instead, are Python-based. For example, Ruby has Rake. What about Python? | Are there any good build frameworks written in Python? | 0.07983 | 0 | 0 | 2,630 |
542,594 | 2009-02-12T18:10:00.000 | 7 | 0 | 0 | 0 | python,django,django-contrib | 542,685 | 3 | true | 1 | 0 | It all depends. We had a need for something that was 98% similar to contrib.flatpages. We could have monkeypatched it, but we decided that the code was so straightforward that we would just copy and fork it. It worked out fine.
Doing this with contrib.auth, on the other hand, might be a bad move given its interaction w... | 2 | 3 | 0 | The Django apps come with their own features and design. If your requirements don't match 100% with the features of the contib app, you end up customizing and tweaking the app. I feel this involves more effort than just building your own app to fit your requirements.
What do you think? | Should I use Django's contrib applications or build my own? | 1.2 | 0 | 0 | 297 |
542,594 | 2009-02-12T18:10:00.000 | 4 | 0 | 0 | 0 | python,django,django-contrib | 543,335 | 3 | false | 1 | 0 | Most of the apps in django.contrib are written very well and are highly extensible.
Don't like quite how comments works? Subclass the models and forms within it, adding your own functionality and you have a working comment system that fits your sites schema, with little effort.
I think the best part when you extend the... | 2 | 3 | 0 | The Django apps come with their own features and design. If your requirements don't match 100% with the features of the contib app, you end up customizing and tweaking the app. I feel this involves more effort than just building your own app to fit your requirements.
What do you think? | Should I use Django's contrib applications or build my own? | 0.26052 | 0 | 0 | 297 |
543,140 | 2009-02-12T20:41:00.000 | 2 | 0 | 1 | 0 | python,ruby,coding-style | 579,842 | 4 | false | 0 | 0 | I am not sure that I ever think about it like this.
Once you start "thinking in Ruby" the multi-paradigms just merge into ... well, Ruby.
Ruby is object-oriented, but I find that other things such as the functional aspect tend to mean that some of the "traditional" design patters present in OO languages are just simp... | 4 | 2 | 0 | When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool ... | Granularity of Paradigm Mixing | 0.099668 | 0 | 0 | 234 |
543,140 | 2009-02-12T20:41:00.000 | 2 | 0 | 1 | 0 | python,ruby,coding-style | 543,166 | 4 | false | 0 | 0 | Different paradigms mix in different ways. For example, Using OOP doesn't eliminate the use of subroutines and procedural code from an outside library. It merely moves the procedures around into a different place.
It is impossible to purely program with one paradigm. You may think you have a single one in mind when ... | 4 | 2 | 0 | When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool ... | Granularity of Paradigm Mixing | 0.099668 | 0 | 0 | 234 |
543,140 | 2009-02-12T20:41:00.000 | 0 | 0 | 1 | 0 | python,ruby,coding-style | 622,514 | 4 | false | 0 | 0 | Different problems require different solutions, but it helps if you solve things the same way in the same layer. And varying to wildly will just confuse you and everyone else in the project.
For C++, I've found that statically typed OOP (use zope.interface in Python) work well for higher-level parts (connecting, updati... | 4 | 2 | 0 | When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool ... | Granularity of Paradigm Mixing | 0 | 0 | 0 | 234 |
543,140 | 2009-02-12T20:41:00.000 | 1 | 0 | 1 | 0 | python,ruby,coding-style | 583,881 | 4 | false | 0 | 0 | Mixing paradigms has an advantage of letting you express solutions in most natural and esy way. Which is very good thing when it help keeping your program logic smaller. For example, filtering a list by some criteria is several times simpler to express with functional solution compared to traditional loop.
On the oth... | 4 | 2 | 0 | When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool ... | Granularity of Paradigm Mixing | 0.049958 | 0 | 0 | 234 |
543,199 | 2009-02-12T20:54:00.000 | 0 | 0 | 0 | 0 | python,ruby,perl | 543,218 | 5 | false | 0 | 0 | write one...
perl is my favourite scripting language... it appears you may prefer Python.
just read in the file and add \" before and after it..
this is pretty easy in perl.
this seems more like a request than a question... should this be on stackoverflow? | 1 | 2 | 0 | I need script to add quotes in url string from url.txt
from http://www.site.com/info.xx to "http://www.site.com/info.xx" | Add Quotes in url string from file | 0 | 0 | 1 | 8,426 |
543,466 | 2009-02-12T21:45:00.000 | 11 | 0 | 1 | 0 | python,eclipse | 545,880 | 2 | true | 0 | 0 | You can set the interpreter version on a per-script basis through the Run Configurations menu.
To do this go to Run -> Run Configurations, and then make a new entry under Python Run. Fill in your project name and the main script, and then go to the Interpeter tab and you can pick which interpreter you want to use for t... | 2 | 15 | 0 | So, I'm slowly working in some Python 3.0, but I still have a lot of things that rely on 2.5.
But, in Eclipse, every time I change projects between a 3.0 and a 2.5, I need to go through
Project -> Properties -> project type.
Issue 1: if I just switch the interpreter in the drop down box, that doesn't seem to change a... | Using different versions of python for different projects in Eclipse | 1.2 | 0 | 0 | 12,277 |
543,466 | 2009-02-12T21:45:00.000 | 1 | 0 | 1 | 0 | python,eclipse | 545,718 | 2 | false | 0 | 0 | OK --
It definitely seems like "interpreter" is a property of your "workspace". I hadn't really considered that too much because I always thought of the workspace as "a folder in which I keep whatever" instead of a consistent unified environment for one kind of development.
Also, you can't switch between workspaces in... | 2 | 15 | 0 | So, I'm slowly working in some Python 3.0, but I still have a lot of things that rely on 2.5.
But, in Eclipse, every time I change projects between a 3.0 and a 2.5, I need to go through
Project -> Properties -> project type.
Issue 1: if I just switch the interpreter in the drop down box, that doesn't seem to change a... | Using different versions of python for different projects in Eclipse | 0.099668 | 0 | 0 | 12,277 |
544,919 | 2009-02-13T06:30:00.000 | 1 | 0 | 1 | 0 | python,variables | 545,742 | 13 | false | 0 | 0 | On second thought:
Since Python does not provide native Enum types, you should not ask for one, but instead use other, more powerful construct to build your program. Otherwise, the next step will invariably be "Why does Python not have a switch ...: statement, and how do I best emulate it?"
Since Enums are often used t... | 3 | 61 | 0 | I have enum and use the variables like myEnum.SomeNameA, myEnum.SomeNameB, etc. When I return one of these variables from a function, can I print their names (such as myEnum.SomeNameA) instead of the value they returned? | How to print original variable's name in Python after it was returned from a function? | 0.015383 | 0 | 0 | 48,535 |
544,919 | 2009-02-13T06:30:00.000 | 0 | 0 | 1 | 0 | python,variables | 544,968 | 13 | false | 0 | 0 | Erlang has a concept called "atoms" -- they are similar to string constants or enumerations. Consider using a string constant as the value of your enum -- the same as the name of the enum. | 3 | 61 | 0 | I have enum and use the variables like myEnum.SomeNameA, myEnum.SomeNameB, etc. When I return one of these variables from a function, can I print their names (such as myEnum.SomeNameA) instead of the value they returned? | How to print original variable's name in Python after it was returned from a function? | 0 | 0 | 0 | 48,535 |
544,919 | 2009-02-13T06:30:00.000 | 0 | 0 | 1 | 0 | python,variables | 544,954 | 13 | false | 0 | 0 | As far as I know, that will require some introspection. You can try using the inspect module.
There are a few simple things you may want to try before that:
This is not the exact code that should be used. You will have to retrieve the variable name from __dict__ before printing.
print myEnum.__dict__
... | 3 | 61 | 0 | I have enum and use the variables like myEnum.SomeNameA, myEnum.SomeNameB, etc. When I return one of these variables from a function, can I print their names (such as myEnum.SomeNameA) instead of the value they returned? | How to print original variable's name in Python after it was returned from a function? | 0 | 0 | 0 | 48,535 |
544,923 | 2009-02-13T06:32:00.000 | 1 | 0 | 0 | 1 | python,winapi | 545,183 | 4 | false | 0 | 0 | That's not possible using plain PDF, as you have create new print job for any particular bin and tray combination (and not all printers allow you to do that, Xerox 4x and DP Series allows you to do such things).
My best bet would be juggling with PostScript: convert PDF to PostScript, where you have access to individua... | 1 | 5 | 0 | I know this question has been asked before, but there was no clear answer.
How do I change the printer tray programmatically?
I am trying to use python to batch print some PDFs. I need to print different pages from different trays. The printer is a Ricoh 2232C. Is there a way to do it through and Acrobat Reader co... | Switching Printer Trays | 0.049958 | 0 | 0 | 4,316 |
545,730 | 2009-02-13T12:20:00.000 | 0 | 0 | 0 | 1 | python,continuous-integration,installation,development-environment,automated-deploy | 545,839 | 7 | false | 1 | 0 | I do exactly this with a combination of setuptools and Hudson. I know Hudson is a java app, but it can run Python stuff just fine. | 1 | 9 | 0 | I used to be a java developer and we used tools like ant or maven to manage our development/testing/UAT environments in a standardized way. This allowed us to handle library dependencies, setting OS variables, compiling, deploying, running unit tests, and all the required tasks. Also, the scripts generated guaranteed t... | Tool (or combination of tools) for reproducible environments in Python | 0 | 0 | 0 | 1,538 |
546,321 | 2009-02-13T15:16:00.000 | -1 | 0 | 1 | 0 | python,datetime | 16,792,632 | 46 | false | 0 | 0 | We probably should use dateutil.relativedelta
however for academic interest I will just add that before I discovered it I was goint to use this:
try:
vexpDt = K.today.replace(K.today.year + (K.today.month+6)//12, (K.today.month+5)%12+1, K.today.day)
except:
vexpDt = K.today.replace(K.today.year + (K.today.month+6... | 3 | 527 | 0 | I am using the datetime Python module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this?
The reason I want to generate a date 6 months from the current date is to produce a review date. If the user enters data into the system it will have a review date ... | How do I calculate the date six months from the current date using the datetime Python module? | -0.004348 | 0 | 0 | 588,437 |
546,321 | 2009-02-13T15:16:00.000 | 1 | 0 | 1 | 0 | python,datetime | 47,685,478 | 46 | false | 0 | 0 | General function to get next date after/before x months.
from datetime import date
def after_month(given_date, month):
yyyy = int(((given_date.year * 12 + given_date.month) + month)/12)
mm = int(((given_date.year * 12 + given_date.month) + month)%12)
if mm == 0:
yyyy -= 1
mm = 12
retu... | 3 | 527 | 0 | I am using the datetime Python module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this?
The reason I want to generate a date 6 months from the current date is to produce a review date. If the user enters data into the system it will have a review date ... | How do I calculate the date six months from the current date using the datetime Python module? | 0.004348 | 0 | 0 | 588,437 |
546,321 | 2009-02-13T15:16:00.000 | -1 | 0 | 1 | 0 | python,datetime | 47,685,537 | 46 | false | 0 | 0 | Using below given function you can get date after/before x months.
from datetime import date
def next_month(given_date, month):
yyyy = int(((given_date.year * 12 + given_date.month) + month)/12)
mm = int(((given_date.year * 12 + given_date.month) + month)%12)
if mm == 0:
yyyy -= 1
mm = 12... | 3 | 527 | 0 | I am using the datetime Python module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this?
The reason I want to generate a date 6 months from the current date is to produce a review date. If the user enters data into the system it will have a review date ... | How do I calculate the date six months from the current date using the datetime Python module? | -0.004348 | 0 | 0 | 588,437 |
546,479 | 2009-02-13T16:00:00.000 | 0 | 0 | 1 | 0 | python,oop | 2,106,180 | 10 | false | 0 | 0 | Yes, you can use plenty of design patterns in Python. A design pattern is just a repeatable implementation of a higher level task. The reason why Python & design patterns don't work the same as other languages is because Python includes most of the basic patterns built in. This means that patterns that emerge in Python... | 8 | 26 | 0 | It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)? | Do OO design principles apply to Python? | 0 | 0 | 0 | 7,174 |
546,479 | 2009-02-13T16:00:00.000 | 4 | 0 | 1 | 0 | python,oop | 549,327 | 10 | false | 0 | 0 | Short answer: Yes; Python is an OO language.
Slightly longer answer: Yes; you can design using OO principles and then implement in any language (even assembler).
The benefit of using an OO language is that it incorporates support for many common OO concepts, so you don't risk unnecessary bugs having to simulate them b... | 8 | 26 | 0 | It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)? | Do OO design principles apply to Python? | 0.07983 | 0 | 0 | 7,174 |
546,479 | 2009-02-13T16:00:00.000 | 36 | 0 | 1 | 0 | python,oop | 546,495 | 10 | true | 0 | 0 | The biggest differences are that Python is duck typed, meaning that you won't need to plan out class hierarchies in as much detail as in Java, and has first class functions. The strategy pattern, for example, becomes much simpler and more obvious when you can just pass a function in, rather than having to make interfa... | 8 | 26 | 0 | It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)? | Do OO design principles apply to Python? | 1.2 | 0 | 0 | 7,174 |
546,479 | 2009-02-13T16:00:00.000 | 4 | 0 | 1 | 0 | python,oop | 546,612 | 10 | false | 0 | 0 | Design patterns are little more than duct-tape to fix a languages deficiencies. | 8 | 26 | 0 | It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)? | Do OO design principles apply to Python? | 0.07983 | 0 | 0 | 7,174 |
546,479 | 2009-02-13T16:00:00.000 | 4 | 0 | 1 | 0 | python,oop | 546,502 | 10 | false | 0 | 0 | It depends on the pattern. Some things are difficult to do in Python: Singleton is an example. You replace this pattern with another, such as, in the case of Singleton, Borg.
It's not insane to use design patterns in Python-- the Iterator pattern, for instance, is integrated into the syntax. However, many things simply... | 8 | 26 | 0 | It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)? | Do OO design principles apply to Python? | 0.07983 | 0 | 0 | 7,174 |
546,479 | 2009-02-13T16:00:00.000 | 0 | 0 | 1 | 0 | python,oop | 546,521 | 10 | false | 0 | 0 | The use of Java or C# is probably due to the mainstream popularity of the language.
But design principle and/or design patterns apply irrespective of the language you use. The implementation of the same design pattern in Python would obviously be different than in Java or C#. | 8 | 26 | 0 | It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)? | Do OO design principles apply to Python? | 0 | 0 | 0 | 7,174 |
546,479 | 2009-02-13T16:00:00.000 | 1 | 0 | 1 | 0 | python,oop | 546,516 | 10 | false | 0 | 0 | I'd say they apply to Python once you're already doing object-oriented programming with Python. Keep in mind that Python can do a lot more than OOP, and you should use common sense in choosing the appropriate paradigm for the job. If you decide that your program is best represented as a collection of objects, then sure... | 8 | 26 | 0 | It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)? | Do OO design principles apply to Python? | 0.019997 | 0 | 0 | 7,174 |
546,479 | 2009-02-13T16:00:00.000 | 1 | 0 | 1 | 0 | python,oop | 546,569 | 10 | false | 0 | 0 | yes, of course they apply. But as noted above, many patterns are built into the language, or made irrelevant by higher level features of the language. | 8 | 26 | 0 | It seems like many OO discussions use Java or C# as examples (e.g. Head First Design Patterns).
Do these patterns apply equally to Python? Or if I follow the design patterns, will I just end up writing Java in Python (which apparently is a very bad thing)? | Do OO design principles apply to Python? | 0.019997 | 0 | 0 | 7,174 |
549,109 | 2009-02-14T13:18:00.000 | 1 | 0 | 0 | 0 | python | 549,122 | 6 | false | 0 | 0 | is .$filename the kind of thing you're looking for? | 1 | 12 | 0 | Is there any way to hide folders/ files with Python?
I'm working a huge project (a vulnerability scanner). The project creates a lot of files and folders. Therefore the question, is there any way to make a script that hides files and folders? | Hide Folders/ File with Python | 0.033321 | 0 | 0 | 26,588 |
549,344 | 2009-02-14T16:41:00.000 | 0 | 1 | 1 | 0 | .net,powershell,scripting,automation,ironpython | 549,602 | 5 | false | 0 | 0 | Out of frustration with PowerShell I did look into IronPython. I think this is a good alternative to powershell, especially if you are a programmer. Even if you are an IT person, I think Windows command shell + IronPython is a good combination that will accomplish what you need in the .NET era (like what command shel... | 4 | 6 | 0 | Imagine that you need to develop and schedule an application/script to do the following:-
Reference one or more .net assemblies
Query the API, get some objects
for each object call another method in the API
What would you use?
In the past I have created small console applications that do the above, but it seems a bit... | What is the best technology to use for automating a task using .net libraries? | 0 | 0 | 0 | 373 |
549,344 | 2009-02-14T16:41:00.000 | 2 | 1 | 1 | 0 | .net,powershell,scripting,automation,ironpython | 564,698 | 5 | true | 0 | 0 | IronPython.
I trialled using both Powershell and IronPython for the above task and came to the conclusion that IronPython was the best fit (for me).
To be fair either Powershell or any DLR based language such as IronPython or IronRuby would suit the task and would be less overhead than looking after trivial console app... | 4 | 6 | 0 | Imagine that you need to develop and schedule an application/script to do the following:-
Reference one or more .net assemblies
Query the API, get some objects
for each object call another method in the API
What would you use?
In the past I have created small console applications that do the above, but it seems a bit... | What is the best technology to use for automating a task using .net libraries? | 1.2 | 0 | 0 | 373 |
549,344 | 2009-02-14T16:41:00.000 | 2 | 1 | 1 | 0 | .net,powershell,scripting,automation,ironpython | 549,356 | 5 | false | 0 | 0 | The problem with application drivers is that they constantly break. Applications are constantly changing their external surface and this wreaks havoc on drivers. Therefore you constantly need to updated parts of the drivers. I find a non-compiled dynamic language is ideal for this as you can quickly make an update a... | 4 | 6 | 0 | Imagine that you need to develop and schedule an application/script to do the following:-
Reference one or more .net assemblies
Query the API, get some objects
for each object call another method in the API
What would you use?
In the past I have created small console applications that do the above, but it seems a bit... | What is the best technology to use for automating a task using .net libraries? | 0.07983 | 0 | 0 | 373 |
549,344 | 2009-02-14T16:41:00.000 | 3 | 1 | 1 | 0 | .net,powershell,scripting,automation,ironpython | 549,404 | 5 | false | 0 | 0 | One of the advantages of PowerShell is that they've done a lot of work in the background to make things fit together easily, doing implicit type conversions etc to make the output of one program usable as the input to another. And since everything passes objects, you don't have to write text munging code to cobble thi... | 4 | 6 | 0 | Imagine that you need to develop and schedule an application/script to do the following:-
Reference one or more .net assemblies
Query the API, get some objects
for each object call another method in the API
What would you use?
In the past I have created small console applications that do the above, but it seems a bit... | What is the best technology to use for automating a task using .net libraries? | 0.119427 | 0 | 0 | 373 |
549,536 | 2009-02-14T18:44:00.000 | 1 | 0 | 0 | 0 | python,queue | 549,555 | 5 | false | 1 | 0 | Why not use a list if you need order (or even a heapq, as was formerly suggested by zacherates before a set was suggested instead) and also use a set to check for duplicates? | 1 | 1 | 0 | I'm working on a simple web crawler in python and I wan't to make a simple queue class, but I'm not quite sure the best way to start. I want something that holds only unique items to process, so that the crawler will only crawl each page once per script run (simply to avoid infinite looping). Can anyone give me or poin... | Simple unique non-priority queue system | 0.039979 | 0 | 1 | 2,069 |
550,050 | 2009-02-15T00:27:00.000 | 2 | 0 | 0 | 0 | python,python-3.x,tkinter,tk | 52,803,981 | 7 | false | 0 | 1 | Alternative to @ubomb's solution for adding custom images by utilizing Tkinter.PhotoImage's built-in support for processing .gif images.
From file:
icon = Tkinter.PhotoImage(file="logo.gif")
from base64:
gif_base64_string = """ R0lGODdhEAAQAIcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0NDQ4O Dg8PDxAQEBERERI... | 1 | 26 | 0 | How to remove tkinter icon from title bar in it's window | Removing the TK icon on a Tkinter window | 0.057081 | 0 | 0 | 45,549 |
550,446 | 2009-02-15T07:06:00.000 | 5 | 0 | 1 | 0 | python,windows,dll,py2exe | 551,368 | 5 | false | 0 | 0 | I doubt that py2exe does this, as it's architectured around providing a bootstrapping .exe that rolls out the python interpreter and runs it.
But why not just embed Python in C code, and compile that code as a DLL? | 2 | 13 | 0 | Is there a way using py2exe or some other method to generate dll files instead of exe files?
I would want to basically create a normal win32 dll with normal functions but these functions would be coded in python instead of c++. | py2exe to generate dlls? | 0.197375 | 0 | 0 | 10,678 |
550,446 | 2009-02-15T07:06:00.000 | 6 | 0 | 1 | 0 | python,windows,dll,py2exe | 598,780 | 5 | true | 0 | 0 | I think you could solve this by doing some hacking:
Take a look at the zipextimporter module in py2exe . It helps with importing pyd-files from a zip.
Using that, you might be able to load py2exe's output file in your own app/dll using raw python-api. (Use boost::python if you can and want)
And, since py2exe's output... | 2 | 13 | 0 | Is there a way using py2exe or some other method to generate dll files instead of exe files?
I would want to basically create a normal win32 dll with normal functions but these functions would be coded in python instead of c++. | py2exe to generate dlls? | 1.2 | 0 | 0 | 10,678 |
550,474 | 2009-02-15T07:28:00.000 | 10 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 550,496 | 12 | false | 0 | 0 | If you want to program for iphone then you should use objective-C. The entire iphone API is based on objective-C, and you have the benefits of using interface builder and IDE support from Xcode. | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 1 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 2 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 1,331,003 | 12 | false | 0 | 0 | I have written small games, interpreters, and tons of awessome stuff in Ruby. I Wouldn't recommend It to write intensive AI programs for instance, but It's fun to learn and powerful for most applications. Even when I do most of my work in C++ Ruby is my favorite language for subjective reasons.
Objective C as most peo... | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 0.033321 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 2 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 552,528 | 12 | false | 0 | 0 | Just my two cents...As I'm sure you're aware, Apple and others in the respective communities are doing a lot of work with Ruby and Python, for both Mac and iPhone development. Objective-C will pretty much get you into Apple arenas only these days (though maybe that's not a bad thing;) However, if you are only going to... | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 0.033321 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 7 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 550,516 | 12 | false | 0 | 0 | Objective-C is the only way to program an iPhone if you want to produce native programs that can be sold in the App Store.
Some of the more advanced concepts in Objective-C are now being added to languages like C# (eg: extension methods in C# v3.0). Learning to think in Objective-C will be useful, the OO model you lear... | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 1 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 2 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 550,980 | 12 | false | 0 | 0 | Ruby. With Ruby you will be able to do both web development (Rails/Sinatra/etc.) and very soon program on the MAC/Iphone platform with the Macruby project. Why not get the best of both worlds?
Tommy | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 0.033321 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 2 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 550,540 | 12 | false | 0 | 0 | To program on Mac OS X, you really do need a good foundation in Objective-C. The vast majority of documentation will assume Objective-C. Even if you choose to program some applications in some other language, you will be better off having a good understanding of it. | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 0.033321 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 2 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 550,499 | 12 | false | 0 | 0 | If you program with Objective-C, your main goal should be writing Cocoa applications on the Mac. Beyond that, it has little use. Ruby and Python are useful scripting languages, and there are also bridges to write Cocoa applications.
If you want to write apps on the Mac, I would start with Objective-C. There is more sup... | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 0.033321 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 7 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 550,829 | 12 | false | 0 | 0 | Which language you guys see the FUTURE???
Future of what? iPhone development? Objective-C.
Web Services? Python/Ruby in parallel for a while. At least until people start trying to do maintenance on large Ruby applications and get frustrated with it's opacity.
Real-time game engine development? Embedded applicati... | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 1 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 4 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 550,485 | 12 | false | 0 | 0 | As a Perlite, I'm just going to point out that OS X has Perl as well as Python or Ruby.
As far as Perl/Python/Ruby goes, programs are almost completely cross-platform. It is fairly easy to run a Perl/Python/Ruby program on any platform and it works more or less the same. There may be some minor differences, but they're... | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 0.066568 | 0 | 0 | 15,650 |
550,474 | 2009-02-15T07:28:00.000 | 1 | 1 | 1 | 0 | python,objective-c,ruby,programming-languages | 550,868 | 12 | false | 0 | 0 | Objective-C is only Mac/iPhone, and I recommend you to learn if you want to develop applications for Mac/iPhone.
Python is everything and it's future, but python more preferable for web development. Python is Google :) Python is web, games, science, graphics, desktop, etc. Also it's very good choice if you are C/C++ de... | 10 | 7 | 0 | I am working on C++ since last 4-5 years . Recently I have bought iphone and macbook and want do do some programming for iphone.
So I have started reading one book about Objective-C. I have also learn that we can program with Ruby and Python on MAC.
So my question is which one to study? Which language you guys see the ... | Study Objective-C , Ruby OR Python? | 0.016665 | 0 | 0 | 15,650 |
550,632 | 2009-02-15T10:06:00.000 | 35 | 0 | 0 | 0 | python,django,hidden-features | 551,499 | 55 | false | 1 | 0 | Add assert False in your view code to dump debug information. | 1 | 308 | 0 | Inspired by the question series 'Hidden features of ...', I am curious to hear about your favorite Django tips or lesser known but useful features you know of.
Please, include only one tip per answer.
Add Django version requirements if there are any. | Favorite Django Tips & Features? | 1 | 0 | 0 | 62,526 |
550,653 | 2009-02-15T10:23:00.000 | 0 | 1 | 0 | 1 | python,cross-platform,jython,hp-ux | 557,021 | 9 | false | 0 | 0 | There isn't, I'm afraid. Processes are uniquely identified by pid not by name. If you really must find a pid by name, then you will have use something like you have suggested, but it won't be portable and probably will not work in all cases.
If you only have to find the pids for a certain application and you have contr... | 3 | 58 | 0 | Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jython?
I want something like pidof but in python. (I don't have pidof anyway.)
I can't parse /proc because it might be unavailable (on HP-UX).
I do not want to run os.popen('... | Cross-platform way to get PIDs by process name in python | 0 | 0 | 0 | 78,794 |
550,653 | 2009-02-15T10:23:00.000 | 0 | 1 | 0 | 1 | python,cross-platform,jython,hp-ux | 727,024 | 9 | false | 0 | 0 | For jython, if Java 5 is used, then you can get the Java process id as following:
from java.lang.management import *
pid = ManagementFactory.getRuntimeMXBean().getName() | 3 | 58 | 0 | Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jython?
I want something like pidof but in python. (I don't have pidof anyway.)
I can't parse /proc because it might be unavailable (on HP-UX).
I do not want to run os.popen('... | Cross-platform way to get PIDs by process name in python | 0 | 0 | 0 | 78,794 |
550,653 | 2009-02-15T10:23:00.000 | 1 | 1 | 0 | 1 | python,cross-platform,jython,hp-ux | 550,672 | 9 | false | 0 | 0 | I don't think you will be able to find a purely python-based, portable solution without using /proc or command line utilities, at least not in python itself. Parsing os.system is not ugly - someone has to deal with the multiple platforms, be it you or someone else. Implementing it for the OS you are interested in shoul... | 3 | 58 | 0 | Several processes with the same name are running on host. What is the cross-platform way to get PIDs of those processes by name using python or jython?
I want something like pidof but in python. (I don't have pidof anyway.)
I can't parse /proc because it might be unavailable (on HP-UX).
I do not want to run os.popen('... | Cross-platform way to get PIDs by process name in python | 0.022219 | 0 | 0 | 78,794 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.