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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
623,054 | 2009-03-08T04:44:00.000 | 3 | 0 | 1 | 0 | python,multithreading | 623,064 | 7 | false | 1 | 0 | It's usually simpler to make multiple concurrent processes. Simply use subprocess to create as many Popens as you feel it necessary to run concurrently.
There's no "optimal" number. Generally, when you run just one crawler, your PC spends a lot of time waiting. How much? Hard to say.
When you're running some small number of concurrent crawlers, you'll see that they take about the same amount of time as one. Your CPU switches among the various processes, filling up the wait time on one with work on the others.
You you run some larger number, you see that the overall elapsed time is longer because there's now more to do than your CPU can manage. So the overall process takes longer.
You can create a graph that shows how the process scales. Based on this you can balance the number of processes and your desirable elapsed time.
Think of it this way.
1 crawler does it's job in 1 minute. 100 pages done serially could take a 100 minutes. 100 crawlers concurrently might take on hour. Let's say that 25 crawlers finishes the job in 50 minutes.
You don't know what's optimal until you run various combinations and compare the results. | 3 | 3 | 0 | I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue. | For my app, how many threads would be optimal? | 0.085505 | 0 | 0 | 2,509 |
623,054 | 2009-03-08T04:44:00.000 | 1 | 0 | 1 | 0 | python,multithreading | 623,515 | 7 | false | 1 | 0 | One thing you should keep in mind is that some servers may interpret too many concurrent requests from the same IP address as a DoS attack and abort connections or return error pages for requests that would otherwise succeed.
So it might be a good idea to limit the number of concurrent requests to the same server to a relatively low number (5 should be on the safe side). | 3 | 3 | 0 | I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue. | For my app, how many threads would be optimal? | 0.028564 | 0 | 0 | 2,509 |
623,504 | 2009-03-08T12:34:00.000 | 1 | 0 | 0 | 0 | python,google-maps,s60,pys60 | 858,276 | 3 | false | 0 | 0 | No, you can't access it from a Python script or another S60 application because of platform security features of S60 3rd ed. Even if Google Maps application would write information to disk, your app is not able to access application specific files of other apps.
Google Maps use cell-based locationing in addition to GPS or when GPS is not available. Google hasn't released any 3rd party API to do these cell-tower to lat-long conversions. | 1 | 1 | 0 | I want to fetch my current latitude/longitude from Google Maps Mobile 3.0 with the help of some script, which I guess could be a Python one. Is this possible? And, more importantly: is the Google Maps Mobile API designed for such interaction? Any legal issues?
Basically i have a S60 phone that doesnt have GPS,and I have found that Google maintains its own database to link Cell IDs with lat/longs so that depending on what Cell ID I am nearest to, it can approximate my current location. So only Cel ID info from the operator won't tell me where i am on Earth until such a linking between Cell ID and latitude/longitude is available (for which I am thinking of seeking help of GMM; of course, if it provides for this...).
Secondly, the GMM 3.0 pushes my current latitude/longitude to the iGoogle Latitude gadget... so there should be some way by which I can fetch the same info by my custom gadget/script, right? | Retrieving the latitude/longitude from Google Map Mobile 3.0's MyLocation feature | 0.066568 | 0 | 0 | 948 |
624,050 | 2009-03-08T18:26:00.000 | 1 | 0 | 0 | 0 | python,qt,wxpython,pyqt | 624,282 | 4 | false | 0 | 1 | As far as I understand EVT_IDLE is sent when application message queue is empty. There is no such event in Qt, but if you need to execute something in Qt when there are no pending events, you should use QTimer with 0 timeout. | 2 | 2 | 0 | wx (and wxPython) has two events I miss in PyQt:
EVT_IDLE that's being sent to a frame. It can be used to update the various widgets according to the application's state
EVT_UPDATE_UI that's being sent to a widget when it has to be repainted and updated, so I can compute its state in the handler
Now, PyQt doesn't seem to have these, and the PyQt book suggests writing an updateUi method and calling it manually. I even ended up calling it from a timer once per 0.1 seconds, in order to avoid many manual calls from methods that may update the GUI. Am I missing something? Is there a better way to achieve this?
An example: I have a simple app with a Start button that initiates some processing. The start button should be enabled only when a file has been opened using the menu. In addition, there's a permanent widget on the status bar that displays information.
My application has states:
Before the file is opened (in this state the status bar show something special and the start button is disabled)
File was opened and processing wasn't started: the start button is enabled, status bar shows something else
The processing is running: the start button now says "Stop", and the status bar reports progress
In Wx, I'd have the update UI event of the button handle its state: the text on it, and whether it's enabled, depending on the application state. The same for the status bar (or I'd use EVT_IDLE for that).
In Qt, I have to update the button in several methods that may affect the state, or just create a update_ui method and call it periodically in a timer. What is the more "QT"-ish way? | wx's idle and UI update events in PyQt | 0.049958 | 0 | 0 | 2,691 |
624,050 | 2009-03-08T18:26:00.000 | 5 | 0 | 0 | 0 | python,qt,wxpython,pyqt | 624,734 | 4 | true | 0 | 1 | The use of EVT_UPDATE_UI in wxWidgets seems to highlight one of the fundamental differences in the way wxWidgets and Qt expect developers to handle events in their code.
With Qt, you connect signals and slots between widgets in the user interface, either handling "business logic" in each slot or delegating it to a dedicated method. You typically don't worry about making separate changes to each widget in your GUI because any repaint requests will be placed in the event queue and delivered when control returns to the event loop. Some paint events may even be merged together for the sake of efficiency.
So, in a normal Qt application where signals and slots are used to handle state changes, there's basically no need to have an idle mechanism that monitors the state of the application and update widgets because those updates should occur automatically.
You would have to say a bit more about what you are doing to explain why you need an equivalent to this event in Qt. | 2 | 2 | 0 | wx (and wxPython) has two events I miss in PyQt:
EVT_IDLE that's being sent to a frame. It can be used to update the various widgets according to the application's state
EVT_UPDATE_UI that's being sent to a widget when it has to be repainted and updated, so I can compute its state in the handler
Now, PyQt doesn't seem to have these, and the PyQt book suggests writing an updateUi method and calling it manually. I even ended up calling it from a timer once per 0.1 seconds, in order to avoid many manual calls from methods that may update the GUI. Am I missing something? Is there a better way to achieve this?
An example: I have a simple app with a Start button that initiates some processing. The start button should be enabled only when a file has been opened using the menu. In addition, there's a permanent widget on the status bar that displays information.
My application has states:
Before the file is opened (in this state the status bar show something special and the start button is disabled)
File was opened and processing wasn't started: the start button is enabled, status bar shows something else
The processing is running: the start button now says "Stop", and the status bar reports progress
In Wx, I'd have the update UI event of the button handle its state: the text on it, and whether it's enabled, depending on the application state. The same for the status bar (or I'd use EVT_IDLE for that).
In Qt, I have to update the button in several methods that may affect the state, or just create a update_ui method and call it periodically in a timer. What is the more "QT"-ish way? | wx's idle and UI update events in PyQt | 1.2 | 0 | 0 | 2,691 |
624,062 | 2009-03-08T18:34:00.000 | 4 | 0 | 1 | 0 | asp.net,python | 624,119 | 3 | false | 1 | 0 | I second the note by Out Into Space on how python is a language versus a web framework; it's an important observation that underlies pretty much everything you will experience in moving from ASP.NET to Python.
On a similar note, you will also find that the differences in language style and developer community between C#/VB.NET and Python influence the basic approach to developing web frameworks. This would be the same whether you were moving from web frameworks written in java, php, ruby, perl or any other language for that matter.
The old "when you have a hammer, everything looks like a nail" adage really shows in the basic design of the frameworks :-) Because of this, though, you will find yourself with a few paradigm shifts to make when you substitute that hammer for a screwdriver.
For example, Python web frameworks rely much less on declarative configuration than ASP.NET. Django, for example, has only a single config file that really has only a couple dozen lines (once you strip out the comments :-) ). Similarly, URL configuration and the page lifecycle are quite compact compared to ASP.NET, while being just as powerful. There's more "convention" over configuration (though much less so that Rails), and heavy use of the fact that modules in Python are top-level objects in the language... not everything has to be a class. This cuts down on the amount of code involved, and makes the application flow highly readable.
As Out Into Space mentioned, zope's page templates are "somewhat" similar to ASP.NET master page, but not exactly. Django also offers page templates that inherit from each other, and they work very well, but not if you're trying to use them like an ASP.NET template.
There also isn't a tradition of user controls in Python web frameworks a la .NET. The configuration machinery, request/response process indirection, handler complexity, and code-library size is just not part of the feel that python developers have for their toolset.
We all argue that you can build the same web application, with probably less code, and more easily debuggable/maintainable using pythonic-tools :-) The main benefit here being that you also get to take advantage of the python language, and a pythonic framework, which is what makes python developers happy to go to work in the morning. YMMV, of course.
All of which to say, you'll find you can do everything you've always done, just differently. Whether or not the differences please or frustrate you will determine if a python web framework is the right tool for you in the long run. | 2 | 3 | 0 | I'm thinking about converting an app from Asp.net to python. I would like to know: what are the key comparisons to be aware of when moving a asp.net app to python(insert framework)?
Does python have user controls? Master pages? | What should I be aware of when moving from asp.net to python for web development? | 0.26052 | 0 | 0 | 390 |
624,062 | 2009-03-08T18:34:00.000 | 0 | 0 | 1 | 0 | asp.net,python | 637,273 | 3 | false | 1 | 0 | Most frameworks for python has a 'templating' engine which provide similar functionality of ASP.NET's Master pages and User Controls. :)
Thanks for the replies Out Of Space and Jarret Hardie | 2 | 3 | 0 | I'm thinking about converting an app from Asp.net to python. I would like to know: what are the key comparisons to be aware of when moving a asp.net app to python(insert framework)?
Does python have user controls? Master pages? | What should I be aware of when moving from asp.net to python for web development? | 0 | 0 | 0 | 390 |
624,345 | 2009-03-08T21:37:00.000 | 1 | 0 | 0 | 0 | python,html,css,pygments | 624,717 | 4 | false | 1 | 0 | Pass full=True to the HtmlFormatter constructor. | 1 | 1 | 0 | If I run a python source file through pygments, it outputs html code whose elements class belong to some CSS file pygments is using. Could the style attributes be included in the outputted html so that I don't have to provide a CSS file? | How can I customize the output from pygments? | 0.049958 | 0 | 0 | 3,304 |
624,535 | 2009-03-08T23:22:00.000 | 4 | 0 | 0 | 0 | python,django,django-admin,styles,look-and-feel | 625,235 | 2 | true | 1 | 0 | Are you sure you want to take every bit of admin-site's look & feel??
I think you would need to customize some, as in header footer etc.
To do that, just copy base.html from
"djangosrc/contrib/admin/templates/admin/"
and keep it in
"your_template_dir/admin/base.html" or
"your_template_dir/admin/mybase.html"
Just change whatever HTML you want to customize and keep rest as it is (like CSS and Javascript) and keep on extending this template in other templates of your application. Your view should provide what it needs to render (take a look at any django view from source) and you'll have everything what admin look & feel had. More you can do by extending base_site.html in same manner.
(Note: if you keep the name
'base.html' the changes made in
html will affect Django Admin too.
As this is the way we change how
Django Admin look itself.) | 1 | 1 | 0 | I like the very simple but still really elegant look and feel of the django admin and I was wondering if there is a way to apply it to my own application.
(I think that I've read something like that somewhere, but now I cannot find the page again.)
(edited: what I am looking for is a way to do it automatically by extending templates, importing modules, or something similar, not just copy&paste the css and javascript code) | Using Django admin look and feel in my own application | 1.2 | 0 | 0 | 1,834 |
624,844 | 2009-03-09T02:42:00.000 | 24 | 0 | 0 | 0 | python,signals,django-signals | 624,865 | 4 | true | 1 | 0 | Actually, "signals" have been around longer than events have. In the earliest usage, a signal was an asynchronous way for processes to get notified that events had occurred. Since Unix is much older than Django (and since a lot of the Django work came from pydispatcher, where the original stuff was done), the name has stuck.
Events are really signals, you might say! | 3 | 4 | 0 | From what I can tell, in Python and and Django, signals are simply delegated events. Is there anything that functionally differentiates them from the typical notion of events in C#, Java, ActionScript, etc? | Why aren't signals simply called events? | 1.2 | 0 | 0 | 676 |
624,844 | 2009-03-09T02:42:00.000 | 1 | 0 | 0 | 0 | python,signals,django-signals | 624,860 | 4 | false | 1 | 0 | You might as well ask "Why aren't events simply called signals?". Differences in terminology happen. | 3 | 4 | 0 | From what I can tell, in Python and and Django, signals are simply delegated events. Is there anything that functionally differentiates them from the typical notion of events in C#, Java, ActionScript, etc? | Why aren't signals simply called events? | 0.049958 | 0 | 0 | 676 |
624,844 | 2009-03-09T02:42:00.000 | 4 | 0 | 0 | 0 | python,signals,django-signals | 624,855 | 4 | false | 1 | 0 | Signals typically have an association with an operating system facility and events are typically application-defined. In some technology stacks, the OS-level stuff may be hidden well enough that there isn't a difference in the API, but in others perhaps not. | 3 | 4 | 0 | From what I can tell, in Python and and Django, signals are simply delegated events. Is there anything that functionally differentiates them from the typical notion of events in C#, Java, ActionScript, etc? | Why aren't signals simply called events? | 0.197375 | 0 | 0 | 676 |
625,042 | 2009-03-09T04:43:00.000 | 1 | 0 | 1 | 1 | python,google-app-engine | 625,632 | 4 | false | 1 | 0 | The app.yaml syntax already supports multiple languages and multiple API versions, though only one of each (Python, API version 1) is currently supported. Presumably, one of those extension mechanisms will be used to specify that you want Python 3, and it'll be up to you to port your app over to work in Python 3, then change that setting. | 2 | 9 | 0 | What is required to make the transition to Python 3.x for Google App Engine?
I know Google App Engine requires the use of at least Python 2.5.
Is it possible to use Python 3.0 already on Google App Engine? | What will be the upgrade path to Python 3.x for Google App Engine Applications? | 0.049958 | 0 | 0 | 4,490 |
625,042 | 2009-03-09T04:43:00.000 | 1 | 0 | 1 | 1 | python,google-app-engine | 625,130 | 4 | false | 1 | 0 | At least at the being, Guido was working closely with the team at Google who is building AppEngine. When this option does become available, you will have to edit your main XAML file.
I agree with Chris B. that Python 3.0 support may not be forthcoming too soon, but I'm not sure I agree that it will come sooner than Perl or PHP. At the Google I/O conference last year, they were very mum on what future languages they would support on AppEngine but they were pretty clear on the fact that they're actively exploring how to safely allow other code to run. One of the main reason they chose to support Python is that they due to it's dynamically compiled nature, they could support 3rd party library extensions with the minimal restriction that all add-ons must be in pure Python.
I wouldn't be surprised if Python 3.0 support was introduced sooner than new languages. | 2 | 9 | 0 | What is required to make the transition to Python 3.x for Google App Engine?
I know Google App Engine requires the use of at least Python 2.5.
Is it possible to use Python 3.0 already on Google App Engine? | What will be the upgrade path to Python 3.x for Google App Engine Applications? | 0.049958 | 0 | 0 | 4,490 |
625,148 | 2009-03-09T05:49:00.000 | 4 | 1 | 0 | 0 | python,gmail,pop3,poplib | 625,175 | 3 | true | 0 | 0 | POP3 has no concept of 'folders'. If gmail is showing you both 'sent' as well as 'received' mail, then you really don't have any option but to receive all that email.
Perhaps you would be better off using IMAP4 instead of POP3. Python has libraries that will work with gmail's IMAP4 server. | 1 | 2 | 0 | I need to download emails from the gmail inbox only using poplib.Unfortunately I do not see any option to select Inbox alone, and poplib gives me emails from sent items too.
How do I select emails only from inbox?
I dont want to use any gmail specific libraries. | Select mails from inbox alone via poplib | 1.2 | 0 | 1 | 2,392 |
625,314 | 2009-03-09T07:49:00.000 | 8 | 0 | 0 | 1 | python,google-app-engine,memcached | 626,559 | 5 | true | 1 | 0 | People ask for this on the memcached list a lot, sometimes with the same type of "just in case I want to look around to debug something" sentiment.
The best way to handle this is to know how you generate your keys, and just go look stuff up when you want to know what's stored for a given value.
If you have too many things using memcached to do that within the scope of your debugging session, then start logging access.
But keep in mind -- memcached is fast because it doesn't allow for such things in general. The community server does have limited functionality to get a subset of the keys available within a given slab class, but it's probably not what you really want, and hopefully google doesn't implement it in theirs. :) | 4 | 1 | 0 | In the "Memcache Viewer", is there any way to dump a list of existing keys? Just for debugging, of course, not for use in any scripts!
I ask because it doesn't seem like the GAE SDK is using a "real" memcache server, so I'm guessing it's emulated in Python (for simplicity, as it's just a development server).. This would mean there is a dict somewhere with the keys/values.. | Dump memcache keys from GAE SDK Console? | 1.2 | 0 | 0 | 2,662 |
625,314 | 2009-03-09T07:49:00.000 | 4 | 0 | 0 | 1 | python,google-app-engine,memcached | 625,331 | 5 | false | 1 | 0 | No. I did not found such functionality in memcached too.
Thinking about this issue, I found this limitation understandable - it would require keeping a registry of keys with all related problems like key expiration, invalidation and of course locking. Such system would not be as fast as memcaches are intended to be. | 4 | 1 | 0 | In the "Memcache Viewer", is there any way to dump a list of existing keys? Just for debugging, of course, not for use in any scripts!
I ask because it doesn't seem like the GAE SDK is using a "real" memcache server, so I'm guessing it's emulated in Python (for simplicity, as it's just a development server).. This would mean there is a dict somewhere with the keys/values.. | Dump memcache keys from GAE SDK Console? | 0.158649 | 0 | 0 | 2,662 |
625,314 | 2009-03-09T07:49:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,memcached | 626,458 | 5 | false | 1 | 0 | Memcache is designed to be quick and there's no convincing use case for this functionality
which would justify the overhead required for a command that is so at odds with the rest of memcached.
The GAE SDK is simulating memcached, so it doesn't offer this functionality either. | 4 | 1 | 0 | In the "Memcache Viewer", is there any way to dump a list of existing keys? Just for debugging, of course, not for use in any scripts!
I ask because it doesn't seem like the GAE SDK is using a "real" memcache server, so I'm guessing it's emulated in Python (for simplicity, as it's just a development server).. This would mean there is a dict somewhere with the keys/values.. | Dump memcache keys from GAE SDK Console? | 0 | 0 | 0 | 2,662 |
625,314 | 2009-03-09T07:49:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,memcached | 660,458 | 5 | false | 1 | 0 | The easiest way that I could think of, would be to maintain a memcache key at a known ID, and then append to it every time you insert a new key. This way you could just query for the single key to get a list of existing keys. | 4 | 1 | 0 | In the "Memcache Viewer", is there any way to dump a list of existing keys? Just for debugging, of course, not for use in any scripts!
I ask because it doesn't seem like the GAE SDK is using a "real" memcache server, so I'm guessing it's emulated in Python (for simplicity, as it's just a development server).. This would mean there is a dict somewhere with the keys/values.. | Dump memcache keys from GAE SDK Console? | 0 | 0 | 0 | 2,662 |
625,614 | 2009-03-09T09:57:00.000 | 5 | 0 | 0 | 0 | iis,web-config,application-pool,python-idle | 627,740 | 3 | true | 1 | 0 | Not in IIS 6. In IIS 6, Application Pools are controlled by Worker Processes, which map to a Request Queue handled by HTTP.sys. HTTP.sys handles the communication with the WWW Server to determine when to start and stop Worker Processes.
Since IIS 6 was created before .Net, there's no communication hooks between .Net and the low-level http handlers.
ASP.net is implimented as an ISAPI filter, which is loaded by the Worker Process itself. You have a chicken-before-the-egg issue if you are looking at the web.config controlling a worker process. This is primarily why MS did the major re-write of IIS 7 which integrates .Net through the entire request life-cycle, not just the ISAPI filter portion. | 1 | 15 | 0 | I know one can set the session timeout. But, if the application itself has received no requests for a given period of time, IIS shuts down the application.
This behavior is configurable in the IIS management console, and I know how to do this. Still, I wonder if it is possible to configure this in web.config. | Is there a way to configure the Application Pool's "Idle timeout" in web.config? | 1.2 | 0 | 0 | 13,542 |
626,759 | 2009-03-09T15:41:00.000 | 1 | 0 | 1 | 0 | python,list,tuples | 63,424,888 | 23 | false | 0 | 0 | Just a quick extension to list vs tuple responses:
Due to dynamic nature, list allocates more bit buckets than the actual memory required. This is done to prevent costly reallocation operation in case extra items are appended in the future.
On the other hand, being static, lightweight tuple object does not reserve extra memory required to store them. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | 0.008695 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | -1 | 0 | 1 | 0 | python,list,tuples | 68,077,098 | 23 | false | 0 | 0 | Along with a lot of the other comments made here the benefit I see in the use of tuples is the flexibility in their being able to have values of different types UNLIKE a list.
Take for example a database table with different values and types designated for each column. A list couldn't replicate this at all (because of its restriction to a singular type of value that it can contain) whereas Tuple can have multiple different types and values with their placements respected for each column (and can even be placed within a list creating your own virtual representation of a database).
That flexibility and restriction (because values cannot be changed)also has its benefits say for the transmission of transaction data (or say something similar to the format of a table). You "seal" the data in the Tuple preventing it from being modifiable before you send protecting it because of what it is designed to do: provide immutability. What difference is this compared to a readonly collection? The fact that you can have different value types.
The applications of it (because of the great use of lists, objects and dictionaries in general) are limited with people generally being of the mindset that an object model would serve as a better option (and in certain cases does), but say you don't want an object model because you prefer to keep that separate to what you have defined as your business entities. Then a tuple might serve you well in what you are trying to achieve. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | -0.008695 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | 0 | 0 | 1 | 0 | python,list,tuples | 66,390,274 | 23 | false | 0 | 0 | Lists are mutable. whereas tuples are immutable. Accessing an offset element with index makes more sense in tuples than lists, Because the elements and their index cannot be changed. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | 0 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | 215 | 0 | 1 | 0 | python,list,tuples | 627,165 | 23 | false | 0 | 0 | If you went for a walk, you could note your coordinates at any instant in an (x,y) tuple.
If you wanted to record your journey, you could append your location every few seconds to a list.
But you couldn't do it the other way around. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | 1 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | 6 | 0 | 1 | 0 | python,list,tuples | 627,901 | 23 | false | 0 | 0 | Lists are intended to be homogeneous sequences, while tuples are heterogeneous data structures. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | 1 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | 8 | 0 | 1 | 0 | python,list,tuples | 16,960,687 | 23 | false | 0 | 0 | The values of list can be changed any time but the values of tuples can't be change.
The advantages and disadvantages depends upon the use. If you have such a data which you never want to change then you should have to use tuple, otherwise list is the best option. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | 1 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | 18 | 0 | 1 | 0 | python,list,tuples | 16,097,958 | 23 | false | 0 | 0 | Lists are for looping, tuples are for structures i.e. "%s %s" %tuple.
Lists are usually homogeneous, tuples are usually heterogeneous.
Lists are for variable length, tuples are for fixed length. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | 1 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | -1 | 0 | 1 | 0 | python,list,tuples | 26,128,173 | 23 | false | 0 | 0 | List is mutable and tuples is immutable. The main difference between mutable and immutable is memory usage when you are trying to append an item.
When you create a variable, some fixed memory is assigned to the variable. If it is a list, more memory is assigned than actually used. E.g. if current memory assignment is 100 bytes, when you want to append the 101th byte, maybe another 100 bytes will be assigned (in total 200 bytes in this case).
However, if you know that you are not frequently add new elements, then you should use tuples. Tuples assigns exactly size of the memory needed, and hence saves memory, especially when you use large blocks of memory. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | -0.008695 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | 1 | 0 | 1 | 0 | python,list,tuples | 36,495,737 | 23 | false | 0 | 0 | First of all, they both are the non-scalar objects (also known as a compound objects) in Python.
Tuples, ordered sequence of elements (which can contain any object with no aliasing issue)
Immutable (tuple, int, float, str)
Concatenation using + (brand new tuple will be created of course)
Indexing
Slicing
Singleton (3,) # -> (3) instead of (3) # -> 3
List (Array in other languages), ordered sequence of values
Mutable
Singleton [3]
Cloning new_array = origin_array[:]
List comprehension [x**2 for x in range(1,7)] gives you
[1,4,9,16,25,36] (Not readable)
Using list may also cause an aliasing bug (two distinct paths
pointing to the same object). | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | 0.008695 | 0 | 0 | 443,616 |
626,759 | 2009-03-09T15:41:00.000 | 86 | 0 | 1 | 0 | python,list,tuples | 626,768 | 23 | false | 0 | 0 | The key difference is that tuples are immutable. This means that you cannot change the values in a tuple once you have created it.
So if you're going to need to change the values use a List.
Benefits to tuples:
Slight performance improvement.
As a tuple is immutable it can be used as a key in a dictionary.
If you can't change it neither can anyone else, which is to say you don't need to worry about any API functions etc. changing your tuple without being asked. | 10 | 1,120 | 0 | What's the difference between tuples/lists and what are their advantages/disadvantages? | What's the difference between lists and tuples? | 1 | 0 | 0 | 443,616 |
626,796 | 2009-03-09T15:48:00.000 | 3 | 0 | 1 | 0 | python,windows,application-data,common-files | 627,071 | 6 | false | 0 | 0 | You can access all of your OS environment variables using the os.environ dictionary in the os module. Choosing which key to use from that dictionary could be tricky, though. In particular, you should remain aware of internationalized (i.e., non-English) versions of Windows when using these paths.
os.environ['ALLUSERSPROFILE'] should give you the root directory for all users on the computer, but after that be careful not to hard code subdirectory names like "Application Data," because these directories don't exist on non-English versions of Windows. For that matter, you may want to do some research on what versions of Windows you can expect to have the ALLUSERSPROFILE environment variable set (I don't know myself -- it may be universal).
My XP machine here has a COMMONAPPDATA environment variable which points to the All Users\Application Data folder, but my Win2K3 system does not have this environment variable. | 1 | 31 | 0 | I would like my application to store some data for access by all users. Using Python, how can I find where the data should go? | How do I find the Windows common application data folder using Python? | 0.099668 | 0 | 0 | 60,928 |
628,192 | 2009-03-09T21:58:00.000 | 0 | 0 | 1 | 0 | python,data-structures | 20,666,684 | 7 | false | 1 | 0 | Do you have the possibility of using Jython? I just mention it because using TreeMap, TreeSet, etc. is trivial. Also if you're coming from a Java background and you want to head in a Pythonic direction Jython is wonderful for making the transition easier. Though I recognise that use of TreeSet in this case would not be part of such a "transition".
For Jython superusers I have a question myself: the blist package can't be imported because it uses a C file which must be imported. But would there be any advantage of using blist instead of TreeSet? Can we generally assume the JVM uses algorithms which are essentially as good as those of CPython stuff? | 1 | 22 | 1 | Does anybody know if Python has an equivalent to Java's SortedSet interface?
Heres what I'm looking for: lets say I have an object of type foo, and I know how to compare two objects of type foo to see whether foo1 is "greater than" or "less than" foo2. I want a way of storing many objects of type foo in a list L, so that whenever I traverse the list L, I get the objects in order, according to the comparison method I define.
Edit:
I guess I can use a dictionary or a list and sort() it every time I modify it, but is this the best way? | Python equivalent to java.util.SortedSet? | 0 | 0 | 0 | 9,278 |
628,903 | 2009-03-10T04:05:00.000 | 2 | 0 | 1 | 0 | python,performance,iterator | 628,978 | 9 | false | 0 | 0 | An iterator is simply an object that provides methods to allow traversing through a collection. You could traverse all of the elements of an array or all the nodes of a tree with the same interface. Trees and arrays are very different data structures and require different methods to traverse .. but with an iterator you can loop through all elements in the same way.
For one type of collection, there may also be different ways to traverse it and a single collection could have multiple iterators .. You could have a depth-first iterator or a breadth-first iterator traversing a tree structure and returning the nodes in different orders.
Iterators are not intended for performance ... but typically for providing a consistent interface for traversing structures. | 4 | 26 | 0 | What (if any) performance advantages are offered by using iterators. It seems like the 'Right Way' to solve many problems, but does it create faster/more memory-conscious code? I'm thinking specifically in Python, but don't restrict answers to just that. | Performance Advantages to Iterators? | 0.044415 | 0 | 0 | 19,830 |
628,903 | 2009-03-10T04:05:00.000 | 3 | 0 | 1 | 0 | python,performance,iterator | 734,050 | 9 | false | 0 | 0 | My inference from many answers above is "Use list to code. If necessary, re-factor using iterators" The difference is not apparent unless you have a large dataset.
Another thing to note is that, even when using lists often, the dataset we are operating upon is progressively smaller and smaller. | 4 | 26 | 0 | What (if any) performance advantages are offered by using iterators. It seems like the 'Right Way' to solve many problems, but does it create faster/more memory-conscious code? I'm thinking specifically in Python, but don't restrict answers to just that. | Performance Advantages to Iterators? | 0.066568 | 0 | 0 | 19,830 |
628,903 | 2009-03-10T04:05:00.000 | 2 | 0 | 1 | 0 | python,performance,iterator | 40,428,520 | 9 | false | 0 | 0 | There is one answer that I think confuses the concept of generator and iterator a little bit. So I decided to give a try answering this question with a metaphor example.
I'm working at a kitchen, my boss give me a task of adding up the weight of 10 (or 100 or a million) breads. I have a scale and a calculator( magic tricks of my algorithmn). Below are the iterable object, generator, iterator, approach difference:
Iterable object:
Each bread is stored in one box(memory), I weigh the first (or the 0th) bread, put down its weight, and put the bread back to the box, then go to the next one, weigh it and put it back, on and on, etc, etc. In the end, I got the overall weight, and the 10 (100 or million) breads are still there in their boxes.
Generator:
There are not enough boxes to store all these bread, So I asked for the help of a baker(the generator), he makes the first bread, give it to me, I weigh it, put the result down, throw that bread away and ask him for another one,on and on, etc, until I got the last bread (or maybe the baker runs out of flour). In the end, I have the result, none of the bread is there. But who cares, my boss only asks me to weigh these breads, he didn't say I cannot throw them away ( what a brilliant busboy).
Iterator:
I ask someone(iterator) to help me move first bread onto the scale, I weigh it, put the result down. This someone would go grab the next one for measuring, on and on, etc. I actually have no idea if someone (iterator) get the bread from a box or from a baker. Eventually, I got the overall weight, it doesn't matter to me.
Anyway, to sum up:
Iterable object need some memory to store data to start with.In the end, data is still there.
Generator wouldn't need memory to store data to start with, it generates data on the go.
Iterator is a channel between algorithm and its data. This data may already been there and stored in memory or may be generated on the go by a generator. In the first case, that memory would be freed bit by bit as iterator keeps iterating. So I agree a lot with above answer that iterator is good because of its abstraction that enables isolation of algorithm and data.
python doesn't exactly work like this. Hope it help clarify a little bit. | 4 | 26 | 0 | What (if any) performance advantages are offered by using iterators. It seems like the 'Right Way' to solve many problems, but does it create faster/more memory-conscious code? I'm thinking specifically in Python, but don't restrict answers to just that. | Performance Advantages to Iterators? | 0.044415 | 0 | 0 | 19,830 |
628,903 | 2009-03-10T04:05:00.000 | 13 | 0 | 1 | 0 | python,performance,iterator | 629,169 | 9 | false | 0 | 0 | Iterators will be faster and have better memory efficiency. Just think of an example of range(1000) vs xrange(1000). (This has been changed in 3.0, range is now an iterator.) With range you pre-build your list, but xrange is an iterator and yields the next item when needed instead.
The performance difference isn't great on small things, but as soon as you start cranking them out getting larger and larger sets of information you'll notice it quite quickly. Also, not just having to generate and then step through, you will be consuming extra memory for your pre-built item whereas with the iterator, only 1 item at a time gets made. | 4 | 26 | 0 | What (if any) performance advantages are offered by using iterators. It seems like the 'Right Way' to solve many problems, but does it create faster/more memory-conscious code? I'm thinking specifically in Python, but don't restrict answers to just that. | Performance Advantages to Iterators? | 1 | 0 | 0 | 19,830 |
629,696 | 2009-03-10T11:09:00.000 | 2 | 0 | 0 | 0 | python,django,deployment,google-analytics | 629,888 | 10 | false | 1 | 0 | I mostly agree with Ned, although I have a single setting called IS_LIVE_SITE which toggles analytics code, adverts and a few other things. This way I can keep all the keys in subversion (as it is a pain to look them up) and still toggle them on or off easily. | 2 | 38 | 0 | We're about to deploy a new Django website, and we want to use Google Analytics to keep track of traffic on the site. However, we don't want all of the hits on development instances to contribute to the Google Analytics statistics.
There are a few ways we could deal with this:
have a configuration option in settings.py which the base template uses to decide whether or not to include the appropriate <script> elements,
maintain a branch which we pull into before deploying to the production server, which we ensure includes the <script> elements,
do something with Google Analytics to block hits to 127.0.0.1 or localhost, or
something else.
The first option seems the most sensible, but I'm not sure if it is. For example, would we have to start passing a google_analytics variable into all of our views?
What are your thoughts? | Deploying Google Analytics With Django | 0.039979 | 0 | 0 | 19,916 |
629,696 | 2009-03-10T11:09:00.000 | 2 | 0 | 0 | 0 | python,django,deployment,google-analytics | 633,029 | 10 | false | 1 | 0 | Instead of including the script tag directly in your html, just change the analytics javascript so it only runs if the href does not contain your prod site's name. This will work without any extra configuration. | 2 | 38 | 0 | We're about to deploy a new Django website, and we want to use Google Analytics to keep track of traffic on the site. However, we don't want all of the hits on development instances to contribute to the Google Analytics statistics.
There are a few ways we could deal with this:
have a configuration option in settings.py which the base template uses to decide whether or not to include the appropriate <script> elements,
maintain a branch which we pull into before deploying to the production server, which we ensure includes the <script> elements,
do something with Google Analytics to block hits to 127.0.0.1 or localhost, or
something else.
The first option seems the most sensible, but I'm not sure if it is. For example, would we have to start passing a google_analytics variable into all of our views?
What are your thoughts? | Deploying Google Analytics With Django | 0.039979 | 0 | 0 | 19,916 |
631,813 | 2009-03-10T19:08:00.000 | 0 | 0 | 1 | 0 | python,svn,distutils | 632,040 | 4 | false | 0 | 0 | Importing the setup script inside your package is silly (especially since it may no longer be present after your library is installed), but importing your library inside setup.py should be fine.
A separate text file would work too, but has the problem that you must install the text file with your package if you want to access the version number at runtime. | 1 | 4 | 0 | I'm writing a Python package. The package needs to know its version number internally, while also including this version in the setup.py script for distutils.
What's the best way of doing this, so that the version number doesn't need to be maintained in two separate places? I don't want to import the setup.py script from the rest of my library (that seems rather silly) and I don't want to import my library from the setup.py script (likewise). Ideally, I'd just set a keyword in svn and have that automatically substituted into the files, but that doesn't seem to be possible in svn. I could read a common text file containing the version number in both places--is this the best solution?
To clarify: I want to maintain the version number in one place. Yes, I could put a variable in the package, and again in the setup.py file. But then they'd inevitably get out of sync. | How do I assign a version number for a Python package using SVN and distutils? | 0 | 0 | 0 | 1,001 |
631,996 | 2009-03-10T19:52:00.000 | 5 | 0 | 1 | 0 | python,packaging | 632,051 | 3 | false | 0 | 0 | Isn't it easier, and cleaner, to just set an environment variable on your development machine, and test for os.environ['development_mode'] (or a setting of your choice)? | 1 | 1 | 0 | I tend to develop my apps in 'setup.py develop' -mode. I'd want the configuration to switch automagically on production mode when the program gets 'setup.py install'ed.
This can be done by poor hacks, like checking whether installation directory contains 'setup.py', but I wonder whether pkg_resources can do this for me somehow. | figure out whether python module is installed or in develop mode programmatically | 0.321513 | 0 | 0 | 218 |
632,730 | 2009-03-10T23:47:00.000 | 1 | 1 | 0 | 1 | python,c | 632,844 | 7 | false | 0 | 0 | If I was faced with a similar situation I'd ask myself a couple of questions:
Is there anything more important I could be working on?
Does Python bring anything to the table that is currently handled poorly by the current application?
Will this allow me to add functionality that was previously too difficult to implement?
Is this going to disrupt service in any way?
If I can't answer those satisfactorily, then I'd put off the rewrite. | 6 | 2 | 0 | I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start/stop) based on the UDP pkt exchange.
Now this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned? | What is the feasibility of porting a legacy C program to Python? | 0.028564 | 0 | 0 | 381 |
632,730 | 2009-03-10T23:47:00.000 | 0 | 1 | 0 | 1 | python,c | 634,093 | 7 | false | 0 | 0 | If this is an embedded program, then it might be a problem to port it since Python programs typically rely on the Python runtime and library, and those are fairly large. Especially when compared to a C program doing a well-defined task. Of course, it's likely you've already considered that aspect, but I wanted to mention it in the context of the question anyway, since I feel it's an important aspect when doing this type of comparison. | 6 | 2 | 0 | I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start/stop) based on the UDP pkt exchange.
Now this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned? | What is the feasibility of porting a legacy C program to Python? | 0 | 0 | 0 | 381 |
632,730 | 2009-03-10T23:47:00.000 | 1 | 1 | 0 | 1 | python,c | 632,740 | 7 | false | 0 | 0 | Assuming that you have control over the environment which this application will run, and that the performance of interpreted language (python) compared to a compiled one (C) can be ignored, I believe Python is a great choice for this. | 6 | 2 | 0 | I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start/stop) based on the UDP pkt exchange.
Now this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned? | What is the feasibility of porting a legacy C program to Python? | 0.028564 | 0 | 0 | 381 |
632,730 | 2009-03-10T23:47:00.000 | 4 | 1 | 0 | 1 | python,c | 632,788 | 7 | false | 0 | 0 | I'd say that if:
Your C code contains no platform specific requirements
You are sure speed is not going to be an issue going from C to python
You have a desire to not compile anymore
You would like to try utilise exception handling
You want to dabble in OO
You might choose to run on many platforms without porting
You are curious about dynamic typing
You want memory handled for you
You know or want to learn python
Then sure, why not.
There doesn't seem to be any technical reason you shouldn't use python here, so it's a preference in this case. | 6 | 2 | 0 | I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start/stop) based on the UDP pkt exchange.
Now this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned? | What is the feasibility of porting a legacy C program to Python? | 0.113791 | 0 | 0 | 381 |
632,730 | 2009-03-10T23:47:00.000 | 2 | 1 | 0 | 1 | python,c | 632,925 | 7 | false | 0 | 0 | Remember as well, you can leave parts of your program in C, turn them into Python modules and build python code around them - you don't need to re-write everything up-front. | 6 | 2 | 0 | I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start/stop) based on the UDP pkt exchange.
Now this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned? | What is the feasibility of porting a legacy C program to Python? | 0.057081 | 0 | 0 | 381 |
632,730 | 2009-03-10T23:47:00.000 | 1 | 1 | 0 | 1 | python,c | 632,935 | 7 | false | 0 | 0 | Yes, I think Python is a good choice, if all your platforms support it. Since this is a network program, I'm assuming the network is your runtime bottleneck? That's likely to still be the case in Python. If you really do need to speed it up, you can include your long-since-debugged, speedy C as Python modules. | 6 | 2 | 0 | I have a program in C that communicates via UDP with another program (in Java) and then does process manipulation (start/stop) based on the UDP pkt exchange.
Now this C program has been legacy and I want to convert it to Python - do you think Python will be a good choice for the tasks mentioned? | What is the feasibility of porting a legacy C program to Python? | 0.028564 | 0 | 0 | 381 |
633,086 | 2009-03-11T02:11:00.000 | 0 | 0 | 0 | 0 | python,objective-c,cocoa,macos,fullscreen | 633,718 | 4 | false | 0 | 1 | The two solutions posted so far apply to “real” full-screen, but it’s worth noting that many full-screen apps just put a window over the whole screen (or, as vasi points out, a whole screen). To be accurate, you’ll have to check both. | 1 | 2 | 0 | I am writing an IM client for Mac (in Python, but an Objective C / Cocoa solution here is fine). I want to detect whether or not the user is currently watching a movie or playing a game in the foreground, or doing anything else that takes up the entire screen. If so, I won't play a sound when a new IM comes in, but if not, I will play the sound.
How can I detect this? Is there some way to get the foreground window with Applescript and look at its dimensions? Or is there some other API call? | Detecting fullscreen on Mac | 0 | 0 | 0 | 1,606 |
633,127 | 2009-03-11T02:32:00.000 | 5 | 0 | 1 | 0 | python,variables | 21,862,978 | 10 | false | 0 | 0 | In my Python 2.7 interpreter, the same whos command that exists in MATLAB exists in Python. It shows the same details as the MATLAB analog (variable name, type, and value/data).
Note that in the Python interpreter, whos lists all variables in the "interactive namespace". | 3 | 352 | 0 | I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).
Is there a way, and how can I do that? | Viewing all defined variables | 0.099668 | 0 | 0 | 520,059 |
633,127 | 2009-03-11T02:32:00.000 | 437 | 0 | 1 | 0 | python,variables | 633,134 | 10 | false | 0 | 0 | A few things you could use:
dir() will give you the list of in scope variables:
globals() will give you a dictionary of global variables
locals() will give you a dictionary of local variables | 3 | 352 | 0 | I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).
Is there a way, and how can I do that? | Viewing all defined variables | 1 | 0 | 0 | 520,059 |
633,127 | 2009-03-11T02:32:00.000 | 16 | 0 | 1 | 0 | python,variables | 633,136 | 10 | false | 0 | 0 | globals(), locals(), vars(), and dir() may all help you in what you want. | 3 | 352 | 0 | I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).
Is there a way, and how can I do that? | Viewing all defined variables | 1 | 0 | 0 | 520,059 |
635,200 | 2009-03-11T16:00:00.000 | 0 | 0 | 1 | 0 | python,visual-studio-2005 | 635,266 | 3 | false | 0 | 0 | I recall, some time ago, giving IronPython a 'whirl' in VS2005. I ran into all kinds of 'esoteric' errors until I figured out that to compile and run I had to add the C++ libraries and tools of VS2005 as well (add/remove).
Maybe this is something similar ? | 1 | 0 | 0 | I am looking for the Visual Studio 2005 build of Python 2.4, 2.5 or 2.6, I also need the python2x_d.lib (the debug version of the .lib) since I embed the interpreter into my app and the python libs implicitly link to the python2x_d.lib with pragmas (grrr).
Any hints where I can find those builds ?
Regards,
Paul | Visual Studio 2005 Build of Python with Debug .lib | 0 | 0 | 0 | 788 |
635,419 | 2009-03-11T16:54:00.000 | 1 | 1 | 1 | 0 | python,documentation,documentation-generation | 22,247,361 | 5 | false | 0 | 0 | using doxypy filter with doxygen is a good thing also | 1 | 21 | 0 | What is out there on conventions and tools for documenting python source code? | code documentation for python | 0.039979 | 0 | 0 | 15,370 |
636,990 | 2009-03-12T00:53:00.000 | 6 | 0 | 0 | 0 | python,wxpython,pygame,playing-cards | 637,017 | 6 | true | 0 | 1 | If all you want is a GUI, wxPython should do the trick.
If you're looking to add sound, controller input, and take it beyond a simple card game, then you may want to use pygame. | 3 | 6 | 0 | I have been playing around with writing some simple card games in Python for fun and I would like to add a graphical user interface (GUI) to the games. Which library would you recommend for writing the GUI for a simple card game? | wxPython or pygame for a simple card game? | 1.2 | 0 | 0 | 5,022 |
636,990 | 2009-03-12T00:53:00.000 | 3 | 0 | 0 | 0 | python,wxpython,pygame,playing-cards | 640,064 | 6 | false | 0 | 1 | Generally, PyGame is the better option for coding games. But that's for the more common type of games - where things move on the screen and you must have a good "frame-rate" performance.
For something like a card game, however, I'd go with wxPython (or rather, PyQt). This is because a card game hasn't much in terms of graphics (drawing 2D card shapes on the screen is no harder in wx / PyQt than in PyGame). And on the other hand, you get lots of benefits from wx - like a ready-made GUI for interaction.
In Pygame you have to create a GUI yourself or wade through several half-baked libraries that do it for you. This actually makes sense for Pygame because when you create a game you usually want a GUI of your own, that fits the game's style. But for card games, most chances are that wx's standard GUI widgets will do the trick and will save you hours of coding. | 3 | 6 | 0 | I have been playing around with writing some simple card games in Python for fun and I would like to add a graphical user interface (GUI) to the games. Which library would you recommend for writing the GUI for a simple card game? | wxPython or pygame for a simple card game? | 0.099668 | 0 | 0 | 5,022 |
636,990 | 2009-03-12T00:53:00.000 | 1 | 0 | 0 | 0 | python,wxpython,pygame,playing-cards | 637,004 | 6 | false | 0 | 1 | I'd say pygame -- I've heard it's lots of fun, easy and happy. Also, all of my experiences with wxPython have been sad an painful.
But I'm not bias or anything. | 3 | 6 | 0 | I have been playing around with writing some simple card games in Python for fun and I would like to add a graphical user interface (GUI) to the games. Which library would you recommend for writing the GUI for a simple card game? | wxPython or pygame for a simple card game? | 0.033321 | 0 | 0 | 5,022 |
637,295 | 2009-03-12T03:50:00.000 | 2 | 0 | 1 | 0 | python,whitespace | 638,131 | 17 | false | 0 | 0 | When I look at C and Java code, it's always nicely indented.
Always. Nicely. Indented.
Clearly, C and Java folks spend a lot of time getting their whitespace right.
So do Python programmers. | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0.023525 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 1 | 0 | 1 | 0 | python,whitespace | 639,671 | 17 | false | 0 | 0 | Pitfalls
It can be annoying posting code snippets on web sites that ignore your indentation.
Its hard to see how multi-line anonymous functions (lambdas) can fit in with the syntax of the language.
It makes it hard to embed Python in HTML files to make templates in the way that PHP or C# can be embedded in PHP or ASP.NET pages. But that's not necessarily the best way to design templates anyway.
If your editor does not have sensible commands for block indent and outdent it will be tedious to realign code.
Advantages
Forces even lazy programmers to produce legible code. I've seen examples of brace-language code that I had to spend hours reformatting to be able to read it...
Python programmers do not need to spend hours discussing whether braces should go at the ends of lines K&R style or on lines on their own in the Microsoft style.
Frees the brace characters for use for dictionary and set expressions.
Is automatically pretty legible | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0.011764 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 0 | 0 | 1 | 0 | python,whitespace | 639,262 | 17 | false | 0 | 0 | One drawback I experienced as a beginner whith python was forgetting to set softtabs in my editors gave me lots of trouble.
But after a year of serious use of the language I'm not able to write poorly indented code anymore in any other language. | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 1 | 0 | 1 | 0 | python,whitespace | 637,404 | 17 | false | 0 | 0 | I used to think that the white space issues was just a question of getting used to it.
Someone pointed out some serious flaws with Python indentation and I think they are quite valid and some subconcious understanding of these is what makes experienced programs nervious about the whole thing:-
Cut and paste just doesnt work anymore! You cannot cut boiler plate code from one app and drop it into another app.
Your editor becomes powerless to help you. With C/Jave etc. there are two things going on the "official" curly brackets indentation, and, the "unnofficial" white space indentation. Most editors are able reformat hte white space indentation to match the curly brackets nesting -- which gives you a string visual clue that something is wrong if the indentation is not what you expected. With pythons "space is syntax" paradigm your editor cannot help you.
The sheer pain of introducing another condition into already complex logic. Adding another if then else into an existing condition involves lots of silly error prone inserting of spaces on many lines line by hand.
Refactoring is a nightmare. Moving blocks of code around your classes is so painful its easier to put up with a "wrong" class structure than refactor it into a better one. | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0.011764 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 1 | 0 | 1 | 0 | python,whitespace | 638,534 | 17 | false | 0 | 0 | If you use Eclipse as your IDE, you should take a look at PyDev; it handles indentation and spacing automatically. You can copy-paste from mixed-spacing sources, and it will convert them for you. Since I started learning the language, I've never once had to think about spacing.
And it's really a non-issue; sane programmers indent anyway. With Python, you just do what you've always done, minus having to type and match braces. | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0.011764 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 0 | 0 | 1 | 0 | python,whitespace | 637,361 | 17 | false | 0 | 0 | The only trouble I've ever had is minor annoyances when I'm using code I wrote before I settled on whether I liked tabs or spaces, or cutting and posting code from a website.
I think most decent editors these days have a convert tabs-to-spaces and back option. Textmate certainly does.
Beyond that, the indentation has never caused me any trouble. | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 0 | 0 | 1 | 0 | python,whitespace | 639,767 | 17 | false | 0 | 0 | No, I would say that is one thing to which I can find no downfalls. Yes, it is no doubt irritating to some, but that is just because they have a different habit about their style of formatting. Learn it early, and it's gonna stick.
Just look how many discussions we have over a style matter in languages like C, Cpp, Java and such. You don't see those (useless, no doubt) discussions about languages like Python, F77, and some others mentioned here which have a "fixed" formatting style.
The only thing which is variable is spaces vs. tabs (can be changed with a little trouble with any good editor), and amount of spaces tab accounts for (can be changed with no trouble with any good editor). Voila ! Style discussion complete.
Now I can do something useful :) | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 2 | 0 | 1 | 0 | python,whitespace | 637,331 | 17 | false | 0 | 0 | That actually kept me away from Python for a while. Coming from a strong C background, I felt like I was driving without a seat belt.
It was aggravating when I was trying to fill up a snippet library in my editor with boilerplate, frequently used classes. I learn best by example, so I was grabbing as many interesting snippets as I could with the aim of writing a useful program while learning.
After I got in the habit of re-formatting everything that I borrowed, it wasn't so bad. But it still felt really awkward. I had to get used to a dynamically typed language PLUS indentation controlling my code.
It was quite a leap for me :) | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0.023525 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 0 | 0 | 1 | 0 | python,whitespace | 637,310 | 17 | false | 0 | 0 | The problem is that in Python, if you use spaces to indent basic blocks in one area of a file, and tabs to indent in another, you get a run-time error. This is quite different from semicolons in C.
This isn't really a programming question, though, is it? | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 0 | 0 | 1 | 0 | python,whitespace | 639,229 | 17 | false | 0 | 0 | If your using emacs, set a hard tab length of 8 and a soft tab length of 4. This way you will be alterted to any extraneous tab characters. You should always uses 4 spaces instead of tabs. | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 11 | 0 | 1 | 0 | python,whitespace | 637,309 | 17 | false | 0 | 0 | It can be confusing in some editors where one line is indented with spaces and the next is indented with a tab. This is confusing as the indentation looks the same but causes an error.
Also when your copying code, if your editor doesn't have a function to indent entire blocks, it could be annoying fixing all the indentation.
But with a good editor and a bit of practice, this shouldn't be a problem. I personally really like the way Python uses white space. | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 1 | 0 | 0 | 4,046 |
637,295 | 2009-03-12T03:50:00.000 | 1 | 0 | 1 | 0 | python,whitespace | 637,341 | 17 | false | 0 | 0 | Whitespace block delimiters force a certain amount of code formatting, which seems to irritate some programmers. Some in our shop seem to be of the attitude that they are too busy, or can't be bothered to pay attention to formatting standards, and a language that forces it rubs them raw. Sometimes the same folks gripe when others do not follow the same patterns of putting curly braces on a new line ;)
I find that Python code from the web is more commonly "readable", since this minor formatting requirement is in place. IMO, this requirement is a very useful feature.
IIRC, does not Haskell, OCaml (#light), and F# also use whitespace in the same fashion? For some reason, I have not seen any complaints about these languages. | 12 | 3 | 0 | At the moment I have never had a problem with whitespace in Python (although I've only used it in two projects and I was the only programmer). What are some potential pitfalls with whitespace and indentation in Python for someone learning the language? | Are there any pitfalls with using whitespace in Python? | 0.011764 | 0 | 0 | 4,046 |
638,150 | 2009-03-12T11:06:00.000 | 16 | 0 | 0 | 0 | python,ruby | 639,650 | 4 | false | 1 | 0 | Ruby gets more attention than Python simply because Ruby has one clear favourite when it comes to web apps while Python has traditionally had a very splintered approach (Zope, Plone, Django, Pylons, Turbogears). The critical mass of having almost all developers using one system as opposed to a variety of individual ones does a lot for improving documentation, finding and removing bugs, building hype and buzz, and so on.
In actual language terms the two are very similar in all but syntax, and Python is more popular generally. Python's perhaps been hindered by being popular in its own right before web frameworks became a big deal, making it harder for the community to agree to concentrate on any single approach. | 2 | 13 | 0 | I am in the field of data crunching and very soon might make a move to the world of web programming. Although I am fascinated both by Python and Ruby as both of them seem to be having every similar styles when it comes to writing business logic or data crunching logic.
But when I start googling for web development I start inclining towards Ruby on Rails my question is why is the web world obsessed with ruby on rails and active records so much?
There seem to be so many screencasts to learn Ruby on Rails and plethora of good books too
why is Python not able to pull the crowd when it comes to creating screencasts or ORM's like active record. | Ruby on Rails versus Python | 1 | 0 | 0 | 26,861 |
638,150 | 2009-03-12T11:06:00.000 | 3 | 0 | 0 | 0 | python,ruby | 639,045 | 4 | false | 1 | 0 | Ruby and Python have more similarities than differences; the same is true for Rails and Django, which are the leading web frameworks in the respective languages.
Both languages and both frameworks are likely to be rewarding to work with - in personal, "fun" terms at least - I don't know what the job markets are like in the specific areas.
There are some similar questions in StackOverflow: you could do worse than clicking around the "Related" list in the right-hand sidebar to get more feel.
Best thing is to get and try both: pick a small project and build it both ways. Decide which you like better and go for it! | 2 | 13 | 0 | I am in the field of data crunching and very soon might make a move to the world of web programming. Although I am fascinated both by Python and Ruby as both of them seem to be having every similar styles when it comes to writing business logic or data crunching logic.
But when I start googling for web development I start inclining towards Ruby on Rails my question is why is the web world obsessed with ruby on rails and active records so much?
There seem to be so many screencasts to learn Ruby on Rails and plethora of good books too
why is Python not able to pull the crowd when it comes to creating screencasts or ORM's like active record. | Ruby on Rails versus Python | 0.148885 | 0 | 0 | 26,861 |
638,272 | 2009-03-12T11:48:00.000 | 6 | 0 | 0 | 0 | .net,silverlight,multiplayer,python-stackless | 1,255,224 | 3 | false | 1 | 0 | I spent a year working on a massively multiplayer online game using Silverlight for the frontend and Python for the backend (I actually used IronPython in Silverlight so as to simplify development)
Silverlight is very well suited for this, I wouldn't do a serious online game in anything else. It already has 35% of the market, by the time you're done developing it should be high enough not to matter much anymore. For serious games, most people really won't mind installing a 4MB browser plugin. If you just want a little asteroids clone, use flash.
If I had to do it over, I think I would keep Python for the server, because it's the server technology I'm most skilled with, but I think I'd use C# on the frontend and use JSON for passing data.
The best advice I can give you is:
Make use of existing libraries and code as much as possible
Don't think about performance prematurely
The toughest part is going to be finishing the game, use technology you know well, and optimize for your time, not the code. Hopefully you can do what I could not - finish the damn game :)
Edit
Regarding why I'd use C# if I had to do it over:
IronPython had it's advantages and disadvantages. It was great that I could share code files (constants, models, etc) across server and client. Making a change and refreshing the browser to see it was awesome. Debugging was not as friendly as C#.
But in some ways it's a second class citizen to C#, data binding didn't work, and you can't use IronPython classes in xaml. Loading time was a problem, so I actually spent a great deal of effort to set up importing in parallel on background threads to speed it up. Because of the second citizen status where xaml is concerned, I used a template language to generate the xaml as if it were html, which actually worked out better than data binding, but no python template languages worked in IronPython, so I wrote my own (another time sink.)
To enable sharing models I had to write my own ORM. That was easy enough. But to transfer them I passed on JSON and made an optimized binary format instead that worked between IronPython and Python. That was another time sink.
In hindsight I shouldn't have gotten distracted by all those rabbit trails. | 1 | 4 | 0 | I'm thinking about developing online multiplayer social game. The shared state of the world would require something fast on the backend, so the potential solutions seem to be:
fast game engine on server (eg. c++ ) and some frontend language (php/python/ruby) + flash
whole stack in python (using twisted or stackless python) + flash
.NET (asp.net or asp.net mvc) + flash
.NET + silverlight
first one may be an overkill from productivity point of view (3 heterogenous layers)
Nr. 4 may be programmer's heaven (common environment on all layers), but:
No such thing has been ever built with Silverlight, maybe there are some showstoppers hiding around the corner
It may be hard to find silverlight designers
Despite Flash movie/clip model being criticized when compared to SL full OO architecture isn't it an advantage when it comes to designing extra parts of the virtual world by external designers? They can just prepare .swf with eg. 4 perspectives of an item on 4 frames - wouldn't it be harder with SL?
Silvelight apparently lacks in some gaming features (like collision detection)
what do you think?
[EDIT] The game itself would be part of the bigger portal - hence it would be nice to integrate the engine with some web framework. | Architecture for social multiplayer browser game (backend choice + frontend choice [flash/silverlight]) | 1 | 0 | 0 | 5,154 |
639,409 | 2009-03-12T16:22:00.000 | 1 | 1 | 0 | 0 | php,python | 639,435 | 5 | false | 1 | 0 | PHP is fine for either use in my opinion, the performance overheads are rarely noticed. It's usually other processes which will delay the program. It's easy to cache PHP programs with something like eAccelerator. | 3 | 5 | 0 | I'd like to have your opinion about writing web apps in PHP vs. a long-running process using tools such as Django or Turbogears for Python.
As far as I know:
- In PHP, pages are fetched from the hard-disk every time (although I assume the OS keeps files in RAM for a while after they've been accessed)
- Pages are recompiled into opcode every time (although tools from eg. Zend can keep a compiled version in RAM)
- Fetching pages every time means reading global and session data every time, and re-opening connections to the DB
So, I guess PHP makes sense on a shared server (multiple sites sharing the same host) to run apps with moderate use, while a long-running process offers higher performance with apps that run on a dedicated server and are under heavy use?
Thanks for any feedback. | PHP vs. long-running process (Python, Java, etc.)? | 0.039979 | 0 | 0 | 1,789 |
639,409 | 2009-03-12T16:22:00.000 | 3 | 1 | 0 | 0 | php,python | 639,537 | 5 | false | 1 | 0 | After you apply memcache, opcode caching, and connection pooling, the only real difference between PHP and other options is that PHP is short-lived, processed based, while other options are, typically, long-lived multithreaded based.
The advantage PHP has is that its dirt simple to write scripts. You don't have to worry about memory management (its always released at the end of the request), and you don't have to worry about concurrency very much.
The major disadvantage, I can see anyways, is that some more advanced (sometimes crazier?) things are harder: pre-computing results, warming caches, reusing existing data, request prioritizing, and asynchronous programming. I'm sure people can think of many more.
Most of the time, though, those disadvantages aren't a big deal. You can scale by adding more machines and using more caching. The average web developer doesn't need to worry about concurrency control or memory management, so taking the minuscule hit from removing them isn't a big deal. | 3 | 5 | 0 | I'd like to have your opinion about writing web apps in PHP vs. a long-running process using tools such as Django or Turbogears for Python.
As far as I know:
- In PHP, pages are fetched from the hard-disk every time (although I assume the OS keeps files in RAM for a while after they've been accessed)
- Pages are recompiled into opcode every time (although tools from eg. Zend can keep a compiled version in RAM)
- Fetching pages every time means reading global and session data every time, and re-opening connections to the DB
So, I guess PHP makes sense on a shared server (multiple sites sharing the same host) to run apps with moderate use, while a long-running process offers higher performance with apps that run on a dedicated server and are under heavy use?
Thanks for any feedback. | PHP vs. long-running process (Python, Java, etc.)? | 0.119427 | 0 | 0 | 1,789 |
639,409 | 2009-03-12T16:22:00.000 | 0 | 1 | 0 | 0 | php,python | 640,138 | 5 | false | 1 | 0 | As many others have noted, PHP nor Django are going to be your bottlenecks. Hitting the hard disk for the bytecode on PHP is irrelevant for a heavily trafficked site because caching will take over at that point. The same is true for Django.
Model/View and user experience design will have order of magnitude benefits to performance over the language itself. | 3 | 5 | 0 | I'd like to have your opinion about writing web apps in PHP vs. a long-running process using tools such as Django or Turbogears for Python.
As far as I know:
- In PHP, pages are fetched from the hard-disk every time (although I assume the OS keeps files in RAM for a while after they've been accessed)
- Pages are recompiled into opcode every time (although tools from eg. Zend can keep a compiled version in RAM)
- Fetching pages every time means reading global and session data every time, and re-opening connections to the DB
So, I guess PHP makes sense on a shared server (multiple sites sharing the same host) to run apps with moderate use, while a long-running process offers higher performance with apps that run on a dedicated server and are under heavy use?
Thanks for any feedback. | PHP vs. long-running process (Python, Java, etc.)? | 0 | 0 | 0 | 1,789 |
639,949 | 2009-03-12T18:41:00.000 | 1 | 0 | 0 | 0 | python,oracle,validation | 640,115 | 3 | false | 0 | 0 | The format of a date string that Oracle recognizes as a date is a configurable property of the database and as such it's considered bad form to rely on implicit conversions of strings to dates.
Typically Oracle dates format to 'DD-MON-YYYY' but you can't always rely on it being set that way.
Personally I would have the CMS write to this "attribute" table in a standard format like 'YYYY-MM-DD', and then whichever job moves that to a DATE column can explicitly cast the value with to_date( value, 'YYYY-MM-DD' ) and you won't have any problems. | 2 | 1 | 0 | Our Python CMS stores some date values in a generic "attribute" table's varchar column. Some of these dates are later moved into a table with an actual date column. If the CMS user entered an invalid date, it doesn't get caught until the migration, when the query fails with an "Invalid string date" error.
How can I use Python to make sure that all dates put into our CMS are valid Oracle string date representations? | Validating Oracle dates in Python | 0.066568 | 1 | 0 | 902 |
639,949 | 2009-03-12T18:41:00.000 | -1 | 0 | 0 | 0 | python,oracle,validation | 640,153 | 3 | false | 0 | 0 | Validate as early as possible. Why don't you store dates as dates in your Python CMS?
It is difficult to know what date a string like '03-04-2008' is. Is it 3 april 2008 or 4 march 2008? An American will say 4 march 2008 but a Dutch person will say 3 april 2008. | 2 | 1 | 0 | Our Python CMS stores some date values in a generic "attribute" table's varchar column. Some of these dates are later moved into a table with an actual date column. If the CMS user entered an invalid date, it doesn't get caught until the migration, when the query fails with an "Invalid string date" error.
How can I use Python to make sure that all dates put into our CMS are valid Oracle string date representations? | Validating Oracle dates in Python | -0.066568 | 1 | 0 | 902 |
640,191 | 2009-03-12T19:47:00.000 | 1 | 0 | 1 | 1 | python,linux | 640,292 | 6 | false | 0 | 0 | For what it's worth, Python 2.6 is available in the Portage tree for Gentoo, but it's hardmasked (that doesn't really count as stable) because apparently there are some programs that don't work with it. My guess is that if you had Gentoo, you could install Python 2.6 and get it to work, but it might not be smart to make it the default version (i.e. you'd want to keep Python 2.5 around as well). | 2 | 4 | 0 | I've heard ubuntu 9.4 will but it's still in alpha. Are there any stable distros that come with python 2.6 or at least don't depend on it so much so reinstalling python won't break anything? | Is there any linux distribution that comes with python 2.6 yet? | 0.033321 | 0 | 0 | 619 |
640,191 | 2009-03-12T19:47:00.000 | 4 | 0 | 1 | 1 | python,linux | 640,447 | 6 | false | 0 | 0 | openSUSE 11.1 ships Python 2.6 as standard. | 2 | 4 | 0 | I've heard ubuntu 9.4 will but it's still in alpha. Are there any stable distros that come with python 2.6 or at least don't depend on it so much so reinstalling python won't break anything? | Is there any linux distribution that comes with python 2.6 yet? | 0.132549 | 0 | 0 | 619 |
640,877 | 2009-03-12T23:26:00.000 | 15 | 0 | 0 | 0 | python,django,turbogears,turbogears2 | 703,311 | 8 | false | 1 | 0 | TG2 has several advantages that I think are important:
Multi-database support
sharding/data partitioning support
longstanding support for aggregates, multi-column primary keys
a transaction system that handles multi-database transactions for you
an admin system that works with all of the above
out of the box support for reusable template snipits
an easy method for creating reusable template tag-libraries
more flexibility in using non-standard components
There are more, but I think it's also important to know that Django has some advantages over TG2:
Larger, community, more active IRC channel
more re-usable app-components
a bit more developed documentation
All of this means that it's a bit easier to get started in Django than TG2, but I personally think the added power and flexibility that you get is worth it. But your needs may always be different. | 4 | 7 | 0 | Django is my favorite python web framework. I've tried out others like pylons, web2py, nevow and others.
But I've never looked into TurboGears with much enthusiasm.
Now with TG2 out of beta I may give it a try. I'd like to know what are some of the pros and cons compared to Django. | Can anyone point out the pros and cons of TG2 over Django? | 1 | 0 | 0 | 2,475 |
640,877 | 2009-03-12T23:26:00.000 | 5 | 0 | 0 | 0 | python,django,turbogears,turbogears2 | 1,387,123 | 8 | false | 1 | 0 | Pros.
SQLAlchemy > django ORM
Multiple template languages out of the box (genshi,mako,jinja2)
more WSGI friendly
Object Dispatch > routes > regexp routing. You can get the first 2 with TG2
Almost all components are optional you can keep the core and use any ORM, template, auth library, etc.
Sprox > django forms
Cons.
- Admin is more basic (no inline objects yet!)
- less third party apps
- "app" system still in the making.
- given it's modularity you need to read documentation from different sources (SQLAlchemy, Genshi or Mako, repoze.who, Pylons, etc.) | 4 | 7 | 0 | Django is my favorite python web framework. I've tried out others like pylons, web2py, nevow and others.
But I've never looked into TurboGears with much enthusiasm.
Now with TG2 out of beta I may give it a try. I'd like to know what are some of the pros and cons compared to Django. | Can anyone point out the pros and cons of TG2 over Django? | 0.124353 | 0 | 0 | 2,475 |
640,877 | 2009-03-12T23:26:00.000 | 0 | 0 | 0 | 0 | python,django,turbogears,turbogears2 | 642,874 | 8 | false | 1 | 0 | Last I checked, django has a very poor data implementation. And that's a huge weakness in my book. Django's orm doesn't allow me to use the power of the underlying database. For example I can't use compound primary keys, which are important to good db design. It also doesn't support more than a single database, which is not a big deal until you really need it and find that you can't do it without resorting to doing it manually. Lastly if you have to make changes to your database structure in a team-friendly way, you have to try to choose between a set of 3rd party migration tools.
Turbogears seems to be more architecturally sound, doing its best to integrate individual tools that are awesome in their own right. And because TG is more of an integrator, you're able to switch out pieces to suit your preferences. Don't like SQL Alchemy? You can use SQLObject. Don't like Genshi templates? You can use Mako or even django's, although you're not exactly stuck with the default on django either.
Time for tg2's cons:
TG has a much smaller community, and community usually has its benefit.
Django has a much better name. I really like that name ;-)
Django seems simpler for the beginning web developer, with pretty cool admin tools.
TG has decent documentation, but you also need to go to Genshi's site to learn Genshi, SQL Alchemy's site to learn that, etc. Django has great docs.
My 2 cents. | 4 | 7 | 0 | Django is my favorite python web framework. I've tried out others like pylons, web2py, nevow and others.
But I've never looked into TurboGears with much enthusiasm.
Now with TG2 out of beta I may give it a try. I'd like to know what are some of the pros and cons compared to Django. | Can anyone point out the pros and cons of TG2 over Django? | 0 | 0 | 0 | 2,475 |
640,877 | 2009-03-12T23:26:00.000 | 0 | 0 | 0 | 0 | python,django,turbogears,turbogears2 | 641,046 | 8 | false | 1 | 0 | Because Django uses its own ORM it limits you to learn that ORM for that specific web framework. I think using an web framework with a more popular ORM (like SqlAlchemy which TG uses) increases your employability chances. Just my 2 cents .. | 4 | 7 | 0 | Django is my favorite python web framework. I've tried out others like pylons, web2py, nevow and others.
But I've never looked into TurboGears with much enthusiasm.
Now with TG2 out of beta I may give it a try. I'd like to know what are some of the pros and cons compared to Django. | Can anyone point out the pros and cons of TG2 over Django? | 0 | 0 | 0 | 2,475 |
640,970 | 2009-03-13T00:09:00.000 | 7 | 0 | 0 | 0 | python,django,email | 641,004 | 6 | false | 1 | 0 | Generally:
1) Set up a dedicated email account for the purpose.
2) Have a programm monitor the mailbox (let's say fetchmail, since that's what I do).
3) When an email arrives at the account, fetchmail downloads the email, writes it to disk, and calls script or program you have written with the email file as an argument.
4) Your script or program parses the email and takes an appropriate action.
The part that's usually mysterious to people is the fetchmail part (#2).
Specifically on Mail Servers (iff you control the mailserver enough to redirect emails to scripts):
1-3) Configure an address to be piped to a script you have written.
4) Same as above. | 1 | 12 | 0 | I was wondering if someone could help me out. In some web application, the app will send out emails, say when a new message has been posted. Then instead of signing into the application to post a reply you can just simply reply to the email and it will automatically update the web app with your response.
My question is, how is this done and what is it called?
Thanks | Email integration | 1 | 0 | 0 | 1,824 |
641,770 | 2009-03-13T07:48:00.000 | 18 | 0 | 0 | 0 | python,opengl | 641,832 | 8 | true | 0 | 1 | If you are worried about 3D performance: Most of the performance-critical parts will be handled by OpenGL (in a C library or even in hardware), so the language you use to drive it should not matter too much.
To really find out if performance is a problem, you'd have to try it. But there is no reason why it cannot work in principle.
At any rate, you could still optimize the critical parts, either in Python or by dropping to C. You still gain Python's benefit for most of the game engine which is less performance-critical. | 2 | 16 | 0 | I am planning to write an simple 3d(isometric view) game in Java using jMonkeyEngine - nothing to fancy, I just want to learn something about OpenGL and writing efficient algorithms (random map generating ones).
When I was planning what to do, I started wondering about switching to Python. I know that Python didn't come into existence to be a tool to write 3d games, but is it possible to write good looking games with this language?
I have in mind 3d graphics, nice effects and free CPU time to power to rest of game engine? I had seen good looking java games - and too be honest, I was rather shocked when I saw level of detail achieved in Runescape HD.
On the other hand, pygame.org has only 2d games, with some starting 3d projects. Are there any efficient 3d game engines for python? Is pyopengl the only alternative? Good looking games in python aren't popular or possible to achieve?
I would be grateful for any information / feedback. | Can 3D OpenGL game written in Python look good and run fast? | 1.2 | 0 | 0 | 17,104 |
641,770 | 2009-03-13T07:48:00.000 | 1 | 0 | 0 | 0 | python,opengl | 645,987 | 8 | false | 0 | 1 | There was a Vampires game out a few years ago where most if not all of the code was in Python. Not sure if the 3D routines were in them, but it worked fine. | 2 | 16 | 0 | I am planning to write an simple 3d(isometric view) game in Java using jMonkeyEngine - nothing to fancy, I just want to learn something about OpenGL and writing efficient algorithms (random map generating ones).
When I was planning what to do, I started wondering about switching to Python. I know that Python didn't come into existence to be a tool to write 3d games, but is it possible to write good looking games with this language?
I have in mind 3d graphics, nice effects and free CPU time to power to rest of game engine? I had seen good looking java games - and too be honest, I was rather shocked when I saw level of detail achieved in Runescape HD.
On the other hand, pygame.org has only 2d games, with some starting 3d projects. Are there any efficient 3d game engines for python? Is pyopengl the only alternative? Good looking games in python aren't popular or possible to achieve?
I would be grateful for any information / feedback. | Can 3D OpenGL game written in Python look good and run fast? | 0.024995 | 0 | 0 | 17,104 |
642,853 | 2009-03-13T14:01:00.000 | -2 | 0 | 0 | 0 | python,coding-style,wxpython | 642,948 | 4 | false | 0 | 1 | Have you tried running your scripts with pythonw.exe instead of python.exe? | 2 | 3 | 0 | I noticed that my programs written with wxPython have Win98 button style.
But Boa Constructor (that is written using wxPython too) got pretty buttons.
How to make buttons look like current Windows buttons style? | WinXP button-style with wxPython | -0.099668 | 0 | 0 | 1,511 |
642,853 | 2009-03-13T14:01:00.000 | 0 | 0 | 0 | 0 | python,coding-style,wxpython | 841,710 | 4 | false | 0 | 1 | The answers so far handle distributing the package as an executable (eg. py2exe), where the answer has already been given.
But since (i think) python 2.6 you have the same problem when just starting the .py file from the commandline (Vista and Windows7). Robin Dunn suggested using update_manifest.py which he distributes with wxPython and puts it in the same directory as python.exe.
After applying update_manifest.py using a copied version of python.exe wxPython apps have the correct themed look and yes it also works using windows7 RC1. | 2 | 3 | 0 | I noticed that my programs written with wxPython have Win98 button style.
But Boa Constructor (that is written using wxPython too) got pretty buttons.
How to make buttons look like current Windows buttons style? | WinXP button-style with wxPython | 0 | 0 | 0 | 1,511 |
643,173 | 2009-03-13T15:14:00.000 | 0 | 0 | 1 | 0 | python,c,regex | 643,200 | 5 | false | 0 | 0 | Nested parenthesis cannot be described by a regexp and require a full parser (able to understand a grammar, which is something more powerful than a regexp). I do not think there is a solution. | 3 | 2 | 0 | I am converting some matlab code to C, currently I have some lines that have powers using the ^, which is rather easy to do with something along the lines \(?(\w*)\)?\^\(?(\w*)\)?
works fine for converting (glambda)^(galpha),using the sub routine in python pattern.sub(pow(\g<1>,\g<2>),'(glambda)^(galpha)')
My problem comes with nested parenthesis
So I have a string like:
glambdastar^(1-(1-gphi)*galpha)*(glambdaq)^(-(1-gphi)*galpha);
And I can not figure out how to convert that line to:
pow(glambdastar,(1-(1-gphi)*galpha))*pow(glambdaq,-(1-gphi)*galpha)); | regular expression help with converting exp1^exp2 to pow(exp1, exp2) | 0 | 0 | 0 | 288 |
643,173 | 2009-03-13T15:14:00.000 | 1 | 0 | 1 | 0 | python,c,regex | 643,252 | 5 | false | 0 | 0 | I think you can use recursion here.
Once you figure out the Left and Right parts, pass each of those to your function again.
The base case would be that no ^ operator is found, so you will not need to add the pow() function to your result string.
The function will return a string with all the correct pow()'s in place.
I'll come up with an example of this if you want. | 3 | 2 | 0 | I am converting some matlab code to C, currently I have some lines that have powers using the ^, which is rather easy to do with something along the lines \(?(\w*)\)?\^\(?(\w*)\)?
works fine for converting (glambda)^(galpha),using the sub routine in python pattern.sub(pow(\g<1>,\g<2>),'(glambda)^(galpha)')
My problem comes with nested parenthesis
So I have a string like:
glambdastar^(1-(1-gphi)*galpha)*(glambdaq)^(-(1-gphi)*galpha);
And I can not figure out how to convert that line to:
pow(glambdastar,(1-(1-gphi)*galpha))*pow(glambdaq,-(1-gphi)*galpha)); | regular expression help with converting exp1^exp2 to pow(exp1, exp2) | 0.039979 | 0 | 0 | 288 |
643,173 | 2009-03-13T15:14:00.000 | 2 | 0 | 1 | 0 | python,c,regex | 643,204 | 5 | false | 0 | 0 | Unfortunately, regular expressions aren't the right tool for handling nested structures. There are some regular expressions engines (such as .NET) which have some support for recursion, but most — including the Python engine — do not, and can only handle as many levels of nesting as you build into the expression (which gets ugly fast).
What you really need for this is a simple parser. For example, iterate over the string counting parentheses and storing their locations in a list. When you find a ^ character, put the most recently closed parenthesis group into a "left" variable, then watch the group formed by the next opening parenthesis. When it closes, use it as the "right" value and print the pow(left, right) expression. | 3 | 2 | 0 | I am converting some matlab code to C, currently I have some lines that have powers using the ^, which is rather easy to do with something along the lines \(?(\w*)\)?\^\(?(\w*)\)?
works fine for converting (glambda)^(galpha),using the sub routine in python pattern.sub(pow(\g<1>,\g<2>),'(glambda)^(galpha)')
My problem comes with nested parenthesis
So I have a string like:
glambdastar^(1-(1-gphi)*galpha)*(glambdaq)^(-(1-gphi)*galpha);
And I can not figure out how to convert that line to:
pow(glambdastar,(1-(1-gphi)*galpha))*pow(glambdaq,-(1-gphi)*galpha)); | regular expression help with converting exp1^exp2 to pow(exp1, exp2) | 0.07983 | 0 | 0 | 288 |
643,422 | 2009-03-13T16:05:00.000 | 2 | 1 | 0 | 0 | python,eclipse,formatting,word-wrap | 643,439 | 2 | false | 0 | 0 | Highlight the text, then press Ctrl-Shift-F, or open the context menu and select Source / Format. | 1 | 2 | 0 | I would like to auto-fill a paragraph to 80 characters (or some other fixed width) in Eclipse. Is this possible via a keyboard command like in Emacs? Or is there maybe a plugin (I did not find anything on google)?
Edit: I am not sure if this is relevant, but I need this for docstrings in Python code (using the PyDev plugin). | How can I auto-fill a paragraph in Eclipse? | 0.197375 | 0 | 0 | 1,354 |
643,565 | 2009-03-13T16:33:00.000 | 1 | 0 | 1 | 0 | javascript,python,gwt | 3,030,515 | 4 | false | 1 | 0 | yes it works fine on windows (it's a compiler: you just need python, to run the conversion to javascript). but if you're thinking of pyjamas-desktop, 0.6 added support for MSHTML as one of the engines, so that works too. | 2 | 18 | 0 | Has any one used this? I don't have a large background in Javascript and this lib looks like it may speed things along.
www.pyjs.org | Anyone use Pyjamas (pyjs) python to javascript compiler (like GWT..) | 0.049958 | 0 | 0 | 5,067 |
643,565 | 2009-03-13T16:33:00.000 | 10 | 0 | 1 | 0 | javascript,python,gwt | 730,960 | 4 | false | 1 | 0 | yep. me. i'm the lead developer. drop by on groups.google.com "pyjamas-dev" and say hello. | 2 | 18 | 0 | Has any one used this? I don't have a large background in Javascript and this lib looks like it may speed things along.
www.pyjs.org | Anyone use Pyjamas (pyjs) python to javascript compiler (like GWT..) | 1 | 0 | 0 | 5,067 |
644,073 | 2009-03-13T18:40:00.000 | 3 | 0 | 1 | 0 | python,alarm | 699,105 | 4 | false | 0 | 0 | The most robust solution is to use a subprocess, then kill that subprocess. Python2.6 adds .kill() to subprocess.Popen().
I don't think your threading approach works as you expect. Deleting your reference to the Thread object won't kill the thread. Instead, you'd need to set an attribute that the thread checks once it wakes up. | 1 | 21 | 0 | I have a function that occasionally hangs.
Normally I would set an alarm, but I'm in Windows and it's unavailable.
Is there a simple way around this, or should I just create a thread that calls time.sleep()? | signal.alarm replacement in Windows [Python] | 0.148885 | 0 | 0 | 11,074 |
644,170 | 2009-03-13T19:09:00.000 | 79 | 0 | 1 | 0 | python | 644,189 | 5 | true | 0 | 0 | It automatically sorts a list of tuples by the first elements in the tuples, then by the second elements and so on tuple([1,2,3]) will go before tuple([1,2,4]). If you want to override this behaviour pass a callable as the second argument to the sort method. This callable should return 1, -1, 0. | 1 | 62 | 0 | Empirically, it seems that Python's default list sorter, when passed a list of tuples, will sort by the first element in each tuple. Is that correct? If not, what's the right way to sort a list of tuples by their first elements? | How does Python sort a list of tuples? | 1.2 | 0 | 0 | 70,869 |
644,237 | 2009-03-13T19:25:00.000 | 1 | 0 | 0 | 0 | python,ruby-on-rails,ruby,django | 644,312 | 7 | false | 1 | 0 | The problem with a "brochure" approach is that it doesn't address the clients needs. Putting the language/platform of choice into a presentation that addresses the clients goals is much more likely to sell them - both on the tools you want to use, as well as you as a provider. As long as you can show that your approach will solve the problem (preferably with the least amount of expense), you'll have fewer objections and less of the "but I've heard that xxx is the best". | 5 | 14 | 0 | Businessmen typically want a web application developed. They are aware of .net or J2EE by names, without much knowledge about either.
Altho' Rails and Django offer for a much better and faster development stack, it is a big task to convince businessmen to use these platforms.
The task begins with introducing Django (or Rails), quoting some blog/research. Then making a case for the use of the framework for the specific project.
Lot of the task is repetitive. What are the sources/blogs/whitepapers and other materials you use to make a case for django (or Rails)
Don't you think there should be a common brochure developed that many development agencies could use to make the same case, over and again. Are there any such ones, now?
There seems to be enough discussion on Django vs Rails. Whereas the need is (Django and Rails) vs (.net and J2EE), at least so, while making a business case. Both represent a faster pragmatic web development in a dynamic language. | How do you make a case for Django [or Ruby on Rails] to non-technical clients | 0.028564 | 0 | 0 | 2,100 |
644,237 | 2009-03-13T19:25:00.000 | 2 | 0 | 0 | 0 | python,ruby-on-rails,ruby,django | 644,291 | 7 | false | 1 | 0 | The first 2 arguments from the top of my mind:
Easier and faster development = cheaper product, less time to market.
SO optimization out of the box. | 5 | 14 | 0 | Businessmen typically want a web application developed. They are aware of .net or J2EE by names, without much knowledge about either.
Altho' Rails and Django offer for a much better and faster development stack, it is a big task to convince businessmen to use these platforms.
The task begins with introducing Django (or Rails), quoting some blog/research. Then making a case for the use of the framework for the specific project.
Lot of the task is repetitive. What are the sources/blogs/whitepapers and other materials you use to make a case for django (or Rails)
Don't you think there should be a common brochure developed that many development agencies could use to make the same case, over and again. Are there any such ones, now?
There seems to be enough discussion on Django vs Rails. Whereas the need is (Django and Rails) vs (.net and J2EE), at least so, while making a business case. Both represent a faster pragmatic web development in a dynamic language. | How do you make a case for Django [or Ruby on Rails] to non-technical clients | 0.057081 | 0 | 0 | 2,100 |
644,237 | 2009-03-13T19:25:00.000 | 1 | 0 | 0 | 0 | python,ruby-on-rails,ruby,django | 644,279 | 7 | false | 1 | 0 | The best case to be made for either of these frameworks is their ability to automate repetitive and time-consuming tasks. This allows developers to be faster and more productive which in turn means projects are delivered faster. | 5 | 14 | 0 | Businessmen typically want a web application developed. They are aware of .net or J2EE by names, without much knowledge about either.
Altho' Rails and Django offer for a much better and faster development stack, it is a big task to convince businessmen to use these platforms.
The task begins with introducing Django (or Rails), quoting some blog/research. Then making a case for the use of the framework for the specific project.
Lot of the task is repetitive. What are the sources/blogs/whitepapers and other materials you use to make a case for django (or Rails)
Don't you think there should be a common brochure developed that many development agencies could use to make the same case, over and again. Are there any such ones, now?
There seems to be enough discussion on Django vs Rails. Whereas the need is (Django and Rails) vs (.net and J2EE), at least so, while making a business case. Both represent a faster pragmatic web development in a dynamic language. | How do you make a case for Django [or Ruby on Rails] to non-technical clients | 0.028564 | 0 | 0 | 2,100 |
644,237 | 2009-03-13T19:25:00.000 | 16 | 0 | 0 | 0 | python,ruby-on-rails,ruby,django | 644,310 | 7 | false | 1 | 0 | You need to speak the language of business: money.
"If we do it Rails, it will cost you 50% less than the same functionality in Java."
Your percentage may vary, and you might need to also include hosting and upkeep costs, to show how it balances out.
When you're convincing other programmers, sure, talk about development speed and automation of repetitive tasks. But talk bottom-line cost to a business person. | 5 | 14 | 0 | Businessmen typically want a web application developed. They are aware of .net or J2EE by names, without much knowledge about either.
Altho' Rails and Django offer for a much better and faster development stack, it is a big task to convince businessmen to use these platforms.
The task begins with introducing Django (or Rails), quoting some blog/research. Then making a case for the use of the framework for the specific project.
Lot of the task is repetitive. What are the sources/blogs/whitepapers and other materials you use to make a case for django (or Rails)
Don't you think there should be a common brochure developed that many development agencies could use to make the same case, over and again. Are there any such ones, now?
There seems to be enough discussion on Django vs Rails. Whereas the need is (Django and Rails) vs (.net and J2EE), at least so, while making a business case. Both represent a faster pragmatic web development in a dynamic language. | How do you make a case for Django [or Ruby on Rails] to non-technical clients | 1 | 0 | 0 | 2,100 |
644,237 | 2009-03-13T19:25:00.000 | 21 | 0 | 0 | 0 | python,ruby-on-rails,ruby,django | 644,316 | 7 | true | 1 | 0 | It's easier to ask forgiveness than permission.
First, build the initial release in Django. Quickly. Build the model well (really well!). But use as much default admin functionality as you can.
Spend time only only reporting and display pages where the HTML might actually matter to the presentation.
Show this and they'll only want more. Once they've gotten addicted to fast turnaround and correct out-of-the box operation, you can discuss technology with them. By then it won't matter any more. | 5 | 14 | 0 | Businessmen typically want a web application developed. They are aware of .net or J2EE by names, without much knowledge about either.
Altho' Rails and Django offer for a much better and faster development stack, it is a big task to convince businessmen to use these platforms.
The task begins with introducing Django (or Rails), quoting some blog/research. Then making a case for the use of the framework for the specific project.
Lot of the task is repetitive. What are the sources/blogs/whitepapers and other materials you use to make a case for django (or Rails)
Don't you think there should be a common brochure developed that many development agencies could use to make the same case, over and again. Are there any such ones, now?
There seems to be enough discussion on Django vs Rails. Whereas the need is (Django and Rails) vs (.net and J2EE), at least so, while making a business case. Both represent a faster pragmatic web development in a dynamic language. | How do you make a case for Django [or Ruby on Rails] to non-technical clients | 1.2 | 0 | 0 | 2,100 |
645,892 | 2009-03-14T13:11:00.000 | 2 | 1 | 1 | 0 | python | 645,935 | 3 | false | 0 | 0 | Py2exe can generate COM dlls from python code, by compiling and embedding python code + interpreter. It does not, AFAIK, support regular DLLs yet. For that, see dirkgently's answer about embedding python yourself. | 1 | 7 | 0 | I have a Python module with nothing but regular global functions. I need to call it from another business-domain scripting environment that can only call out to C DLLs. Is there anyway to build my Python modules so that to other code it can be called like a standard C function that's exported from a DLL? This is for a Windows environment. I'm aware of IronPython, but as far as I know it can only build .NET Assemblies, which are not callable as C DLL functions. | Is there a way to build a C-like DLL from a Python module? | 0.132549 | 0 | 0 | 310 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.