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 times. I'm wondering if, and how, to clear the Python interpreter console. I've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do. Note: I'm running on Windows, so Ctrl+L doesn't work.
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 times. I'm wondering if, and how, to clear the Python interpreter console. I've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do. Note: I'm running on Windows, so Ctrl+L doesn't work.
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 also be extended to allow "archived" objects (or any other state that makes sense).
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 rendering methods, e.g.), I get an error message that says that I have to save the instances first. The documentation says that this is because the models are in a many-to-many relationship. How do I present objects to the user and allowing him/her to save or discard them without cluttering my database? (I guess I could turn off transactions-handling and do them myself throughout the whole project, but this sounds like a potentially error-prone measure...) Thx!
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, asp.net, mysql, and sql server. EDIT: I am running this locally, if the connections are closing like they should be then I only have 1 connection open at a time. I did have a GUI open to the database but even closed I am getting this error. It is happening very shortly after I run my program. I have a function I call that returns a connection that is opened like: psycopg2.connect(connectionString) Thanks Final Edit: It was my mistake, I was recursively calling the same method on mistake that was opening the same method over and over. It has been a long day..
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 things could be the problem. If you are the admin, you can up the number of clients, but if a program is hanging it open, then that won't help for long. There are many reasons why you could be having too many clients running at the same time.
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, asp.net, mysql, and sql server. EDIT: I am running this locally, if the connections are closing like they should be then I only have 1 connection open at a time. I did have a GUI open to the database but even closed I am getting this error. It is happening very shortly after I run my program. I have a function I call that returns a connection that is opened like: psycopg2.connect(connectionString) Thanks Final Edit: It was my mistake, I was recursively calling the same method on mistake that was opening the same method over and over. It has been a long day..
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, asp.net, mysql, and sql server. EDIT: I am running this locally, if the connections are closing like they should be then I only have 1 connection open at a time. I did have a GUI open to the database but even closed I am getting this error. It is happening very shortly after I run my program. I have a function I call that returns a connection that is opened like: psycopg2.connect(connectionString) Thanks Final Edit: It was my mistake, I was recursively calling the same method on mistake that was opening the same method over and over. It has been a long day..
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 know about building a career out of that only but I'd definitely say that knowing Python is a very valuable asset on your resume, it'll strengthen your "smell of usefulness".
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 (a/@href in xpath), filter out hyperlinks that do not point to URL below the current page, recurse into the remaining urls. You can do further filtering, depending on your use case, such as removing the query part of the URL (anything after the first ?). When the server has a directory listing feature enabled, this gives you something usable. This also gives you something usable if the website has no directory listing but is organized in a sensible way.
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, but any other solutions might be helpful as well.
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 allows passthrough to interactive subprocesses (with specific key sequences from the user or strings received from the child process triggering matches and sending control back to your program), the same thing can be done from Python with pexpect. Alternately, as another post mentioned, the curses module provides full control over the drawing of terminal displays -- which you'll want if this history menu is happening within the window rather than in a graphical (X11/win32) pop-up.
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 the results. So far, so good. If the user chooses a command and then press the right or left key, I want to insert the command into the prompt - so that the user can edit the command before executing it. If you are on Linux, just fire up a bash console, press Ctrl+r, type cd(or something), and then press the right arrow key - the selected command will be shown at the prompt. This is the functionality I am looking for - but I want to know how to do that from within python.
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, it might be worth considering a view that accepts the XML file itself via an HTTP POST. If that makes sense for your data (you don't give much information about that XML file), it would still work from cron, but could also accept an upload from a browser -- potentially letting the person who produces the XML file update the DB by themselves. That's a big win if you're not the one making the XML file, which is usually the case in my experience.
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 create a python script and install that script as a cron (with DJANGO _SETTINGS _MODULE variable setup before executing the script)?
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 database. Then in the main thread start a CherryPy application that will query that SQLite database and serve the data. My problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application? If I'd do a connection per thread to the database will I also be able to create/use an in memory database?
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 database. Then in the main thread start a CherryPy application that will query that SQLite database and serve the data. My problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application? If I'd do a connection per thread to the database will I also be able to create/use an in memory database?
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 traditionally handled using thread-local sessions, and is performed rather well (for example) using SQLAlchemy's ScopedSession. I would use this if I were you, even if you aren't using the SQLAlchemy ORM features.
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 database. Then in the main thread start a CherryPy application that will query that SQLite database and serve the data. My problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application? If I'd do a connection per thread to the database will I also be able to create/use an in memory database?
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 start ordinary processes to do gathering and run Cherry Py. You have no real use for concurrent threads in a single process for this. Gathering data at a specified interval -- when done with simple OS processes -- can be scheduled by the OS very simply. Cron, for example, does a great job of this. A CherryPy App, also, is an OS process, not a single thread of some larger process. Just use processes -- threads won't help you.
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 database. Then in the main thread start a CherryPy application that will query that SQLite database and serve the data. My problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application? If I'd do a connection per thread to the database will I also be able to create/use an in memory database?
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 script breaks, you fix it and run again. If it's not a proper error, but a logic problem of some kind, then the program finishes, but doesn't work correctly. No language can anticipate what you hoped for and break for you. Or perhaps you mean something else. "...code that needs a lot of enums" You'll need to provide examples of code that needs a lot of enums. I've been writing Python for years, and have no use for enums. Indeed, I've been writing C++ with no use for enums either. You'll have to provide code that needs a lot of enums as a specific example. Perhaps in another question along the lines of "What's a Pythonic replacement for all these enums." It's usually polymorphic class definitions, but without an example, it's hard to be sure.
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 write code that needs a lot of enums and types, should I be doing it in C++? It feels like I can do it quicker in C++.
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 during runtime. There are a large number of ways in which you can implement enums, a quick google search for "python enums" gives everything you're likely to need. However, you should look into whether or not you really need them, and if there's a better, more 'pythonic' way of doing the same thing.
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 write code that needs a lot of enums and types, should I be doing it in C++? It feels like I can do it quicker in C++.
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) {Pyflakes, pychecker, pylint} will do static analysis on your code. That settles the syntax issue mostly. 2) Test-driven development with nosetests or the like will help you. If you make a code change that breaks your existing code, the tests will fail and you will know about it. This is actually better than static analysis and can be as fast. If you test-first, then you will have all your code checked at test runtime instead of program runtime. Note that with 1 & 2 in place you are a bit better off than if you had just a static-typing compiler on your side. Even so, it will not create a proof of correctness. It is possible that your tests may miss some plumbing you need for the app to actually run. If that happens, you fix it by writing more tests usually. But you still need to fire up the app and bang on it to see what tests you should have written and didn't.
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 write code that needs a lot of enums and types, should I be doing it in C++? It feels like I can do it quicker in C++.
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 you want to skip backup. sed -i '' 's/find/replace' /file.txt All merit to @Austin
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 from being a command line interface, can be a very powerful scripting language. So, if this is true, I assume you can perform actions like these. Can I do it with bash, and what's the simplest (one line) script to achieve my goal?
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 from being a command line interface, can be a very powerful scripting language. So, if this is true, I assume you can perform actions like these. Can I do it with bash, and what's the simplest (one line) script to achieve my goal?
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 performance.
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 Processes actually means and what Windows features it may be running? NB: I am not measuring performance using the task manager, I just used it to take a look at what else was running during a particularly slow measurement. Please think before saying this is not programming related and closing the question. I would not ask it unless I thought there were grounds to say it is. In this case I believe it clearly is because it is detrimentally affecting my development and test environments and in order to sort it out I need to know a bit more about it. Programming does not start and end with the writing of the code.
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, recently I've found myself wanting to add some additional functionality to the layer editor in Maya. I've seen tutorials that explain how to do this, but now that I want to do it, I can't find any. Links to tutorials or a brief code snippet to get me started would be great. I just need to know how to find the layer editor/panel and, say, add a button or text field to it.
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 Anyway, the approach I use depends on modifying sys.path, and works like this: Require python and setuptools (to enable loading code from eggs) on all computers that will use your software. Organize your directory structure this: project/ *.py scriptcustomize.py file.pth thirdparty/ eggs/ mako-vNNN.egg ... .egg code/ elementtree\ *.py ... In your top-level script(s) include the following code at the top: from scriptcustomize import apply_pth_files apply_pth_files(__file__) Add scriptcustomize.py to your project folder: import os from glob import glob import fileinput import sys def apply_pth_files(scriptfilename, at_beginning=False): """At the top of your script: from scriptcustomize import apply_pth_files apply_pth_files(__file__) """ directory = os.path.dirname(scriptfilename) files = glob(os.path.join(directory, '*.pth')) if not files: return for line in fileinput.input(files): line = line.strip() if line and line[0] != '#': path = os.path.join(directory, line) if at_beginning: sys.path.insert(0, path) else: sys.path.append(path) Add one or more *.pth file(s) to your project folder. On each line, put a reference to a directory with packages. For instance: # contents of *.pth file thirdparty/code thirdparty/eggs/mako-vNNN.egg I "kind-of" like this approach. What I like: it is similar to how *.pth files work, but for individual programs instead of your entire site-packages. What I do not like: having to add the two lines at the beginning of the top-level scripts. Again: I use virtualenv most of the time. But I tend to use virtualenv for projects where I have tight control of the deployment scenario. In cases where I do not have tight control, I tend to use the approach I describe above. It makes it really easy to package a project as a zip and have the end user "install" it (by unzipping).
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 program has about 6 different Python library dependencies (e.g. ElementTree, Mako) The situation: Developers want to hack on the source of this tool and then run it without having to build the binary. Currently this means that they need a python 2.6 interpreter (which is fine) and also have the 6 libraries installed locally using easy_install. The Problem This is not a public, classical open source environment: I'm inside a corporate network, the tool will never leave the "walled garden" and we have seriously inconvenient barriers to getting to the outside internet (NTLM authenticating proxies and/or machines without direct internet access). I want the hurdles to starting to hack on this tool to be minimal: nobody should have to hunt for the right dependency in the right version, they should have to execute as little setup as possible. Optimally the prerequisites would be having a Python installation and just checking out the program from Subversion. Anecdote: The more self-contained the process is the easier it is to repeat it. I had my machine swapped out for a new one and went through the unpleasant process of having to reverse engineer the dependencies, reinstall distutils, hunting down the libraries online and getting them to install (see corporate internet restrictions above).
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 etc. Sure provide them with a bootstrap script, but beyond that you will be molly-coddling to the point that they are clueless. Then there are specific issues such as "what if one user wants to install a different version or implementation of a library?", a glaring example here is ElementTree, as this has a number of implementations.
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 program has about 6 different Python library dependencies (e.g. ElementTree, Mako) The situation: Developers want to hack on the source of this tool and then run it without having to build the binary. Currently this means that they need a python 2.6 interpreter (which is fine) and also have the 6 libraries installed locally using easy_install. The Problem This is not a public, classical open source environment: I'm inside a corporate network, the tool will never leave the "walled garden" and we have seriously inconvenient barriers to getting to the outside internet (NTLM authenticating proxies and/or machines without direct internet access). I want the hurdles to starting to hack on this tool to be minimal: nobody should have to hunt for the right dependency in the right version, they should have to execute as little setup as possible. Optimally the prerequisites would be having a Python installation and just checking out the program from Subversion. Anecdote: The more self-contained the process is the easier it is to repeat it. I had my machine swapped out for a new one and went through the unpleasant process of having to reverse engineer the dependencies, reinstall distutils, hunting down the libraries online and getting them to install (see corporate internet restrictions above).
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 the same. I don't see a problem. Please update your question with specific problems you need solved. Disliking the way open source is distributed isn't a problem -- it's the way that open source works. Edit. The "walled garden" doesn't matter very much. Choice 1. You could, BTW, build an "installer" that runs easy_install 6 times for them. Choice 2. You can save all of the installer kits that easy_install would have used. Then you can provide a script that does an unzip and a python setup.py install for all six. Choice 3. You can provide a zipped version of your site-packages. After they install Python, they unzip your site-packages directory into `C:\Python2.5\lib\site-packages``. Choice 4. You can build your own MSI installer kit for your Python environment. Choice 5. You can host your own pypi-like server and provide an easy_install that checks your server first.
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 program has about 6 different Python library dependencies (e.g. ElementTree, Mako) The situation: Developers want to hack on the source of this tool and then run it without having to build the binary. Currently this means that they need a python 2.6 interpreter (which is fine) and also have the 6 libraries installed locally using easy_install. The Problem This is not a public, classical open source environment: I'm inside a corporate network, the tool will never leave the "walled garden" and we have seriously inconvenient barriers to getting to the outside internet (NTLM authenticating proxies and/or machines without direct internet access). I want the hurdles to starting to hack on this tool to be minimal: nobody should have to hunt for the right dependency in the right version, they should have to execute as little setup as possible. Optimally the prerequisites would be having a Python installation and just checking out the program from Subversion. Anecdote: The more self-contained the process is the easier it is to repeat it. I had my machine swapped out for a new one and went through the unpleasant process of having to reverse engineer the dependencies, reinstall distutils, hunting down the libraries online and getting them to install (see corporate internet restrictions above).
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, so this can be relatively fast. A new developer on the project simply checks out from subversion and then types "make". This approach might work well for you, given that your audience is already used to the idea of using subversion checkouts as part of their fetch process. Also, it has the nice property that all knowledge about your program, including its external dependencies, are captured in the source code repository.
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 program has about 6 different Python library dependencies (e.g. ElementTree, Mako) The situation: Developers want to hack on the source of this tool and then run it without having to build the binary. Currently this means that they need a python 2.6 interpreter (which is fine) and also have the 6 libraries installed locally using easy_install. The Problem This is not a public, classical open source environment: I'm inside a corporate network, the tool will never leave the "walled garden" and we have seriously inconvenient barriers to getting to the outside internet (NTLM authenticating proxies and/or machines without direct internet access). I want the hurdles to starting to hack on this tool to be minimal: nobody should have to hunt for the right dependency in the right version, they should have to execute as little setup as possible. Optimally the prerequisites would be having a Python installation and just checking out the program from Subversion. Anecdote: The more self-contained the process is the easier it is to repeat it. I had my machine swapped out for a new one and went through the unpleasant process of having to reverse engineer the dependencies, reinstall distutils, hunting down the libraries online and getting them to install (see corporate internet restrictions above).
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 able to break the connection to the COM-Server, once severed there seems to be no safe way to re-connect to the Excel application. There's absolutely no safety built into the COM Application object. The Excel COM interface will not allow me to safely remote-control two seperate instances of the Excel application operating on the same workbook file, even if they are read-only. Also when something does go wrong I seldom get any useful error-messages... at best I can except a numerical error-code or a barely useful message such as "An Exception has occurred". It's almost impossible to know why something went wrong. Finally, COM lacks the ability to control some of the most fundamental aspects of Excel? For example there's no way to do a guaranteed close of just the Excel process that a COM client is connected to. You cannot even use COM to find Excel's PID. So what if I were to completely abandon COM? Is there an alternative way to control Excel? All I want to do is run macros, open and close workbooks and read and write cell-ranges? Perhaps some .NET experts know a trick or two which have not yet bubbled into the Python community? What about you office-hackers? Could there be a better way to get at Excel's innards than COM?
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 impact on a system? What is the preferred way to do nothing, but keep a python app running?
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 program?
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 program?
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, though, you're better off creating a video with ffmpeg. It can create videos out of multiple images, so if you're somehow able to render the frames you want in the presentation, you could use ffmpeg to make a video out of it. If you only want charts, use SWF Charts. You could use external languages that have a library for creating flash files. And finally there was another script language that could be compiled into several other languages, where swf waas one of the targets, but I can't remember its name right now.
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 in table B cannot be written to and it looks like table A is fine. Whats happening? -edit- I fixed it but unsure how. I notice the code not doing the correct things (i copied the wrong field) and after fixing it up and cleaning it, it magically started working again. -edit2- Someone else posted so i might as well update. I think the problem was i was trying to do a statement with a command/cursor in use.
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(), but is there a simple way I could accomplish this without using eval()?" Nothing simpler than repr and eval. What's wrong with eval? Is is the "someone could insert malicious code into the file where I serialized my lists" issue? Who -- specifically -- is going to find and edit this file to put in malicious code? Anything you do to secure this (i.e., encryption) removes "simple" from it.
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 terms of space but the result is full of nasty \x00 bytes. Ideally I would like the result to be human readable. I thought of just using repr() and eval(), but is there a simple way I could accomplish this without using eval()? This is getting stored in a db, not a file. Byte overhead matters because it could make the difference between requiring a TEXT column versus a varchar, and generally data compactness affects all areas of db performance.
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 into all tutorials but they are not helping much.
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 type of list building shows up in a few hotspots of my code, so I want to make it as efficient as possible. Edit: Also, does it even make sense to do something like this in a language like Python? I'm a fairly experienced programmer, but new to Python and still getting a feel for its way of doing things. Does Python internally allocate all objects in separate heap spaces, defeating the purpose of trying to minimize allocations, or are primitives like ints, floats, etc. stored directly in lists?
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 owns. Just a tip, hope it helps.
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 through one of the modules I've imported: pylab/matplotlib?). Can anyone shed some light on how to enable this mode in the interpreter?
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 at the end.)
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 your Panel class. The place to look is demo/wxXmlResourceHandler.py You can even extend XRCed to recognize your own resource, and insert it into future dialogs with ease.
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 reference external xrc files. I'd like something that worked similar to the way you can define xsd elements in one file and include and reference them in another xsd file.
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 with contrib.admin & contrib.session.
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 contrib apps is you're not really doing anything hacky, you're just writing (mostly) regular Python code to add the functionality.
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 simply not relevant. The iterator is a classic example ... iteration is something that is handled elegantly in Ruby and the heavy-weight OO iteration patterns no longer really apply. This seems to be true throughout the language.
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 for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?
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 you program, but that's your illusion. Your resultant code will land along the borders and within the bounds of many paradigms.
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 for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?
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, updating, signaling, etc) and functional stuff solves many lower-level problems (parsing, nuts 'n bolts data processing, etc) more nicely. And usually, a dynamically typed scripting system is good for selecting and configuring the specific app, game level, whatnot. This may be the language itself (i.e. Python) or something else (an xml-script engine + necessary system for dynamic links in C++).
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 for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?
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 other hand, to get benefit from mixing two or more paradigms programmer should be reasonably fluent with all of them. So this is powerful tool that should be used with care.
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 for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?
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 that script. I've used this to have Python 2.2, 2.5, and 3.0 projects in the same workspace.
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 anything. I need to click "click here to configure an interpreter not listed", and UP the interpreter I wish to use. Issue 2: That would be fine if I was switching to 3.0 for every project for the rest of my life, but I still am doing a lot of switching between projects and I don't see that changing anytime soon. So, I'm just trying to save a few operations. Is there a way to configure Eclipse so that it remembers which interpreter I want associated with which project? What if I created an entirely new workspace? Is "interpreter" a property of a workspace? Also, it doesn't seem to matter what I choose when I create a new project via File -> New -> Pydev Project. Whatever I last selected through "Properties" is what eclipse is using. This is Eclipse 3.4.0, running in Windows XP.
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 one instance of Eclipse (it shuts down and restarts), but you can run two instances of Eclipse at once, one for each workspace. Now, I guess I like the fact that Eclipse handles it that way. It has a more "modular" feel, and what originally bothered me I now think it sensible. I don't need to worry about having two interpreters to choose from, or choosing the default or moving one up. I just need to worry about which workspace I'm in. Hope this helps someone. . . EDIT: as noted by Kiv, "interpreter" is not a property of your "workspace" (as I stated above). Instead, for any project, there is a "run configuration" (incidentally, there is also a debug configuration). The run config allows the user to set the executable, and the path, and a number of other options. *I'm sure these things are known to long-time users, but I never had to deal with this until I changed python versions.**
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 anything. I need to click "click here to configure an interpreter not listed", and UP the interpreter I wish to use. Issue 2: That would be fine if I was switching to 3.0 for every project for the rest of my life, but I still am doing a lot of switching between projects and I don't see that changing anytime soon. So, I'm just trying to save a few operations. Is there a way to configure Eclipse so that it remembers which interpreter I want associated with which project? What if I created an entirely new workspace? Is "interpreter" a property of a workspace? Also, it doesn't seem to matter what I choose when I create a new project via File -> New -> Pydev Project. Whatever I last selected through "Properties" is what eclipse is using. This is Eclipse 3.4.0, running in Windows XP.
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 to define some kind of state, a much better approach is this: Create a base class that define all the abstract properties, attributes and methods belonging to a state. Then, for each state, derive a sub class that implements the specific behavior of this state. You can then pass around these classes (or maybe instances thereof) to handle the state and its behaviour. If you use classes instead of instances (the Python way of a "singleton"), you can simply check for any given state (not that it should be necessary) by if current_state is StateA: (note the is instead of ==) with no performance penalty over comparing integer values. And of course, you can define a name attribute and a __str__() method to access and print the state's name.
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__ If you want to print the variable name from inside the function, you can try the functions - vars(), locals() and globals(). Edit: I just noticed that this is not what you want. In that case adding a dict and a function may work You may want to print the __dict__ of the class of your enums. All that said, there aren't standard enumerations in Python. It would help to know how you are creating them. On second thoughts, you can maintain your variables as a dictionary in the enum, keyed by variable name and provide a method of the enumeration to find the right variable and print its name. This solution (keeping a dict) is bad because variable values aren't necessarily unique. Edit: The problem is not trivial, so you may want to use a tried and tested solution. IMHO, you would be better off avoiding the situation if you can.
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 individual pages, then extract the pages you need and for each such page (or pages) create new print job (eg. using Windows program lpr). To ease the task, I'd create print queue for any combination of bin and tray you have to print to, then use these queues as printers.
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 command line parameter? I am able to use the Win32 api to find out which bins correspond to which binnames, but that is about it. Any advice/shortcuts/etc?
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 that all the environments were almost equally configured, and all the task were performed in the same way by all the members of the team. I'm starting to work in Python now and I'd like your advice in which tools should I use to accomplish the same as described for java.
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)//12, (K.today.month+6)%12+1, 1) - timedelta(days = 1) it seems quite simple but still catches all the issues like 29,30,31 it also works for - 6 mths by doing -timedelta nb - don't be confused by K.today its just a variable in my program
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 of 6 months from the date they entered the data.
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 return given_date.replace(year=yyyy, month=mm) if __name__ == "__main__": today = date.today() print(today) for mm in [-12, -1, 0, 1, 2, 12, 20 ]: next_date = after_month(today, mm) print(next_date)
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 of 6 months from the date they entered the data.
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 return given_date.replace(year=yyyy, month=mm) if __name__ == "__main__": today = date.today() print(today) for mm in [-12, -1, 0, 1, 2, 12, 20 ]: next_date = next_month(today, mm) print(next_date)
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 of 6 months from the date they entered the data.
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 are likely to be higher level design patterns instead of the menial tasks for which patterns are usually needed.
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 by convention. Of course there will always be language-specific details with greater or lesser applicability; you asked about "design principles", which should be expressed above that level of detail. Long, verbose, boring answer: (The development of programming languages isn't a simple linear progression, but let me oversimplify and ignore that fact to make an observation that spans about 40 years' of programming experience.) There's always going to be a role for language features vs. design principles and patterns. At every stage, attentive practitioners have noticed: "Here's a problem we keep solving by hand in our current language(s)." "Here's a bug we keep writing in our current language(s)." "Here are some good practices we keep observing in our best programs." And so the next generation of language(s) tend provide support for observed good behavior, tend to incorporate concepts so they don't have to be done by convention/agreement (or accidentally broken by the same), and enforce practices that prevent easily avoidable errors. Regardless of how sophisticated, specialized, or generalized our tools, there are always programmers who "just turn the crank" and others who keep looking watching for how the "best and brightest" (in the mind of the beholder) use the tools. They then describe and promote those practices. Correctly defined (and whether called "style", "guidelines", "patterns", "principles", etc.), those practices end up forming "the next level" that we're always trying to reach, regardless of where we are currently standing.
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 interfaces, etc. just to simulate higher order functions. More generally, Python has syntactic sugar for a lot of common design patterns, such as the iterator and the aforementioned strategy. It might be useful to understand these patterns (I've read Head First and found it pretty useful), but think about Pythonic ways to implement them rather than just doing things the same way you would in Java.
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 aren't done as OO- or pattern-heavy stuff. Python is made to be procedural or functional when it best suits the task, and OO too. Overall, I'd just say to use your best judgment. If it seems like using Design Pattern Alpha-Gamma is overkill and overcomplication, then it probably is. If it seems like the pattern is perfect for what you want, it probably is.
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, go ahead and use the design patterns, but don't be afraid to do something completely different if it's called for.
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 shell + vbscript was fine for in the COM era).
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 clumsy and overkill. I imagine something like PowerShell or IronPython might be a better fit. Any recommendations?
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 applications. If all you are doing is consuming a .net library and doing some scripting then IronPython edges Powershell. If you want to utilise some sort of shell-type functionality or use existing CMDLETS then Powershell is a better choice. IronPython, being a implementation of python, brings all the advantages of python for scripting such as being easy to learn, easy to read and quick to develop in.
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 clumsy and overkill. I imagine something like PowerShell or IronPython might be a better fit. Any recommendations?
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 and kick off a task. Powershell is a great technology for this. It is an amazingly flexible and really easy to pick up. It is a mix of compiled and dynamic code. So the more algorithm heavy portions of your driver can be any compiled language and the more fragile and frequently updated pieces can be script. They integrate seamlessly. I'm an avid Powershell user and really don't have much experience with IronPython (hence my choice). IronPython could also have these features though so if you're more comfortable with that language it's where you should go.
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 clumsy and overkill. I imagine something like PowerShell or IronPython might be a better fit. Any recommendations?
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 things together. I do prefer Python, however, when I'm writing a large amount of original code rather than relying heavily on libraries and gluing together components.
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 clumsy and overkill. I imagine something like PowerShell or IronPython might be a better fit. Any recommendations?
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 point me to a simple queue example that I could run off of?
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 Dg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8fHyAgICEh ... 4B8AAP9Ci/4HoLTpfwD+qV4NoHVAADs= """ icon = Tkinter.PhotoImage(data=gif_base64_string) Visit the undermentioned link for more details: //effbot.org/tkinterbook/photoimage.htm
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 outputfile is a zip, you could attach it at the end of your dll, making the whole thing even more integrated. (Old trick that works with jar-files too.) Not tested, but I think the theory is sound. Essentially, you reimplement py2exe's output executable's main() in your 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?
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 people said Is a must in iPhone development, and fun if You're enthusiastic about learning languages. I haven't tried Python, but I hear nothing but good things about It, and PyGames Is quite popular. I would learn the three ( well...I would skip objective C unless You're curious about getting into iPhone development), the most languages you know, the best professional You will be. As a good professor of mine always said..It's not about being the master in just one language, It's about knowing the pros and cons of each one to choose the right one according to the particular problem You want to solve. Cheers !
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 learn one language in the foreseeable future, think about where you will be using it, and what for. Ruby and Python will get you a lot further if you are looking beyond solely Mac desktop and iPhone.
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 learn will be applicable to most other languages and environments as an addition to your C++ experience. Ruby's object model is closer to that of Objective-C than is Python so I suggest also learning Ruby but not until you have your Objective-C skills down solidly. Note that you can use Objective-C++ and use C++ for all but your GUI code by having .mm suffixes on your files - this works on both iPhone and Mac. Given your C++ experience, that help you be productive. If you want to program iPhone, don't bother learning the new Objective-C 2.0 memory management but you can still use the Properties model (iPhone effectively has a subset of the Objective-C 2.0 runtime).
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 support available. In terms of the future, it seems like a lot of people are jumping on the Ruby bandwagon at the moment. Good luck.
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 applications? Future of what? "Can we program with these languages on other platforms? Or are these only limited on MAC?" Ruby and Python: Yes. These are designed to run on any platform that supports C. Objective-C: Yes. It's open source, it's in the GCC, it should work almost anywhere. Learning a new language is not a zero-sum game. You can learn more than one language; learning Objective-C now does not prevent you from learning Python or Ruby in the future.
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 not major. Objective-C, while not strictly confined to OS X, is only really used in OpenStep-based environments, which generally means OS X and the iPhone. The only Objective-C compiler I know of is gcc, and I imagine you can write Objective-C on Linux, but I don't know if Windows support is very good (if it exists). As for which is the language of the "future", all 3 (or 4) languages will be used very widely in the future. No one can really predict this kind of thing, and none of the languages are really going to die off (unless Apple switches to a new language as a "standard" for making Mac programs), so you'll be pretty safe with any of them. My advice: try them all out and see which one you think most suits your style, and learn that one.
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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++ developer. Not sure if i can recommend you to learn Ruby...
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 FUTURE??? Can we program with these languages on other platforms? Or are these only limited on MAC? I am just a beginner in objective-C.Need some expert thoughts which way to go. AC
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 control over this application, then I'd suggest changing this app to store its pid in files in some location where your script can find it.
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('ps') and parse the output because I think it is ugly (field sequence may be different in different OS). Target platforms are Solaris, HP-UX, and maybe others.
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('ps') and parse the output because I think it is ugly (field sequence may be different in different OS). Target platforms are Solaris, HP-UX, and maybe others.
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 should be fairly easy, honestly.
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('ps') and parse the output because I think it is ugly (field sequence may be different in different OS). Target platforms are Solaris, HP-UX, and maybe others.
Cross-platform way to get PIDs by process name in python
0.022219
0
0
78,794