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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
712,510 | 2009-04-03T04:02:00.000 | 0 | 0 | 0 | 0 | python,csv | 1,396,578 | 12 | false | 0 | 0 | Disagreeing with the noble colleagues, I often use DBD::CSV from Perl. There are good reasons to do it. Foremost is data update made simple using a spreadsheet. As a bonus, since I am using SQL queries, the application can be easily upgraded to a real database engine. Bear in mind these were extremely small database in a single user application.
So rephrasing the question: Is there a python module equivalent to Perl's DBD:CSV | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0 | 1 | 0 | 2,433 |
712,510 | 2009-04-03T04:02:00.000 | 0 | 0 | 0 | 0 | python,csv | 713,531 | 12 | false | 0 | 0 | What about postgresql? I've found that quite nice to work with, and python supports it well.
But I really would look for another provider unless it's really not an option. | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0 | 1 | 0 | 2,433 |
712,510 | 2009-04-03T04:02:00.000 | 1 | 0 | 0 | 0 | python,csv | 713,396 | 12 | false | 0 | 0 | "Anyways, now, the question: is it possible to update values SQL-style in a CSV database?"
Technically, it's possible. However, it can be hard.
If both PHP and Python are writing the file, you'll need to use OS-level locking to assure that they don't overwrite each other. Each part of your system will have to lock the file, rewrite it from scratch with all the updates, and unlock the file.
This means that PHP and Python must load the entire file into memory before rewriting it.
There are a couple of ways to handle the OS locking.
Use the same file and actually use some OS lock module. Both processes have the file open at all times.
Write to a temp file and do a rename. This means each program must open and read the file for each transaction. Very safe and reliable. A little slow.
Or.
You can rearchitect it so that only Python writes the file. The front-end reads the file when it changes, and drops off little transaction files to create a work queue for Python. In this case, you don't have multiple writers -- you have one reader and one writer -- and life is much, much simpler. | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0.016665 | 1 | 0 | 2,433 |
712,510 | 2009-04-03T04:02:00.000 | 0 | 0 | 0 | 0 | python,csv | 712,567 | 12 | false | 0 | 0 | I agree. Tell them that 5 random strangers agree that you being forced into a corner to use CSV is absurd and unacceptable. | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0 | 1 | 0 | 2,433 |
712,510 | 2009-04-03T04:02:00.000 | 1 | 0 | 0 | 0 | python,csv | 712,568 | 12 | false | 0 | 0 | You can probably used sqlite3 for more real database. It's hard to imagine hosting that won't allow you to install it as a python module.
Don't even think of using CSV, your data will be corrupted and lost faster than you say "s#&t" | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0.016665 | 1 | 0 | 2,433 |
712,510 | 2009-04-03T04:02:00.000 | 1 | 0 | 0 | 0 | python,csv | 712,522 | 12 | false | 0 | 0 | I couldn't imagine this ever being a good idea. The current mess I've inherited writes vital billing information to CSV and updates it after projects are complete. It runs horribly and thousands of dollars are missed a month. For the current restrictions that you have, I'd consider finding better hosting. | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0.016665 | 1 | 0 | 2,433 |
712,510 | 2009-04-03T04:02:00.000 | 1 | 0 | 0 | 0 | python,csv | 712,515 | 12 | false | 0 | 0 | Keep calling on the help desk.
While you can use a CSV as a database, it's generally a bad idea. You would have to implement you own locking, searching, updating, and be very careful with how you write it out to make sure that it isn't erased in case of a power outage or other abnormal shutdown. There will be no transactions, no query language unless you write your own, etc. | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0.016665 | 1 | 0 | 2,433 |
712,510 | 2009-04-03T04:02:00.000 | 0 | 0 | 0 | 0 | python,csv | 712,512 | 12 | false | 0 | 0 | I'd keep calling help desk. You don't want to use CSV for data if it's relational at all. It's going to be nightmare. | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0 | 1 | 0 | 2,433 |
712,510 | 2009-04-03T04:02:00.000 | 0 | 0 | 0 | 0 | python,csv | 712,974 | 12 | false | 0 | 0 | If I understand you correctly: you need to access the same database from both python and php, and you're screwed because you can only use mysql from php, and only sqlite from python?
Could you further explain this? Maybe you could use xml-rpc or plain http requests with xml/json/... to get the php program to communicate with the python program (or the other way around?), so that only one of them directly accesses the db.
If this is not the case, I'm not really sure what the problem. | 9 | 4 | 0 | Yes, this is as stupid a situation as it sounds like. Due to some extremely annoying hosting restrictions and unresponsive tech support, I have to use a CSV file as a database.
While I can use MySQL with PHP, I can't use it with the Python backend of my program because of install issues with the host. I can't use SQLite with PHP because of more install issues, but can use it as it's a Python builtin.
Anyways, now, the question: is it possible to update values SQL-style in a CSV database? Or should I keep on calling the help desk? | Using CSV as a mutable database? | 0 | 1 | 0 | 2,433 |
712,791 | 2009-04-03T06:56:00.000 | 6 | 0 | 1 | 0 | python,json,simplejson | 714,748 | 13 | false | 0 | 0 | Another reason projects use simplejson is that the builtin json did not originally include its C speedups, so the performance difference was noticeable. | 4 | 405 | 0 | I have seen many projects using simplejson module instead of json module from the Standard Library. Also, there are many different simplejson modules. Why would use these alternatives, instead of the one in the Standard Library? | What are the differences between json and simplejson Python modules? | 1 | 0 | 1 | 141,384 |
712,791 | 2009-04-03T06:56:00.000 | 2 | 0 | 1 | 0 | python,json,simplejson | 38,016,773 | 13 | false | 0 | 0 | In python3, if you a string of b'bytes', with json you have to .decode() the content before you can load it. simplejson takes care of this so you can just do simplejson.loads(byte_string). | 4 | 405 | 0 | I have seen many projects using simplejson module instead of json module from the Standard Library. Also, there are many different simplejson modules. Why would use these alternatives, instead of the one in the Standard Library? | What are the differences between json and simplejson Python modules? | 0.03076 | 0 | 1 | 141,384 |
712,791 | 2009-04-03T06:56:00.000 | 5 | 0 | 1 | 0 | python,json,simplejson | 712,795 | 13 | false | 0 | 0 | The builtin json module got included in Python 2.6. Any projects that support versions of Python < 2.6 need to have a fallback. In many cases, that fallback is simplejson. | 4 | 405 | 0 | I have seen many projects using simplejson module instead of json module from the Standard Library. Also, there are many different simplejson modules. Why would use these alternatives, instead of the one in the Standard Library? | What are the differences between json and simplejson Python modules? | 0.076772 | 0 | 1 | 141,384 |
712,791 | 2009-04-03T06:56:00.000 | 0 | 0 | 1 | 0 | python,json,simplejson | 31,269,030 | 13 | false | 0 | 0 | I came across this question as I was looking to install simplejson for Python 2.6. I needed to use the 'object_pairs_hook' of json.load() in order to load a json file as an OrderedDict. Being familiar with more recent versions of Python I didn't realize that the json module for Python 2.6 doesn't include the 'object_pairs_hook' so I had to install simplejson for this purpose. From personal experience this is why i use simplejson as opposed to the standard json module. | 4 | 405 | 0 | I have seen many projects using simplejson module instead of json module from the Standard Library. Also, there are many different simplejson modules. Why would use these alternatives, instead of the one in the Standard Library? | What are the differences between json and simplejson Python modules? | 0 | 0 | 1 | 141,384 |
713,847 | 2009-04-03T13:13:00.000 | 0 | 0 | 0 | 0 | python,web-services,rest,frameworks | 1,722,910 | 16 | false | 0 | 0 | I strongly recommend TurboGears or Bottle:
TurboGears:
less verbose than django
more flexible, less HTML-oriented
but: less famous
Bottle:
very fast
very easy to learn
but: minimalistic and not mature | 2 | 321 | 0 | Is there a list somewhere of recommendations of different Python-based REST frameworks for use on the serverside to write your own RESTful APIs? Preferably with pros and cons.
Please feel free to add recommendations here. :) | Recommendations of Python REST (web services) framework? | 0 | 0 | 1 | 241,535 |
713,847 | 2009-04-03T13:13:00.000 | 8 | 0 | 0 | 0 | python,web-services,rest,frameworks | 6,897,383 | 16 | false | 0 | 0 | I don't see any reason to use Django just to expose a REST api, there are lighter and more flexible solutions. Django carries a lot of other things to the table, that are not always needed. For sure not needed if you only want to expose some code as a REST service.
My personal experience, fwiw, is that once you have a one-size-fits-all framework, you'll start to use its ORM, its plugins, etc. just because it's easy, and in no time you end up having a dependency that is very hard to get rid of.
Choosing a web framework is a tough decision, and I would avoid picking a full stack solution just to expose a REST api.
Now, if you really need/want to use Django, then Piston is a nice REST framework for django apps.
That being said, CherryPy looks really nice too, but seems more RPC than REST.
Looking at the samples (I never used it), probably web.py is the best and cleanest if you only need REST. | 2 | 321 | 0 | Is there a list somewhere of recommendations of different Python-based REST frameworks for use on the serverside to write your own RESTful APIs? Preferably with pros and cons.
Please feel free to add recommendations here. :) | Recommendations of Python REST (web services) framework? | 1 | 0 | 1 | 241,535 |
715,550 | 2009-04-03T20:14:00.000 | 1 | 0 | 1 | 0 | python,json | 715,569 | 5 | false | 0 | 0 | Could it simply be a two dimensional array? Then you may use integers as keys | 2 | 47 | 0 | In python I have a dictionary that maps tuples to a list of tuples. e.g.
{(1,2): [(2,3),(1,7)]}
I want to be able to encode this data use it with javascript, so I looked into json but it appears keys must be strings so my tuple does not work as a key.
Is the best way to handle this is encode it as "1,2" and then parse it into something I want on the javascript? Or is there a more clever way to handle this. | Best way to encode tuples with json | 0.039979 | 0 | 0 | 76,643 |
715,550 | 2009-04-03T20:14:00.000 | 2 | 0 | 1 | 0 | python,json | 715,584 | 5 | false | 0 | 0 | You can't use an array as a key in JSON. The best you can do is encode it. Sorry, but there's really no other sane way to do it. | 2 | 47 | 0 | In python I have a dictionary that maps tuples to a list of tuples. e.g.
{(1,2): [(2,3),(1,7)]}
I want to be able to encode this data use it with javascript, so I looked into json but it appears keys must be strings so my tuple does not work as a key.
Is the best way to handle this is encode it as "1,2" and then parse it into something I want on the javascript? Or is there a more clever way to handle this. | Best way to encode tuples with json | 0.07983 | 0 | 0 | 76,643 |
715,758 | 2009-04-03T21:19:00.000 | 10 | 0 | 1 | 0 | python,generator,coroutine,continuations | 7,252,061 | 3 | false | 0 | 0 | In newer version of Python, you can send values to Generators with generator.send(), which makes python Generators effectively coroutines.
The main difference between python Generator, and other generator, say greenlet, is that in python, your yield value can only return back to the caller. While in greenlet, target.switch(value) can take you to a specific target coroutine and yield a value where the target would continue to run. | 2 | 157 | 0 | What is the difference between a coroutine and a continuation and a generator ? | Coroutine vs Continuation vs Generator | 1 | 0 | 0 | 34,625 |
715,758 | 2009-04-03T21:19:00.000 | 34 | 0 | 1 | 0 | python,generator,coroutine,continuations | 715,801 | 3 | false | 0 | 0 | Coroutine is one of several procedures that take turns doing their job and then pause to give control to the other coroutines in the group.
Continuation is a "pointer to a function" you pass to some procedure, to be executed ("continued with") when that procedure is done.
Generator (in .NET) is a language construct that can spit out a value, "pause" execution of the method and then proceed from the same point when asked for the next value. | 2 | 157 | 0 | What is the difference between a coroutine and a continuation and a generator ? | Coroutine vs Continuation vs Generator | 1 | 0 | 0 | 34,625 |
716,524 | 2009-04-04T04:52:00.000 | 1 | 0 | 0 | 1 | python,ruby,deployment | 718,216 | 5 | false | 1 | 0 | You can't strictly do this (creating a single installer/executable) in a general cross-platform way, because different platforms use different executable formats. The JVM thing is relying on having a platform-specific JVM already installed on the destination computer; if there is not one installed, then your JAR won't run unless you install a JVM in a platform-specific way. Perhaps more importantly, any third-party Python packages that rely on binary extensions will not play well with Jython unless specifically released in a Jython version, which is unusual. (I presume that a similar situation holds for Ruby packages, though I have no direct knowledge there, nor even how common it is for Ruby packages to use binary extensions....) You'd be able to use the whole range of Java libraries, but very little in the way of Python/Ruby libraries. It's also worth noting that the JVM versions of languages tend to lag behind the standard version, offering fewer language features and less-frequent bugfixes.
If your code is pure Python, then it's already cross-platform as long as the destination machine already has Python installed, just as Java is... but at least in Windows, it's rather less safe to assume that Python is installed than to assume that Java is installed. The third-party elements (database, etc) are likely to be platform-specific binaries, too. User expectations about what's a reasonable installation process vary considerably across platforms, too -- if your app uses third-party libraries or tools, you'd better include all of them for Windows users, but *nix users tend to be more tolerant of downloading dependencies. (However, expectations for that to be handled automatically by a package manager are growing...)
Really, if this is a large-ish application stack and you want to be able to have a drop-in bundle that can be deployed on almost any server, the easiest route would probably be to distribute it as a complete VMWare virtual machine -- the player software is free (for at least Windows and *nix, but I presume for Mac as well), and it allows you to create a dedicated Linux/BSD system that's already fully configured specifically for your application. (I say Linux/BSD because then you don't need to worry about OS licensing fees...)
(If it's a smaller application that you want to allow to run on a client's existing webserver, then I suspect that cross-OS compatibility will be less of a concern than cross-webserver compatibility -- while Apache does have a Windows version, the vast majority of Windows webservers run IIS, and having a single package distribution (or even single version of your application) that plays well with both of those webservers is likely to be impractical.) | 2 | 4 | 0 | Are there any good options other than the JVM for packaging Python or Ruby applications for distribution to end-users? Specifically, I'm looking for ways to be able to write and test a web-based application written in either Ruby or Python, complete with a back-end database, that I can then wrap up in a convenient set of platform-independent packages (of some type) for deployment on Windows, Linux, OS X, and FreeBSD?
Edit: What I mean by a 'web-based application' is a webapp that end-users can run on servers at their companies, providing a web service internally to their end-users. There are a lot of ways to do this on the JVM via JPython or JRuby, but I'm curious if there's a non-JVM route with alternate VMs or interpreters. | Packaging Ruby or Python applications for distribution? | 0.039979 | 0 | 0 | 2,181 |
716,524 | 2009-04-04T04:52:00.000 | 1 | 0 | 0 | 1 | python,ruby,deployment | 7,002,189 | 5 | false | 1 | 0 | You can either distribute the app as a virtual machine or create an installer that includes all dependencies, like the GitHub guys did for their on-premise version. | 2 | 4 | 0 | Are there any good options other than the JVM for packaging Python or Ruby applications for distribution to end-users? Specifically, I'm looking for ways to be able to write and test a web-based application written in either Ruby or Python, complete with a back-end database, that I can then wrap up in a convenient set of platform-independent packages (of some type) for deployment on Windows, Linux, OS X, and FreeBSD?
Edit: What I mean by a 'web-based application' is a webapp that end-users can run on servers at their companies, providing a web service internally to their end-users. There are a lot of ways to do this on the JVM via JPython or JRuby, but I'm curious if there's a non-JVM route with alternate VMs or interpreters. | Packaging Ruby or Python applications for distribution? | 0.039979 | 0 | 0 | 2,181 |
716,795 | 2009-04-04T08:58:00.000 | 1 | 0 | 1 | 0 | python,exception,event-handling,stack-trace | 718,230 | 4 | false | 0 | 0 | I'd think that the simplest method would be to add an ID field to the event(s) in question, and to have each event source (by whatever definition of 'event source' is appropriate here) provide a unique identifier when it posts the event. You do get slightly more overhead, but probably not enough to be problematic, and I'd suspect that you'll find other ways that knowing an event's source would be helpful. | 2 | 1 | 0 | I'm implementing a event system: Various pieces of code will post events to a central place where they will be distributed to all listeners. The main problem with this approach: When an exception happens during event processing, I can't tell anymore who posted the event.
So my question is: Is there an efficient way to figure out who called the constructor and remember that in Python 2.5?
More info: The simple way would be to use the traceback module to get a copy of the stack in the constructor and remember that. Alas, I only need this information rarely, so I'm wondering if there was a way to cache this or whether I could just remember the topmost stack frame and work my way back in the rare case that I actually need this data. | Locating (file/line) the invocation of a constructor in python | 0.049958 | 0 | 0 | 185 |
716,795 | 2009-04-04T08:58:00.000 | 0 | 0 | 1 | 0 | python,exception,event-handling,stack-trace | 716,803 | 4 | false | 0 | 0 | It may be worthwhile to attach a hash of the stack trace to the constructor of your event and to store the actual contents in memcache with the hash as the key. | 2 | 1 | 0 | I'm implementing a event system: Various pieces of code will post events to a central place where they will be distributed to all listeners. The main problem with this approach: When an exception happens during event processing, I can't tell anymore who posted the event.
So my question is: Is there an efficient way to figure out who called the constructor and remember that in Python 2.5?
More info: The simple way would be to use the traceback module to get a copy of the stack in the constructor and remember that. Alas, I only need this information rarely, so I'm wondering if there was a way to cache this or whether I could just remember the topmost stack frame and work my way back in the rare case that I actually need this data. | Locating (file/line) the invocation of a constructor in python | 0 | 0 | 0 | 185 |
716,946 | 2009-04-04T11:47:00.000 | 0 | 1 | 0 | 0 | python,sms,notifications | 716,953 | 7 | false | 1 | 0 | I don't have any knowledge in this area. But I think you'll have to talk to the mobile operators, and see if they have any API for sending SMS messages.
You'll probably have to pay them, or have some scheme for customers to pay them. Alternatively there might be some 3rd party that implements this functionality. | 2 | 1 | 0 | I have a web application and I would like to enable real time SMS notifications to the users of the applications.
Note: I currently cannot use the Twitter API because I live in West Africa, and Twitter doesn't send SMS to my country.
Also email2sms is not an option because the mobile operators don't allow that in my country. | How do I enable SMS notifications in my web apps? | 0 | 0 | 1 | 2,976 |
716,946 | 2009-04-04T11:47:00.000 | 2 | 1 | 0 | 0 | python,sms,notifications | 5,414,483 | 7 | false | 1 | 0 | The easiest way to accomplish this is by using a third party API. Some I know that work well are:
restSms.me
Twilio.com
Clicatell.com
I have used all of them and they easiest/cheapest one to implement was restSms.me
Hope that helps. | 2 | 1 | 0 | I have a web application and I would like to enable real time SMS notifications to the users of the applications.
Note: I currently cannot use the Twitter API because I live in West Africa, and Twitter doesn't send SMS to my country.
Also email2sms is not an option because the mobile operators don't allow that in my country. | How do I enable SMS notifications in my web apps? | 0.057081 | 0 | 1 | 2,976 |
717,148 | 2009-04-04T14:03:00.000 | 2 | 0 | 1 | 0 | python,queue,thread-safety,python-multithreading,deque | 717,199 | 7 | false | 0 | 0 | deque is thread-safe. "operations that do not require locking" means that you don't have to do the locking yourself, the deque takes care of it.
Taking a look at the Queue source, the internal deque is called self.queue and uses a mutex for accessors and mutations, so Queue().queue is not thread-safe to use.
If you're looking for an "in" operator, then a deque or queue is possibly not the most appropriate data structure for your problem. | 3 | 230 | 0 | I need a queue which multiple threads can put stuff into, and multiple threads may read from.
Python has at least two queue classes, Queue.Queue and collections.deque, with the former seemingly using the latter internally. Both claim to be thread-safe in the documentation.
However, the Queue docs also state:
collections.deque is an alternative
implementation of unbounded queues
with fast atomic append() and
popleft() operations that do not
require locking.
Which I guess I don't quite unterstand: Does this mean deque isn't fully thread-safe after all?
If it is, I may not fully understand the difference between the two classes. I can see that Queue adds blocking functionality. On the other hand, it loses some deque features like support for the in-operator.
Accessing the internal deque object directly, is
x in Queue().deque
thread-safe?
Also, why does Queue employ a mutex for it's operations when deque is thread-safe already? | Queue.Queue vs. collections.deque | 0.057081 | 0 | 0 | 85,204 |
717,148 | 2009-04-04T14:03:00.000 | 363 | 0 | 1 | 0 | python,queue,thread-safety,python-multithreading,deque | 717,261 | 7 | true | 0 | 0 | Queue.Queue and collections.deque serve different purposes. Queue.Queue is intended for allowing different threads to communicate using queued messages/data, whereas collections.deque is simply intended as a datastructure. That's why Queue.Queue has methods like put_nowait(), get_nowait(), and join(), whereas collections.deque doesn't. Queue.Queue isn't intended to be used as a collection, which is why it lacks the likes of the in operator.
It boils down to this: if you have multiple threads and you want them to be able to communicate without the need for locks, you're looking for Queue.Queue; if you just want a queue or a double-ended queue as a datastructure, use collections.deque.
Finally, accessing and manipulating the internal deque of a Queue.Queue is playing with fire - you really don't want to be doing that. | 3 | 230 | 0 | I need a queue which multiple threads can put stuff into, and multiple threads may read from.
Python has at least two queue classes, Queue.Queue and collections.deque, with the former seemingly using the latter internally. Both claim to be thread-safe in the documentation.
However, the Queue docs also state:
collections.deque is an alternative
implementation of unbounded queues
with fast atomic append() and
popleft() operations that do not
require locking.
Which I guess I don't quite unterstand: Does this mean deque isn't fully thread-safe after all?
If it is, I may not fully understand the difference between the two classes. I can see that Queue adds blocking functionality. On the other hand, it loses some deque features like support for the in-operator.
Accessing the internal deque object directly, is
x in Queue().deque
thread-safe?
Also, why does Queue employ a mutex for it's operations when deque is thread-safe already? | Queue.Queue vs. collections.deque | 1.2 | 0 | 0 | 85,204 |
717,148 | 2009-04-04T14:03:00.000 | 11 | 0 | 1 | 0 | python,queue,thread-safety,python-multithreading,deque | 43,500,869 | 7 | false | 0 | 0 | All single-element methods on deque are atomic and thread-safe. All other methods are thread-safe too. Things like len(dq), dq[4] yield momentary correct values. But think e.g. about dq.extend(mylist): you don't get a guarantee that all elements in mylist are filed in a row when other threads also append elements on the same side - but thats usually not a requirement in inter-thread communication and for the questioned task.
So a deque is ~20x faster than Queue (which uses a deque under the hood) and unless you don't need the "comfortable" synchronization API (blocking / timeout), the strict maxsize obeyance or the "Override these methods (_put, _get, ..) to implement other queue organizations" sub-classing behavior, or when you take care of such things yourself, then a bare deque is a good and efficient deal for high-speed inter-thread communication.
In fact the heavy usage of an extra mutex and extra method ._get() etc. method calls in Queue.py is due to backwards compatibility constraints, past over-design and lack of care for providing an efficient solution for this important speed bottleneck issue in inter-thread communication. A list was used in older Python versions - but even list.append()/.pop(0) was & is atomic and threadsafe ... | 3 | 230 | 0 | I need a queue which multiple threads can put stuff into, and multiple threads may read from.
Python has at least two queue classes, Queue.Queue and collections.deque, with the former seemingly using the latter internally. Both claim to be thread-safe in the documentation.
However, the Queue docs also state:
collections.deque is an alternative
implementation of unbounded queues
with fast atomic append() and
popleft() operations that do not
require locking.
Which I guess I don't quite unterstand: Does this mean deque isn't fully thread-safe after all?
If it is, I may not fully understand the difference between the two classes. I can see that Queue adds blocking functionality. On the other hand, it loses some deque features like support for the in-operator.
Accessing the internal deque object directly, is
x in Queue().deque
thread-safe?
Also, why does Queue employ a mutex for it's operations when deque is thread-safe already? | Queue.Queue vs. collections.deque | 1 | 0 | 0 | 85,204 |
717,506 | 2009-04-04T17:54:00.000 | 21 | 0 | 1 | 0 | python,ruby,language-features,monkeypatching | 717,563 | 8 | false | 0 | 0 | It's a technique less practised in Python, in part because "core" classes in Python (those implemented in C) are not really modifiable. In Ruby, on the other hand, because of the way it's implemented internally (not better, just different) just about anything can be modified dynamically.
Philosophically, it's something that tends to be frowned on within the Python community, distinctly less so in the Ruby world. I don't know why you assert that it's more controversial (can you link to an authoritative reference?) - my experience has been that monkey-patching is an accepted technique if one where the user should be aware of possible consequences. | 3 | 15 | 0 | In many discussions I have heard about Ruby in which people have expressed their reservations about the language, the issue of monkey patching comes up as one of their primary concerns.
However, I rarely hear the same arguments made in the context of Python although it is also permitted in the Python language.
Why this distinction?
Does Python include different types of safeguards to minimize the risks of this feature? | If monkey patching is permitted in both Ruby and Python, why is it more controversial in Ruby? | 1 | 0 | 0 | 2,615 |
717,506 | 2009-04-04T17:54:00.000 | 13 | 0 | 1 | 0 | python,ruby,language-features,monkeypatching | 717,553 | 8 | false | 0 | 0 | "Does Python include different types of safeguards to minimize the risks of this feature?"
Yes. The community refuses to do it. The safeguard is entirely social. | 3 | 15 | 0 | In many discussions I have heard about Ruby in which people have expressed their reservations about the language, the issue of monkey patching comes up as one of their primary concerns.
However, I rarely hear the same arguments made in the context of Python although it is also permitted in the Python language.
Why this distinction?
Does Python include different types of safeguards to minimize the risks of this feature? | If monkey patching is permitted in both Ruby and Python, why is it more controversial in Ruby? | 1 | 0 | 0 | 2,615 |
717,506 | 2009-04-04T17:54:00.000 | 2 | 0 | 1 | 0 | python,ruby,language-features,monkeypatching | 721,025 | 8 | false | 0 | 0 | I think that monkey patching should only be used as the last solution.
Normally Python programmers know how a class or a method behave. They know that class xxx is doing things in a certain way.
When you monkey patch a class or a method, you are changing it's behavior. Other Python programmers using this class can be very surprised if that class is behaving differently.
The normal way of doing things is subclassing. That way, other programmers know that they are using a different object. They can use the original class or the subclass if they choose to. | 3 | 15 | 0 | In many discussions I have heard about Ruby in which people have expressed their reservations about the language, the issue of monkey patching comes up as one of their primary concerns.
However, I rarely hear the same arguments made in the context of Python although it is also permitted in the Python language.
Why this distinction?
Does Python include different types of safeguards to minimize the risks of this feature? | If monkey patching is permitted in both Ruby and Python, why is it more controversial in Ruby? | 0.049958 | 0 | 0 | 2,615 |
719,194 | 2009-04-05T16:07:00.000 | 3 | 0 | 0 | 0 | javascript,python,html,ajax | 719,293 | 4 | false | 1 | 0 | You create the buttons, which can be links or images or whatever. Now hook a JavaScript function up to each button's click event. On clicking, the function fires and
Sends a request to the server code that says, more or less, +1 or -1.
Server code takes over. This will vary wildly depending on what framework you use (or don't) and a bunch of other things.
Code connects to the database and runs a query to +1 or -1 the score. How this happens will vary wildly depending on your database design, but it'll be something like UPDATE posts SET score=score+1 WHERE score_id={{insert id here}};.
Depending on what the database says, the server returns a success code or a failure code as the AJAX request response.
Response gets sent to AJAX, asynchronously.
The JS response function updates the score if it's a success code, displays an error if it's a failure.
You can store the code in a variable, but this is complicated and depends on how well you know the semantics of your code's runtime environment. It eventually needs to be pushed to persistent storage anyway, so using the database 100% is a good initial solution. When the time for optimizing performance comes, there are enough software in the world to cache database queries to make you feel woozy so it's not that big a deal. | 1 | 32 | 0 | Problems
how to make an Ajax buttons (upward and downward arrows) such that the number can increase or decrease
how to save the action af an user to an variable NumberOfVotesOfQuestionID
I am not sure whether I should use database or not for the variable. However, I know that there is an easier way too to save the number of votes.
How can you solve those problems?
[edit]
The server-side programming language is Python. | How can you make a vote-up-down button like in Stackoverflow? | 0.148885 | 0 | 1 | 7,516 |
719,705 | 2009-04-05T21:13:00.000 | 8 | 0 | 1 | 0 | python,class,oop,language-features | 10,376,716 | 9 | false | 0 | 0 | I understand the arguments against nested classes, but there is a case for using them in some occasions. Imagine I'm creating a doubly-linked list class, and I need to create a node class for maintaing the nodes. I have two choices, create Node class inside the DoublyLinkedList class, or create the Node class outside the DoublyLinkedList class. I prefer the first choice in this case, because the Node class is only meaningful inside the DoublyLinkedList class. While there's no hiding/encapsulation benefit, there is a grouping benefit of being able to say the Node class is part of the DoublyLinkedList class. | 1 | 110 | 0 | Python's inner/nested classes confuse me. Is there something that can't be accomplished without them? If so, what is that thing? | What is the purpose of python's inner classes? | 1 | 0 | 0 | 66,321 |
719,886 | 2009-04-05T23:34:00.000 | 2 | 0 | 0 | 0 | python,postgresql | 719,913 | 3 | false | 0 | 0 | Have you considered keeping your same "schedule", and just shuffling the teams? Generating a schedule where everyone plays each other the proper number of times is possible, but if you already have such a schedule then it's much easier to just shuffle the teams.
You could keep your current table, but replace each team in it with an id (0-23, or A-X, or whatever), then randomly generate into another table where you assign each team to each id (0 = TeamJoe, 1 = TeamBob, etc). Then when it's time to shuffle again next year, just regenerate that mapping table.
Not sure if this answers the question the way you want, but is probably what I would go with (and is actually how I do it on my fantasy football website). | 2 | 0 | 0 | I am trying to do the schedule for the upcoming season for my simulation baseball team. I have an existing Postgresql database that contains the old schedule.
There are 648 rows in the database: 27 weeks of series for 24 teams. The problem is that the schedule has gotten predictable and allows teams to know in advance about weak parts of their schedule. What I want to do is take the existing schedule and randomize it. That way teams are still playing each other the proper number of times but not in the same order as before.
There is one rule that has been tripping me up: each team can only play one home and one road series PER week. I had been fooling around with SELECT statements based on ORDER BY RANDOM() but I haven't figured out how to make sure a team only has one home and one road series per week.
Now, I could do this in PHP (which is the language I am most comfortable with) but I am trying to make the shift to Python so I'm not sure how to get this done in Python. I know that Python doesn't seem to handle two dimensional arrays very well.
Any help would be greatly appreciated. | Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL | 0.132549 | 1 | 0 | 2,359 |
719,886 | 2009-04-05T23:34:00.000 | 1 | 0 | 0 | 0 | python,postgresql | 719,909 | 3 | false | 0 | 0 | I'm not sure I fully understand the problem, but here is how I would do it:
1. create a complete list of matches that need to happen
2. iterate over the weeks, selecting which match needs to happen in this week.
You can use Python lists to represent the matches that still need to happen, and, for each week, the matches that are happening in this week.
In step 2, selecting a match to happen would work this way:
a. use random.choice to select a random match to happen.
b. determine which team has a home round for this match, using random.choice([1,2]) (if it could have been a home round for either team)
c. temporarily remove all matches that get blocked by this selection. a match is blocked if one of its teams has already two matches in the week, or if both teams already have a home match in this week, or if both teams already have a road match in this week.
d. when there are no available matches anymore for a week, proceed to the next week, readding all the matches that got blocked for the previous week. | 2 | 0 | 0 | I am trying to do the schedule for the upcoming season for my simulation baseball team. I have an existing Postgresql database that contains the old schedule.
There are 648 rows in the database: 27 weeks of series for 24 teams. The problem is that the schedule has gotten predictable and allows teams to know in advance about weak parts of their schedule. What I want to do is take the existing schedule and randomize it. That way teams are still playing each other the proper number of times but not in the same order as before.
There is one rule that has been tripping me up: each team can only play one home and one road series PER week. I had been fooling around with SELECT statements based on ORDER BY RANDOM() but I haven't figured out how to make sure a team only has one home and one road series per week.
Now, I could do this in PHP (which is the language I am most comfortable with) but I am trying to make the shift to Python so I'm not sure how to get this done in Python. I know that Python doesn't seem to handle two dimensional arrays very well.
Any help would be greatly appreciated. | Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL | 0.066568 | 1 | 0 | 2,359 |
721,035 | 2009-04-06T11:22:00.000 | 0 | 0 | 0 | 0 | python,django,django-templates | 18,688,638 | 8 | false | 1 | 0 | '\s' might be ok in the use case described above, but be careful, this replaces other whitespaces like '\t' or '\n' as well! If this is not what you want, just use " " instead. | 2 | 16 | 0 | I'm having trouble with Django templates and CharField models.
So I have a model with a CharField that creates a slug that replaces spaces with underscores. If I create an object, Somename Somesurname, this creates slug Somename_Somesurname and gets displayed as expected on the template.
However, if I create an object, Somename Somesurname (notice the second space), slug Somename__Somesurname is created, and although on the Django console I see this as <Object: Somename Somesurname>, on the template it is displayed as Somename Somesurname.
So do Django templates somehow strip spaces? Is there a filter I can use to get the name with its spaces? | Django templates stripping spaces? | 0 | 0 | 0 | 27,195 |
721,035 | 2009-04-06T11:22:00.000 | 1 | 0 | 0 | 0 | python,django,django-templates | 57,768,087 | 8 | false | 1 | 0 | For someone having issue with django template try this :
I had a similar issue with my <optgorup> tag, i am getting my values from django model to display under select. I simple used '' around label option to get the complete text with space.<optgroup label='{{key}}'> | 2 | 16 | 0 | I'm having trouble with Django templates and CharField models.
So I have a model with a CharField that creates a slug that replaces spaces with underscores. If I create an object, Somename Somesurname, this creates slug Somename_Somesurname and gets displayed as expected on the template.
However, if I create an object, Somename Somesurname (notice the second space), slug Somename__Somesurname is created, and although on the Django console I see this as <Object: Somename Somesurname>, on the template it is displayed as Somename Somesurname.
So do Django templates somehow strip spaces? Is there a filter I can use to get the name with its spaces? | Django templates stripping spaces? | 0.024995 | 0 | 0 | 27,195 |
721,436 | 2009-04-06T13:27:00.000 | 8 | 1 | 1 | 0 | python,encryption | 721,444 | 3 | true | 0 | 0 | If it's two-way, it's not really a "hash". It's encryption (and from the sounds of things this is really more of a 'salt' or 'cypher', not real encryption.) A hash is one-way by definition. So rather than something like MD5 or SHA1 you need to look for something more like PGP.
Secondly, can you explain the reasoning behind the 2-way requirement? That's not generally considered good practice for authentication systems any more. | 1 | 5 | 0 | The authentication system for an application we're using right now uses a two-way hash that's basically little more than a glorified caesar cypher. Without going into too much detail about what's going on with it, I'd like to replace it with a more secure encryption algorithm (and it needs to be done server-side). Unfortunately, it needs to be two-way and the algorithms in hashlib are all one-way.
What are some good encryption libraries that will include algorithms for this kind of thing? | What's a good two-way encryption library implemented in Python? | 1.2 | 0 | 0 | 3,449 |
723,635 | 2009-04-06T23:30:00.000 | 9 | 1 | 0 | 0 | python,networking,automated-tests,ethernet | 724,009 | 4 | false | 0 | 0 | It can be handled in hardware, but isn't always -- and even if it is, you can turn that off; see the ethtool offload parameters.
With regard to getting full control over the frames you create -- look into PF_PACKET (for one approach) or the tap driver (for another).
Here's an article on using PF_PACKET to send hand-crafted frames from Python. | 1 | 9 | 0 | I'm not sure if this is even possible since this might be handled in hardware, but I need to send some Ethernet frames with errors in them. I'd like to be able to create runts, jabber, misalignment, and bad FCS errors. I'm working in Python. | How do you send an Ethernet frame with a corrupt FCS? | 1 | 0 | 0 | 12,680 |
723,652 | 2009-04-06T23:38:00.000 | 0 | 0 | 0 | 0 | python,django,dreamweaver | 5,149,029 | 4 | false | 1 | 0 | Beshir Kayali's plugin fails installation for DW CS5 and Extension Manager CS4.
Irony that it asks for DW CS4 or better, else "upgrade" Extension manager to CS3.
I could put some effort in to make this work, yet this is the sole review of the extension:
I allows you to insert 6 kinds of template tags; if, for, template variable, block, comment, and tags. You press a button and then get a dialog box asking you for some info with maybe a few options. It doesn't actually do too much from what I can tell, definitely skippable. | 1 | 6 | 0 | Does a plugin exists for Python/Django into Dreamweaver? Just wondering since Dreamweaver is a great web dev tool. | Python/Django plugin for Dreamweaver | 0 | 0 | 0 | 24,140 |
723,757 | 2009-04-07T00:39:00.000 | 0 | 0 | 0 | 0 | python,sql,xml | 723,931 | 5 | false | 0 | 0 | It may be a common task, but maybe 20GB isn't as common with MySQL as it is with SQL Server.
I've done this using SQL Server Integration Services and a bit of custom code. Whether you need either of those depends on what you need to do with 20GB of XML in a database. Is it going to be a single column of a single row of a table? One row per child element?
SQL Server has an XML datatype if you simply want to store the XML as XML. This type allows you to do queries using XQuery, allows you to create XML indexes over the XML, and allows the XML column to be "strongly-typed" by referring it to a set of XML schemas, which you store in the database. | 1 | 5 | 0 | I'm working with a 20 gig XML file that I would like to import into a SQL database (preferably MySQL, since that is what I am familiar with). This seems like it would be a common task, but after Googling around a bit I haven't been able to figure out how to do it. What is the best way to do this?
I know this ability is built into MySQL 6.0, but that is not an option right now because it is an alpha development release.
Also, if I have to do any scripting I would prefer to use Python because that's what I am most familiar with.
Thanks. | Import XML into SQL database | 0 | 1 | 0 | 12,197 |
724,212 | 2009-04-07T05:18:00.000 | 1 | 0 | 0 | 0 | python,django,unicode | 724,957 | 2 | false | 1 | 0 | Create a File with the data. Use a Django models.FileField to hold a reference to the file.
No it does not involve a ton of I/O. If your file is small it adds 2 or 3 I/O's (the directory read, the iNode read and the data read.) | 2 | 1 | 0 | I want to save some text to the database using the Django ORM wrappers. The problem is, this text is generated by scraping external websites and many times it seems they are listed with the wrong encoding. I would like to store the raw bytes so I can improve my encoding detection as time goes on without redoing the scrapes. But Django seems to want everything to be stored as unicode. Can I get around that somehow? | How to handle unicode of an unknown encoding in Django? | 0.099668 | 0 | 0 | 487 |
724,212 | 2009-04-07T05:18:00.000 | 1 | 0 | 0 | 0 | python,django,unicode | 724,955 | 2 | false | 1 | 0 | You can store data, encoded into base64, for example. Or try to analize HTTP headers from browser, may be it is simplier to get proper encoding from there. | 2 | 1 | 0 | I want to save some text to the database using the Django ORM wrappers. The problem is, this text is generated by scraping external websites and many times it seems they are listed with the wrong encoding. I would like to store the raw bytes so I can improve my encoding detection as time goes on without redoing the scrapes. But Django seems to want everything to be stored as unicode. Can I get around that somehow? | How to handle unicode of an unknown encoding in Django? | 0.099668 | 0 | 0 | 487 |
724,664 | 2009-04-07T08:36:00.000 | -1 | 0 | 1 | 0 | python,compiler-construction,installation,distutils | 724,745 | 6 | false | 0 | 0 | import distutils.ccompiler
compiler_name = distutils.ccompiler.get_default_compiler() | 2 | 35 | 0 | For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)?
UPD.: I don't need the default compiler, I need the one that is actually going to be used, which is not necessarily the default one. So far I haven't found a better way than to parse sys.argv to see if there's a --compiler... string there. | Python distutils, how to get a compiler that is going to be used? | -0.033321 | 0 | 0 | 15,132 |
724,664 | 2009-04-07T08:36:00.000 | 8 | 0 | 1 | 0 | python,compiler-construction,installation,distutils | 1,671,060 | 6 | false | 0 | 0 | You can subclass the distutils.command.build_ext.build_ext command.
Once build_ext.finalize_options() method has been called, the compiler type is stored in self.compiler.compiler_type as a string (the same as the one passed to the build_ext's --compiler option, e.g. 'mingw32', 'gcc', etc...). | 2 | 35 | 0 | For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)?
UPD.: I don't need the default compiler, I need the one that is actually going to be used, which is not necessarily the default one. So far I haven't found a better way than to parse sys.argv to see if there's a --compiler... string there. | Python distutils, how to get a compiler that is going to be used? | 1 | 0 | 0 | 15,132 |
727,410 | 2009-04-07T20:14:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,logging | 18,987,161 | 11 | false | 1 | 0 | Use log.setLevel(Level.ALL) to see messages
The default message filtering level seems to be 'error'. I didn't see any useful log messages until I used the setLevel() method to make the .info and .warning messages visible.
Text printed to System.out wasn't showing up either. It seems to be interpreted as log.info() level messaages. | 2 | 50 | 0 | Often when I am coding I just like to print little things (mostly the current value of variables) out to console. I don't see anything like this for Google App Engine, although I note that the Google App Engine Launcher does have a Log terminal. Is there any way to write to said Terminal, or to some other terminal, using Google App Engine? | How do I write to the console in Google App Engine? | 0 | 0 | 0 | 25,274 |
727,410 | 2009-04-07T20:14:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,logging | 20,152,111 | 11 | false | 1 | 0 | Hello I'm using the version 1.8.6 of GoogleAppEngineLauncher, you can use a flag to set the messages log level you want to see, for example for debug messages:
--dev_appserver_log_level debug
Use it instead of --debug (see @Christopher answer). | 2 | 50 | 0 | Often when I am coding I just like to print little things (mostly the current value of variables) out to console. I don't see anything like this for Google App Engine, although I note that the Google App Engine Launcher does have a Log terminal. Is there any way to write to said Terminal, or to some other terminal, using Google App Engine? | How do I write to the console in Google App Engine? | 0.01818 | 0 | 0 | 25,274 |
730,394 | 2009-04-08T14:53:00.000 | 6 | 0 | 0 | 0 | python,layout,wxpython,widget | 730,452 | 1 | true | 0 | 1 | Got it.
When creating the widget, use a size of (-1,100), where "100" is the height you want. Apparently the "-1" is a sort of "None" in this context.
When adding the widget to the sizer, use a proportion of 0, like this:
self.sizer.Add(self.timeline,0,wx.EXPAND) | 1 | 2 | 0 | I have a wx.Frame, in which I have a vertical BoxSizer with two items, a TextCtrl and a custom widget. I want the custom widget to have a fixed pixel height, while the TextCtrl will expand normally to fill the window. What should I do? | wxPython: Making a fixed-height panel | 1.2 | 0 | 0 | 2,175 |
731,016 | 2009-04-08T17:34:00.000 | 2 | 0 | 0 | 0 | python,actionscript,flash | 731,089 | 3 | false | 1 | 0 | It might help to look at the arguments passed to the Flash movie. If there's reference to an FLV file then there's a good chance the SWF is being used to play a movie.
The path to the SWF might help too. If it's under, say an /ads directory then it's probably just a banner ad. Or if it's under /games then it's probably a game.
Other than using heuristics like this there's probably not much you can do. SWFs can be used for a lot of different things, and there's really nothing in the SWF itself that would tell you what "type" it is. | 2 | 1 | 0 | I'm doing some crawling with Python, and would like to be able to identify (however imperfectly) the flash I come across - is it a video, an ad, a game, or whatever.
I assume I would have to decompile the swf, which seems doable. But what sort of processing would I do with the decompiled Actionscript to figure out what it's purpose is?
Edit: or any better ideas would be most welcome also. | How can I get useful information from flash swf files? | 0.132549 | 0 | 0 | 1,325 |
731,016 | 2009-04-08T17:34:00.000 | 4 | 0 | 0 | 0 | python,actionscript,flash | 731,053 | 3 | false | 1 | 0 | I think your best bet would be to check the context where you see the swf file
usually they're embedded within web pages so if that page has 100 occurences of the word "game", then it might be a game, as an example
To detect an ad it might be trickier but i think that checking the domainname where the swf is hosted might do the trick, also html tags around the swf will be of great use | 2 | 1 | 0 | I'm doing some crawling with Python, and would like to be able to identify (however imperfectly) the flash I come across - is it a video, an ad, a game, or whatever.
I assume I would have to decompile the swf, which seems doable. But what sort of processing would I do with the decompiled Actionscript to figure out what it's purpose is?
Edit: or any better ideas would be most welcome also. | How can I get useful information from flash swf files? | 0.26052 | 0 | 0 | 1,325 |
731,470 | 2009-04-08T19:31:00.000 | 0 | 0 | 0 | 0 | javascript,python | 731,629 | 9 | false | 1 | 0 | Is this for a real webapp? Or is this a convenience thing for you to view output in the browser? If it's more so for convenience, you could consider using mod_python.
mod_python is an extension for the apache webserver that embeds a python interpreter in the web server (so the script runs server side). It would easily let you do this sort of thing locally or for your own convenience. Then you could just run the script with mod python and have the handler post your results. You could probably easily implement the refreshing too, but I would not know off the top of my head how to do this.
Hope this helps... check out mod_python. It's not too bad once you get everything configured. | 3 | 7 | 0 | I have a python script that runs continuously. It outputs 2 lines of info every 30 seconds. I'd like to be able to view this output on the web. In particular, I'd like the site to auto-update (add the new output at the top of the page/site every 30 seconds without having to refresh the page).
I understand I can do this with javascript but is there a python only based solution? Even if there is, is javascript the way to go? I'm more than willing to learn javascript if needed but if not, I'd like to stay focused on python.
Sorry for the basic question but I'm still clueless when it comes to web programming.
Thx! | What's easiest way to get Python script output on the web? | 0 | 0 | 1 | 16,918 |
731,470 | 2009-04-08T19:31:00.000 | 0 | 0 | 0 | 0 | javascript,python | 731,476 | 9 | false | 1 | 0 | JavaScript is the primary way to add this sort of interactivity to a website. You can make the back-end Python, but the client will have to use JavaScript AJAX calls to update the page. Python doesn't run in the browser, so you're out of luck if you want to use just Python.
(It's also possible to use Flash or Java applets, but that's a pretty heavyweight solution for what seems like a small problem.) | 3 | 7 | 0 | I have a python script that runs continuously. It outputs 2 lines of info every 30 seconds. I'd like to be able to view this output on the web. In particular, I'd like the site to auto-update (add the new output at the top of the page/site every 30 seconds without having to refresh the page).
I understand I can do this with javascript but is there a python only based solution? Even if there is, is javascript the way to go? I'm more than willing to learn javascript if needed but if not, I'd like to stay focused on python.
Sorry for the basic question but I'm still clueless when it comes to web programming.
Thx! | What's easiest way to get Python script output on the web? | 0 | 0 | 1 | 16,918 |
731,470 | 2009-04-08T19:31:00.000 | 1 | 0 | 0 | 0 | javascript,python | 731,477 | 9 | false | 1 | 0 | You need Javascript in one way or another for your 30 second refresh. Alternatively, you could set a meta tag refresh for every 30 seconds to redirect to the current page, but the Javascript route will prevent page flicker. | 3 | 7 | 0 | I have a python script that runs continuously. It outputs 2 lines of info every 30 seconds. I'd like to be able to view this output on the web. In particular, I'd like the site to auto-update (add the new output at the top of the page/site every 30 seconds without having to refresh the page).
I understand I can do this with javascript but is there a python only based solution? Even if there is, is javascript the way to go? I'm more than willing to learn javascript if needed but if not, I'd like to stay focused on python.
Sorry for the basic question but I'm still clueless when it comes to web programming.
Thx! | What's easiest way to get Python script output on the web? | 0.022219 | 0 | 1 | 16,918 |
731,759 | 2009-04-08T20:46:00.000 | 0 | 0 | 0 | 0 | python,user-interface,named-pipes | 731,919 | 3 | false | 0 | 1 | When I did something like this I used a separate thread listening on the pipe. The thread had a pointer/handle back to the GUI so it could send the data to be displayed.
I suppose you could do it in the GUI's update/event loop, but you'd have to make sure it's doing non-blocking reads on the pipe. I did it in a separate thread because I had to do lots of processing on the data that came through.
Oh and when you're doing the displaying, make sure you do it in non-trivial "chunks" at a time. It's very easy to max out the message queue (on Windows at least) that's sending the update commands to the textbox. | 2 | 0 | 0 | I'm kind of lost on how to approach this problem, I'd like to write a GUI ideally using Tkinter with python, but I initially started with Qt and found that the problem extends either with all GUI frameworks or my limited understanding.
The data in this case is coming from a named pipe, and I'd like to display whatever comes through the pipe into a textbox. I've tried having one thread listen on the pipe and another create the GUI, but in both cases one thread always seems to hang or the GUI never gets created.
Any suggestions? | Showing data in a GUI where the data comes from an outside source | 0 | 0 | 0 | 641 |
731,759 | 2009-04-08T20:46:00.000 | 0 | 0 | 0 | 0 | python,user-interface,named-pipes | 731,927 | 3 | false | 0 | 1 | In the past when I've had GUI's reading data off of external things (eg: ethernet sockets), I've had a separate thread that handles servicing the external thing, and a timed callback (generally set to something like half a second) to update the GUI widget that displays the external data. | 2 | 0 | 0 | I'm kind of lost on how to approach this problem, I'd like to write a GUI ideally using Tkinter with python, but I initially started with Qt and found that the problem extends either with all GUI frameworks or my limited understanding.
The data in this case is coming from a named pipe, and I'd like to display whatever comes through the pipe into a textbox. I've tried having one thread listen on the pipe and another create the GUI, but in both cases one thread always seems to hang or the GUI never gets created.
Any suggestions? | Showing data in a GUI where the data comes from an outside source | 0 | 0 | 0 | 641 |
731,887 | 2009-04-08T21:14:00.000 | 1 | 0 | 0 | 0 | python,tkinter | 732,131 | 3 | true | 0 | 1 | You could take all your GUI building logic and initial state code out of the mainloop and put it into functions. Call these functions from the mainloop (something like: buildgui() & initstate()) and then, when the user clicks your menu icon, just call initstate() to set it back like it was when the application first started. | 3 | 3 | 0 | I just want the equivalent of closing and reopening my main program. I want to invoke it when a "new"-like option from a drop-down menu is clicked on. Something like calling root.destroy() and then re-initiating the mainloop.
How can I get this done? | Resetting the main GUI window | 1.2 | 0 | 0 | 6,011 |
731,887 | 2009-04-08T21:14:00.000 | 4 | 0 | 0 | 0 | python,tkinter | 732,529 | 3 | false | 0 | 1 | There are at least three ways you can solve this.
Method one: the head fake. When you create your app, don't put all the widgets in the root window. Instead, hide the root window and create a new toplevel that represents your application. When you restart it's just a matter of destroying that new toplevel and re-running all your start-up logic.
Method two: nuke and pave. Similar in concept but slightly different in execution. In this model, when you want to restart you simply delete all the widgets in the main window, reset the geometry to null (so the window will once again resize itself based on its contents) and then run the logic that draws all the other widgets.
Method three: if it worked the first time... As suggested by Martin v. Löwis, simply have your program exec a new instance of the program, then exit.
The first two methods are potentially faster and have the (dis?)advantage of preserving the current environment. For example you could save the copy of the clipboard, column widths, etc. The third method absolutely guarantees a blank slate. | 3 | 3 | 0 | I just want the equivalent of closing and reopening my main program. I want to invoke it when a "new"-like option from a drop-down menu is clicked on. Something like calling root.destroy() and then re-initiating the mainloop.
How can I get this done? | Resetting the main GUI window | 0.26052 | 0 | 0 | 6,011 |
731,887 | 2009-04-08T21:14:00.000 | 2 | 0 | 0 | 0 | python,tkinter | 732,085 | 3 | false | 0 | 1 | If you are on Unix, restart the entire application with os.execv. Make sure you pass all command line arguments etc. | 3 | 3 | 0 | I just want the equivalent of closing and reopening my main program. I want to invoke it when a "new"-like option from a drop-down menu is clicked on. Something like calling root.destroy() and then re-initiating the mainloop.
How can I get this done? | Resetting the main GUI window | 0.132549 | 0 | 0 | 6,011 |
731,993 | 2009-04-08T21:44:00.000 | 1 | 0 | 1 | 0 | python,multithreading,multiprocessing,multicore,python-stackless | 732,026 | 9 | false | 0 | 0 | I always prefer multiple threads for simplicity, but there is a real issue with affinity. There is no way (that I know of) to tell Python's threading implementation to bind to a specific processor. This may not be an issue for you, it doesnt sound like it should be. Unless you have a good reason not to, it sounds like your problem can be solved easily with Python's threading implementation.
If you do decided on using processed, sharing information between sub processes can be accomplished in several ways: tcp/udp connections, shared memory or pipes. It does add some overhead and complexity. | 6 | 24 | 0 | I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes.
When the user starts a simulation, and defines an initial state, I want the program to render the simulation continuously in the background, while the user may be doing different things in the program. Sort of like a YouTube-style bar that fills up: You can play the simulation only up to the point that was rendered.
Should I use multiple processes or multiple threads or what? People told me to use the multiprocessing package, I checked it out and it looks good, but I also heard that processes, unlike threads, can't share a lot of information (and I think my program will need to share a lot of information.) Additionally I also heard about Stackless Python: Is it a separate option? I have no idea.
Please advise. | Multiprocessing or Multithreading? | 0.022219 | 0 | 0 | 9,001 |
731,993 | 2009-04-08T21:44:00.000 | 0 | 0 | 1 | 0 | python,multithreading,multiprocessing,multicore,python-stackless | 734,919 | 9 | false | 0 | 0 | It sounds like you'd want threading.
The way you described it, it sounded like there was one single thing that actually took a lot of CPU...the actual running of the simulation.
What you're trying to get is more responsive displays, by allowing user interaction and graphics updates while the simulation is running. This is exactly what python's threading was built for.
What this will NOT get you is the ability to take advantage of multiple cores/processors on your system. I have no idea what your simulation looks like, but if it is that CPU intensive, it might be a good candidate for splitting up. In this case, you can use multiprocessing to run separate parts of the simulation on separate cores/processors. However, this isn't trivial...you now need some way to pass data back and fourth between the processes, as the separate processes can't easily access the same memory space. | 6 | 24 | 0 | I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes.
When the user starts a simulation, and defines an initial state, I want the program to render the simulation continuously in the background, while the user may be doing different things in the program. Sort of like a YouTube-style bar that fills up: You can play the simulation only up to the point that was rendered.
Should I use multiple processes or multiple threads or what? People told me to use the multiprocessing package, I checked it out and it looks good, but I also heard that processes, unlike threads, can't share a lot of information (and I think my program will need to share a lot of information.) Additionally I also heard about Stackless Python: Is it a separate option? I have no idea.
Please advise. | Multiprocessing or Multithreading? | 0 | 0 | 0 | 9,001 |
731,993 | 2009-04-08T21:44:00.000 | 18 | 0 | 1 | 0 | python,multithreading,multiprocessing,multicore,python-stackless | 732,116 | 9 | false | 0 | 0 | "I checked it out and it looks good, but I also heard that processes, unlike threads, can't share a lot of information..."
This is only partially true.
Threads are part of a process -- threads share memory trivially. Which is as much of a problem as a help -- two threads with casual disregard for each other can overwrite memory and create serious problems.
Processes, however, share information through a lot of mechanisms. A Posix pipeline (a | b) means that process a and process b share information -- a writes it and b reads it. This works out really well for a lot things.
The operating system will assign your processes to every available core as quickly as you create them. This works out really well for a lot of things.
Stackless Python is unrelated to this discussion -- it's faster and has different thread scheduling. But I don't think threads are the best route for this.
"I think my program will need to share a lot of information."
You should resolve this first. Then, determine how to structure processes around the flow of information. A "pipeline" is very easy and natural to do; any shell will create the pipeline trivially.
A "server" is another architecture where multiple client processes get and/or put information into a central server. This is a great way to share information. You can use the WSGI reference implementation as a way to build a simple, reliable server. | 6 | 24 | 0 | I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes.
When the user starts a simulation, and defines an initial state, I want the program to render the simulation continuously in the background, while the user may be doing different things in the program. Sort of like a YouTube-style bar that fills up: You can play the simulation only up to the point that was rendered.
Should I use multiple processes or multiple threads or what? People told me to use the multiprocessing package, I checked it out and it looks good, but I also heard that processes, unlike threads, can't share a lot of information (and I think my program will need to share a lot of information.) Additionally I also heard about Stackless Python: Is it a separate option? I have no idea.
Please advise. | Multiprocessing or Multithreading? | 1 | 0 | 0 | 9,001 |
731,993 | 2009-04-08T21:44:00.000 | 14 | 0 | 1 | 0 | python,multithreading,multiprocessing,multicore,python-stackless | 732,119 | 9 | false | 0 | 0 | Stackless: uses 1 cpu. "Tasklets" must yield voluntarily. The preemption option doesn't work all the time.
Threaded: uses 1 cpu. Native threads share time somewhat randomly after running 20-100 python opcodes.
Multiprocessing: uses multiple cpu
Update
Indepth Analysis
Use threaded for an easy time. However, if you call C routines that take a long time before returning, then this may not be a choice if your C routine does not release the lock.
Use multiprocessing if it is very limited by cpu power and you need maximum responsiveness.
Don't use stackless, I have had it segfault before and threads are pretty much equivalent unless you are using hundreds of them or more. | 6 | 24 | 0 | I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes.
When the user starts a simulation, and defines an initial state, I want the program to render the simulation continuously in the background, while the user may be doing different things in the program. Sort of like a YouTube-style bar that fills up: You can play the simulation only up to the point that was rendered.
Should I use multiple processes or multiple threads or what? People told me to use the multiprocessing package, I checked it out and it looks good, but I also heard that processes, unlike threads, can't share a lot of information (and I think my program will need to share a lot of information.) Additionally I also heard about Stackless Python: Is it a separate option? I have no idea.
Please advise. | Multiprocessing or Multithreading? | 1 | 0 | 0 | 9,001 |
731,993 | 2009-04-08T21:44:00.000 | 1 | 0 | 1 | 0 | python,multithreading,multiprocessing,multicore,python-stackless | 35,972,455 | 9 | false | 0 | 0 | Very puzzled. Bastien Léonard rightly pointed out that the GIL will stop any ability to use threading in any useful way. His reference states:
"Use of a global interpreter lock in a language effectively limits the
amount of parallelism reachable through concurrency of a single
interpreter process with multiple threads. If the process is almost
purely made up of interpreted code and does not make calls outside of
the interpreter for long periods of time (which can release the lock
on the GIL on that thread while it processes), there is likely to be
very little increase in speed when running the process on a
multiprocessor machine. Due to signaling with a CPU-bound thread, it
can cause a significant slowdown, even on single processors."
This being the case, multi-processing is then the sensible choice. From my own experience Python + MT is of no noticeable benefit to the user. | 6 | 24 | 0 | I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes.
When the user starts a simulation, and defines an initial state, I want the program to render the simulation continuously in the background, while the user may be doing different things in the program. Sort of like a YouTube-style bar that fills up: You can play the simulation only up to the point that was rendered.
Should I use multiple processes or multiple threads or what? People told me to use the multiprocessing package, I checked it out and it looks good, but I also heard that processes, unlike threads, can't share a lot of information (and I think my program will need to share a lot of information.) Additionally I also heard about Stackless Python: Is it a separate option? I have no idea.
Please advise. | Multiprocessing or Multithreading? | 0.022219 | 0 | 0 | 9,001 |
731,993 | 2009-04-08T21:44:00.000 | 10 | 0 | 1 | 0 | python,multithreading,multiprocessing,multicore,python-stackless | 732,199 | 9 | false | 0 | 0 | A process has its own memory space. It makes it more difficult to share information, but also makes the program safer (less need for explicit synchronization). That being said, processes can share the same memory in read-only mode.
A thread is cheaper to create or kill, but the main difference is that it shares memory with other threads in the same process. This is sometimes risky, and in addition crashing the process would kill all threads.
One advantage of using multiple processes over multiple threads is that it would be easier to scale your program to work with multiple machines that communicate via network protocols.
For example, you could potentially run 16 processes on 8 dual-core machines, but would not have a benefit from more than 4 threads on a quad-core machine. If the amount of information you need to communicate is low, multiprocessing may make more sense.
As for the youtube-style you've described, I would say that suggests multiprocessing. If you follow MVC approaches, your GUI should not also contain the model (calculation result). With multiprocess, you can then communicate to a work manager that can report what data is already available. | 6 | 24 | 0 | I'm making a program for running simulations in Python, with a wxPython interface. In the program, you can create a simulation, and the program renders (=calculates) it for you. Rendering can be very time-consuming sometimes.
When the user starts a simulation, and defines an initial state, I want the program to render the simulation continuously in the background, while the user may be doing different things in the program. Sort of like a YouTube-style bar that fills up: You can play the simulation only up to the point that was rendered.
Should I use multiple processes or multiple threads or what? People told me to use the multiprocessing package, I checked it out and it looks good, but I also heard that processes, unlike threads, can't share a lot of information (and I think my program will need to share a lot of information.) Additionally I also heard about Stackless Python: Is it a separate option? I have no idea.
Please advise. | Multiprocessing or Multithreading? | 1 | 0 | 0 | 9,001 |
732,192 | 2009-04-08T22:47:00.000 | 0 | 0 | 0 | 0 | python,colors,tkinter | 732,452 | 4 | false | 0 | 1 | Instantiate Tk(), run the code once, and then stick the information into your source as a dict literal? | 1 | 2 | 0 | I know I can call Tkinter.Tk().winfo_rgb(color) to get a tuple of values that represent the named color.
for instance Tkinter.Tk().winfo_rgb("red") returns (65535, 0, 0)
The problem is it also opens a window. I was hoping to abstract some color calculations into a generic color class, and handle whether or not the class was instantiated with "red" or "#ff0000" or maybe even some other formats.
With the class abstracted, I don't have a tk parent to pull this info from without instantiating a new window, or passing in a parent.
Is there any way to get this kind of color name → hex value conversion without having an instantiated Tk window? | Get Tk winfo_rgb() without having a window instantiated | 0 | 0 | 0 | 1,348 |
732,222 | 2009-04-08T22:58:00.000 | 2 | 0 | 1 | 0 | python,http,chunked-encoding | 9,326,192 | 6 | false | 0 | 0 | Twisted supports chunked transfer and it does so transparently. i.e., if your request handler does not specify a response length, twisted will automatically switch to chunked transfer and it will generate one chunk per call to Request.write. | 1 | 7 | 0 | I'm looking for a well-supported multithreaded Python HTTP server that supports chunked encoding replies. (I.e. "Transfer-Encoding: chunked" on responses). What's the best HTTP server base to start with for this purpose? | Python HTTP server that supports chunked encoding? | 0.066568 | 0 | 1 | 6,143 |
732,429 | 2009-04-09T00:52:00.000 | 1 | 0 | 0 | 0 | javascript,python,http,pylons,widget | 732,453 | 3 | false | 1 | 1 | webkit-gtk is getting very stable, and i believe has python bindings now so technically you could use that (then your text editor merely needs to be <body contenteditable></body> and you'd be done. Unfortunately i'm not sure how complete its bindings are at present | 1 | 4 | 0 | I'm writing a web-app using Python and Pylons. I need a textbox that is rich (ie, provides the ability to bold/underline/add bullets..etc...). Does anyone know a library or widget I can use?
It doesn't have to be Python/Pylons specific, as it can be a Javascript implementation as well.
Thanks! | HTML Rich Textbox | 0.066568 | 0 | 0 | 8,362 |
732,476 | 2009-04-09T01:33:00.000 | 2 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 8,218,516 | 16 | false | 1 | 0 | Rails is like Bible. Unless you are a Saint, you do not need to understand it and you probably will never understand; all you need to do is to believe in it. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 0.024995 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 1 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 738,453 | 16 | false | 1 | 0 | Like others suggest, trying both is one good way, but really, to me, I would base it more on which language you prefer to use. Sure, if it's a web app, you'll do a lot with the framework, but "every" line of code you write will be in that language. Since both frameworks are strong, it's really more a matter of what language you'll be happiest writing code in, day in and day out.
I personally use Rails and love it, but have many friends using Django. When we discuss things, time and again, it boils down more to language than framework. The languages are fairly different, and you'll typically find one you prefer a lot more than the other, at least in my opinion. I had originally thought Python sounded great, learned it, wrote a few things with it, etc., but it just never "clicked" for me. When I first saw Ruby many years ago it seemed a bit odd, but when I revisited it via Rails, it just felt so natural. When I write code in Ruby I feel like I'm pretty much writing English - if I can think of how I think the code should be written, I can pretty much type that and it works. It just fits my brain better.
Community wise, you'll get a lot of different opinions. I don't think being "too big" means it's bad, nor do I think the Ruby community is by any means "too big", especially compared to say the Java community. Ruby and Rails have certainly gone mainstream to some degree, and for those of us who've worked with it for several years, it seems mainstream, but in the grand scheme of things it's actually still fairly small.
Anyway, good luck, and enjoy looking into them and finding what will delight you to work with. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 0.012499 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 0 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 735,375 | 16 | false | 1 | 0 | Your question must be : Python or Ruby ;) | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 0 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 2 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 733,441 | 16 | false | 1 | 0 | You are at a point where you cant make a bad choice!
My personal preference is django, but I know for a fact rails is good too.
I think the best answer is what the BFDLs of django themselves say:
Try both, use whichever you like. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 0.024995 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 1 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 733,185 | 16 | false | 1 | 0 | Since you're a seasoned .NET programmer, you really should look at ASP.NET and MVC before turning to Rails and Django, at least if your goal is to get up-and-running quickly. It's always easier to leverage something that you already know in-depth.
I was in a similar situation recently -- I had a project that I wanted to push out on Windows and Unix, and so rather than leveraging what I know well (Ruby/Rails), I jumped ship and gave Groovy on Grails a go. It was a really rewarding experience, and I'm really glad I did a few small projects in Grails, but in the end I had a tiny fraction of the productivity I did in the environment where I had a few years' experience, even after months of hacking away on Grails.
So, pick up Django, Rails, Lift, or whatever you feel like doing -- it will help expand your mind, and give you different ways to look at solving problems. But if you want to get going quickly, use what you know (.NET) on a platform designed for you (MVC). | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 0.012499 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 0 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 732,624 | 16 | false | 1 | 0 | I'm curious. If you are a C# programmer, why have you ruled out Microsoft's MVC?
You have two different needs expressed in your question:
1) Want to try something new
2) Want to build community finance site quickly.
I understand the desire to look at RoR or Django for need 1, but for need 2 I'd expect you would be more productive more quickly with MVC.
Please note I am not saying that EVERYONE would be more productive more quickly nor am I saying that Microsoft's MVP is inherently more productive, just that someone who is currently a C# programmer would be able to come up to speed more quickly on something that uses C#... | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 0 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 2 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 732,604 | 16 | false | 1 | 0 | i'm another C#/.net guy with the same itch to tinker. Django is appealing. Though the development is easy and fun, i've heard some stories about deployment and configuration headaches with both Rails and Django (mostly rails). It's not like just throwing an asp.net app at IIS or PHP at Apache. For those things you can set it and forget it. I'd be curious to get c.batt's comments on his/her experince with deploying django.
Lately I've been looking at Grails. It uses Groovy which is ruby like. It's very easy to develop in and you can build apps as fast as Rails but you get access to the Java platform via the JVM which could come in handy. There's a ton of open source java components you could drop into your Grails app, plenty of the types of components you'd be looking for. It's really not like building a java app. So far it does feel like Rails. Good luck. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 0.024995 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 6 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 732,712 | 16 | false | 1 | 0 | I just finished building a small social networking site with Django for a client. I was new to Python and new to Django, but it was one of the most enjoyable development experiences I've had in a while (even with the headaches of being new to a language and framework). And it only took two weeks.
If you're building this for yourself then I would try both Rails and Django (or one of the other frameworks that c.batt mentioned) to see what feels the most comfortable. I ended up choosing Django/Python because I liked the language. It felt clean and efficient, and you can't argue with the speed at which you can get a bare-bones site up and running.
As mentioned previously, Pinax is great. If anything you get a solid base to build on top of. I found that I had to extend parts of it to get exactly what I wanted, and a couple of sections I decided to code from scratch because the changes would get "hacky" to match what I needed. Other parts, however, are perfect. The private messaging was used out of the box, just with some new templates to match the site. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 1 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 6 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 732,574 | 16 | false | 1 | 0 | funny... I'm in the same boat, though perhaps I've been looking around for a bit longer.
I came in from MS-land (C# too) and I went with Django, but only after I tinkered around with Google's AppEngine, which re-introduced me to Python. Django is well organized, internally consistent (as far as I could tell), and well supported with a vibrant community. Python is well organized, internally consistent (as far as I can tell), and extremely well supported with an amazing community.
Anyhow, there's more to rapid Python web development than Django. You might want to search for: python wsgi framework. Pylons and TurboGears offer enormous flexibility and focus on "best of breed" components, web2py appears to have a very cool DAL/ORM that I'm itching to dig into, and web.py and werkzeug (amongst others) are minimalistic and don't try to dictate how you should build your app. And if you're sticking with Django, definitely check out the Pinax project - it might help kickstart your development efforts. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 1 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 7 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 733,369 | 16 | false | 1 | 0 | I like Django better because it's less magic, with Rails i feel they pushed the convention over configuration principle too far, so i prefer the more explicit nature of Django. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 1 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 10 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 732,489 | 16 | false | 1 | 0 | If you want a quick stack check out Sinatra.
Django will make more sense faster. It has awesome routing, simple file structure, nice clean syntax, not a lot of WTF moments, and understandable ORM functionality.
Rails you will have to dive into. You will battle activerecord. You will try to wrap your head around the many facets of a rails application.
I like them both. Try them both out. They don't take that long to get a feel for. You should ultimately base your decision on a per-app basis and factor in which language has better modules/extensions/gems for what you need. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 1 | 0 | 0 | 6,353 |
732,476 | 2009-04-09T01:33:00.000 | 20 | 0 | 0 | 0 | c#,python,ruby-on-rails,ruby,django | 732,557 | 16 | true | 1 | 0 | I kind of like the Python language
better and it seems to be more
full-featured than Ruby for
statistical, scientific and networking
(let me know if you think this is
wrong).
If you think you'll need libraries like NumPy or SciPy, probably best to stick with python/django. I've struggled to find ruby equivalents.
However, the RoR community seems to be
much bigger
Bigger is of course not going to be better. I've had great experiences with the django community in terms of support, and the pluggable app ecosystem is maturing quite quickly.
I would also add that I find the django documentation to be very easy to follow. | 12 | 11 | 0 | I'm a C#/.NET developer looking to mess around with something completely different - something LAM(*) stackish for building web apps quickly.
I'm thinking either Django or Rails. I kind of like the Python language better and it seems to be more full-featured than Ruby for statistical, scientific and networking (let me know if you think this is wrong). However, the RoR community seems to be much bigger - which might make it a safer bet. Do you think this is important? Anybody have experience with both RoR and Django?
Update: Specifically I'm looking to be able to build a community finance oriented site quickly. There are definitely a lot of Ruby Gems to speed up the process, but I noticed Pinax on the Django side which looks promising.
I know that Python is already fairly popular for financial/mathematical programming. Anyone else have an opinion?
Update 2: Noticed some comments about ASP.NET MVC. I have in fact done pretty significant work with ASP.NET MVC - a LOB app for Medical Equipment Servicing, and I loved it. It is IMHO a much better and more intuitive way to write web apps compared with ASP.NET web forms. But, I'm really looking for a non-.NET development environment to develop some chops in. | Django or Ruby on Rails | 1.2 | 0 | 0 | 6,353 |
735,743 | 2009-04-09T20:03:00.000 | 3 | 1 | 1 | 0 | python,ping | 735,801 | 3 | false | 0 | 0 | Just because a site fails a ping doesn't mean the domain is available. The domain could be reserved but not pointing anywhere, or the machine may not respond to pings, or it may just be down. | 1 | 0 | 0 | Is there any way to generate words based on characters and checking if a domain exists with this word (ping)?
What I want to do is to generate words based on some characters, example "abcdefgh", and then ping generatedword.com to check if it exists. | Looping through chars, generating words and checking if domain exists | 0.197375 | 0 | 0 | 382 |
736,335 | 2009-04-10T00:22:00.000 | 1 | 0 | 1 | 0 | python,python-3.x | 4,898,617 | 5 | false | 0 | 0 | The reason it wasn't obvious to you is that Python intentionally doesn't try to support such a thing. Namespaces are a feature, and using them is to your advantage. If you want something you defined in another file, import it. This means from reading your source code you can figure out where everything came from, and also makes your code easier to test and modify. | 2 | 4 | 0 | Is there is a super global (like PHP) in Python? I have certain variables I want to use throughout my whole project in separate files, classes, and functions, and I don't want to have to keep declaring it throughout each file. | Python Superglobal? | 0.039979 | 0 | 0 | 4,007 |
736,335 | 2009-04-10T00:22:00.000 | 4 | 0 | 1 | 0 | python,python-3.x | 4,900,210 | 5 | false | 0 | 0 | in years of practice, i've grown quite disappointed with python's import system: it is complicated and difficult to handle correctly. also, i have to maintain scores of imports in each and every module i write, which is a pita.
namespaces are a very good idea, and they're indispensable---php doesn't have proper namespaces, and it's a mess.
conceptually, part of writing an application consists in defining a suitable vocabulary, the words that you'll use to do the things you want to. yet in the classical way, it's exactly these words that won't come easy, as you have to first import this, import that to obtain access.
when namespaces came into focus in the javascript community, john resig of jquery fame decided that providing a single $ variable in the global namespace was the way to go: it would only affect the global namespace minimally, and provide easy access to everything with jquery.
likewise, i experimented with a global variable g, and it worked to an extent. basically, you have two options here: either have a startup module that must be run prior to any other module in your app, which defines what things should be available in g, so it is ready to go when needed. the other approach which i tried was to make g lazy and to react with custom imports when a new name was required; so whenever you need to g.foo.frob(42) for the first time, the mechanism will try something like import foo; g.foo = foo behind the scenes. that was considerable more difficult to do right.
these days, i've ditched the import system almost completely except for standard library and site packages. most of the time i write wrappers for hose libraries, as 90% of those have inanely convoluted interfaces anyhow. those wrappers i then publish in the global namespace, using spelling conventions to keep the risk of collisions to a minimum.
i only tell this to alleviate the impression that modifying the global namespace is something that is inherently evil, which the other answers seem to state. not so. what is evil is to do it thoughtlessly, or be compelled by language or package design to do so.
let me add one remark, as i almost certainly will get some fire here: 99% of all imports done by people who religiously defend namespace purity are wrong. proof? you'll read in the beginning lines of any module foo.py that needs to do trigonometrics something like from math import sin. now when you correctly import foo and have a look at that namespace, what are you going to find? something named foo.sin. but that sin isn't part of the interface of foo, it is just a helper, it shouldn't clutter that namespace---hence, from math import sin as _sin or somesuch would've been correct. however, almost nobody does it that way.
i'm sure to arouse some heated comments with these views, so go ahead. | 2 | 4 | 0 | Is there is a super global (like PHP) in Python? I have certain variables I want to use throughout my whole project in separate files, classes, and functions, and I don't want to have to keep declaring it throughout each file. | Python Superglobal? | 0.158649 | 0 | 0 | 4,007 |
737,511 | 2009-04-10T12:40:00.000 | 2 | 0 | 0 | 0 | python,sql,linux,sqlite,hosting | 737,617 | 4 | false | 0 | 0 | There is no out-of-the-box solution; you either have to backport the SQLlite module from Python 2.5 to Python 2.2 or ask your web hoster to upgrade to the latest Python version.
Python 2.2 is really ancient! At least for security reasons, they should upgrade (no more security fixes for 2.2 since May 30, 2003!).
Note that you can install several versions of Python in parallel. Just make sure you use "/usr/bin/python25" instead of "/usr/bin/python" in your scripts. To make sure all the old stuff is still working, after installing Python 2.5, you just have to fix the two symbolic links "/usr/bin/python" and "/usr/lib/python" which should now point to 2.5. Bend them back to 2.2 and you're good. | 2 | 1 | 0 | I've written a web-app in python using SQLite and it runs fine on my server at home (with apache and python 2.5.2). I'm now trying to upload it to my web host and there servers use python 2.2.3 without SQLite.
Anyone know of a way to use SQLite in python 2.2.3 e.g. a module that I can upload and import? I've tried butchering the module from newer versions of python, but they don't seem to be compatible.
Thanks,
Mike | SQLite in Python 2.2.3 | 0.099668 | 1 | 0 | 1,012 |
737,511 | 2009-04-10T12:40:00.000 | 0 | 0 | 0 | 0 | python,sql,linux,sqlite,hosting | 4,066,757 | 4 | false | 0 | 0 | In case anyone comes across this question, the reason why neither pysqlite nor APSW are available for Python 2.2 is because Python 2.3 added the simplified GIL API. Prior to Python 2.3 it required a lot of code to keep track of the GIL. (The GIL is the lock used by Python to ensure correct behaviour while multi-threading.)
Doing a backport to 2.2 would require ripping out all the threading code. Trying to make it also be thread safe under 2.2 would be a nightmare. There was a reason they introduced the simplified GIL API!
I am still astonished at just how popular older Python versions are. APSW for Python 2.3 is still regularly downloaded. | 2 | 1 | 0 | I've written a web-app in python using SQLite and it runs fine on my server at home (with apache and python 2.5.2). I'm now trying to upload it to my web host and there servers use python 2.2.3 without SQLite.
Anyone know of a way to use SQLite in python 2.2.3 e.g. a module that I can upload and import? I've tried butchering the module from newer versions of python, but they don't seem to be compatible.
Thanks,
Mike | SQLite in Python 2.2.3 | 0 | 1 | 0 | 1,012 |
737,947 | 2009-04-10T15:11:00.000 | 0 | 0 | 0 | 0 | python,windows,memory-management | 4,207,006 | 7 | false | 0 | 1 | You are probably looking for something like ZODB. However, though ZODB tries hard to be transparent, no solution is going to be 100% free of artifacts. You have to write your code with an awareness that your objects primarily live in a database, but that there are multiple representations of your objects, there are caching/syncing issues, etc. Nothing is going to make this very difficult problem completely trivial for you. | 2 | 2 | 0 | I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason for this is some limitation by Windows XP on how much total memory a process can take, regardless of HD space. I think it's around 3 GB. Did I get it right so far?
I am making an application in Python for running simulations. It will take a lot of memory, and will run on Windows XP. Is it possible for it to use scratch disks? How? | Scratch disks in Python? | 0 | 0 | 0 | 561 |
737,947 | 2009-04-10T15:11:00.000 | 1 | 0 | 0 | 0 | python,windows,memory-management | 737,963 | 7 | false | 0 | 1 | Scratch disks will benefit your application in the case that it works with very big files,
Is that the case?
If not, then i don't think you may find something that will benefit your application in scratch disks. | 2 | 2 | 0 | I understood that in certain Windows XP programs, like Photoshop, there is something called "scratch disks". What I understood that this means, and please correct me if I'm wrong, is that Photoshop manages its own virtual memory on the hard-drive, instead of letting Windows manage it. I understood that the reason for this is some limitation by Windows XP on how much total memory a process can take, regardless of HD space. I think it's around 3 GB. Did I get it right so far?
I am making an application in Python for running simulations. It will take a lot of memory, and will run on Windows XP. Is it possible for it to use scratch disks? How? | Scratch disks in Python? | 0.028564 | 0 | 0 | 561 |
738,433 | 2009-04-10T18:22:00.000 | 2 | 0 | 0 | 0 | python,django | 3,727,548 | 1 | false | 1 | 0 | InstantDjango uses sqlite by default. What database did you set your normal django to use? and you did you create that database before you ran the syncdb?
InstantDjango uses different packaging for all the django required libraries (portable versions) which might be less stable but they should work for your development needs. | 1 | 0 | 0 | I've been trying to get Django running and when going through the intro to projects it seems that I keep having trouble when I get to the 'sync database' section. When using InstantDjango this doesn't seem to be as much of a problem. My question is, can one just do Django development with the InstantDjango program or do you really need to run it the normal way? | Getting started with Django-Instant Django | 0.379949 | 0 | 0 | 1,541 |
739,090 | 2009-04-10T22:43:00.000 | 0 | 0 | 0 | 1 | python,debugging,gdb,subprocess,selinux | 750,128 | 3 | false | 0 | 0 | Your comment notes that you're sshing in with putty... do you have a controlling tty? With openssh you would want to add the -T option, I don't know how/if putty will do this the way you're using it.
Also: you might try using cygwin's ssh instead of putty. | 2 | 4 | 0 | Scenario:
There is a complex piece of software that is annoying to launch by hand. What I've done is to create a python script to launch the executable and attach gdb for debugging.
The process launching script:
ensures an environment variable is set.
ensures a local build directory gets added to the environment's LD_LIBRARY_PATH variable.
changes the current working directory to where the executable expects to be (not my design)
launches the executable with a config file the only command line option
pipes the output from the executable to a second logging process
remembers PID of executable, then launches & attaches gdb to running executable.
The script works, with one caveat. ctrl-c doesn't interrupt the debugee and return control to gdb. So if I "continue" with no active breakpoints I can never stop the process again, it has to be killed/interrupted from another shell. BTW, running "kill -s SIGINT <pid>" where <pid> is the debuggee's pid does get me back to gdb's prompt... but it is really annoying to have to do things this way
At first I thought Python was grabbing the SIGINT signal, but this doesn't seem to be the case as I set up signal handlers forward the signal to the debugee and that doesn't fix the problem.
I've tried various configurations to the python script (calling os.spawn* instead of subprocess, etc.) It seems that any way I go about it, if python launched the child process, SIGINT (ctrl-c) signals DO NOT to get routed to gdb or the child process.
Current line of thinking
This might be related to needing a
separate process group id for the debugee & gdb...any credence to this?
Possible bug with SELinux?
Info:
gdb 6.8
Python 2.5.2 (problem present with Python 2.6.1 as well)
SELinux Environment (bug delivering signals to processes?)
Alternatives I've considered:
Setting up a .gdbinit file to do as much of what the script does, environment variables and current working directory are a problem with this approach.
Launching executable and attaching gdb manually (yuck)
Question:
How do you automate the launching/debugging of large scale projects?
Update:
I've tried Nicholas Riley's examples below, on my Macintosh at home they all allow cntl-c to work to varrying degrees, on the production boxen (which I now to believe may be running SELinux) they don't... | How do you automate the launching/debugging of large scale projects? | 0 | 0 | 0 | 1,141 |
739,090 | 2009-04-10T22:43:00.000 | 0 | 0 | 0 | 1 | python,debugging,gdb,subprocess,selinux | 753,721 | 3 | false | 0 | 0 | if you already have a current script set up to do this, but are having problems automating part of it, maybe you can just grab expect and use it to provide the setup, then drop back into interactive mode in expect to launch the process. Then you can still have your ctrl-c available to interrupt. | 2 | 4 | 0 | Scenario:
There is a complex piece of software that is annoying to launch by hand. What I've done is to create a python script to launch the executable and attach gdb for debugging.
The process launching script:
ensures an environment variable is set.
ensures a local build directory gets added to the environment's LD_LIBRARY_PATH variable.
changes the current working directory to where the executable expects to be (not my design)
launches the executable with a config file the only command line option
pipes the output from the executable to a second logging process
remembers PID of executable, then launches & attaches gdb to running executable.
The script works, with one caveat. ctrl-c doesn't interrupt the debugee and return control to gdb. So if I "continue" with no active breakpoints I can never stop the process again, it has to be killed/interrupted from another shell. BTW, running "kill -s SIGINT <pid>" where <pid> is the debuggee's pid does get me back to gdb's prompt... but it is really annoying to have to do things this way
At first I thought Python was grabbing the SIGINT signal, but this doesn't seem to be the case as I set up signal handlers forward the signal to the debugee and that doesn't fix the problem.
I've tried various configurations to the python script (calling os.spawn* instead of subprocess, etc.) It seems that any way I go about it, if python launched the child process, SIGINT (ctrl-c) signals DO NOT to get routed to gdb or the child process.
Current line of thinking
This might be related to needing a
separate process group id for the debugee & gdb...any credence to this?
Possible bug with SELinux?
Info:
gdb 6.8
Python 2.5.2 (problem present with Python 2.6.1 as well)
SELinux Environment (bug delivering signals to processes?)
Alternatives I've considered:
Setting up a .gdbinit file to do as much of what the script does, environment variables and current working directory are a problem with this approach.
Launching executable and attaching gdb manually (yuck)
Question:
How do you automate the launching/debugging of large scale projects?
Update:
I've tried Nicholas Riley's examples below, on my Macintosh at home they all allow cntl-c to work to varrying degrees, on the production boxen (which I now to believe may be running SELinux) they don't... | How do you automate the launching/debugging of large scale projects? | 0 | 0 | 0 | 1,141 |
739,687 | 2009-04-11T07:37:00.000 | 1 | 0 | 1 | 0 | python,multithreading,locking,multiprocessing | 739,698 | 3 | false | 0 | 0 | I don't think so. Threading locks are within the same process, while the multiprocessing lock would likely be in shared memory.
Last time I checked, multiprocessing doesn't allow you to share the lock in a Queue, which is a threading lock. | 3 | 7 | 0 | Are the locks from the threading module interchangeable with those from the multiprocessing module? | Python: Locks from `threading` and `multiprocessing` interchangable? | 0.066568 | 0 | 0 | 2,042 |
739,687 | 2009-04-11T07:37:00.000 | 8 | 0 | 1 | 0 | python,multithreading,locking,multiprocessing | 740,197 | 3 | true | 0 | 0 | You can typically use the two interchangeably, but you need to cognizant of the differences. For example, multiprocessing.Event is backed by a named semaphore, which is sensitive to the platform under the application.
Multiprocessing.Lock is backed by Multiprocessing.SemLock - so it needs named semaphores. In essence, you can use them interchangeably, but using multiprocessing's locks introduces some platform requirements on the application (namely, it doesn't run on BSD :)) | 3 | 7 | 0 | Are the locks from the threading module interchangeable with those from the multiprocessing module? | Python: Locks from `threading` and `multiprocessing` interchangable? | 1.2 | 0 | 0 | 2,042 |
739,687 | 2009-04-11T07:37:00.000 | 1 | 0 | 1 | 0 | python,multithreading,locking,multiprocessing | 739,705 | 3 | false | 0 | 0 | Yes, you can use locks from the multiprocessing module as normal in your one-process application, but if you're using multiprocessing, you should use its locks. | 3 | 7 | 0 | Are the locks from the threading module interchangeable with those from the multiprocessing module? | Python: Locks from `threading` and `multiprocessing` interchangable? | 0.066568 | 0 | 0 | 2,042 |
739,993 | 2009-04-11T12:34:00.000 | 0 | 0 | 1 | 0 | python,module,pip | 63,098,126 | 31 | false | 0 | 0 | If none of the above seem to help, in my environment was broken from a system upgrade and I could not upgrade pip. While it won't give you an accurate list you can get an idea of which libraries were installed simply by looking inside your env>lib>python(version here)>site-packages> . Here you will get a good indication of modules installed. | 1 | 1,152 | 0 | How do I get a list of Python modules installed on my computer? | How do I get a list of locally installed Python modules? | 0 | 0 | 0 | 1,573,801 |
740,630 | 2009-04-11T19:07:00.000 | 0 | 0 | 0 | 0 | python,sqlalchemy | 776,246 | 4 | false | 0 | 0 | Could you post a sample of your table and mapper set up? It might be easier to spot what is going on.
Without seeing the code it is hard to tell, but perhaps there is something wrong with the direction of the relationship? | 3 | 9 | 0 | I'm trying to use SQLAlchemy to implement a basic users-groups model where users can have multiple groups and groups can have multiple users.
When a group becomes empty, I want the group to be deleted, (along with other things associated with the group. Fortunately, SQLAlchemy's cascade works fine with these more simple situations).
The problem is that cascade='all, delete-orphan' doesn't do exactly what I want; instead of deleting the group when the group becomes empty, it deletes the group when any member leaves the group.
Adding triggers to the database works fine for deleting a group when it becomes empty, except that triggers seem to bypass SQLAlchemy's cascade processing so things associated with the group don't get deleted.
What is the best way to delete a group when all of its members leave and have this deletion cascade to related entities.
I understand that I could do this manually by finding every place in my code where a user can leave a group and then doing the same thing as the trigger however, I'm afraid that I would miss places in the code (and I'm lazy). | SQLAlchemy many-to-many orphan deletion | 0 | 1 | 0 | 3,255 |
740,630 | 2009-04-11T19:07:00.000 | 3 | 0 | 0 | 0 | python,sqlalchemy | 763,256 | 4 | true | 0 | 0 | The way I've generally handled this is to have a function on your user or group called leave_group. When you want a user to leave a group, you call that function, and you can add any side effects you want into there. In the long term, this makes it easier to add more and more side effects. (For example when you want to check that someone is allowed to leave a group). | 3 | 9 | 0 | I'm trying to use SQLAlchemy to implement a basic users-groups model where users can have multiple groups and groups can have multiple users.
When a group becomes empty, I want the group to be deleted, (along with other things associated with the group. Fortunately, SQLAlchemy's cascade works fine with these more simple situations).
The problem is that cascade='all, delete-orphan' doesn't do exactly what I want; instead of deleting the group when the group becomes empty, it deletes the group when any member leaves the group.
Adding triggers to the database works fine for deleting a group when it becomes empty, except that triggers seem to bypass SQLAlchemy's cascade processing so things associated with the group don't get deleted.
What is the best way to delete a group when all of its members leave and have this deletion cascade to related entities.
I understand that I could do this manually by finding every place in my code where a user can leave a group and then doing the same thing as the trigger however, I'm afraid that I would miss places in the code (and I'm lazy). | SQLAlchemy many-to-many orphan deletion | 1.2 | 1 | 0 | 3,255 |
740,630 | 2009-04-11T19:07:00.000 | 3 | 0 | 0 | 0 | python,sqlalchemy | 770,287 | 4 | false | 0 | 0 | I think you want cascade='save, update, merge, expunge, refresh, delete-orphan'. This will prevent the "delete" cascade (which you get from "all") but maintain the "delete-orphan", which is what you're looking for, I think (delete when there are no more parents). | 3 | 9 | 0 | I'm trying to use SQLAlchemy to implement a basic users-groups model where users can have multiple groups and groups can have multiple users.
When a group becomes empty, I want the group to be deleted, (along with other things associated with the group. Fortunately, SQLAlchemy's cascade works fine with these more simple situations).
The problem is that cascade='all, delete-orphan' doesn't do exactly what I want; instead of deleting the group when the group becomes empty, it deletes the group when any member leaves the group.
Adding triggers to the database works fine for deleting a group when it becomes empty, except that triggers seem to bypass SQLAlchemy's cascade processing so things associated with the group don't get deleted.
What is the best way to delete a group when all of its members leave and have this deletion cascade to related entities.
I understand that I could do this manually by finding every place in my code where a user can leave a group and then doing the same thing as the trigger however, I'm afraid that I would miss places in the code (and I'm lazy). | SQLAlchemy many-to-many orphan deletion | 0.148885 | 1 | 0 | 3,255 |
740,844 | 2009-04-11T21:53:00.000 | 3 | 0 | 1 | 0 | python,multiprocessing,pool | 741,852 | 3 | true | 0 | 0 | From Jesse Noller:
It is not currently supported in the
API, but would not be a bad addition.
I'll look at adding it to
python2.7/2.6.3 3.1 this week | 1 | 7 | 0 | I am subclassing the Process class, into a class I call EdgeRenderer. I want to use multiprocessing.Pool, except instead of regular Processes, I want them to be instances of my EdgeRenderer. Possible? How? | Python multiprocessing: Pool of custom Processes | 1.2 | 0 | 0 | 5,413 |
741,950 | 2009-04-12T15:43:00.000 | 4 | 0 | 1 | 0 | python,parameters,function | 40,388,500 | 6 | false | 0 | 0 | In Python 3, use someMethod.__code__.co_argcount
(since someMethod.func_code.co_argcount doesn't work anymore) | 3 | 34 | 0 | I was creating a simple command line utility and using a dictionary as a sort of case statement with key words linking to their appropriate function. The functions all have different amount of arguments required so currently to check if the user entered the correct amount of arguments needed for each function I placed the required amount inside the dictionary case statement in the form {Keyword:(FunctionName, AmountofArguments)}.
This current setup works perfectly fine however I was just wondering in the interest of self improval if there was a way to determine the required number of arguments in a function and my google attempts have returned so far nothing of value but I see how args and kwargs could screw such a command up because of the limitless amount of arguments they allow. | Programmatically determining amount of parameters a function requires - Python | 0.132549 | 0 | 0 | 27,364 |
741,950 | 2009-04-12T15:43:00.000 | 2 | 0 | 1 | 0 | python,parameters,function | 38,776,881 | 6 | false | 0 | 0 | This has already been answered but without the inspect module you can also use someMethod.func_code.co_argcount | 3 | 34 | 0 | I was creating a simple command line utility and using a dictionary as a sort of case statement with key words linking to their appropriate function. The functions all have different amount of arguments required so currently to check if the user entered the correct amount of arguments needed for each function I placed the required amount inside the dictionary case statement in the form {Keyword:(FunctionName, AmountofArguments)}.
This current setup works perfectly fine however I was just wondering in the interest of self improval if there was a way to determine the required number of arguments in a function and my google attempts have returned so far nothing of value but I see how args and kwargs could screw such a command up because of the limitless amount of arguments they allow. | Programmatically determining amount of parameters a function requires - Python | 0.066568 | 0 | 0 | 27,364 |
741,950 | 2009-04-12T15:43:00.000 | 1 | 0 | 1 | 0 | python,parameters,function | 742,452 | 6 | false | 0 | 0 | Make each command a class, derived from an abstract base defining the general structure of a command. As much as possible, the definition of command properties should be put into class variables with methods defined in the base class handling that data.
Register each of these subclasses with a factory class.
This factory class get the argument list an decides which command to execute by instantiating the appropriate command sub class.
Argument checking is handled by the command sub classes themselves, using properly defined general methods form the command base class.
This way, you never need to repeatedly code the same stuff, and there is really no need to emulate the switch statement. It also makes extending and adding commands very easy, as you can simply add and register a new class. Nothing else to change. | 3 | 34 | 0 | I was creating a simple command line utility and using a dictionary as a sort of case statement with key words linking to their appropriate function. The functions all have different amount of arguments required so currently to check if the user entered the correct amount of arguments needed for each function I placed the required amount inside the dictionary case statement in the form {Keyword:(FunctionName, AmountofArguments)}.
This current setup works perfectly fine however I was just wondering in the interest of self improval if there was a way to determine the required number of arguments in a function and my google attempts have returned so far nothing of value but I see how args and kwargs could screw such a command up because of the limitless amount of arguments they allow. | Programmatically determining amount of parameters a function requires - Python | 0.033321 | 0 | 0 | 27,364 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.