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
1,108,918
2009-07-10T10:58:00.000
3
0
0
0
python,mysql,perl,ip-address
1,109,278
7
false
0
0
Having seperate fields doesn't sound particularly sensible to me - much like splitting a zipcode into sections or a phone number. Might be useful if you wanted specific info on the sections, but I see no real reason to not use a 32 bit int.
3
25
0
We've got a healthy debate going on in the office this week. We're creating a Db to store proxy information, for the most part we have the schema worked out except for how we should store IPs. One camp wants to use 4 smallints, one for each octet and the other wants to use a 1 big int,INET_ATON. These tables are going to be huge so performance is key. I am in middle here as I normally use MS SQL and 4 small ints in my world. I don't have enough experience with this type of volume storing IPs. We'll be using perl and python scripts to access the database to further normalize the data into several other tables for top talkers, interesting traffic etc. I am sure there are some here in the community that have done something simular to what we are doing and I am interested in hearing about their experiences and which route is best, 1 big int, or 4 small ints for IP addresses. EDIT - One of our concerns is space, this database is going to be huge like in 500,000,000 records a day. So we are trying to weigh the space issue along with the performance issue. EDIT 2 Some of the conversation has turned over to the volume of data we are going to store...that's not my question. The question is which is the preferable way to store an IP address and why. Like I've said in my comments, we work for a large fortune 50 company. Our log files contain usage data from our users. This data in turn will be used within a security context to drive some metrics and to drive several security tools.
How to store an IP in mySQL
0.085505
1
0
14,213
1,108,967
2009-07-10T11:09:00.000
0
0
0
0
python,django,validation,architecture,django-models
1,108,987
5
false
1
0
I am not sure if this is best practise but what I do is that I tend to validate both client side and server side before pushing the data to the database. I know it requires a lot more effort but this can be done by setting some values before use and then maintaining them. You could also try push in size contraints with **kwargs into a validation function that is called before the put() call.
4
0
0
I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: one should use form-based validation. It is because ORM is ORM and validation is completely another concept. Take a look at CharField: forms.CharField allows min_length specification, but models.CharField does not. Ok cool, but what the hell all that validation features are doing in django.db.models? I can specify that CharField can't be blank, I can use EmailField, FileField, SlugField validation of which are performed here, in python, not on RDBMS. Furthermore there is the URLField which checks existance of url involving some really complex logic. From another side, if I have an entity I want to guarantee that it will not be saved in inconsistent state whether it came from a form or was modified/created by some internal algorithms. I have a model with name field, I expect it should be longer than one character. I have a min_age and a max_age fields also, it makes not much sense if min_age > max_age. So should I check such conditions in save method? What are the best practices of model validation?
Separation of ORM and validation
0
0
0
585
1,108,967
2009-07-10T11:09:00.000
0
0
0
0
python,django,validation,architecture,django-models
1,109,190
5
false
1
0
Your two options are two different things. Form-based validation can be regarded as syntactic validation + convert HTTP request parameters from text to Python types. Model-based validation can be regarded as semantic validation, sometimes using context not available at the HTTP/form layer. And of course there is a third layer at the DB where constraints are enforced, and may not be checkable anywhere else because of concurrent requests updating the database (e.g. uniqueness constraints, optimistic locking).
4
0
0
I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: one should use form-based validation. It is because ORM is ORM and validation is completely another concept. Take a look at CharField: forms.CharField allows min_length specification, but models.CharField does not. Ok cool, but what the hell all that validation features are doing in django.db.models? I can specify that CharField can't be blank, I can use EmailField, FileField, SlugField validation of which are performed here, in python, not on RDBMS. Furthermore there is the URLField which checks existance of url involving some really complex logic. From another side, if I have an entity I want to guarantee that it will not be saved in inconsistent state whether it came from a form or was modified/created by some internal algorithms. I have a model with name field, I expect it should be longer than one character. I have a min_age and a max_age fields also, it makes not much sense if min_age > max_age. So should I check such conditions in save method? What are the best practices of model validation?
Separation of ORM and validation
0
0
0
585
1,108,967
2009-07-10T11:09:00.000
0
0
0
0
python,django,validation,architecture,django-models
1,109,327
5
false
1
0
"but what the hell all that validation features are doing in django.db.models? " One word: Legacy. Early versions of Django had less robust forms and the validation was scattered. "So should I check such conditions in save method?" No, you should use a form for all validation. "What are the best practices of model validation?"* Use a form for all validation. "whether it came from a form or was modified/created by some internal algorithms" What? If your algorithms suffer from psychotic episodes or your programmers are sociopaths, then -- perhaps -- you have to validate internally-generated data. Otherwise, internally-generated data is -- by definition -- valid. Only user data can be invalid. If you don't trust your software, what's the point of writing it? Are your unit tests broken?
4
0
0
I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: one should use form-based validation. It is because ORM is ORM and validation is completely another concept. Take a look at CharField: forms.CharField allows min_length specification, but models.CharField does not. Ok cool, but what the hell all that validation features are doing in django.db.models? I can specify that CharField can't be blank, I can use EmailField, FileField, SlugField validation of which are performed here, in python, not on RDBMS. Furthermore there is the URLField which checks existance of url involving some really complex logic. From another side, if I have an entity I want to guarantee that it will not be saved in inconsistent state whether it came from a form or was modified/created by some internal algorithms. I have a model with name field, I expect it should be longer than one character. I have a min_age and a max_age fields also, it makes not much sense if min_age > max_age. So should I check such conditions in save method? What are the best practices of model validation?
Separation of ORM and validation
0
0
0
585
1,108,967
2009-07-10T11:09:00.000
0
0
0
0
python,django,validation,architecture,django-models
1,111,592
5
false
1
0
DB/Model validation The data store in database must always be in a certain form/state. For example: required first name, last name, foreign key, unique constraint. This is where the logic of you app resides. No matter where you think the data comes from - it should be "validated" here and an exception raised if the requirements are not met. Form validation Data being entered should look right. It is ok if this data is entered differently through some other means (through admin or api calls). Examples: length of person's name, proper capitalization of the sentence... Example1: Object has a StartDate and an EndDate. StartDate must always be before EndDate. Where do you validate this? In the model of course! Consider a case when you might be importing data from some other system - you don't want this to go through. Example2: Password confirmation. You have a field for storing the password in the db. However you display two fields: password1 and password2 on your form. The form, and only the form, is responsible for comparing those two fields to see that they are the same. After form is valid you can safely store the password1 field into the db as the password.
4
0
0
I use django and I wonder in what cases where model validation should go. There are at least two variants: Validate in the model's save method and to raise IntegrityError or another exception if business rules were violated Validate data using forms and built-in clean_* facilities From one point of view, answer is obvious: one should use form-based validation. It is because ORM is ORM and validation is completely another concept. Take a look at CharField: forms.CharField allows min_length specification, but models.CharField does not. Ok cool, but what the hell all that validation features are doing in django.db.models? I can specify that CharField can't be blank, I can use EmailField, FileField, SlugField validation of which are performed here, in python, not on RDBMS. Furthermore there is the URLField which checks existance of url involving some really complex logic. From another side, if I have an entity I want to guarantee that it will not be saved in inconsistent state whether it came from a form or was modified/created by some internal algorithms. I have a model with name field, I expect it should be longer than one character. I have a min_age and a max_age fields also, it makes not much sense if min_age > max_age. So should I check such conditions in save method? What are the best practices of model validation?
Separation of ORM and validation
0
0
0
585
1,108,974
2009-07-10T11:12:00.000
1
0
1
0
python,development-environment,ubuntu-9.04
1,109,305
7
false
1
0
"Question1: How will i tell any framework that go and use version so and so pf python like day django to use 2.6 and say mjango to use 2.4?" You simply run them with the specific python version they need. Run mjango with /usr/bin/python2.4 and django with /usr/bin/python2.6. As easy as that. "Question2: Is there more elegant way to switch between version as my hack of symlinking was a virtual disaster?" Yes, see above. Have two separate installs of Python, and run explicitly with the different versions. "Question3: Can I download a deb for say hardy and make jaunty believe its for her?" That generally works. If it doesn't, it's because it has dependencies that exist in Hardy, and does not exist in Jaunty, and then you can't. And here is a Question 4 you didn't ask, but should have. ;) "Is there an easier way to download all those Python modules?" Yes, there is. Install setuptools, and use easy_install. It will not help you with library dependecies for those Python modules that have C code and need to be compiled. But it will help with all others. easy_install will download and install all the Python dependencies of the module in question in one go. That makes it a lot quicker to install Python modules.
2
16
0
Story: One of the app that i have works on python 2.4 and other on 2.6. I tried to do a sym link of python2.4 to python and things started to break loose on ubuntu jaunty. Now i am downloading every dependency of 2.4 and installing it using python2.4 setup.py install. The dependencies seem to be endless. Question1: How will i tell any framework that go and use version so and so pf python like day django to use 2.6 and say mjango to use 2.4? Something like we say use database databasename kinda syntax. Question2: Is there more elegant way to switch between version as my hack of symlinking was a virtual disaster? Question3: Can I download a deb for say hardy and make jaunty believe its for her?
switch versions of python
0.028564
0
0
26,273
1,108,974
2009-07-10T11:12:00.000
0
0
1
0
python,development-environment,ubuntu-9.04
35,381,570
7
false
1
0
Move to the project directory : Create an environment : virtualenv -p python2.7 --no-site-packages ~/env/twoseven Then activate your source : source ~/env/twoseven/bin/activate
2
16
0
Story: One of the app that i have works on python 2.4 and other on 2.6. I tried to do a sym link of python2.4 to python and things started to break loose on ubuntu jaunty. Now i am downloading every dependency of 2.4 and installing it using python2.4 setup.py install. The dependencies seem to be endless. Question1: How will i tell any framework that go and use version so and so pf python like day django to use 2.6 and say mjango to use 2.4? Something like we say use database databasename kinda syntax. Question2: Is there more elegant way to switch between version as my hack of symlinking was a virtual disaster? Question3: Can I download a deb for say hardy and make jaunty believe its for her?
switch versions of python
0
0
0
26,273
1,109,422
2009-07-10T13:08:00.000
1
0
1
0
python,image,python-imaging-library
22,503,379
9
false
0
0
As I commented above, problem seems to be the conversion from PIL internal list format to a standard python list type. I've found that Image.tostring() is much faster, and depending on your needs it might be enough. In my case, I needed to calculate the CRC32 digest of image data, and it suited fine. If you need to perform more complex calculations, tom10 response involving numpy might be what you need.
1
47
0
Guys, I'm looking for a bit of assistance. I'm a newbie programmer and one of the problems I'm having at the minute is trying to convert a black & white .jpg image into a list which I can then modulate into an audio signal. This is part of a lager project to create a python SSTV program. I have imported the PIL module and am trying to call the built-in function: list(im.getdata()). When I call it, python crashes. Is there some way of breaking down the image (always 320x240) into 240 lines to make the computations easier? Or am I just calling the wrong function. If anyone has any suggestions please fire away. If anyone has experience of generating modulated audio tones using python I would gladly accept any 'pearls of wisdom' they are willing to impart. Thanks in advance
Getting list of pixel values from PIL
0.022219
0
0
170,867
1,109,498
2009-07-10T13:24:00.000
4
0
0
0
python,fonts,pygame
1,109,553
2
false
0
1
A quick and dirty way would be to render your text multiple times with the outline color, shifted by small amounts on a circle around the text position: 1 8 | 2 \ | / \|/ 7----*----3 /|\ / | \ 6 | 4 5 Edit: Doh you've been faster ! I wont delete my answer though, this ASCII art is just too good and deserves to live ! Edit 2: As OregonGhost mentioned, you may need more or fewer steps for the outline rendering, depending on your outline width.
1
7
0
I'm writing a game in python with pygame and need to render text onto the screen. I want to render this text in one colour with an outline, so that I don't have to worry about what sort of background the the text is being displayed over. pygame.font doesn't seem to offer support for doing this sort of thing directly, and I'm wondering if anyone has any good solutions for achieving this?
What's a good way to render outlined fonts?
0.379949
0
0
2,637
1,109,870
2009-07-10T14:27:00.000
7
0
1
0
python,multiprocessing
1,109,930
5
true
0
0
Best is to designate one specific process as owning that instance and dedicated to it; any other process requiring access to that instance obtains it by sending messages to the owning process via a Queue (as supplied by the multiprocessing module) or other IPC mechanisms for message passing, and gets answers back via similar mechanisms.
1
6
0
How can I code to share the same instance of a "singletonic" class among processes?
python singleton into multiprocessing
1.2
0
0
7,503
1,110,804
2009-07-10T17:16:00.000
0
0
0
1
python,subprocess
1,110,847
4
false
0
0
The short answer is that there is no such thing as a good cross platform system for process management, without designing that concept into your system. This is especially in the standar libraries. Even the various unix versions have their own compatibility issues. Your best bet is to instrument all the processes with the proper event handling to notice events that come in from whatever IPC system works best on whatever platform. Named pipes will be the general route for the problem you describe, but there will be implementation differences on each platform.
1
4
0
I would like to be able to spawn a process in python and have two way communication. Of course, Pexpect does this and is indeed a way I might go. However, it is not quite ideal. My ideal situation would be to have a cross platform generic technique that involved only the standard python libraries. Subprocess gets pretty close, but the fact that I have to wait for the process to terminate before safely interacting with it is not desirable. Looking at the documentation, it does say there is a stdin,stdout and stderr file descriptors that I can directly manipulate, but there is a big fat warning that says "Don't Do This". Unfortunately its not entirely clear why this warning exists, but from what I gather from google is that it is related to os buffering, and it is possible to write code that unexpectedly deadlocks when those internal buffers fail (as a side note, any examples that show the wrong way and right way would be appreciated). So, risking my code to potential deadlocks, I thought it might be interesting to use poll or select to interactively read from the running process without killing it. Although I lose (i think) the cross platform ability, I like the fact that it requires no additional libraries. But more importantly, I would like to know if this is this a good idea. I have yet to try this approach, but I am concerned about gotchas that could potentially devastate my program. Can it work? What should I test for? In my specific case I am not really concerned about being able to write to the process, just repeatedly reading from it. Also, I don't expect my processes to dump huge amounts of text, so I hope to avoid the deadlocking issue, however I would like to know exactly what those limits are and be able to write some tests to see where it breaks down.
Python subprocess question
0
0
0
1,227
1,110,805
2009-07-10T17:16:00.000
1
0
0
0
python,sqlalchemy
1,110,990
3
true
0
0
I had some issues with sqlalchemy's performance as well - I think you should first figure out in which ways you are using it ... they recommend that for big data sets is better to use the sql expression language. Either ways try and optimize the sqlalchemy code and have the Oracle database optimized as well, so you can better figure out what's wrong. Also, do some tests on the database.
2
1
0
HI , I made a ICAPServer (similar with httpserver) for which the performance is very important. The DB module is sqlalchemy. I then made a test about the performance of sqlalchemy, as a result, i found that it takes about 30ms for sqlalchemy to write <50kb data to DB (Oracle), i don`t know if the result is normal, or i did something wrong? BUT, no matter right or wrong, it seems the bottle-neck comes from the DB part. HOW can i improve the performance of sqlalchemy? OR it is up to DBA to improve Oracle? BTW, ICAPServer and Oracle are on the same pc , and i used the essential way of sqlalchemy..
python sqlalchemy performance?
1.2
1
0
4,462
1,110,805
2009-07-10T17:16:00.000
1
0
0
0
python,sqlalchemy
1,110,888
3
false
0
0
You can only push SQLAlchemy so far as a programmer. I would agree with you that the rest of the performance is up to your DBA, including creating proper indexes on tables, etc.
2
1
0
HI , I made a ICAPServer (similar with httpserver) for which the performance is very important. The DB module is sqlalchemy. I then made a test about the performance of sqlalchemy, as a result, i found that it takes about 30ms for sqlalchemy to write <50kb data to DB (Oracle), i don`t know if the result is normal, or i did something wrong? BUT, no matter right or wrong, it seems the bottle-neck comes from the DB part. HOW can i improve the performance of sqlalchemy? OR it is up to DBA to improve Oracle? BTW, ICAPServer and Oracle are on the same pc , and i used the essential way of sqlalchemy..
python sqlalchemy performance?
0.066568
1
0
4,462
1,111,173
2009-07-10T18:22:00.000
3
0
0
0
python,django,shopping-cart
1,111,510
3
false
1
0
Ingredients: one cup PayPal (or subsitute with other equivalent payment system) few cups html add css to taste add django if desired Cooking: Mix well. Bake for 1-2 month. Release as open source :-)
1
1
0
Is there a book or a tutorial which teaches how to build a shopping cart with django or any other python framework ?
How to build an Ecommerce Shopping Cart in Django?
0.197375
0
0
10,724
1,111,869
2009-07-10T20:39:00.000
2
0
1
0
python,quine
1,112,795
10
false
0
0
What are quines used for? Programming exercises and viruses. A virus needs to replicate somehow -- and one way is to make it a quine. Let's say that a hypothetical antivirus program would flag any process that read its own binary into memory (to pass it to the intended victim); the way to get around that would to have it output itself. Bear in mind that a quine in machine code would require no compilation.
2
18
0
I came across this term - Quine (also called self-reproducing programs). Just wanted to know more on it. How does one write a quine and are they used anywhere or they are just an exercise for fun? I've started with Python, and I might try writing one in Python. Any suggestions?
What are quines? Any specific purpose to have them?
0.039979
0
0
4,308
1,111,869
2009-07-10T20:39:00.000
9
0
1
0
python,quine
1,764,933
10
false
0
0
As others explained, quines are programs that reproduce exact copies of themselves. With regards to applications, if you think that the DNA encodes logic to interpret itself and reproduce itself - the answer is pretty straightforward, without the concept of quines we wouldn't be here and we would never be able to create artificial (self-reproducing) life.
2
18
0
I came across this term - Quine (also called self-reproducing programs). Just wanted to know more on it. How does one write a quine and are they used anywhere or they are just an exercise for fun? I've started with Python, and I might try writing one in Python. Any suggestions?
What are quines? Any specific purpose to have them?
1
0
0
4,308
1,112,198
2009-07-10T21:59:00.000
6
0
1
0
python
1,112,223
2
false
1
0
__name__ is usually the module name, but it's changed to '__main__' when the module in question is executed directly instead of being imported by another one. I understand that other values can only be set directly by the code you're running.
1
9
0
Checking to see if __name__ == '__main__' is a common idiom to run some code when the file is being called directly, rather than through a module. In the process of writing a custom command for Django's manage.py, I found myself needing to use code.InteractiveConsole, which gives the effect to the user of a standard python shell. In some test code I was doing, I found that in the script I'm trying to execute, I get that __name__ is __console__, which caused my code (dependent on __main__) to not run. I'm fairly certain that I have some things in my original implementation to change, but it got me wondering as to what different things __name__ could be. I couldn't find any documentation on the possible values, nor what they mean, so that's how I ended up here.
What are the different possible values for __name__ in a Python script, and what do they mean?
1
0
0
1,833
1,113,040
2009-07-11T05:45:00.000
1
1
0
1
python,c,macos,fonts
1,113,055
5
false
0
0
Do you want to write a program to do it, or do you want to use a program to do it? There are many programs that list fonts, xlsfonts comes to mind.
1
5
0
I'm trying to programatically get a list of installed fonts in C or Python. I need to be able to do this on OS X, does anyone know how?
List of installed fonts OS X / C
0.039979
0
0
5,834
1,113,066
2009-07-11T06:02:00.000
1
0
0
1
java,python,google-app-engine,httpwebrequest,keep-alive
4,707,002
4
false
1
0
App engine also has a new PAY feature where you can have it "always-on". Costs about $0.30 USD cents a day. Just go into your billing settings and enable it if you don't mind paying for the feature. I believe it guarantees you at least 3 instances always running. (I didn't realize hitting a /ping url which caused an instance to spin up would cause it to exceed the 30 sec limit!)
1
3
0
App Engine allows you 30 seconds to load your application My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this. If the app is idle (does not receive a request for a while), it needs to be re-loaded. So, to avoid the app needing to be reloaded, I want to simulate user activity by pinging the app every so often. But there's a catch . . . If I ping the app and it has already been unloaded by App Engine, my web request will be the first request to the app and the app will try to reload. This could take longer than 30 seconds and exceed the loading time limit. So my idea is to ping the app but not wait for the response. I have simulated this manually by going to the site from a browser, making the request and immediately closing the browser - it seems to keep the app alive. Any suggestions for a good way to do this in a Python or Java web cron (I'm assuming a Python solution will be simpler)?
How to keep an App Engine/Java app running with deaf requests from a Java/Python web cron?
0.049958
0
0
1,731
1,113,479
2009-07-11T10:57:00.000
3
1
1
0
python,configuration,google-maps
1,113,496
3
true
0
0
No, there's no standard location - on Windows, it's usually in the directory os.path.join(os.environ['APPDATA'], 'appname') and on Unix it's usually os.path.join(os.environ['HOME'], '.appname').
1
3
0
I have a small Python program, which uses a Google Maps API secret key. I'm getting ready to check-in my code, and I don't want to include the secret key in SVN. In the canonical PHP app you put secret keys, database passwords, and other app specific config in LocalSettings.php. Is there a similar file/location which Python programmers expect to find and modify?
Where to store secret keys and password in Python
1.2
0
0
3,025
1,114,312
2009-07-11T18:11:00.000
14
0
1
1
python,process
1,114,435
3
false
0
0
os.kill does not kill processes, it sends them signals (it's poorly named). If you send signal 0, you can determine whether you are allowed to send other signals. An error code will indicate whether it's a permission problem or a missing process. See man 2 kill for more info. Also, if the process is your child, you can get a SIGCHLD when it dies, and you can use one of the wait calls to deal with it.
1
3
0
I have a process id in Python. I know I can kill it with os.kill(), but how do I check if it is alive ? Is there a built-in function or do I have to go to the shell?
How do I check if a process is alive in Python on Linux?
1
0
0
15,728
1,115,238
2009-07-12T03:21:00.000
0
0
0
0
python,database,django,django-models,synchronization
1,117,089
5
false
1
0
Just to throw in an extra opinion - dmigrations is pretty nice and clear to use, but I'd say South is your best bet. Again, it's easy to get into, but it's more powerful and also has support for more database backends than just MySQL. It even handles MSSQL, if that's your thing
2
4
0
If I change a field in a Django model, how can I synchronize it with the database tables? Do I need to do it manually on the database or is there a tool that does helps with the process?
Django Model Sync Table
0
0
0
6,973
1,115,238
2009-07-12T03:21:00.000
4
0
0
0
python,database,django,django-models,synchronization
1,232,838
5
false
1
0
Can't seem to be able to add a comment to the marked answer, probably because I haven't got enough rep (be nice if SO told me so though). Anyway, just wanted to add that in the answered post, I believe it is wrong about syncdb - syncdb does not touch tables once they have been created and have data in them. You should not lose data by calling it (otherwise, how could you add new tables for new apps?) I believe the poster was referring to the reset command instead, which does result in data loss - it will drop the table and recreate it and hence it'll have all the latest model changes.
2
4
0
If I change a field in a Django model, how can I synchronize it with the database tables? Do I need to do it manually on the database or is there a tool that does helps with the process?
Django Model Sync Table
0.158649
0
0
6,973
1,115,420
2009-07-12T06:32:00.000
8
0
1
0
python,django,thread-safety
1,115,427
2
false
1
0
Functions in a module are equivalent to static methods in a class. The issue of thread safety arises when multiple threads may be modifying shared data, or even one thread may be modifying such data while others are reading it; it's best avoided by making data be owned by ONE module (accessed via Queue.Queue from others), but when that's not feasible you have to resort to locking and other, more complex, synchronization primitives. This applies whether the access to shared data happens in module functions, static methods, or instance methods -- and the shared data is such whether it's instance variables, class ones, or global ones (scoping and thread safety are essentially disjoint, except that function-local data is, to a pont, intrinsically thread-safe -- no other thread will ever see the data inside a function instance, until and unless the function deliberately "shares" it through shared containers). If you use the multiprocessing module in Python's standard library, instead of the threading module, you may in fact not have to care about "thread safety" -- essentially because NO data is shared among processes... well, unless you go out of your way to change that, e.g. via mmapped files;-).
1
3
0
In python with all this idea of "Everything is an object" where is thread-safety? I am developing django website with wsgi. Also it would work in linux, and as I know they use effective process management, so we could not think about thread-safety alot. I am not doubt in how module loads, and there functions are static or not? Every information would be helpfull.
Static methods and thread safety
1
0
0
3,314
1,116,163
2009-07-12T14:54:00.000
0
0
1
0
python,sqlalchemy,twisted
1,116,170
3
false
0
0
Put an upper limit on the amount of data in the queue?
2
0
0
My program is ICAPServer (similar with httpserver), it's main job is to receive data from clients and save the data to DB. There are two main steps and two threads: ICAPServer receives data from clients, puts the data in a queue (50kb <1ms); another thread pops data from the queue, and writes them to DB SO, if 2nd step is too slow, the queue will fill up memory with those data. Wondering if anyone have any suggestion...
python program choice
0
0
0
232
1,116,163
2009-07-12T14:54:00.000
2
0
1
0
python,sqlalchemy,twisted
1,116,224
3
false
0
0
It is hard to say for sure, but perhaps using two processes instead of threads will help in this situation. Since Python has the Global Interpreter Lock (GIL), it has the effect of only allowing any one thread to execute Python instructions at any time. Having a system designed around processes might have the following advantages: Higher concurrency, especially on multiprocessor machines Greater throughput, since you can probably spawn multiple queue consumers / DB writer processes to spread out the work. Although, the impact of this might be minimal if it is really the DB that is the bottleneck and not the process writing to the DB.
2
0
0
My program is ICAPServer (similar with httpserver), it's main job is to receive data from clients and save the data to DB. There are two main steps and two threads: ICAPServer receives data from clients, puts the data in a queue (50kb <1ms); another thread pops data from the queue, and writes them to DB SO, if 2nd step is too slow, the queue will fill up memory with those data. Wondering if anyone have any suggestion...
python program choice
0.132549
0
0
232
1,116,362
2009-07-12T16:25:00.000
3
0
0
0
python,cookies,urllib2,cookiejar
1,116,535
4
true
1
0
If all pages have the same JavaScript then maybe you could parse the HTML to find that piece of code, and from that get the value the cookie would be set to? That would make your scraping quite vulnerable to changes in the third party website, but that's most often the case while scraping. (Please bear in mind that the third-party website owner may not like that you're getting the content this way.)
1
2
0
I've had a look at many tutorials regarding cookiejar, but my problem is that the webpage that i want to scape creates the cookie using javascript and I can't seem to retrieve the cookie. Does anybody have a solution to this problem?
Retrieve cookie created using javascript in python
1.2
0
0
2,627
1,116,449
2009-07-12T17:13:00.000
4
1
1
0
python,unicode
1,116,549
6
false
0
0
Additional to Mihails comment I would say: Use Unicode, since it is the future. In Python 3.0, Non-Unicode will be gone, and as much I know, all the "U"-Prefixes will make trouble, since they are also gone.
5
20
0
Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.
Should I use Unicode string by default?
0.132549
0
0
3,614
1,116,449
2009-07-12T17:13:00.000
19
1
1
0
python,unicode
1,116,476
6
true
0
0
From my practice -- use unicode. At beginning of one project we used usuall strings, however our project was growing, we were implementing new features and using new third-party libraries. In that mess with non-unicode/unicode string some functions started failing. We started spending time localizing this problems and fixing them. However, some third-party modules doesn't supported unicode and started failing after we switched to it (but this is rather exclusion than a rule). Also I have some experience when we needed to rewrite some third party modules(e.g. SendKeys) cause they were not supporting unicode. If it was done in unicode from beginning it will be better :) So I think today we should use unicode. P.S. All that mess upwards is only my hamble opinion :)
5
20
0
Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.
Should I use Unicode string by default?
1.2
0
0
3,614
1,116,449
2009-07-12T17:13:00.000
2
1
1
0
python,unicode
1,116,487
6
false
0
0
If you are dealing with severely constrained memory or disk space, use ASCII strings. In this case, you should additionally write your software in C or something even more compact :)
5
20
0
Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.
Should I use Unicode string by default?
0.066568
0
0
3,614
1,116,449
2009-07-12T17:13:00.000
13
1
1
0
python,unicode
1,116,660
6
false
0
0
Yes, use unicode. Some hints: When doing input output in any sort of binary format, decode directly after reading and encode directly before writing, so that you never need to mix strings and unicode. Because mixing that tends to lead to UnicodeEncodeDecodeErrors sooner or later. [Forget about this one, my explanations just made it even more confusing. It's only an issue when porting to Python 3, you can care about it then.] Common Python newbie errors with Unicode (not saying you are a newbie, but this may be read by newbies): Don't confuse encode and decode. Remember, UTF-8 is an ENcoding, so you ENcode Unicode to UTF-8 and DEcode from it. Do not fall into the temptation of setting the default encoding in Python (by setdefaultencoding in sitecustomize.py or similar) to whatever you use most. That is just going to give you problems if you reinstall or move to another computer or suddenly need to use another encoding. Be explicit. Remember, not all of Python 2s standard library accepts unicode. If you feed a method unicode and it doesn't work, but it should, try feeding it ascii and see. Examples: urllib.urlopen(), which fails with unhelpful errors if you give it a unicode object instead of a string. Hm. That's all I can think of now!
5
20
0
Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.
Should I use Unicode string by default?
1
0
0
3,614
1,116,449
2009-07-12T17:13:00.000
6
1
1
0
python,unicode
1,116,581
6
false
0
0
It can be tricky to consistently use unicode strings in Python 2.x - be it because somebody inadvertently uses the more natural str(blah) where they meant unicode(blah), forgetting the u prefix on string literals, third-party module incompatibilities - whatever. So in Python 2.x, use unicode only if you have to, and are prepared to provide good unit test coverage. If you have the option of using Python 3.x however, you don't need to care - strings will be unicode with no extra effort.
5
20
0
Is it considered as a good practice to pick Unicode string over regular string when coding in Python? I mainly work on the Windows platform, where most of the string types are Unicode these days (i.e. .NET String, '_UNICODE' turned on by default on a new c++ project, etc ). Therefore, I tend to think that the case where non-Unicode string objects are used is a sort of rare case. Anyway, I'm curious about what Python practitioners do in real-world projects.
Should I use Unicode string by default?
1
0
0
3,614
1,116,725
2009-07-12T19:36:00.000
0
0
0
0
python,excel,formula
1,116,782
6
false
0
0
If you are using COM bindings, then you can simply record a macro in Excel, then translate it into Python code. If you are using xlwt, you have to resort to normal loops in python..
1
1
0
I would like to insert a calculation in Excel using Python. Generally it can be done by inserting a formula string into the relevant cell. However, if i need to calculate a formula multiple times for the whole column the formula must be updated for each individual cell. For example, if i need to calculate the sum of two cells, then for cell C(k) the computation would be A(k)+B(k). In excel it is possible to calculate C1=A1+B1 and then automatically expand the calculation by dragging the mouse from C1 downwards. My question is: Is it possible to the same thing with Python, i.e. to define a formula in only one cell and then to use Excel capabilities to extend the calculation for the whole column/row? Thank you in advance, Sasha
Calculating formulae in Excel with Python
0
1
0
12,592
1,116,948
2009-07-12T21:19:00.000
19
0
1
0
python,django
1,117,692
2
false
1
0
settings.py is for Django settings; it's fine to put your own settings in there, but using it for arbitrary non-configuration data structures isn't good practice. Just put it in the module it logically belongs to, and it'll be run just once per instance. If you want to guarantee that the module is loaded on startup and not on first use later on, import that module from your top-level __init__.py to force it to be loaded immediately.
2
10
0
I have a big array, that I would like to load into memory only once when django starts up and then treat it as a read only global variable. What is the best place to put the code for the initialization of that array? If I put it in settings.py it will be reinitialized every time the settings module is imported, correct?
Django Initialization
1
0
0
6,064
1,116,948
2009-07-12T21:19:00.000
9
0
1
0
python,django
1,117,100
2
true
1
0
settings.py is the right place for that. Settings.py is, like any other module, loaded once. There is still the problem of the fact that a module must be imported once for each process, so a respawning style of web server (like apache) will reload it once for each instance in question. For mod_python this will be once per process. for mod_wsgi, this is likely to be just one time, unless you have to restart. tl;dr modules are imported once, even if multiple import statements are used. put it in settings.py
2
10
0
I have a big array, that I would like to load into memory only once when django starts up and then treat it as a read only global variable. What is the best place to put the code for the initialization of that array? If I put it in settings.py it will be reinitialized every time the settings module is imported, correct?
Django Initialization
1.2
0
0
6,064
1,116,990
2009-07-12T21:35:00.000
2
0
1
0
python,decimal,precision
20,875,524
3
false
0
0
I know this question was a long time ago, but I figured people probably still search something like this so I figured I'd mention some things to keep in mind when doing it since I tried coding and eventually changed my mind to using long division and finding where repetition occurs when you get a remainder after dividing into it. I was actually originally trying to use the method suggested by Ants Aasma. I was trying to get output such as this for 1/7, since my function was trying to output a string which could be used as an answer to a question; "0.142857 142857..." Decimals such as 1/7 are very easily found using the method provided by Ants Aasma, however it gets painful when you try something such as 1/35 - this cant be divided into a number full of 9s. First of all, any denominators will have to have any factors of 10 divided out - i.e. divide out all the 5s and 2s, converting a fraction such as 1/35 to 0.2/7 For a fraction such as 1/70, I believe the best way is to actually find 1/7 and then stick a 0 right after the decimal place. For 1/35, you would convert it to 0.2/7 and then to 2/7 with a 0 between the repeating part and the decimal place. Just a couple of tips to keep in mind if using Ants Aasma's suggested method.
2
9
0
I'm working with fractions using Python's decimal module and I'd like to get just the repeating part of a certain fraction. For example: if I had 1/3 I'd like to get 3, if I had 1/7 I'd like to get 142857. Is there any standard function to do this?
Is there any way to get the repeating decimal section of a fraction in Python?
0.132549
0
0
17,332
1,116,990
2009-07-12T21:35:00.000
2
0
1
0
python,decimal,precision
1,117,033
3
false
0
0
Find the first number of the form 10**k - 1 that divides exactly by the denominator of the fraction, divide it by the denominator and multiply by the numerator and you get your repeating part.
2
9
0
I'm working with fractions using Python's decimal module and I'd like to get just the repeating part of a certain fraction. For example: if I had 1/3 I'd like to get 3, if I had 1/7 I'd like to get 142857. Is there any standard function to do this?
Is there any way to get the repeating decimal section of a fraction in Python?
0.132549
0
0
17,332
1,117,414
2009-07-13T01:29:00.000
0
0
0
1
python,filesystems,cygwin,path,utilities
1,117,427
3
false
0
0
What happens when you type "ls"? Do you see "infile.txt" listed there?
1
1
0
I have lots of directories with text files written using (g)vim, and I have written a handful of utilities that I find useful in Python. I start off the utilities with a pound-bang-/usr/bin/env python line in order to use the Python that is installed under cygwin. I would like to type commands like this: %cd ~/SomeBook %which pythonUtil /usr/local/bin/pythonUtil %pythonUtil ./infile.txt ./outfile.txt (or % pythonUtil someRelPath/infile.txt somePossiblyDifferentRelPath/outfile.txt) pythonUtil: Found infile.txt; Writing outfile.txt; Done (or some such, if anything) However, my pythonUtil programs keep telling me that they can't find infile.txt. If I copy the utility into the current working directory, all is well, but then I have copies of my utilities littering the landscape. What should I be doing? Yet Another Edit: To summarize --- what I wanted was os.path.abspath('filename'). That returns the absolute pathname as a string, and then all ambiguity has been removed. BUT: IF the Python being used is the one installed under cygwin, THEN the absolute pathname will be a CYGWIN-relative pathname, like /home/someUser/someDir/someFile.txt. HOWEVER, IF the Python has been installed under Windows (and is here being called from a cygwin terminal commandline), THEN the absolute pathname will be the complete Windows path, from 'drive' on down, like D:\cygwin\home\someUser\someDir\someFile.txt. Moral: Don't expect the cygwin Python to generate a Windows-complete absolute pathname for a file not rooted at /; it's beyond its event horizon. However, you can reach out to any file on a WinXP system with the cygwin-python if you specify the file's path using the "/cygdrive/driveLetter" leadin convention. Remark: Don't use '\'s for separators in the WinXP path on the cygwin commandline; use '/'s and trust the snake. No idea why, but some separators may be dropped and the path may be modified to include extra levels, such as "Documents and Settings\someUser" and other Windows nonsense. Thanks to the responders for shoving me in the right direction.
How do I tell a Python script (cygwin) to work in current (or relative) directories?
0
0
0
2,062
1,117,538
2009-07-13T02:44:00.000
1
0
0
0
python,sqlalchemy
1,117,592
2
false
0
0
As long as each concurrent thread has it's own session you should be fine. Trying to use one shared session is where you'll get into trouble.
1
0
0
HI,i got a multi-threading program which all threads will operate on oracle DB. So, can sqlalchemy support parallel operation on oracle? tks!
python sqlalchemy parallel operation
0.099668
1
0
2,195
1,117,828
2009-07-13T05:31:00.000
1
0
0
0
python,mysql,exception
1,117,841
2
false
0
0
I think that the connections and the query can raised errors so you should have try/excepy for both of them.
2
9
0
Just starting to get to grips with python and MySQLdb and was wondering Where is the best play to put a try/catch block for the connection to MySQL. At the MySQLdb.connect point? Also should there be one when ever i query? What exceptions should i be catching on any of these blocks? thanks for any help Cheers Mark
Python MySQLdb exceptions
0.099668
1
0
5,063
1,117,828
2009-07-13T05:31:00.000
16
0
0
0
python,mysql,exception
1,118,129
2
true
0
0
Catch the MySQLdb.Error, while connecting and while executing query
2
9
0
Just starting to get to grips with python and MySQLdb and was wondering Where is the best play to put a try/catch block for the connection to MySQL. At the MySQLdb.connect point? Also should there be one when ever i query? What exceptions should i be catching on any of these blocks? thanks for any help Cheers Mark
Python MySQLdb exceptions
1.2
1
0
5,063
1,117,958
2009-07-13T06:36:00.000
2
0
0
1
python,sockets,raw-sockets
1,186,810
8
false
0
0
Eventually the best solution for this case was to write the entire thing in C, because it's not a big application, so it would've incurred greater penalty to write such a small thing in more than 1 language. After much toying with both the C and python RAW sockets, I eventually preferred the C RAW sockets. RAW sockets require bit-level modifications of less than 8 bit groups for writing the packet headers. Sometimes writing only 4 bits or less. python defines no assistance to this, whereas Linux C has a full API for this. But I definitely believe that if only this little bit of header initialization was handled conveniently in python, I would've never used C here.
1
46
0
I am writing an application to test a network driver for handling corrupted data. And I thought of sending this data using raw socket, so it will not be corrected by the sending machine's TCP-IP stack. I am writing this application solely on Linux. I have code examples of using raw sockets in system-calls, but I would really like to keep my test as dynamic as possible, and write most if not all of it in Python. I have googled the web a bit for explanations and examples of the usage of raw sockets in python, but haven't found anything really enlightening. Just a a very old code example that demonstrates the idea, but in no means work. From what I gathered, Raw Socket usage in Python is nearly identical in semantics to UNIX's raw socket, but without the structs that define the packets structure. I was wondering if it would even be better not to write the raw socket part of the test in Python, but in C with system-calls, and call it from the main Python code?
How Do I Use Raw Socket in Python?
0.049958
0
1
109,072
1,118,163
2009-07-13T07:49:00.000
-1
0
0
0
python,django,google-app-engine,turbogears,turbogears2
51,161,118
7
false
1
0
Django ORM uses the active record implementation – you’ll see this implementation in most ORMs. Basically what it means is that each row in the database is directly mapped to an object in the code and vice versa. ORM frameworks such as Django won’t require predefining the schema to use the properties in the code. You just use them, as the framework can ‘understand’ the structure by looking at the database schema. Also, you can just save the record to the database, as it’s mapped to a specific row in the table. SQLAlchemy uses the Data Mapper implementation – When using this kind of implementation, there is a separation between the database structure and the objects structure (they are not 1:1 as in the Active Record implementation). In most cases, you’ll have to use another persistence layer to keep interact with the database (for example, to save the object). So you can’t just call the save() method as you can when using the Active Record implementation (which is a con) but on the other hand, you code doesn’t have to know the entire relational structure in the database to function, as there is no direct relationship between the code and the database. So which of them wins this battle? None. It depends on what you’re trying to accomplish. It’s my believe that if your application is a mostly a CRUD (Create, Read, Update, Delete) application which no hard and complex rules to apply on the relationships between the different data entities, you should use the Active Record implementation (Django). It will allow you to easily and quickly set up an MVP for your product, without any hassle. If you have a lot of “business rules” and restrictions in your applications, you might be better with the Data Mapper model, as it won’t tie you up and force you to think strictly as Active Record does.
4
12
0
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support. Any advice?
Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?
-0.028564
0
0
20,511
1,118,163
2009-07-13T07:49:00.000
-1
0
0
0
python,django,google-app-engine,turbogears,turbogears2
1,584,576
7
false
1
0
Ive only got one question...is the app you are developing directed towards social networking or customized business logic? I personally find Django is good for social networking and pylons/turbogears if you really want the flexibility and no boundaries... just my 2c
4
12
0
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support. Any advice?
Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?
-0.028564
0
0
20,511
1,118,163
2009-07-13T07:49:00.000
4
0
0
0
python,django,google-app-engine,turbogears,turbogears2
1,118,237
7
false
1
0
I have been using Django for a year now and when I started I had no experience of Python or Django and found it very intuitive to use. I have created a number of hobbyist Google App Engine apps using Django with the latest one being a CMS for my site. Using Django has meant that I have been able to code a lot quicker and with a lot less bugs.
4
12
0
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support. Any advice?
Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?
0.113791
0
0
20,511
1,118,163
2009-07-13T07:49:00.000
11
0
0
0
python,django,google-app-engine,turbogears,turbogears2
1,118,670
7
true
1
0
I have experience with both Django and TG1.1. IMO, TurboGears strong point is it's ORM: SQLAlchemy. I prefer TurboGears when the database side of things is non-trivial. Django's ORM is just not that flexible and powerful. That being said, I prefer Django. If the database schema is a good fit with Django's ORM I would go with Django. In my experience, it is simply less hassle to use Django compared with TurboGears.
4
12
0
I have been using Turbogears 1 for prototyping small sites for the last couple of years and it is getting a little long in the tooth. Any suggestions on making the call between upgrading to Turbogears 2 or switching to something like Django? I'm torn between the familiarity of the TG community who are pretty responsive and do pretty good documentation vs the far larger community using Django. I am quite tempted by the built-in CMS features and the Google AppEngine support. Any advice?
Turbogears 2 vs Django - any advice on choosing replacement for Turbogears 1?
1.2
0
0
20,511
1,118,266
2009-07-13T08:27:00.000
0
0
0
0
python,audio
1,120,253
3
false
0
0
All you need to do is just append the new data on the end of your wav file. So if you haven't closed your file, just keep writing to it, or if you have, reopen it in append mode (w = open(myfile, 'ba')) and write the new data. For this to sound reasonable without clicks and such, the trick will be to make the waveform continuous from one frequency to the next. Assuming that you're using sine waves of the same amplitude, you need to start each sine wave with the same phase that you ended the previous. You can do this either by playing with the length of the waveform to make sure you always end at, say, zero phase and then always start at zero phase, or by explicitly including the phase in the sine wave.
1
0
0
Im trying to engineer in python a way of transforming a list of integer values between 0-255 into representative equivalent tones from 1500-2200Hz. Timing information (at 1200Hz) is given by the (-1),(-2) and (-3) values. I have created a function that generates a .wav file and then call this function with the parameters of each tone. I need to create a 'stream' either by concatenating lots of individual tones into one output file or creating some way of running through the entire list and creating a separate file. Or by some other crazy function I don't know of.... The timing information will vary in duration but the information bits (0-255) will all be fixed length. A sample of the list is shown below: [-2, 3, 5, 7, 7, 7, 16, 9, 10, 21, 16, -1, 19, 13, 8, 8, 0, 5, 9, 21, 19, 11, -1, 11, 16, 19, 5, 21, 34, 39, 46, 58, 50, -1, 35, 46, 17, 28, 23, 19, 8, 2, 13, 12, -1, 9, 6, 8, 11, 2, 3, 2, 13, 14, 42, -1, 35, 41, 46, 55, 73, 69, 56, 47, 45, 26, -1, -3] The current solution I'm thinking of involves opening the file, checking the next value in the list using an 'if' statement to check whether the bit is timing (-ve) and if not: run an algorithm to see what freq needs to be generated and add the tone to the output file. Continue until -3 or end of list. Can anyone guide on how this complete output file might be created or any suggestions... I'm new to programming so please be gentle. Thanks in advance
List of values to a sound file
0
0
0
1,399
1,118,761
2009-07-13T10:40:00.000
1
0
0
1
python,django,google-app-engine
1,118,790
4
false
1
0
There are a few things that you can't do on the App Engine that you can do on your own server like uploading of files. On the App Engine you kinda have to upload it and store the datastore which can cause a few problems. Other than that it should be fine from the Presentation part. There are a number of other little things that are better on your own dedicated server but I think eventually a lot of those things will be in the App Engine
2
9
0
I'm developing a web application and considering Django, Google App Engine, and several other options. I wondered what kind of "penalty" I will incur if I develop a complete Django application assuming it runs on a dedicated server, and then later want to migrate it to Google App Engine. I have a basic understanding of Google's data store, so please assume I will choose a column based database for my "stand-alone" Django application rather than a relational database, so that the schema could remain mostly the same and will not be a major factor. Also, please assume my application does not maintain a huge amount of data, so that migration of tens of gigabytes is not required. I'm mainly interested in the effects on the code and software architecture. Thanks
Migrating Django Application to Google App Engine?
0.049958
1
0
1,845
1,118,761
2009-07-13T10:40:00.000
8
0
0
1
python,django,google-app-engine
1,119,377
4
true
1
0
Most (all?) of Django is available in GAE, so your main task is to avoid basing your designs around a reliance on anything from Django or the Python standard libraries which is not available on GAE. You've identified the glaring difference, which is the database, so I'll assume you're on top of that. Another difference is the tie-in to Google Accounts and hence that if you want, you can do a fair amount of access control through the app.yaml file rather than in code. You don't have to use any of that, though, so if you don't envisage switching to Google Accounts when you switch to GAE, no problem. I think the differences in the standard libraries can mostly be deduced from the fact that GAE has no I/O and no C-accelerated libraries unless explicitly stated, and my experience so far is that things I've expected to be there, have been there. I don't know Django and haven't used it on GAE (apart from templates), so I can't comment on that. Personally I probably wouldn't target LAMP (where P = Django) with the intention of migrating to GAE later. I'd develop for both together, and try to ensure if possible that the differences are kept to the very top (configuration) and the very bottom (data model). The GAE version doesn't necessarily have to be perfect, as long as you know how to make it perfect should you need it. It's not guaranteed that this is faster than writing and then porting, but my guess is it normally will be. The easiest way to spot any differences is to run the code, rather than relying on not missing anything in the GAE docs, so you'll likely save some mistakes that need to be unpicked. The Python SDK is a fairly good approximation to the real App Engine, so all or most of your tests can be run locally most of the time. Of course if you eventually decide not to port then you've done unnecessary work, so you have to think about the probability of that happening, and whether you'd consider the GAE development to be a waste of your time if it's not needed.
2
9
0
I'm developing a web application and considering Django, Google App Engine, and several other options. I wondered what kind of "penalty" I will incur if I develop a complete Django application assuming it runs on a dedicated server, and then later want to migrate it to Google App Engine. I have a basic understanding of Google's data store, so please assume I will choose a column based database for my "stand-alone" Django application rather than a relational database, so that the schema could remain mostly the same and will not be a major factor. Also, please assume my application does not maintain a huge amount of data, so that migration of tens of gigabytes is not required. I'm mainly interested in the effects on the code and software architecture. Thanks
Migrating Django Application to Google App Engine?
1.2
1
0
1,845
1,119,696
2009-07-13T14:15:00.000
7
0
1
0
java,python,integration
58,624,426
12
false
1
0
The best solutions, is to use Python programs throw REST API. You define your services and call them. You perhaps need to learn some new modules. But you will be more flexible for futures changes. Here a small list of use full modules for this purpose: Python modules Flask Flask-SQLAlchemy Flask-Restful SQlite3 Jsonify Java modules (for calling rest api) Jersey or Apache CXF You will need a small Learning curve, but later you will get more productivity and modularity and even elasticity...
1
57
0
I have a Java app that needs to integrate with a 3rd party library. The library is written in Python, and I don't have any say over that. I'm trying to figure out the best way to integrate with it. I'm trying out JEPP (Java Embedded Python) - has anyone used that before? My other thought is to use JNI to communicate with the C bindings for Python. Any thoughts on the best way to do this would be appreciated. Thanks.
Java Python Integration
1
0
0
81,995
1,119,722
2009-07-13T14:19:00.000
3
1
1
0
python,math,base62
1,119,762
22
false
0
0
You probably want base64, not base62. There's an URL-compatible version of it floating around, so the extra two filler characters shouldn't be a problem. The process is fairly simple; consider that base64 represents 6 bits and a regular byte represents 8. Assign a value from 000000 to 111111 to each of the 64 characters chosen, and put the 4 values together to match a set of 3 base256 bytes. Repeat for each set of 3 bytes, padding at the end with your choice of padding character (0 is generally useful).
1
103
0
How would you convert an integer to base 62 (like hexadecimal, but with these digits: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'). I have been trying to find a good Python library for it, but they all seems to be occupied with converting strings. The Python base64 module only accepts strings and turns a single digit into four characters. I was looking for something akin to what URL shorteners use.
Base 62 conversion
0.027266
0
0
83,868
1,120,297
2009-07-13T15:48:00.000
0
0
0
1
java,python,android,platform
1,121,377
3
false
1
0
I'd throw down another vote for Eclipse. I've been using it on the mac and I find it to be very buggy. Not sure if that's just the nature of the beast... My experiences with it on XP have been more stable. Haven't had time to check it out on Ubuntu.
2
4
0
I am interested in developing things for google apps and android using python and java. I am new to both and was wondering if a environment set in windows or linux would be more productive for these tasks?
Platform for developing all things google?
0
0
0
263
1,120,297
2009-07-13T15:48:00.000
0
0
0
1
java,python,android,platform
1,122,211
3
false
1
0
Internally, I believe Google uses Eclipse running on Ubuntu for Android development, so that'd be your best bet if you're completely paranoid about avoiding all potential issues. Of course, this is impossible, and really you should just use whatever you're comfortable in.
2
4
0
I am interested in developing things for google apps and android using python and java. I am new to both and was wondering if a environment set in windows or linux would be more productive for these tasks?
Platform for developing all things google?
0
0
0
263
1,120,914
2009-07-13T17:31:00.000
1
0
0
0
python,django,django-templates
1,120,987
2
false
1
0
The answer to this depends a lot on how you've structured your data, which you don't say - are the extra bits of information in separate related tables, subclassed models, individual fields on the same model...? In general, this sounds like a job for a template tag. I would probably write a custom tag that took your parent object as a parameter, and inspected the data to determine what to output. Each choice could potentially be rendered by a different sub-template, called by the tag itself.
1
0
0
I just started using django for development. At the moment, I have the following issue: I have to write a page template able to represent different categories of data. For example, suppose I have a medical record of a patient. The represented information about this patient are, for example: name, surname and similar data data about current treatments ..and beyond: specific data about any other analysis (eg. TAC, NMR, heart, blood, whatever) Suppose that for each entry at point 3, I need to present a specific section. The template for this page would probably look like a long series of if statements, one for each data entry, which will be used only if that information is present. This would result in a very long template. One possible solution is to use the include directive in the template, and then fragment the main template so that instead of a list of if's i have a list of includes, one for each if. Just out of curiosity, I was wondering if someone know an alternative strategy for this kind of pattern, either at the template level or at the view level.
Django templates: adding sections conditionally
0.099668
0
0
235
1,121,299
2009-07-13T18:40:00.000
1
0
0
0
python,django,session
1,121,363
1
true
1
0
Sessions are lazily loaded: if you don't use the session during a request, Django won't load it. This includes request.user: if you access it, it accesses the session to find the user. (It loads lazily, too--if you don't access request.user, it won't access the session, either.) So, figure out what's accessing the session and eliminate it--and if you can't, at least you'll know why the session is being pulled in.
1
0
0
I was wondering if I could eliminate django session calls for specific views. For example, if I have a password reset form I don't want a call to the DB to check for a session or not. Thanks!
Eliminating certain Django Session Calls
1.2
0
0
208
1,121,951
2009-07-13T20:48:00.000
3
0
0
0
python
1,122,107
2
false
0
0
AFAIK, the numbers of internet sockets (necessary to make TCP/IP connections) is naturally limited on every machine, but it's pretty high. 1000 simulatneous connections shouldn't be a problem for the client machine, as each socket uses only little memory. If you start receiving data through all these channels, this might change though. I've heard of test setups that created a couple of thousands connections simultaneously from a single client. The story is usually different for the server, when it does heavy lifting for each incoming connection (like forking off a worker process etc.). 1000 incoming connections will impact its performance, and coming from the same client they can easily be taken for a DoS attack. I hope you're in charge of both the client and the server... or is it the same machine?
1
4
0
To be more specific, I'm using python and making a pool of HTTPConnection (httplib) and was wondering if there is an limit on the number of concurrent HTTP connections on a windows server.
What is the maximum simultaneous HTTP connections allowed on one machine (windows server 2008) using python
0.291313
0
1
4,587
1,122,537
2009-07-13T22:53:00.000
0
0
0
0
python,thread-safety,pylons
1,128,979
2
false
0
0
Whatever you were to set on the request will only survive for the duration of the request. the problem you are describing is more appropriately handled with a Session as TCH4k has said. It's already enabled in the middleware, so go ahead.
1
2
0
I want keep track of a unique identifier for each browser that connects to my web application (that is written in Pylons.) I keep a cookie on the client to keep track of this, but if the cookie isn't present, then I want to generate a new unique identifier that will be sent back to the client with the response, but I also may want to access this value from other code used to generate the response. Is attaching this value to pylons.request safe? Or do I need to do something like use threading_local to make a thread local that I reset when each new request is handled?
What can I attach to pylons.request in Pylons?
0
0
0
470
1,122,924
2009-07-14T00:45:00.000
1
0
1
1
python,bash,path,cygwin,reboot
1,123,139
4
false
0
0
A couple of things to try and rule out at least: Do you get the same behavior as the following from the shell? (Pasted from my cygwin, which works as expected.) $ echo $PATH /usr/local/bin:/usr/bin:/bin $ export PATH=$PATH:/cygdrive/c/python/bin $ echo $PATH /usr/local/bin:/usr/bin:/bin:/cygdrive/c/python/bin Is your bashrc setting the PATH in a similar way to the above? (i.e. the second command). Does your bashrc contain a "source" or "." command anywhere? (Maybe it's sourcing another file which overwrites your PATH variable.)
2
5
0
I wanted to use the Python installed under cygwin rather than one installed under WinXP directly, so I edited ~/.bashrc and sourced it. Nothing changed. I tried other things, but nothing I did changed $PATH in any way. So I rebooted. Aha; now $PATH has changed to what I wanted. But, can anyone explain WHY this happened? When do changes to the environment (and its variables) made via cygwin (and bash) take effect only after a reboot? (Is this any way to run a railroad?) (This question is unlikely to win any points, but I'm curious, and I'm also tired of wading through docs which don't help on this point.)
bash/cygwin/$PATH: Do I really have to reboot to alter $PATH?
0.049958
0
0
9,783
1,122,924
2009-07-14T00:45:00.000
2
0
1
1
python,bash,path,cygwin,reboot
1,123,086
4
false
0
0
If you want your changes to be permanent, you should modify the proper file (.bashrc in this case) and perform ONE of the following actions: Restart the cygwin window source .bashrc (This should work, even if is not working for you) . .bashrc (that is dot <space> <filename>) However, .bashrc is used by default when using a BASH shell, so if you are using another shell (csh, ksh, zsh, etc) then your changes will not be reflected by modifying .bashrc.
2
5
0
I wanted to use the Python installed under cygwin rather than one installed under WinXP directly, so I edited ~/.bashrc and sourced it. Nothing changed. I tried other things, but nothing I did changed $PATH in any way. So I rebooted. Aha; now $PATH has changed to what I wanted. But, can anyone explain WHY this happened? When do changes to the environment (and its variables) made via cygwin (and bash) take effect only after a reboot? (Is this any way to run a railroad?) (This question is unlikely to win any points, but I'm curious, and I'm also tired of wading through docs which don't help on this point.)
bash/cygwin/$PATH: Do I really have to reboot to alter $PATH?
0.099668
0
0
9,783
1,124,810
2009-07-14T11:30:00.000
0
0
1
1
python
1,124,862
6
false
0
0
Uh... This question is a bit unclear. What do you mean "have"? Do you have the name of the file? Have you opened it? Is it a file object? Is it a file descriptor? What??? If it's a name, what do you mean with "find"? Do you want to search for the file in a bunch of directories? Or do you know which directory it's in? If it is a file object, then you must have opened it, reasonably, and then you know the path already, although you can get the filename from fileob.name too.
1
11
0
I have a file, for example "something.exe" and I want to find path to this file How can I do this in python?
How can I find path to given file?
0
0
0
91,787
1,126,116
2009-07-14T15:19:00.000
13
0
0
1
python,shell,variables,subprocess,persistent
1,126,137
2
true
0
0
subprocess.Popen takes an optional named argument env that's a dictionary to use as the subprocess's environment (what you're describing as "shell variables"). Prepare a dict as you need it (you may start with a copy of os.environ and alter that as you need) and pass it to all the subprocess.Popen calls you perform.
1
8
0
I'm trying to execute a series of commands using Pythons subprocess module, however I need to set shell variables with export before running them. Of course the shell doesn't seem to be persistent so when I run a command later those shell variables are lost. Is there any way to go about this? I could create a /bin/sh process, but how would I get the exit codes of the commands run under that?
Python: Persistent shell variables in subprocess
1.2
0
0
3,185
1,126,173
2009-07-14T15:28:00.000
0
1
1
0
python,unit-testing,testing,tdd
8,462,601
7
false
0
0
I started unit testing a handful of years ago, and I've read quite a few on it since my initial book. However, my initial was "Test Driven" by Lasse. For me, the author made it simple to understand. Perhaps you could pull some info from it for your teaching. And btw, I've taught TDD as well. I have found that ensuring the audience understands how to use unit tests before going into TDD to be quite handy. Good luck! :-)
1
17
0
I'm working with a Python development team who is experienced with programming in Python, but is just now trying to pick up TDD. Since I have some experience working with TDD myself, I've been asked to give a presentation on it. Mainly, I'm just wanting to see articles on this so that I can see how other people are teaching TDD and get some ideas for material to put in my presentation. Preferably, I'd like the intro to be for Python, but any language will do as long as the examples are easy to read and the concepts transfer to Python easily.
Are there any good online tutorials to TDD for an experienced programmer who is new to testing?
0
0
0
6,164
1,126,842
2009-07-14T17:28:00.000
0
0
1
0
python,windows-xp,cygwin
1,128,193
5
false
0
0
This probably has little value, but... I found myself in this exact situation -- we use ActivePython2.5 in production (pure windows environment) and I was trying to do my development within cygwin and cygwin's Python... After ripping out half of my hair, I have now switched over to Console2, gvim, iPython and ActivePython2.5. I'm less than thrilled dealing with Windows tools (and their concomitant warts), but at least I'm not getting in my own way when it comes to development. For a while I found I was spending more time trying to get my tools to play nice than actually getting any work done. Good luck on this one.
4
3
0
Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.
Best way to have full Python install under cygwin/XP?
0
0
0
2,747
1,126,842
2009-07-14T17:28:00.000
2
0
1
0
python,windows-xp,cygwin
1,126,885
5
true
0
0
I use Python from within cygwin, but I don't use the version that cygwin gives you the option of installing as I don't have the control over version number used that I need (we use an older version at work). I have my python version installed via the windows installer (the xp version as you put it) and add the /cygdrive/c/Python2x directory to my PATH environment variable.
4
3
0
Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.
Best way to have full Python install under cygwin/XP?
1.2
0
0
2,747
1,126,842
2009-07-14T17:28:00.000
0
0
1
0
python,windows-xp,cygwin
1,126,874
5
false
0
0
Just a little off the question, but... Have you considered running Sun's VirtualBox with Fedora or Ubuntu inside of it? I'm assuming you have to / need to use windows because you still are, but don't like it. Then you would have python running inside a native linux desktop without any of the troubles you mentioned. And if you want something that is really easy and portable, then just use Python on Windows, not mixed in with cygwin. $0.02
4
3
0
Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.
Best way to have full Python install under cygwin/XP?
0
0
0
2,747
1,126,842
2009-07-14T17:28:00.000
0
0
1
0
python,windows-xp,cygwin
11,792,553
5
false
0
0
I accidentally stumbled on this - If I launch Cygwin from the Cygwin.bat file (which is present directly under the main folder), I get access to the Python version installed under Cygwin (i.e 2.6.8) If I instead launch the Cygwin from bash.exe under bin directory (C:\Cygwin\bin\bash.exe for me), running "Python -V" shows that I have access to 2.7.3 version of Python (that was installed for Windows). So, I guess you can do the same.
4
3
0
Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.
Best way to have full Python install under cygwin/XP?
0
0
0
2,747
1,126,930
2009-07-14T17:45:00.000
0
0
1
0
python,shell,debugging,ipython,pdb
51,654,762
13
false
0
0
This is pretty simple: ipython some_script.py --pdb It needs iPython installing, usually this works: pip install ipython I use ipython3 instead of ipython, so I know it's a recent version of Python. This is simple to remember because you just use iPython instead of python, and add --pdb to the end.
2
84
0
For my debugging needs, pdb is pretty good. However, it would be much cooler (and helpful) if I could go into ipython. Is this thing possible?
Is it possible to go into ipython from code?
0
0
0
23,603
1,126,930
2009-07-14T17:45:00.000
8
0
1
0
python,shell,debugging,ipython,pdb
1,127,042
13
false
0
0
Normally, when I use ipython, I turn automatic debugging on with the "pdb" command inside it. I then run my script with the "run myscript.py" command in the directory where my script is located. If I get an exception, ipython stops the program inside the debugger. Check out the help command for the magic ipython commands (%magic)
2
84
0
For my debugging needs, pdb is pretty good. However, it would be much cooler (and helpful) if I could go into ipython. Is this thing possible?
Is it possible to go into ipython from code?
1
0
0
23,603
1,127,836
2009-07-14T20:29:00.000
1
0
1
0
python,garbage-collection,cpython
1,128,216
5
false
0
0
It might also be the case that a reference was leaked by a buggy C extension, IMHO you will not see the referer, yet still the refcount does not go down to 0. You might want to check the return value of sys.getrefcount.
2
4
0
Should it be possible for gc.get_referrers(obj) to return an empty list for an object, but the object still be accessible through a weak reference? If so how would I start trying to identify the cause for this object not being garbage collected? Edit: I'm not sure exactly how a code sample would help in this case - there's obviously a strong reference somewhere, but I'll be damned if I can find it. I was of the impression that all strong references to an object would be identified by get_referrers(). Edit: Solved. I found the variable with a strong reference - It was inside the game event loop but wasn't a class variable so get_referrers wasn't picking it up.
Python object has no referrers but still accessible via a weakref?
0.039979
0
0
2,129
1,127,836
2009-07-14T20:29:00.000
1
0
1
0
python,garbage-collection,cpython
4,093,658
5
false
0
0
I am glad you have found your problem, unrelated to the initial question. Nonetheless, I have a different take on the answer for posterity, in case others have the problem. It IS legal for the object to have no referrers and yet not be garbage collected. From the Python 2.7 manual: "An implementation is allowed to postpone garbage collection or omit it altogether — it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that are still reachable." The NO-OP garbage collector is legal. The discussions about generational and reference-counting garbage collectors are referring to a particular CPython implementation (as tagged in the question)
2
4
0
Should it be possible for gc.get_referrers(obj) to return an empty list for an object, but the object still be accessible through a weak reference? If so how would I start trying to identify the cause for this object not being garbage collected? Edit: I'm not sure exactly how a code sample would help in this case - there's obviously a strong reference somewhere, but I'll be damned if I can find it. I was of the impression that all strong references to an object would be identified by get_referrers(). Edit: Solved. I found the variable with a strong reference - It was inside the game event loop but wasn't a class variable so get_referrers wasn't picking it up.
Python object has no referrers but still accessible via a weakref?
0.039979
0
0
2,129
1,129,210
2009-07-15T03:15:00.000
1
0
0
0
python,ajax,django
1,129,395
4
false
1
0
Maybe a few iFrames and some Comet/long-polling? Have the comment submission in an iFrame (so the whole page doesn't reload), and then show the result in the long-polled iFrame... Having said that, it's a pretty bad design idea, and you probably don't want to be doing this. AJAX/JavaScript is pretty much the way to go for things like this. I have heard it's possible with AJAX...but I was wondering if it was possible to do with Django. There's no reason you can't use both - specifically, AJAX within a Django web application. Django provides your organization and framework needs (and a page that will respond to AJAX requests) and then use some JavaScript on the client side to make AJAX calls to your Django-backed page that will respond correctly. I suggest you go find a basic jQuery tutorial which should explain enough basic JavaScript to get this working.
2
0
0
As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request. For example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it. What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page. Is it possible to do with only Django and Python with no Javascript/AJAX knowledge? I have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django. Thanks,
creating non-reloading dynamic webapps using Django
0.049958
0
0
823
1,129,210
2009-07-15T03:15:00.000
8
0
0
0
python,ajax,django
1,129,222
4
true
1
0
You want to do that with out any client side code (javascript and ajax are just examples) and with out reloading your page (or at least part of it)? If that is your question, then the answer unfortunately is you can't. You need to either have client side code or reload your page. Think about it, once the client get's the page it will not change unless The client requests the same page from the server and the server returns and updated one the page has some client side code (eg: javascript) that updates the page. I can not imagine a third possibility. I have not coded in Django for more than 30 mins and this is clearly obvious to me. If I am wrong plz down vote :D
2
0
0
As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request. For example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it. What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page. Is it possible to do with only Django and Python with no Javascript/AJAX knowledge? I have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django. Thanks,
creating non-reloading dynamic webapps using Django
1.2
0
0
823
1,130,697
2009-07-15T10:50:00.000
1
1
0
0
python,ruby,jruby,jython
1,130,727
5
false
1
0
The compatibility in either case is at the source-code level; with necessary changes where the Python or Ruby code invokes packages that involve native code (especially, standard Python packages like ctypes are not present in Jython).
3
4
0
It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?
Jython or JRuby?
0.039979
0
0
5,421
1,130,697
2009-07-15T10:50:00.000
1
1
0
0
python,ruby,jruby,jython
1,140,847
5
false
1
0
Anything you can do in one, you can do in the other. Learn enough of both to realise which one appeals to your coding sensibilities. There is no right or wrong answer here.
3
4
0
It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?
Jython or JRuby?
0.039979
0
0
5,421
1,130,697
2009-07-15T10:50:00.000
5
1
0
0
python,ruby,jruby,jython
1,130,722
5
false
1
0
In both cases, most of the code should Just Work™. I don't know of a really compelling reason to choose Jython over JRuby or vice versa if you'll be learning either from scratch. Python places a heavy emphasis on readability and not using "magic", but Ruby tends to give you a little more rope to do fancy things, e.g., define your own DSL. The main difference is in the community, and largely revolves around the different focus mentioned above.
3
4
0
It's a high level conceptual question. I have two separate code bases that serve the same purpose, one built in Python and the other in Ruby. I need to develop something that will run on JVM. So I have two choices: convert the Python code to Jython or convert the Ruby to JRuby. Since I don't know any of them, I was wondering if anyone can give me some guidance. Like which one runs faster, or more importantly which one has tools available for easy code migration(.pyc to .jar files)?
Jython or JRuby?
0.197375
0
0
5,421
1,130,992
2009-07-15T12:04:00.000
-1
1
1
0
python,data-structures,dictionary,lookup
1,131,017
4
false
0
0
string array. then binary search through it to search the first match then step one by one through it for all subsequent matches (i originally had linked list here too... but of course this doesn't have random access so this was 'bs' (which probably explains why I was downvoted). My binary search algorithm still is the fastest way to go though
1
6
0
I'm writing an application that needs to read a list of strings from a file, save them in a data structure, and then look up those strings by prefixes. The list of strings is simply a list of words in a given language. For example, if the search function gets "stup" as a parameter, it should return ["stupid", "stupidity", "stupor"...]. It should do so in O(log(n)*m) time, where n is the size of the data structure and m is the number of results and should be as fast as possible. Memory consumption is not a big issue right now. I'm writing this in python, so it would be great if you could point me to a suitable data structure (preferably) implemented in c with python wrappers.
most efficient data structure for a read-only list of strings (about 100,000) with fast prefix search
-0.049958
0
0
3,095
1,131,430
2009-07-15T13:32:00.000
63
0
1
0
python,multithreading,thread-safety,generator
1,131,458
6
true
0
0
It's not thread-safe; simultaneous calls may interleave, and mess with the local variables. The common approach is to use the master-slave pattern (now called farmer-worker pattern in PC). Make a third thread which generates data, and add a Queue between the master and the slaves, where slaves will read from the queue, and the master will write to it. The standard queue module provides the necessary thread safety and arranges to block the master until the slaves are ready to read more data.
1
49
0
I have a multithreaded program where I create a generator function and then pass it to new threads. I want it to be shared/global in nature so each thread can get the next value from the generator. Is it safe to use a generator like this, or will I run into problems/conditions accessing the shared generator from multiple threads? If not, is there a better way to approach the problem? I need something that will cycle through a list and produce the next value for whichever thread calls it.
Are Generators Threadsafe?
1.2
0
0
18,065
1,131,599
2009-07-15T14:01:00.000
2
0
1
0
python,oop,multiple-inheritance
1,131,636
8
false
0
0
It doesn't sound like you really need multiple inheritance. In fact, you don't ever really need multiple inheritance. It's just a question of whether multiple inheritance simplifies things (which I couldn't see as being the case here). I would create a Person class that has all the code that the adult and student would share. Then, you can have an Adult class that has all of the things that only the adult needs and a Child class that has the code only the child needs.
4
9
0
I have the following problem and I'm wondering if there's a nice way to model these objects without using multiple inheritance. If it makes any difference, I am using Python. Students need contact information plus student information. Adults need contact information plus billing information. Students can be adult students, in which case I need contact/student/billing info, or they can be children, in which case I need contact/student/parent info. Just to be clear on how the system will be used, I need to be able to ask for a list of all adults (and I will get adult students plus parents), or a list of all students (and I will get child students plus adult students). Also, all of these objects need to have a common base class.
Eliminating multiple inheritance
0.049958
0
0
681
1,131,599
2009-07-15T14:01:00.000
8
0
1
0
python,oop,multiple-inheritance
1,131,655
8
true
0
0
What you have is an example of Role -- it's a common trap to model Role by inheritance, but Roles can change, and changing an object's inheritance structure (even in languages where it's possible, like Python) is not recommended. Children grow and become adults, and some adults will also be parents of children students as well as adult students themselves -- they might then drop either role but need to keep the other (their child changes schools but they don't, or viceversa). Just have a class Person with mandatory fields and optional ones, and the latter, representing Roles, can change. "Asking for a list" (quite independently of inheritance or otherwise) can be done either by building the list on the fly (walking through all objects to check for each whether it meets requirements) or maintaining lists corresponding to the possible requirements (or a mix of the two strategies for both frequent and ad-hoc queries). A database of some sort is likely to help here (and most DBs work much better without inheritance in the way;-).
4
9
0
I have the following problem and I'm wondering if there's a nice way to model these objects without using multiple inheritance. If it makes any difference, I am using Python. Students need contact information plus student information. Adults need contact information plus billing information. Students can be adult students, in which case I need contact/student/billing info, or they can be children, in which case I need contact/student/parent info. Just to be clear on how the system will be used, I need to be able to ask for a list of all adults (and I will get adult students plus parents), or a list of all students (and I will get child students plus adult students). Also, all of these objects need to have a common base class.
Eliminating multiple inheritance
1.2
0
0
681
1,131,599
2009-07-15T14:01:00.000
2
0
1
0
python,oop,multiple-inheritance
1,131,633
8
false
0
0
Very simple solution: Use composition rather than inheritance. Rather than having Student inherit from Contact and Billing, make Contact a field/attribute of Person and inherit from that. Make Billing a field of Student. Make Parent a self-reference field of Person.
4
9
0
I have the following problem and I'm wondering if there's a nice way to model these objects without using multiple inheritance. If it makes any difference, I am using Python. Students need contact information plus student information. Adults need contact information plus billing information. Students can be adult students, in which case I need contact/student/billing info, or they can be children, in which case I need contact/student/parent info. Just to be clear on how the system will be used, I need to be able to ask for a list of all adults (and I will get adult students plus parents), or a list of all students (and I will get child students plus adult students). Also, all of these objects need to have a common base class.
Eliminating multiple inheritance
0.049958
0
0
681
1,131,599
2009-07-15T14:01:00.000
0
0
1
0
python,oop,multiple-inheritance
1,131,714
8
false
0
0
One solution is to create a base Info class/interface that the classes ContactInfo, StudentInfo, and BillingInfo inherit from. Have some sort of Person object that contains a list of Info objects, and then you can populate the list of Info objects with ContactInfo, StudentInfo, etc.
4
9
0
I have the following problem and I'm wondering if there's a nice way to model these objects without using multiple inheritance. If it makes any difference, I am using Python. Students need contact information plus student information. Adults need contact information plus billing information. Students can be adult students, in which case I need contact/student/billing info, or they can be children, in which case I need contact/student/parent info. Just to be clear on how the system will be used, I need to be able to ask for a list of all adults (and I will get adult students plus parents), or a list of all students (and I will get child students plus adult students). Also, all of these objects need to have a common base class.
Eliminating multiple inheritance
0
0
0
681
1,132,766
2009-07-15T17:25:00.000
5
1
1
0
python,file,cryptography,digital-signature
1,132,796
2
true
0
0
The digital signature from C alone should be enough for both A and B to confirm that their file is not corrupted, without ever communicating with eachother. If A and B did not receive a signature from C, they could each create a cryptographic hash of the file and compare the hash, but that does not require any digital signing on C's part. If you want C to sign the file, either send the signature and the file seperately, or wrap them both in some sort of container, such as a zip file or home grown solution (e.g., the first line in the file represents the signature, the rest is the payload). To answer your question literally, the signature doesn't have to be outside the file per se, but the part that is being signed cannot include the signature itself.
1
1
0
I'm programming a pet project in Python, and it involves users A & B interacting over network, attempting to insure that each has a local copy of the same file from user C. The idea is that C gives each a file that has been digitally signed. A & B trade the digital signatures they have, and check it out on their own copy. If the signature fails, then one of them has an incorrect/corrupt/modified version of the file. The question is, therefore, can C distribute a single file that somehow includes it's own signature? Or does C need to supply the file and signature separately?
Must a secure cryptographic signature reside outside of the file it refers to?
1.2
0
0
187
1,133,391
2009-07-15T19:17:00.000
1
0
0
0
python,django
1,133,417
5
false
1
0
Check out the wc command on unix.
1
11
0
Is there an easy way to count the lines of code you have written for your django project? Edit: The shell stuff is cool, but how about on Windows?
Count lines of code in a Django Project
0.039979
0
0
6,904
1,134,071
2009-07-15T21:03:00.000
-1
0
1
0
python,configuration,configparser
1,134,323
4
false
1
0
ConfigParser is based on the ini file format, who in it's design is supposed to NOT be sensitive to order. If your config file format is sensitive to order, you can't use ConfigParser. It may also confuse people if you have an ini-type format that is sensitive to the order of the statements...
1
7
0
I've noticed with my source control that the content of the output files generated with ConfigParser is never in the same order. Sometimes sections will change place or options inside sections even without any modifications to the values. Is there a way to keep things sorted in the configuration file so that I don't have to commit trivial changes every time I launch my application?
Keep ConfigParser output files sorted
-0.049958
0
0
6,931
1,136,676
2009-07-16T10:20:00.000
0
0
0
0
python,mysql
1,136,692
3
false
0
0
How did you install MySQLdb? This sounds like your MySQLdb module is not within your PYTHONPATH which indicates some inconsistancy between how you installed Python itself and how you installed MySQLdb. Or did you perhaps install a MySQLdb binary that was not targeted for your version of Python? Modules are normally put into version-dependant folders.
1
1
0
I am using Python 2.6.1, MySQL4.0 in Windows platform and I have successfully installed MySQLdb. Do we need to set any path for my python code and MySQLdb to successful run my application? Without any setting paths (in my code I am importing MySQLdb) I am getting No module named MySQLdb error is coming and I am not able to move further.
is it required to give path after installation MySQL db for Python 2.6
0
1
0
770
1,138,024
2009-07-16T14:30:00.000
6
0
1
0
python,string,list
1,138,036
6
false
0
0
To remove all empty strings, [s for s in list_of_strings if s] To get the first non-empty string, simply create this list and get the first element, or use the lazy method as suggested by wuub.
1
15
0
In Python I have a list of strings, some of which may be the empty string. What's the best way to get the first non-empty string?
Get first non-empty string from a list in python
1
0
0
19,680
1,139,151
2009-07-16T17:40:00.000
2
0
0
1
python,django,google-app-engine,unicode
1,140,751
3
false
1
0
Are you using Django 0.96 or Django 1.0? You can check by looking at your main.py and seeing if it contains the following: from google.appengine.dist import use_library use_library('django', '1.0') If you're using Django 1.0, both FILE_CHARSET and DEFAULT_CHARSET should default to 'utf-8'. If your template is saved under a different encoding, just set FILE_CHARSET to whatever that is. If you're using Django 0.96, you might want to try directly reading the template from the disk and then manually handling the encoding. e.g., replace template.render( templatepath , template_values) with Template(unicode(template_fh.read(), 'utf-8')).render(template_values)
3
2
0
When trying to render a Django template file in Google App Engine from google.appengine.ext.webapp import template templatepath = os.path.join(os.path.dirname(file), 'template.html') self.response.out.write (template.render( templatepath , template_values)) I come across the following error: <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 17692: ordinal not in range(128) args = ('ascii', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> ', 17692, 17693, 'ordinal not in range(128)') encoding = 'ascii' end = 17693 message = '' object = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> reason = 'ordinal not in range(128)' start = 17692 It seems that the underlying django template engine has assumed the "ascii" encoding, which should have been "utf-8". Anyone who knows what might have caused the trouble and how to solve it? Thanks.
Google App engine template unicode decoding problem
0.132549
0
0
2,383
1,139,151
2009-07-16T17:40:00.000
1
0
0
1
python,django,google-app-engine,unicode
1,139,534
3
false
1
0
Did you check in your text editor that the template is encoded in utf-8?
3
2
0
When trying to render a Django template file in Google App Engine from google.appengine.ext.webapp import template templatepath = os.path.join(os.path.dirname(file), 'template.html') self.response.out.write (template.render( templatepath , template_values)) I come across the following error: <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 17692: ordinal not in range(128) args = ('ascii', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> ', 17692, 17693, 'ordinal not in range(128)') encoding = 'ascii' end = 17693 message = '' object = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> reason = 'ordinal not in range(128)' start = 17692 It seems that the underlying django template engine has assumed the "ascii" encoding, which should have been "utf-8". Anyone who knows what might have caused the trouble and how to solve it? Thanks.
Google App engine template unicode decoding problem
0.066568
0
0
2,383
1,139,151
2009-07-16T17:40:00.000
6
0
0
1
python,django,google-app-engine,unicode
1,141,420
3
true
1
0
Well, turns out the rendered results returned by the template needs to be decoded first: self.response.out.write (template.render( templatepath , template_values).decode('utf-8') ) A silly mistake, but thanks for everyone's answers anyway. :)
3
2
0
When trying to render a Django template file in Google App Engine from google.appengine.ext.webapp import template templatepath = os.path.join(os.path.dirname(file), 'template.html') self.response.out.write (template.render( templatepath , template_values)) I come across the following error: <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 17692: ordinal not in range(128) args = ('ascii', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> ', 17692, 17693, 'ordinal not in range(128)') encoding = 'ascii' end = 17693 message = '' object = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Str...07/a-beautiful-method-to-find-peace-of-mind/ --> reason = 'ordinal not in range(128)' start = 17692 It seems that the underlying django template engine has assumed the "ascii" encoding, which should have been "utf-8". Anyone who knows what might have caused the trouble and how to solve it? Thanks.
Google App engine template unicode decoding problem
1.2
0
0
2,383
1,139,835
2009-07-16T19:38:00.000
1
0
0
1
python,browser,debian,uid
1,140,199
1
true
0
0
This could be your environment. Changing the permissions will still leave environment variables like $HOME pointing at the root user's directory, which will be inaccessible. It may be worth trying altering these variables by changing os.environ before launching the browser. There may also be other variables worth checking.
1
0
0
I can't run firefox from a sudoed python script that drops privileges to normal user. If i write $ sudo python >>> import os >>> import pwd, grp >>> uid = pwd.getpwnam('norby')[2] >>> gid = grp.getgrnam('norby')[2] >>> os.setegid(gid) >>> os.seteuid(uid) >>> import webbrowser >>> webbrowser.get('firefox').open('www.google.it') True >>> # It returns true but doesn't work >>> from subprocess import Popen,PIPE >>> p = Popen('firefox www.google.it', shell=True,stdout=PIPE,stderr=PIPE) >>> # Doesn't execute the command >>> You shouldn't really run Iceweasel through sudo WITHOUT the -H option. Continuing as if you used the -H option. No protocol specified Error: cannot open display: :0 I think that is not a python problem, but firefox/iceweasel/debian configuration problem. Maybe firefox read only UID and not EUID, and doesn't execute process because UID is equal 0. What do you think about?
Python fails to execute firefox webbrowser from a root executed script with privileges drop
1.2
0
1
903
1,140,661
2009-07-16T22:27:00.000
3
0
0
0
python
1,491,225
8
false
0
0
The urllib2.HTTPError exception does not contain a getcode() method. Use the code attribute instead.
1
90
0
I’m looking for a quick way to get an HTTP response code from a URL (i.e. 200, 404, etc). I’m not sure which library to use.
What’s the best way to get an HTTP response code from a URL?
0.07486
0
1
153,420
1,140,958
2009-07-17T00:21:00.000
1
0
1
0
python,string,line-endings
67,993,293
13
false
0
0
using regex re.sub(r'^$\n', '', somestring, flags=re.MULTILINE)
2
78
0
I have some code in a python string that contains extraneous empty lines. I would like to remove all empty lines from the string. What's the most pythonic way to do this? Note: I'm not looking for a general code re-formatter, just a quick one or two-liner. Thanks!
What's a quick one-liner to remove empty lines from a python string?
0.015383
0
0
89,033
1,140,958
2009-07-17T00:21:00.000
1
0
1
0
python,string,line-endings
1,141,067
13
false
0
0
This one will remove lines of spaces too. re.replace(u'(?imu)^\s*\n', u'', code)
2
78
0
I have some code in a python string that contains extraneous empty lines. I would like to remove all empty lines from the string. What's the most pythonic way to do this? Note: I'm not looking for a general code re-formatter, just a quick one or two-liner. Thanks!
What's a quick one-liner to remove empty lines from a python string?
0.015383
0
0
89,033
1,141,047
2009-07-17T01:04:00.000
10
0
1
0
python,multithreading,python-3.x
1,141,115
3
false
0
0
It's been quite a long time since the low-level thread module was informally deprecated, with all users heartily encouraged to use the higher-level threading module instead; now with the ability to introduce backwards incompatibilities in Python 3, we've made that deprecation rather more than just "informal", that's all!-)
1
10
0
Python 3.x renamed the low-level module 'thread' to '_thread' -- I don't see why in the documentation. Does anyone know?
Why was the 'thread' module renamed to '_thread' in Python 3.x?
1
0
0
5,673
1,145,286
2009-07-17T19:41:00.000
-1
0
0
0
python,file
1,148,604
7
false
0
0
Its a time to buy a new hard drive! You can make backup before trying all other answers and don't get data lost :)
3
8
0
I have a large xml file (40 Gb) that I need to split into smaller chunks. I am working with limited space, so is there a way to delete lines from the original file as I write them to new files? Thanks!
Change python file in place
-0.028564
0
1
1,833
1,145,286
2009-07-17T19:41:00.000
1
0
0
0
python,file
1,145,329
7
false
0
0
I'm pretty sure there is, as I've even been able to edit/read from the source files of scripts I've run, but the biggest problem would probably be all the shifting that would be done if you started at the beginning of the file. On the other hand, if you go through the file and record all the starting positions of the lines, you could then go in reverse order of position to copy the lines out; once that's done, you could go back, take the new files, one at a time, and (if they're small enough), use readlines() to generate a list, reverse the order of the list, then seek to the beginning of the file and overwrite the lines in their old order with the lines in their new one. (You would truncate the file after reading the first block of lines from the end by using the truncate() method, which truncates all data past the current file position if used without any arguments besides that of the file object, assuming you're using one of the classes or a subclass of one of the classes from the io package to read your file. You'd just have to make sure that the current file position ends up at the beginning of the last line to be written to a new file.) EDIT: Based on your comment about having to make the separations at the proper closing tags, you'll probably also have to develop an algorithm to detect such tags (perhaps using the peek method), possibly using a regular expression.
3
8
0
I have a large xml file (40 Gb) that I need to split into smaller chunks. I am working with limited space, so is there a way to delete lines from the original file as I write them to new files? Thanks!
Change python file in place
0.028564
0
1
1,833
1,145,286
2009-07-17T19:41:00.000
0
0
0
0
python,file
1,145,341
7
false
0
0
If time is not a major factor (or wear and tear on your disk drive): Open handle to file Read up to the size of your partition / logical break point (due to the xml) Save the rest of your file to disk (not sure how python handles this as far as directly overwriting file or memory usage) Write the partition to disk goto 1 If Python does not give you this level of control, you may need to dive into C.
3
8
0
I have a large xml file (40 Gb) that I need to split into smaller chunks. I am working with limited space, so is there a way to delete lines from the original file as I write them to new files? Thanks!
Change python file in place
0
0
1
1,833
1,145,414
2009-07-17T20:06:00.000
2
0
0
0
python,django,apache
1,152,601
8
false
1
0
Found Python Web Development with Django by Forcier, Bissex and Chun a great start. 50 pages on python to get you going and all the basics of Django.
1
15
0
I'm a newbie on the Django scene coming from an ASP.NET C# background. I'm looking for some good resources to help me learn the ins and outs of Django/Python. Any recommendations?
What are the best books and resources for learning to develop, deploy and/or host Django?
0.049958
0
0
2,869
1,145,524
2009-07-17T20:29:00.000
5
0
1
0
python,django,setuptools,easy-install,egg
1,145,611
1
true
1
0
You add zip_safe = False as an option to setup(). I don't think it has to do with directories. Setuptools will happily eggify packages with loads of directories in it. Then of course it's another problem that this part of Django doesn't find the package even though it's zipped. It should.
1
3
0
How exactly do I configure my setup.py file so that when someone runs easy_install the package gets expanded into \site-packages\ as a directory, rather than remaining inside an egg. The issue I'm encountering is that one of the django apps I've created won't auto-detect if it resides inside an egg. EDIT: For example, if I type easy_install photologue it simply installs a \photologue\ directory into site-packages. This the the behaviour I'd like, but it seems that in order to make that happen, there needs to be at least one directory/module within the directory being packaged.
How to make easy_install expand a package into directories rather than a single egg file?
1.2
0
0
1,188
1,145,741
2009-07-17T21:18:00.000
1
1
0
1
python,signals,mpi
1,149,142
3
false
0
0
If you use mpirun --nw, then mpirun itself should terminate as soon as it's started the subprocesses, instead of waiting for their termination; if that's acceptable then I believe your processes would be able to catch their own signals.
1
5
0
When using mpirun, is it possible to catch signals (for example, the SIGINT generated by ^C) in the code being run? For example, I'm running a parallelized python code. I can except KeyboardInterrupt to catch those errors when running python blah.py by itself, but I can't when doing mpirun -np 1 python blah.py. Does anyone have a suggestion? Even finding how to catch signals in a C or C++ compiled program would be a helpful start. If I send a signal to the spawned Python processes, they can handle the signals properly; however, signals sent to the parent orterun process (i.e. from exceeding wall time on a cluster, or pressing control-C in a terminal) will kill everything immediately.
MPI signal handling
0.066568
0
0
2,988