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,849,523 | 2009-12-04T20:39:00.000 | 36 | 0 | 1 | 1 | python,file-io,pickle | 1,850,806 | 6 | true | 0 | 0 | Python's pickle is perfectly cross-platform.
This is likely due to EOL (End-Of-Line) differences between Windows and Linux. Make sure to open your pickle files in binary mode both when writing them and when reading them, using open()'s "wb" and "rb" modes respectively.
Note: Passing pickles between different versions of Python can cause trouble, so try to have the same version on both platforms. | 2 | 21 | 0 | I have created a small python script of mine. I saved the pickle file on Linux and then used it on windows and then again used it back on Linux but now that file is not working on Linux but it is working perfectly on windows.
Is is so that python is coss-platform but the pickle file is not.
Is there any solution to this one??? | Is pickle file of python cross-platform? | 1.2 | 0 | 0 | 24,001 |
1,849,523 | 2009-12-04T20:39:00.000 | 1 | 0 | 1 | 1 | python,file-io,pickle | 1,849,549 | 6 | false | 0 | 0 | You could use json instead of pickle. If it can save your data, you know it's cross platform. | 2 | 21 | 0 | I have created a small python script of mine. I saved the pickle file on Linux and then used it on windows and then again used it back on Linux but now that file is not working on Linux but it is working perfectly on windows.
Is is so that python is coss-platform but the pickle file is not.
Is there any solution to this one??? | Is pickle file of python cross-platform? | 0.033321 | 0 | 0 | 24,001 |
1,850,607 | 2009-12-05T00:40:00.000 | -1 | 0 | 1 | 0 | python,datetime | 1,850,623 | 5 | false | 0 | 0 | For what purpose? import time -> time.clock() returns the current time in milliseconds, so it can be used for timing purposes to millisecond accuracy. | 1 | 26 | 0 | What is the best way to handle portions of a second in Python? The datetime library is excellent, but as far as I can tell it cannot handle any unit less than a second. | Python fraction of seconds | -0.039979 | 0 | 0 | 38,662 |
1,850,640 | 2009-12-05T00:55:00.000 | 5 | 0 | 0 | 0 | python,ruby,web-services,api,rest | 1,850,652 | 7 | true | 1 | 0 | I know Ruby, don't know python... you can see which way I'm leaning toward, right? | 5 | 6 | 0 | So this thread is definitely NOT a thread for why Python is better than Ruby or the inverse. Instead, this thread is for objective criticism on why you would pick one over the other to write a RESTful web API that's going to be used by many different clients, (mobile, web browsers, tablets etc).
Again, don't compare Ruby on Rails vs Django. This isn't a web app that's dependent on high level frameworks such as RoR or Django. I'd just like to hear why someone might choose one over the other to write a RESTful web API that they had to start tomorrow, completely from scratch and reasons they might go from one to another.
For me, syntax and language features are completely superfluous. The both offer an abundant amount of features and certainly both can achieve the same exact end goals. I think if someone flips a coin, it's a good enough reason to use one over the other. I'd just love to see what some of you web service experts who are very passionate about their work respond to why they would use one over the other in a very objective format. | Objective reasons for using Python or Ruby for a new REST Web API | 1.2 | 0 | 0 | 3,675 |
1,850,640 | 2009-12-05T00:55:00.000 | 4 | 0 | 0 | 0 | python,ruby,web-services,api,rest | 1,850,653 | 7 | false | 1 | 0 | Choose the one you're most familiar with and most likely to get things done with the fastest. | 5 | 6 | 0 | So this thread is definitely NOT a thread for why Python is better than Ruby or the inverse. Instead, this thread is for objective criticism on why you would pick one over the other to write a RESTful web API that's going to be used by many different clients, (mobile, web browsers, tablets etc).
Again, don't compare Ruby on Rails vs Django. This isn't a web app that's dependent on high level frameworks such as RoR or Django. I'd just like to hear why someone might choose one over the other to write a RESTful web API that they had to start tomorrow, completely from scratch and reasons they might go from one to another.
For me, syntax and language features are completely superfluous. The both offer an abundant amount of features and certainly both can achieve the same exact end goals. I think if someone flips a coin, it's a good enough reason to use one over the other. I'd just love to see what some of you web service experts who are very passionate about their work respond to why they would use one over the other in a very objective format. | Objective reasons for using Python or Ruby for a new REST Web API | 0.113791 | 0 | 0 | 3,675 |
1,850,640 | 2009-12-05T00:55:00.000 | 2 | 0 | 0 | 0 | python,ruby,web-services,api,rest | 1,850,743 | 7 | false | 1 | 0 | I think they are fairly evenly matched in features. I prefer Python, but I have been using it for over a decade so I freely admit that what follows is totally biased.
IMHO Python is more mature - there are more libraries for it (although Ruby may be catching up), and the included libraries I think are better designed. The language evolution process is more mature too, with each proposed feature discussed in public via the PEPs before the decision is made to include them in a release. I get the impression that development of the Ruby language is much more ad-hoc.
Python is widely used in a lot of areas apart from web development - scientific computing, CGI rendering pipelines, distributed computing, Linux GUI tools etc. Ruby got very little attention before Rails came along, so I get the impression that most Ruby work is focused on web development. That may not be a problem if that is all you want to do with the language, but it does mean that Python has a more diverse user base and a more diverse set of libraries.
Python is faster too. | 5 | 6 | 0 | So this thread is definitely NOT a thread for why Python is better than Ruby or the inverse. Instead, this thread is for objective criticism on why you would pick one over the other to write a RESTful web API that's going to be used by many different clients, (mobile, web browsers, tablets etc).
Again, don't compare Ruby on Rails vs Django. This isn't a web app that's dependent on high level frameworks such as RoR or Django. I'd just like to hear why someone might choose one over the other to write a RESTful web API that they had to start tomorrow, completely from scratch and reasons they might go from one to another.
For me, syntax and language features are completely superfluous. The both offer an abundant amount of features and certainly both can achieve the same exact end goals. I think if someone flips a coin, it's a good enough reason to use one over the other. I'd just love to see what some of you web service experts who are very passionate about their work respond to why they would use one over the other in a very objective format. | Objective reasons for using Python or Ruby for a new REST Web API | 0.057081 | 0 | 0 | 3,675 |
1,850,640 | 2009-12-05T00:55:00.000 | 1 | 0 | 0 | 0 | python,ruby,web-services,api,rest | 1,852,162 | 7 | false | 1 | 0 | Either will do a great job and you'll gain in other ways from learning something new. Why not spend as couple of days with each? See how far you can get with a simple subset of the problem, then see how you feel. For bonus points report back here and answer your own question! | 5 | 6 | 0 | So this thread is definitely NOT a thread for why Python is better than Ruby or the inverse. Instead, this thread is for objective criticism on why you would pick one over the other to write a RESTful web API that's going to be used by many different clients, (mobile, web browsers, tablets etc).
Again, don't compare Ruby on Rails vs Django. This isn't a web app that's dependent on high level frameworks such as RoR or Django. I'd just like to hear why someone might choose one over the other to write a RESTful web API that they had to start tomorrow, completely from scratch and reasons they might go from one to another.
For me, syntax and language features are completely superfluous. The both offer an abundant amount of features and certainly both can achieve the same exact end goals. I think if someone flips a coin, it's a good enough reason to use one over the other. I'd just love to see what some of you web service experts who are very passionate about their work respond to why they would use one over the other in a very objective format. | Objective reasons for using Python or Ruby for a new REST Web API | 0.028564 | 0 | 0 | 3,675 |
1,850,640 | 2009-12-05T00:55:00.000 | 6 | 0 | 0 | 0 | python,ruby,web-services,api,rest | 1,850,701 | 7 | false | 1 | 0 | I would say the important thing is that regardless of which you choose, make sure that your choice does not leak through your REST API. It should not matter to the client of your API which you chose. | 5 | 6 | 0 | So this thread is definitely NOT a thread for why Python is better than Ruby or the inverse. Instead, this thread is for objective criticism on why you would pick one over the other to write a RESTful web API that's going to be used by many different clients, (mobile, web browsers, tablets etc).
Again, don't compare Ruby on Rails vs Django. This isn't a web app that's dependent on high level frameworks such as RoR or Django. I'd just like to hear why someone might choose one over the other to write a RESTful web API that they had to start tomorrow, completely from scratch and reasons they might go from one to another.
For me, syntax and language features are completely superfluous. The both offer an abundant amount of features and certainly both can achieve the same exact end goals. I think if someone flips a coin, it's a good enough reason to use one over the other. I'd just love to see what some of you web service experts who are very passionate about their work respond to why they would use one over the other in a very objective format. | Objective reasons for using Python or Ruby for a new REST Web API | 1 | 0 | 0 | 3,675 |
1,851,396 | 2009-12-05T06:52:00.000 | 1 | 1 | 0 | 0 | python | 1,852,706 | 2 | false | 1 | 0 | At the risk of stating the obvious, why not just do the rubyquiz examples in python. Those exercises as well as others aren't tied to a language - you're just as well off just doing projecteuler problems in python rather than searching for python-specific puzzles. A puzzle is a puzzle a language is just a tool to solve it. | 1 | 2 | 0 | Is there a blog/forum/listserv that is equivalent to RubyQuiz.com for the Python language? | Ruby Quiz for Python | 0.099668 | 0 | 0 | 463 |
1,851,862 | 2009-12-05T10:48:00.000 | 2 | 0 | 0 | 0 | python,user-interface,pygtk,gtk | 1,872,356 | 2 | true | 0 | 1 | There's no way to automatically do you want you want. You might want to subclass gtk.Image and in your subclass, scale a pixbuf to your widget's allocation size. The advantage of this is that you'll have a reusable widget and you'll be able to have it resize your image on the fly.
The downside is that you'll have an ugly, scaled up pixmap. You may want to look into scalable vector graphics. | 1 | 2 | 0 | I have a GTK layout with a widget on the left of an HBox deciding the maximum height I want, and a VBox on the right containing three buttons, each containing only an image and no text. The images are a GTK stock icon, and so have the stock storage type.
Using expand=True, fill=True packing the buttons without images are exactly the height I want - some arbitrary small width, and 1/3 each the height of the left half of the HBox. However with an image, they are either too tall - 3 * ICON_SIZE_MENU is too tall in many themes - or if I force the button's height request, they get clipped. I would rather scale them to the size of the parent button.
Do I have to make my own pixbufs for each of the stock icons I'm using (and regenerate them if the size changes)? Or can GTK automatically size the image to fit the button, rather than the other way around? Since the images are only a few pixels off from fitting in every theme I've tried, is there a way to just disable the button's clipping?
This application is written in Python using PyGTK, but solutions in any language are appreciated.
(I tried just making it an icon name storage type, but one of the icons is REVERT_TO_SAVED, which turned into the broken stock image when I tried to force it to a particular pixel height. Plus, I'd rather not force it to any fixed pixel height.) | Scaling an image to its parent button size in GTK? | 1.2 | 0 | 0 | 2,476 |
1,852,897 | 2009-12-05T17:51:00.000 | 2 | 1 | 1 | 0 | ironpython,dynamic-language-runtime | 1,852,956 | 2 | true | 0 | 1 | No, there is no way to statically verify at compile time that the interface changes have not broken your IronPython code. This is the nature of dynamic languages. Such errors are instead presented at runtime | 2 | 4 | 0 | I know that IronPython is a dynamically typed language so what I am asking sounds pretty stupid, but is it possible to do something with an IronPython script to make sure the changing of the CLR libraries it references will not result in a runtime error when the script is executed?
The reason I ask is that I have written a library referenced by IronPython scripts in C#, and I want a way to know if I've broken any of the interfaces used by the IronPhon scripts when I change the C# library. This is easy to do with another C# project by just compiling the code and seeing compile errors, but this doesn't seem to work when compiling the IronPython scripts.
Any ideas? | IronPython compile-time checks against CLR libraries? | 1.2 | 0 | 0 | 244 |
1,852,897 | 2009-12-05T17:51:00.000 | 1 | 1 | 1 | 0 | ironpython,dynamic-language-runtime | 1,866,436 | 2 | false | 0 | 1 | A good set of fast running unit tests would be a good alternative to compile time checking. | 2 | 4 | 0 | I know that IronPython is a dynamically typed language so what I am asking sounds pretty stupid, but is it possible to do something with an IronPython script to make sure the changing of the CLR libraries it references will not result in a runtime error when the script is executed?
The reason I ask is that I have written a library referenced by IronPython scripts in C#, and I want a way to know if I've broken any of the interfaces used by the IronPhon scripts when I change the C# library. This is easy to do with another C# project by just compiling the code and seeing compile errors, but this doesn't seem to work when compiling the IronPython scripts.
Any ideas? | IronPython compile-time checks against CLR libraries? | 0.099668 | 0 | 0 | 244 |
1,853,673 | 2009-12-05T22:28:00.000 | 3 | 0 | 0 | 0 | python,web-crawler | 1,853,865 | 6 | false | 1 | 0 | You waste a lot of time waiting for network requests when spidering, so you'll definitely want to make your requests in parallel. I would probably save the result data to disk and then have a second process looping over the files searching for the term. That phase could easily be distributed across multiple machines if you needed extra performance. | 3 | 6 | 0 | I'm writing a spider in Python to crawl a site. Trouble is, I need to examine about 2.5 million pages, so I could really use some help making it optimized for speed.
What I need to do is examine the pages for a certain number, and if it is found to record the link to the page. The spider is very simple, it just needs to sort through a lot of pages.
I'm completely new to Python, but have used Java and C++ before. I have yet to start coding it, so any recommendations on libraries or frameworks to include would be great. Any optimization tips are also greatly appreciated. | Writing a Faster Python Spider | 0.099668 | 0 | 1 | 7,091 |
1,853,673 | 2009-12-05T22:28:00.000 | 0 | 0 | 0 | 0 | python,web-crawler | 1,854,592 | 6 | false | 1 | 0 | What Adam said. I did this once to map out Xanga's network. The way I made it faster is by having a thread-safe set containing all usernames I had to look up. Then I had 5 or so threads making requests at the same time and processing them. You're going to spend way more time waiting for the page to DL than you will processing any of the text (most likely), so just find ways to increase the number of requests you can get at the same time. | 3 | 6 | 0 | I'm writing a spider in Python to crawl a site. Trouble is, I need to examine about 2.5 million pages, so I could really use some help making it optimized for speed.
What I need to do is examine the pages for a certain number, and if it is found to record the link to the page. The spider is very simple, it just needs to sort through a lot of pages.
I'm completely new to Python, but have used Java and C++ before. I have yet to start coding it, so any recommendations on libraries or frameworks to include would be great. Any optimization tips are also greatly appreciated. | Writing a Faster Python Spider | 0 | 0 | 1 | 7,091 |
1,853,673 | 2009-12-05T22:28:00.000 | 3 | 0 | 0 | 0 | python,web-crawler | 1,853,689 | 6 | false | 1 | 0 | Spidering somebody's site with millions of requests isn't very polite. Can you instead ask the webmaster for an archive of the site? Once you have that, it's a simple matter of text searching. | 3 | 6 | 0 | I'm writing a spider in Python to crawl a site. Trouble is, I need to examine about 2.5 million pages, so I could really use some help making it optimized for speed.
What I need to do is examine the pages for a certain number, and if it is found to record the link to the page. The spider is very simple, it just needs to sort through a lot of pages.
I'm completely new to Python, but have used Java and C++ before. I have yet to start coding it, so any recommendations on libraries or frameworks to include would be great. Any optimization tips are also greatly appreciated. | Writing a Faster Python Spider | 0.099668 | 0 | 1 | 7,091 |
1,854,278 | 2009-12-06T03:48:00.000 | 2 | 0 | 1 | 0 | python,concurrency,stackless,python-stackless | 1,854,333 | 2 | true | 0 | 0 | Focus on functionality first, and performance second (unless you know you have the need).
Most of the time on a server is spent with I/O, so multi-cores do not help so much. If it is mostly I/O that you are working with, multi-threading python may be the simplest answer.
If the server requests are CPU intensive, then having a parent process (be it multi-threaded or not), and respective child processes does make a good bit of sense.
If you really want to scale, you could look at a different platform, like Erlang. If you really want to scale and still use python, you could look at distributed erlang with Python processes managed as Erlang ports on a distributed cluster.
Lots of options, but unless you are dealing with someting big big, you could most likely take a simple approach.
release early, release often. | 2 | 2 | 0 | stackless python didn't take a good usage of multi-core, so where is the point it should be faster than python thread/multiprocessing ?
all the benchmark use stackless python tasklet to compare with python thread lock and queue, that's unfair, cause lock always has low efficiency
see, if use single thread function call without lock it should be as efficient as stackless python | how stackless python can be fast for concurrency? | 1.2 | 0 | 0 | 1,656 |
1,854,278 | 2009-12-06T03:48:00.000 | 0 | 0 | 1 | 0 | python,concurrency,stackless,python-stackless | 4,222,704 | 2 | false | 0 | 0 | There is this new and trendy thing called asynchronous-IO-loops and message-passing-concurrency and a few other trendy terms. Well, its not at all new, but it is only just these last 5 years being discovered by the mainstream.
Stackless Python is a version of Python where the VM has itself been modified to better support these message passing and IO loops, and its trick is green threading / coroutines.
There are other libraries for doing the same with different tools, e.g. Twisted and Tornado, on Python. You can even run hybrid Twisted on Stackless Python and so on.
The IO loop bit maps directly to how Berkley sockets do asynchronous IO, and with a bit of effort can be extended to be proactive rather than reactive and work with file systems as well as network sockets, e.g. the newest libevent.
To scale sideways to utilise more than one core is where you have two approaches - multithreading; shared state e.g. threads or between processes - multiprocessing e.g. message queues. It is a general limitation of current architectures that the threads approach works well for a large number of cores locally, whereas message passing overtakes performance-wise as the number of cores becomes massive or if those cores are on different machines. And you can make a hybrid approach.
Because of internal design choices in the Python VM, it is generally not as efficient at multi-threading as multi-processing, so you go to multiple processes with message passing sooner than you might on other platforms.
But generally the message passing approach is a cleaner, easily correct version.
And there are other languages that build on this same approach with different additional aims and constraints e.g. Erlang, node.js, Clojure, Go.
Of these, Clojure is perhaps the most informative. When you understand how Clojure ticks, and think through the whys, the whole aims and constraints of the other systems will fall into place... | 2 | 2 | 0 | stackless python didn't take a good usage of multi-core, so where is the point it should be faster than python thread/multiprocessing ?
all the benchmark use stackless python tasklet to compare with python thread lock and queue, that's unfair, cause lock always has low efficiency
see, if use single thread function call without lock it should be as efficient as stackless python | how stackless python can be fast for concurrency? | 0 | 0 | 0 | 1,656 |
1,854,718 | 2009-12-06T08:10:00.000 | -3 | 0 | 0 | 1 | python,autorun | 1,854,777 | 5 | false | 0 | 0 | You want the script to download the weather information online and output the clothes based on your predefined rules?
If this is the case, use urllib to download the page and do some ad hoc parsing over the downloaded html page to get the whether information. And write your logic using nested IF THEN ELSE blocks. | 3 | 4 | 0 | I created a script that will tell me what to wear in the morning based on the weather (i.e. rain slicker if it will rain, heavy jacket if it will be cold, etc). I have fairly basic programming experience with python and the script works perfectly, but I want to be able to create a file that I can just double-click from my desktop and the script will automatically run.
My goal is to be able to simply double click [something] in the morning and it will automatically run the script and thus tell me what to wear. How could I go about doing this?
System Specifications:
python
Mac OSX | How to auto-run a script | -0.119427 | 0 | 0 | 35,644 |
1,854,718 | 2009-12-06T08:10:00.000 | 0 | 0 | 0 | 1 | python,autorun | 34,125,858 | 5 | false | 0 | 0 | Use a batch file to make it automatic
Example :
1. Open Notepad -> type the following.
This one's for Windows..It might give you a hint
:start
C:\Python34\python.exe(your python file location)Your *.py file location.
:end
Save this with a *.bat extension
That's it ..you can configure more on this batch,I guess batch is the automation for day to day script | 3 | 4 | 0 | I created a script that will tell me what to wear in the morning based on the weather (i.e. rain slicker if it will rain, heavy jacket if it will be cold, etc). I have fairly basic programming experience with python and the script works perfectly, but I want to be able to create a file that I can just double-click from my desktop and the script will automatically run.
My goal is to be able to simply double click [something] in the morning and it will automatically run the script and thus tell me what to wear. How could I go about doing this?
System Specifications:
python
Mac OSX | How to auto-run a script | 0 | 0 | 0 | 35,644 |
1,854,718 | 2009-12-06T08:10:00.000 | -2 | 0 | 0 | 1 | python,autorun | 51,091,871 | 5 | false | 0 | 0 | In Linux/unix based OS , add #!/usr/bin/python3 line on top of your script file with extension .py , if you have python version 3. Or change it to the version installed in the machine
Further , make the file executable by
sudo chmod +x <fileName>
for windows, add windows python path and make the file executable | 3 | 4 | 0 | I created a script that will tell me what to wear in the morning based on the weather (i.e. rain slicker if it will rain, heavy jacket if it will be cold, etc). I have fairly basic programming experience with python and the script works perfectly, but I want to be able to create a file that I can just double-click from my desktop and the script will automatically run.
My goal is to be able to simply double click [something] in the morning and it will automatically run the script and thus tell me what to wear. How could I go about doing this?
System Specifications:
python
Mac OSX | How to auto-run a script | -0.07983 | 0 | 0 | 35,644 |
1,854,821 | 2009-12-06T08:58:00.000 | 3 | 0 | 0 | 1 | python,django,google-app-engine | 2,908,765 | 8 | false | 1 | 0 | I used pingdom for obvious reasons - no cold starts is a bonus. Of course the customers will soon come flocking and it will be a non-issue | 5 | 17 | 0 | I created a Hello World website in Google App Engine. It is using Django 1.1 without any patch.
Even though it is just a very simple web page, it takes long time and often it times out.
Any suggestions to solve this?
Note: It is responding fast after the first call. | Google App Engine Application Extremely slow | 0.07486 | 0 | 0 | 8,372 |
1,854,821 | 2009-12-06T08:58:00.000 | 3 | 0 | 0 | 1 | python,django,google-app-engine | 1,856,432 | 8 | false | 1 | 0 | I encounteres the same with pylons based app. I have the initial page server as static, and have a dummy ajax call in it to bring the app up, before the user types in credentials. It is usually enough to avoid a lengthy response... Just an idea that you might use before you actually have a million users ;). | 5 | 17 | 0 | I created a Hello World website in Google App Engine. It is using Django 1.1 without any patch.
Even though it is just a very simple web page, it takes long time and often it times out.
Any suggestions to solve this?
Note: It is responding fast after the first call. | Google App Engine Application Extremely slow | 0.07486 | 0 | 0 | 8,372 |
1,854,821 | 2009-12-06T08:58:00.000 | 4 | 0 | 0 | 1 | python,django,google-app-engine | 1,854,829 | 8 | false | 1 | 0 | If it's responding quickly after the first request, it's probably just a case of getting the relevant process up and running. Admittedly it's slightly surprising that it takes so long that it times out. Is this after you've updated the application and verified that the AppEngine dashboard shows it as being ready?
"First hit slowness" is quite common in many web frameworks. It's a bit of a pain during development, but not a problem for production. | 5 | 17 | 0 | I created a Hello World website in Google App Engine. It is using Django 1.1 without any patch.
Even though it is just a very simple web page, it takes long time and often it times out.
Any suggestions to solve this?
Note: It is responding fast after the first call. | Google App Engine Application Extremely slow | 0.099668 | 0 | 0 | 8,372 |
1,854,821 | 2009-12-06T08:58:00.000 | 14 | 0 | 0 | 1 | python,django,google-app-engine | 1,854,875 | 8 | true | 1 | 0 | This is a horrible suggestion but I'll make it anyway:
Build a little client application or just use wget with cron to periodically access your app, maybe once every 5 minutes or so. That should keep Google from putting it into a dormant state.
I say this is a horrible suggestion because it's a waste of resources and an abuse of Google's free service. I'd expect you to do this only during a short testing/startup phase. | 5 | 17 | 0 | I created a Hello World website in Google App Engine. It is using Django 1.1 without any patch.
Even though it is just a very simple web page, it takes long time and often it times out.
Any suggestions to solve this?
Note: It is responding fast after the first call. | Google App Engine Application Extremely slow | 1.2 | 0 | 0 | 8,372 |
1,854,821 | 2009-12-06T08:58:00.000 | 4 | 0 | 0 | 1 | python,django,google-app-engine | 1,856,888 | 8 | false | 1 | 0 | One more tip which might increase the response time.
Enabling billing does increase the quotas, and, to my personal experience, increase the overall response of an application as well. Probably because of the higher priority for billing-enabled applications google has. For instance, an app with billing disabled, can send up to 5-10 emails/request, an app with billing enabled easily copes with 200 emails/request.
Just be sure to set low billing levels - you never know when Slashdot, Digg or HackerNews notices your site :) | 5 | 17 | 0 | I created a Hello World website in Google App Engine. It is using Django 1.1 without any patch.
Even though it is just a very simple web page, it takes long time and often it times out.
Any suggestions to solve this?
Note: It is responding fast after the first call. | Google App Engine Application Extremely slow | 0.099668 | 0 | 0 | 8,372 |
1,854,827 | 2009-12-06T09:04:00.000 | 0 | 0 | 0 | 0 | python,coding-style,code-readability | 2,628,550 | 9 | false | 1 | 0 | Maybe you have a project in mind that you want to code up? It's very hard to read what other people write, the best way to learn is to try something. Other people will have gone through the problems you will come across, and so why code is written the way it is may start to make sense. This is an excellent site to post questions, no matter how stupid you consider them. | 5 | 2 | 0 | I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML.
I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a particular order I should look for?
Thanks.
EDIT: Sorry guys, I forgot to mention that I already have both the online tutorial and a couple of books handy. I basically I don't quite understand how to "dismantle" and understand complex source code, in order to grasp programming techniques and concepts.
EDIT2: Thanks for the extremely quick comments, guys. I really appreciate it. This website is awesome. | How can a total, complete beginner read source code? | 0 | 0 | 1 | 1,248 |
1,854,827 | 2009-12-06T09:04:00.000 | 6 | 0 | 0 | 0 | python,coding-style,code-readability | 1,854,832 | 9 | false | 1 | 0 | I would recommend you understand the basics. What are methods, classes, variables and so on. It would be important to understand the constructs you are seeing. If you don't understand those then it's just going to be a bunch of characters. | 5 | 2 | 0 | I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML.
I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a particular order I should look for?
Thanks.
EDIT: Sorry guys, I forgot to mention that I already have both the online tutorial and a couple of books handy. I basically I don't quite understand how to "dismantle" and understand complex source code, in order to grasp programming techniques and concepts.
EDIT2: Thanks for the extremely quick comments, guys. I really appreciate it. This website is awesome. | How can a total, complete beginner read source code? | 1 | 0 | 1 | 1,248 |
1,854,827 | 2009-12-06T09:04:00.000 | 3 | 0 | 0 | 0 | python,coding-style,code-readability | 1,973,070 | 9 | false | 1 | 0 | Donald Knuth suggests:
"It [is] basically the way you solve some kind of unknown puzzle -- make tables and charts and get a little more information here and make a hypothesis."
(From "Coders at Work", Chapter 15)
In my opinion, the easiest way to understand a program is to study the data structures first. Write them down, memorize them. Only then, think about how they move through program-time.
As an aside, it is sort of a shame how few books there are on code reading. "Coders at Work" is probably the best so far. Ironically, "Reading Code" is one of the worst so far. | 5 | 2 | 0 | I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML.
I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a particular order I should look for?
Thanks.
EDIT: Sorry guys, I forgot to mention that I already have both the online tutorial and a couple of books handy. I basically I don't quite understand how to "dismantle" and understand complex source code, in order to grasp programming techniques and concepts.
EDIT2: Thanks for the extremely quick comments, guys. I really appreciate it. This website is awesome. | How can a total, complete beginner read source code? | 0.066568 | 0 | 1 | 1,248 |
1,854,827 | 2009-12-06T09:04:00.000 | 3 | 0 | 0 | 0 | python,coding-style,code-readability | 1,854,841 | 9 | false | 1 | 0 | There is no magic way to learn anything without reading and writing code yourself. If you get stuck there are always folks in SO who will help you. | 5 | 2 | 0 | I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML.
I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a particular order I should look for?
Thanks.
EDIT: Sorry guys, I forgot to mention that I already have both the online tutorial and a couple of books handy. I basically I don't quite understand how to "dismantle" and understand complex source code, in order to grasp programming techniques and concepts.
EDIT2: Thanks for the extremely quick comments, guys. I really appreciate it. This website is awesome. | How can a total, complete beginner read source code? | 0.066568 | 0 | 1 | 1,248 |
1,854,827 | 2009-12-06T09:04:00.000 | 3 | 0 | 0 | 0 | python,coding-style,code-readability | 1,854,836 | 9 | false | 1 | 0 | To understand source code in any language, you first need to learn the language. It's as simple as that!
Usually, reading source code (as a sole activity) will hurt your head without giving much benefit in terms of learning the underlying language. You need a structured tour through carefully chosen small source code examples, such as a book or tutorial will give you.
Check Amazon out for books and Google for tutorials, try a few. The links offered by some of the other answers would also be a great starting point. | 5 | 2 | 0 | I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML.
I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin. Is there a particular order I should look for?
Thanks.
EDIT: Sorry guys, I forgot to mention that I already have both the online tutorial and a couple of books handy. I basically I don't quite understand how to "dismantle" and understand complex source code, in order to grasp programming techniques and concepts.
EDIT2: Thanks for the extremely quick comments, guys. I really appreciate it. This website is awesome. | How can a total, complete beginner read source code? | 0.066568 | 0 | 1 | 1,248 |
1,855,748 | 2009-12-06T15:59:00.000 | 0 | 1 | 0 | 0 | javascript,python,ajax | 1,855,787 | 4 | false | 1 | 0 | Update img.src attribute in onsubmit() handler.
img.src url points to your Python script that should generate an image in response.
onsubmit() for your form could be registered and written using JQuery. | 1 | 2 | 0 | I've been researching this on and off for a number of months now, but I am incapable of finding clear direction.
My goal is to have a page which has a form on it and a graph on it. The form can be filled out and then sent to the CGI Python script (yeah, I'll move to WSGI or fast_cgi later, I'm starting simple!) I'd like the form to be able to send multiple times, so the user can update the graph, but I don't want the page to reload every time it doe that. I have a form and a graph now, but they're on separate pages and work as a conventional script.
I'd like to avoid ALL frameworks except JQuery (as I love it, don't like dealing with the quirks of different browsers, etc).
A nudge in the right direction(s) is all I'm asking for here, or be as specific as you care to.
(I've found similar guides to doing this in PHP, I believe, but for some reason, they didn't serve my purpose.)
EDIT: The graph is generated using Flot (a JQuery plugin) using points generated from the form input and processed in the Python script. The Python script prints the Javascript which produces the graph in the end. It could all be done in Javascript, but I want the heavier stuff to be handled server-side, hence the Python.
Thanks! | Dynamically Refreshed Pages produced by Python | 0 | 0 | 0 | 1,212 |
1,856,786 | 2009-12-06T22:10:00.000 | 3 | 0 | 0 | 1 | python,twisted,p2p | 1,857,145 | 1 | true | 0 | 0 | Without knowing all the details of the protocol, I would still recommend using a single reactor -- a reactor scales quite well (especially advanced ones such as PollReactor) and this way you will avoid the overhead connected with threads (that's how Twisted and other async systems get their fundamental performance boost, after all -- by avoiding such overhead). In practice, threads in Twisted are useful mainly when you need to interface to a library whose functions could block on you. | 1 | 3 | 0 | I'm working on writing a Python client for Direct Connect P2P networks. Essentially, it works by connecting to a central server, and responding to other users who are searching for files.
Occasionally, another client will ask us to connect to them, and they might begin downloading a file from us. This is a direct connection to the other client, and doesn't go through the central server.
What is the best way to handle these connections to other clients? I'm currently using one Twisted reactor to connect to the server, but is it better have multiple reactors, one per client, with each one running in a different thread? Or would it be better to have a completely separate Python script that performs the connection to the client?
If there's some other solution that I don't know about, I'd love to hear it. I'm new to programming with Twisted, so I'm open to suggestions and other resources.
Thanks! | Proper way to implement a Direct Connect client in Twisted? | 1.2 | 0 | 1 | 1,176 |
1,858,117 | 2009-12-07T06:06:00.000 | 0 | 0 | 1 | 0 | python,validation,parsing,numbers | 1,858,289 | 4 | false | 0 | 0 | I haven't heard of one. Do you know of any such library for any other languages? That way you could leverage their documentation and tests.
If you can't find one, write a bunch of testcases, then we can help you fill out the parsing code.
Google must have one, try searching for 5.5billion * 10, but I don't think they have opensourced anything like that. Depending on how you need to use it, you might be able to use Google to do some of the work ;) | 1 | 7 | 0 | Are there any Python libraries that help parse and validate numeric strings beyond what is supported by the built-in float() function? For example, in addition to simple numbers (1234.56) and scientific notation (3.2e15), I would like to be able to parse formats like:
Numbers with commas: 2,147,483,647
Named large numbers: 5.5 billion
Fractions: 1/4
I did a bit of searching and could not find anything, though I would be surprised if such a library did not already exist. | Flexible numeric string parsing in Python | 0 | 0 | 0 | 2,001 |
1,859,195 | 2009-12-07T10:38:00.000 | 0 | 0 | 0 | 0 | python,video,pyglet | 1,860,559 | 2 | true | 0 | 1 | I think calling "pyglet.app.run()" is missing. | 1 | 1 | 0 | I'm new to pyglet and i have a problem with video..
I'm trying to play a video using pyglet .. but instead of playing the video in the window it just exits immediately and terminates ..
do you guys have any solution for this problem how can i hold the window to play vedio??
i use windows vista 64x with python 2.5
please help
and here is the code :
vidPath="vid.avi"
widnow = pyglet.window.Window()
source = pyglet.media.StreamingSource()
MediaLoad = pyglet.media.load(vidPath)
player = pyglet.media.Player()
player.queue(MediaLoad)
player.play()
@window.event
...def on_draw():
... player.get_texture.blit(0,0)
thank u very much for your time | problem with pyglet playing video | 1.2 | 0 | 0 | 4,199 |
1,859,634 | 2009-12-07T12:12:00.000 | 0 | 0 | 0 | 1 | python,web-services,google-app-engine,xmpp | 1,859,664 | 3 | false | 1 | 0 | In that situation, I would perform ajax calls every 5 minutes in example to check it.
It's easy to implement and the data exchanged can be reduced to the max (taking advantage of "fast query/response" bonifications of google-app).
Regards. | 2 | 1 | 0 | I've been looking for a way to tell clients about expired objects and AppEngine's XMPP implementation seems really interesting because it's scalable, should be reliable and can contain up to 100kb of data.
But as I understand it, before a client can listen to messages, he should have a gmail account. That's very impractical.
Is there maybe a way to make temporary readonly XMPP accounts to use with this? | Using AppEngine XMPP for Client Notifications | 0 | 0 | 0 | 1,077 |
1,859,634 | 2009-12-07T12:12:00.000 | 1 | 0 | 0 | 1 | python,web-services,google-app-engine,xmpp | 1,859,647 | 3 | true | 1 | 0 | No this isn't true: you can have the AppEngine robot as contact over any Jabber/XMPP based networks.
Unless you are talking about the need for a GMAIL account to create an AppEngine robot... in which case YES you need to have a Google account. | 2 | 1 | 0 | I've been looking for a way to tell clients about expired objects and AppEngine's XMPP implementation seems really interesting because it's scalable, should be reliable and can contain up to 100kb of data.
But as I understand it, before a client can listen to messages, he should have a gmail account. That's very impractical.
Is there maybe a way to make temporary readonly XMPP accounts to use with this? | Using AppEngine XMPP for Client Notifications | 1.2 | 0 | 0 | 1,077 |
1,859,865 | 2009-12-07T13:08:00.000 | 0 | 0 | 1 | 0 | java,python,jython | 57,640,568 | 10 | false | 0 | 0 | To achieve a good speed performance or implementing a real multithreading program, calling python script directly from java (native) is the best way. Just prepare your python script then let java do the rest for concurrent invocation into your python script. | 6 | 31 | 0 | I know Python, but what is Jython?
When will I need Jython?
What are the drawbacks?
I assume it is slow?
Please detail it out! thanks. | What is Jython and is it useful at all? | 0 | 0 | 0 | 33,340 |
1,859,865 | 2009-12-07T13:08:00.000 | 4 | 0 | 1 | 0 | java,python,jython | 1,860,018 | 10 | false | 0 | 0 | When will I need Jython?
For example to add a nice scripting language to your code.
What are the drawbacks?
The main drawback is that Jython lags behind the official CPython distribution. Currently, you can get a version of Jython that is compatible with Python 2.5.2 while CPython is at 3.1.
Also some esoteric modules aren't supported. Usually, you won't notice and/or be able to easily find a Java replacement.
I assume it is slow?
Compared to what? Usually, it's either fast enough or, when it isn't, you can replace a few lines of Python with about 1'000 lines of much faster Java. | 6 | 31 | 0 | I know Python, but what is Jython?
When will I need Jython?
What are the drawbacks?
I assume it is slow?
Please detail it out! thanks. | What is Jython and is it useful at all? | 0.07983 | 0 | 0 | 33,340 |
1,859,865 | 2009-12-07T13:08:00.000 | 5 | 0 | 1 | 0 | java,python,jython | 1,860,242 | 10 | false | 0 | 0 | Two other reasons:
Embedding scripting into large Java application.
Use Java threads to write multi-threaded programs in Jython. | 6 | 31 | 0 | I know Python, but what is Jython?
When will I need Jython?
What are the drawbacks?
I assume it is slow?
Please detail it out! thanks. | What is Jython and is it useful at all? | 0.099668 | 0 | 0 | 33,340 |
1,859,865 | 2009-12-07T13:08:00.000 | 1 | 0 | 1 | 0 | java,python,jython | 1,865,328 | 10 | false | 0 | 0 | When will I need Jython?
I need Jython to test JDBC drivers. Some of apps I use work use ODBC, some use JDBC. Using Jython I can test both type of drivers from one Python source
(to test ODBC I use JDBC-ODBC bridge). | 6 | 31 | 0 | I know Python, but what is Jython?
When will I need Jython?
What are the drawbacks?
I assume it is slow?
Please detail it out! thanks. | What is Jython and is it useful at all? | 0.019997 | 0 | 0 | 33,340 |
1,859,865 | 2009-12-07T13:08:00.000 | 9 | 0 | 1 | 0 | java,python,jython | 1,872,738 | 10 | false | 0 | 0 | If you know Python and has bought into the "pythonic" way of doing things, then Jython allows you to bring that philosophy to the JVM stack. If you do this, it is much more than just adding scripting capability.
In our latest projects, all the custom and business logic is built in Jython, at the same time we can still leverage some of the great tried and tested Java libraries like Solr, Jasperreports, Quartz, Jetty, Velocity to name a few.
It does get compiled to bytecode, however, an extra layer is being added, but is no different to using an ORM instead of straight JDBC for example.
What you gain in productivity far out weighs the minuscule lost in performance.
On the server side, Jython is rarely the bottleneck. For mini desktop apps, there may be issues, but very much dependent on what you are trying to do.
The latest JDK, together with containers like Jetty or Tomcat are very mature and stable, adding Python on top, in many cases, gives the best of both worlds. | 6 | 31 | 0 | I know Python, but what is Jython?
When will I need Jython?
What are the drawbacks?
I assume it is slow?
Please detail it out! thanks. | What is Jython and is it useful at all? | 1 | 0 | 0 | 33,340 |
1,859,865 | 2009-12-07T13:08:00.000 | 7 | 0 | 1 | 0 | java,python,jython | 1,859,971 | 10 | false | 0 | 0 | When will I need Jython?
When you want to program in Python but need (or want) to have the result run on a Java virtual machine, or use existing Java components.
What are the drawbacks.
Jython may not be 100% compatible with Python, though any incompatibility would be considered a bug. If you later want/need to run on CPython, any code that uses Java components will have to be rewritten.
I assume it is slow?
That depends, as always, on your specific usecase. It may actually be faster than CPython in some cases; and of course it depends on the specific JVM you run under - these get better all the time. | 6 | 31 | 0 | I know Python, but what is Jython?
When will I need Jython?
What are the drawbacks?
I assume it is slow?
Please detail it out! thanks. | What is Jython and is it useful at all? | 1 | 0 | 0 | 33,340 |
1,860,348 | 2009-12-07T14:35:00.000 | 3 | 0 | 1 | 0 | python,virtualenv | 1,860,614 | 2 | false | 0 | 0 | Newly created virtual environment by default have access to global site-packages directory, unless created with --no-site-packages. Calling easy_install (installing new packages) with certain environment activated will cause local overwrite of already existing ones in global site-packages (similar to inheritance). Environment will use its own local packages, when missing - global ones. | 1 | 7 | 0 | If I have a certain package installed both in the global site-packages and in the local one, which package will get imported? Will that even work or will I get an error?
Which packages should I put in the global site-packages and which in the local one? | Virtualenv: global site-packages vs the site-packages in the virtual environment | 0.291313 | 0 | 0 | 3,915 |
1,861,267 | 2009-12-07T16:52:00.000 | 1 | 0 | 0 | 0 | python,django,django-cms | 1,872,391 | 1 | true | 1 | 0 | This all depends on your model. Plugins use standard django admin features.
This also depends on the source data for the table.
If you have a CSV or Exel sheet as source i only would make a file field and render the file in the render function with some optional caching.
If you want to enter data by hand:
A Table model.
An Row model with a foreign key to table.
The row model can then be used as a django-admin Inline. So you can add new rows as needed.
Be aware that CMSPluginBase extends ModelAdmin so you can define inlines like you would do in normal admin. | 1 | 1 | 0 | I don't see any possibility for creating a table in django-cms. I need this functionnality so I am evaluating the possibility to write my own plugin.
I am getting started with this product. I've read the documentation carefully and I see more or less how to do that.
However, I would be happy to hear some tips and tricks before starting this task. Does anybody have experience with django-cms plugin?
Thanks in advance | Writing my own django-cms plugin. Any recommendations? | 1.2 | 0 | 0 | 1,710 |
1,861,457 | 2009-12-07T17:21:00.000 | 1 | 0 | 1 | 0 | java,python,concurrency,python-stackless | 1,861,594 | 11 | false | 0 | 0 | For some tasks, Python is too slow. Your single thread Java program could be faster than the concurrent version of Python on a multi-core computer...
I'd like to use Java or Scala, F# or simply go to C++(MPI and OpenMPI). | 3 | 9 | 0 | Also, if not python or java, then would you more generally pick a statically-typed language or a dynamic-type language? | Python vs. Java -- Which would you pick to do concurrent programming and why? | 0.01818 | 0 | 0 | 16,957 |
1,861,457 | 2009-12-07T17:21:00.000 | 1 | 0 | 1 | 0 | java,python,concurrency,python-stackless | 1,862,045 | 11 | false | 0 | 0 | I'd look at Objective-C and the Foundation Framework. Asynchronous, concurrent programming is well provided for.
This of course depends on your access to Apple's Developer Tools or GnuStep, but if you have access to either one it's a good route to take with concurrent programming. | 3 | 9 | 0 | Also, if not python or java, then would you more generally pick a statically-typed language or a dynamic-type language? | Python vs. Java -- Which would you pick to do concurrent programming and why? | 0.01818 | 0 | 0 | 16,957 |
1,861,457 | 2009-12-07T17:21:00.000 | 2 | 0 | 1 | 0 | java,python,concurrency,python-stackless | 1,861,532 | 11 | false | 0 | 0 | I would use Java, via Jython. Java has strong thread capabilities, and it can be written using the Python syntax with Jython, so you got the best of the two worlds.
Python itself is not really good with concurrency, and is slower than Java anyway.
But if you have concurrency issues and free hands, I'd have a look at Erlang because it has been design for such problems. Of course, you must consider Erlang only if you have:
time to master a (very) new technology
control on a reasonable part of the production chain, since Erland need some adaptations in your toolbox to fit | 3 | 9 | 0 | Also, if not python or java, then would you more generally pick a statically-typed language or a dynamic-type language? | Python vs. Java -- Which would you pick to do concurrent programming and why? | 0.036348 | 0 | 0 | 16,957 |
1,862,782 | 2009-12-07T20:47:00.000 | 0 | 0 | 1 | 0 | python,regex | 1,864,066 | 3 | false | 0 | 0 | If you have not figured it out yet, I recommend trying [python_root]/tools/scripts/redemo.py It is a nice testing area. | 1 | 1 | 0 | One rule that I need is that if the last vowel (aeiou) of a string is before a character from the set ('t','k','s','tk'), then a : needs to be added right after the vowel.
So, in Python if I have the string "orchestras" I need a rule that will turn it into "orchestra:s"
edit: The (t, k, s, tk) would be the final character(s) in the string | Regular Expression search/replace help needed, Python | 0 | 0 | 0 | 253 |
1,865,262 | 2009-12-08T07:33:00.000 | 6 | 0 | 1 | 0 | python,programming-languages | 1,865,329 | 8 | false | 0 | 0 | By explicit, do you mean "explicitly passed as an argument to each class function"?
If so, then Python is the only one I know off-hand.
Most OO languages support this or self in some form, but most of them let you define class functions without always defining self as the first argument. | 3 | 4 | 0 | It seems a bit weird that Python requires you to explicitly pass self as the first argument to all class functions. Are there other languages that require something similar? | What languages other than Python have an explicit self? | 1 | 0 | 0 | 467 |
1,865,262 | 2009-12-08T07:33:00.000 | 0 | 0 | 1 | 0 | python,programming-languages | 1,865,411 | 8 | false | 0 | 0 | many object oriented languages if not all of them
for example c++ support "this" instead of "self"
but you dont have to pass it, it is passed passively
hope that helps ;) | 3 | 4 | 0 | It seems a bit weird that Python requires you to explicitly pass self as the first argument to all class functions. Are there other languages that require something similar? | What languages other than Python have an explicit self? | 0 | 0 | 0 | 467 |
1,865,262 | 2009-12-08T07:33:00.000 | 4 | 0 | 1 | 0 | python,programming-languages | 1,865,386 | 8 | false | 0 | 0 | Depending on your point of view, Lua. To quote the reference: "A call v:name(args) is syntactic sugar for v.name(v,args), except that v is evaluated only once." You can also define methods using either notation. So you could say that Lua has an optional explicit self. | 3 | 4 | 0 | It seems a bit weird that Python requires you to explicitly pass self as the first argument to all class functions. Are there other languages that require something similar? | What languages other than Python have an explicit self? | 0.099668 | 0 | 0 | 467 |
1,865,581 | 2009-12-08T08:45:00.000 | 1 | 0 | 1 | 0 | python,blender | 2,582,123 | 1 | false | 0 | 0 | your grammar is really bad but i think i understand what you are asking. When you use a camera you have to zoom in until the box fills your screen. | 1 | 0 | 0 | i try to create car's type game, but when i choose camera view , a view is not real every building have miss shape its look like perspective view .So i finding how to config it | How to setting Camera options in Blender | 0.197375 | 0 | 0 | 279 |
1,867,357 | 2009-12-08T14:33:00.000 | 2 | 0 | 0 | 1 | python,linux,file,filesystems,ext2 | 1,867,399 | 7 | false | 0 | 0 | Most reliable would be create a wrapping class which would check file's size when you open it, track write and seek operations, count current size based on those operations and prevent from exceeding size limit. | 1 | 12 | 0 | There's a file that I would like to make sure does not grow larger than 2 GB (as it must run on a system that uses ext 2). What's a good way to check a file's size bearing in mind that I will be writing to this file in between checks? In particular, do I need to worry about buffered, unflushed changes that haven't been written to disk yet? | How do I determine an open file's size in Python? | 0.057081 | 0 | 0 | 11,581 |
1,868,879 | 2009-12-08T18:22:00.000 | 1 | 0 | 1 | 0 | python,software-design | 1,869,817 | 18 | false | 0 | 0 | Wow, I wonder why nobody said until now that U really should not go too deep into theory. After one year Ur code is ugly. Nothing to do about it. If U get most things done U want to finish, it is already very awesome. But U cannot cheat Ur brain with theory. Just go on writing and be angry about Ur code. That is the best way to write better. Take Ur time to think about how to write working code in a more readable/usable/maintainable way as often as U can.
AND: Read other peoples code + get reviews on Ur code! There should be people out there who can write better then U. Learn by example!
And maybe 20% of Ur programming time (that means if U code every day, not more than 2 months a year!) get some theory.
Why not start with masses of theory? U kill Ur motivation and Ur instinct. But when U sit there and try to solve a problem it is mostly about the right instinct. With too much theory U overthink the problem and Ur solutions. But Ur instinct will be still on the level of Ur experience, no matter how much U read.
(sorry, if bad english. not my mothertounge) | 5 | 15 | 0 | I've been programming for around a year now, and all the stuff that I've written works - it's just extremely poorly written from my point of view. I'd like to know if there are any (free) good books on Software Design out there that can offer a little guidance to the beginning programmer? I don't think I'd have as many problems if I knew a little about the thought processes that go into software design. | Design principles for complete noobs? | 0.011111 | 0 | 0 | 2,727 |
1,868,879 | 2009-12-08T18:22:00.000 | 2 | 0 | 1 | 0 | python,software-design | 1,869,761 | 18 | false | 0 | 0 | The best way to learn good software design is to write code in a bunch of different ways, read code written by others, and learn what works and what doesn't first-hand.
When you are writing code, ask the following questions:
How will I test it?
How will I debug it?
What do I find myself doing over and over again?
I'm sure other people have other ideas, based on their own experiences. | 5 | 15 | 0 | I've been programming for around a year now, and all the stuff that I've written works - it's just extremely poorly written from my point of view. I'd like to know if there are any (free) good books on Software Design out there that can offer a little guidance to the beginning programmer? I don't think I'd have as many problems if I knew a little about the thought processes that go into software design. | Design principles for complete noobs? | 0.022219 | 0 | 0 | 2,727 |
1,868,879 | 2009-12-08T18:22:00.000 | 1 | 0 | 1 | 0 | python,software-design | 1,869,151 | 18 | false | 0 | 0 | Learn a different language! I love python, and, despite what everyone says, my python is better because I know java. (Some people complain that starting with java causes one to initially write clunky python, but if you already know more or less the easy way to do something in python, you will be safe from this.)
Let me do a little bit of chainsaw surgery here. It is easy to write python the first time. I write it in vim, because I can and because I love vim. It is easy to maintain and refactor java if you have an IDE. I write java in Eclipse, because I'd be hopeless without it. But the point is, writing in a language that forces you to use abstractions with a tool that makes abstractions easier will slowly shape your brain to code more abstractly. You will bring that back to python, even though the preferred abstractions will be slightly different. | 5 | 15 | 0 | I've been programming for around a year now, and all the stuff that I've written works - it's just extremely poorly written from my point of view. I'd like to know if there are any (free) good books on Software Design out there that can offer a little guidance to the beginning programmer? I don't think I'd have as many problems if I knew a little about the thought processes that go into software design. | Design principles for complete noobs? | 0.011111 | 0 | 0 | 2,727 |
1,868,879 | 2009-12-08T18:22:00.000 | 0 | 0 | 1 | 0 | python,software-design | 1,869,025 | 18 | false | 0 | 0 | Forget the books. In my experience (which includes time as an instructor and writer of OO design courses) some people can do design and some pople can't - it's a talent, like being a sculptor. At best, reading books on the subject will enable you to design badly, if you don't have the talent. | 5 | 15 | 0 | I've been programming for around a year now, and all the stuff that I've written works - it's just extremely poorly written from my point of view. I'd like to know if there are any (free) good books on Software Design out there that can offer a little guidance to the beginning programmer? I don't think I'd have as many problems if I knew a little about the thought processes that go into software design. | Design principles for complete noobs? | 0 | 0 | 0 | 2,727 |
1,868,879 | 2009-12-08T18:22:00.000 | 0 | 0 | 1 | 0 | python,software-design | 1,868,911 | 18 | false | 0 | 0 | Get the Gang of four book - Design Patterns..
But please don't over follow it and try to use Singleton everywhere :)
Just know it and use it wisely. Also after that look into good open source code and try to learn from their structures.. I suggest google code and sourceforge | 5 | 15 | 0 | I've been programming for around a year now, and all the stuff that I've written works - it's just extremely poorly written from my point of view. I'd like to know if there are any (free) good books on Software Design out there that can offer a little guidance to the beginning programmer? I don't think I'd have as many problems if I knew a little about the thought processes that go into software design. | Design principles for complete noobs? | 0 | 0 | 0 | 2,727 |
1,870,140 | 2009-12-08T21:59:00.000 | 0 | 0 | 1 | 0 | python,google-app-engine,cron | 1,870,164 | 4 | false | 1 | 0 | Can you use cron to schedule the job to run at certain intervals? It's usually considered better than infinite loops, and was designed to help solve this sort of problem. | 1 | 1 | 0 | Question for Python 2.6
I would like to create an simple web application which in specified time interval will run a script that modifies the data (in database). My problem is code for infinity loop or some other method to achieve this goal. The script should be run only once by the user. Next iterations should run automatically, even when the user leaves the application. If someone have idea for method detecting apps breaks it would be great to show it too. I think that threads can be the best way to achive that. Unfortunately, I just started my adventure with Python and don't know yet how to use them.
The application will have also views showing database and for control of loop script.
Any ideas? | Render in infinity loop | 0 | 0 | 0 | 283 |
1,870,383 | 2009-12-08T22:36:00.000 | 0 | 0 | 0 | 0 | python,xml,excel,csv | 1,870,411 | 3 | false | 0 | 0 | Reformat it as CSV. It's dead easy to do, is fairly human readable, and can be read by loads of pieces of spreadsheet software. | 1 | 0 | 0 | I have a Python script gathering info from some remote network devices. The output can be maybe 20 to 1000 lines of text. This then goes into excel on my local PC for now.
Now access to this Linux device is convoluted, a citrix session to a remote windows server then ssh to the Linux device half way around the world. There is no ftp, scp, or anything like that, so I can't generate the excel on the Linux device and transfer it locally. The ONLY way to get the info is to copy/paste from the ssh window into the local machine and post-process it
My question is what would be the best (from a user point of view as others will be using it) format to generate? 1.as it is now (spaces & tabs), 2.reformat as csv or as 3.convert to xml | Python to generate output ready for Excel | 0 | 0 | 1 | 720 |
1,871,549 | 2009-12-09T04:18:00.000 | 5 | 0 | 1 | 1 | python,virtualenv | 57,109,196 | 15 | false | 0 | 0 | Easiest way is to just run: which python, if you are in a virtualenv it will point to its python instead of the global one | 3 | 397 | 0 | Is it possible to determine if the current script is running inside a virtualenv environment? | Determine if Python is running inside virtualenv | 0.066568 | 0 | 0 | 237,037 |
1,871,549 | 2009-12-09T04:18:00.000 | 9 | 0 | 1 | 1 | python,virtualenv | 51,409,948 | 15 | false | 0 | 0 | You can do which python and see if its pointing to the one in virtual env. | 3 | 397 | 0 | Is it possible to determine if the current script is running inside a virtualenv environment? | Determine if Python is running inside virtualenv | 1 | 0 | 0 | 237,037 |
1,871,549 | 2009-12-09T04:18:00.000 | 204 | 0 | 1 | 1 | python,virtualenv | 38,939,054 | 15 | false | 0 | 0 | Try using pip -V (notice capital V)
If you are running the virtual env. it'll show the path to the env.'s location. | 3 | 397 | 0 | Is it possible to determine if the current script is running inside a virtualenv environment? | Determine if Python is running inside virtualenv | 1 | 0 | 0 | 237,037 |
1,871,672 | 2009-12-09T05:01:00.000 | 6 | 0 | 1 | 0 | python,design-patterns,oop,pygame | 1,871,698 | 3 | false | 0 | 1 | If this is your first Pygame application, don't spend time worrying about "object oriented design patterns for managing levels". What you need to do now is to figure out how to make Pygame do what you want it to do.
Can you display everything you want to?
Is your display flicker-free?
Can you read the user input controls properly?
etc.
Object oriented patterns for managing levels comes later, much later. | 3 | 3 | 0 | Hey--I'm trying to design my first game using the Pygame library for Python, and I was wondering what the best practices are for level design in general. I would love to hear what you guys think are good object oriented design patterns for managing levels. Also, I'm fairly new to Python--thanks! | Level Design in Pygame | 1 | 0 | 0 | 5,646 |
1,871,672 | 2009-12-09T05:01:00.000 | 1 | 0 | 1 | 0 | python,design-patterns,oop,pygame | 1,871,700 | 3 | false | 0 | 1 | Generally speaking, a simple way to do it is using matrices (or multidimensional arrays - they work the same way here).
Basically, each Map is an Array, with each item in the array being a square on the grid.
For example a 3 by 3 grid would be as follows:
(Psuedocode)
var Map = [[1,2,3][1,2,3][1,2,3]];
In place of numbers, you could put strings for a function to parse and draw or take action based on what the value of the cell is. | 3 | 3 | 0 | Hey--I'm trying to design my first game using the Pygame library for Python, and I was wondering what the best practices are for level design in general. I would love to hear what you guys think are good object oriented design patterns for managing levels. Also, I'm fairly new to Python--thanks! | Level Design in Pygame | 0.066568 | 0 | 0 | 5,646 |
1,871,672 | 2009-12-09T05:01:00.000 | 7 | 0 | 1 | 0 | python,design-patterns,oop,pygame | 1,873,480 | 3 | true | 0 | 1 | With this type of game your maps are in terms of tiles (I'm assuming that by level you mean an individual level, not managing all of your levels). Each tile has
an associated picture (what it looks like on the display)
a type (ie, a wall, the ground, a trap, etc.)
When I create tile-based games in Pygame, I usually have a Map class which contains the current map:
the pygame.Surface of the map (what you'll be blitting to the display)
a list of lists (ie, a matrix) where each item is a Tile object (I've also done games where you just have a string that tells you what type of tile it is, and then you don't need a separate Tile class)
The map should be relatively static - you could have that traps become normal tiles after you step on them (this is pretty easy - when you do collision detection and it's a hit, just change that tile to a different Tile object (presumably the one for an empty tile)), but you don't want characters or movable blocks in the map if you can help it. Since the movable blocks have their own rules for how they can be moved, it's not as simple as just changing a tile - you'd have a whole set of logic, and at least two tiles would have to be changed (and what if you could move the blocks onto traps - you'd then have to remember, separately, what was below it - bleh). In my opinion it's easier to just have a class for each moving object and item.
In short, you have:
Tile
Map
Block
other movable objects/sprites
And that's basically your whole level. For multiple levels, if individual levels are always the same, you can just have a list of Map objects, one for each level. | 3 | 3 | 0 | Hey--I'm trying to design my first game using the Pygame library for Python, and I was wondering what the best practices are for level design in general. I would love to hear what you guys think are good object oriented design patterns for managing levels. Also, I'm fairly new to Python--thanks! | Level Design in Pygame | 1.2 | 0 | 0 | 5,646 |
1,873,806 | 2009-12-09T13:15:00.000 | 1 | 0 | 0 | 0 | python,django | 40,871,533 | 10 | false | 1 | 0 | Once the url pattern is added as shown in Ciro Santilli's answer, a quick way to allow users to change passwords is to give them "staff access" for the admin functions. If you don't add them to any groups or give them special permissions, they can still change their password by going to the example.com/admin page. The staff access lets them go to the page even if it is blank; in the upper right corner they can click "change password" and use the admin funtionality. | 2 | 93 | 0 | Can any one point me to code where users can change their own passwords in Django? | How to allow users to change their own passwords in Django? | 0.019997 | 0 | 0 | 92,604 |
1,873,806 | 2009-12-09T13:15:00.000 | 26 | 0 | 0 | 0 | python,django | 1,873,933 | 10 | false | 1 | 0 | You can also just use the django.contrib.auth.views.password_change view in your URLconf. It uses a default form and template; supplying your own is optional. | 2 | 93 | 0 | Can any one point me to code where users can change their own passwords in Django? | How to allow users to change their own passwords in Django? | 1 | 0 | 0 | 92,604 |
1,876,908 | 2009-12-09T21:11:00.000 | 0 | 0 | 0 | 0 | python,google-wave | 1,932,852 | 2 | false | 1 | 0 | At the moment the answer is that i can't be done. Hopefully in a future version of the Api. | 1 | 1 | 0 | I'm working on a small wave thingy where i need to load a wave based on an outside event. So i don't have a context to work with.
I've been looking at the python api for a while but i can't figure out the correct way to get a wave object (that i can then call CreateBlip() on) when i just have the waveid.
Is there something i've just overlooked? or do I have to make a 'raw' json request instead of using the api ? | Loading a wave from waveid | 0 | 0 | 1 | 95 |
1,877,238 | 2009-12-09T22:04:00.000 | 2 | 0 | 1 | 0 | powershell,ironpython,etl,fileparsing | 1,877,311 | 2 | false | 0 | 0 | Depending on the complexity and variability of your work, you should consider an ETL tool like SSIS (SQL Server Integration Services). | 1 | 0 | 0 | I am looking for the best solution for custom file parsing for our enterprise import routines. I want to basically change one file format into a standard file format and have one routine that imports that data into the database. I need to be able to create custom scripts for each client since its difficult to get the customer to comply with a standard or template format. I have looked at PowerShell and Iron Python to do this so far but I am not sure this is the route I want to go. I have also looked at some tools such as Talend which is a drag and drop style tool which may or may not give me what I want as far as flexibility. We are a .NET shop and have created custom code to do this in the past but I need something that is quicker to create then coding custom parsing functions each time we get a new file format in. | What is the best file parsing solution for converting files? | 0.197375 | 0 | 0 | 2,314 |
1,877,402 | 2009-12-09T22:32:00.000 | 1 | 0 | 0 | 0 | python,drag-and-drop,wxpython | 1,935,002 | 2 | false | 0 | 1 | IMO the best way is, Panel should bind to control's wx.EVT_LEFT_DOWN and drag only when special key combination e.g. cntrl-alt-d are pressed
Panel can do it recursively or have a function in Panel, addControl and only such control will be hooked.
Your point that "individual controls may already be using that event for other purposes" is not valid because either you can use that event for dragging or not, you can't have both way.
If you want drag on control to be used as drag of whole group, then you MUST override such event, but with doing dragging only inspecial key combination or modes you can let child control have their behaviour too. | 1 | 0 | 0 | I have a wxPython program where I want to be able to drag groups of controls around to reorder them. Each group of controls is on a panel, and I want the panel object to handle the drag-and-drop.
Currently it works if you click and drag on the panel itself, but it doesn't work if you click on any control inside the panel. This is because the wx.EVT_LEFT_DOWN event that I am using to trigger the drag is not a command event, so is not propagated up to the parent panel.
The only way I can think of to get round this is to bind that event to the panel's handler for every control on the panel.
This does not seem very elegant to me - either I have to explicitly do it when I create each child event, which breaks encapsulation, or the panel recurses through the child controls and does the binding - this seems dangerous, since the individual controls may already be using that event for other purposes. Ideally I would like the controls on the panel to not need to know anything about the DnD.
Does anyone know of any alternative solutions? Are there any command events that I could use to initiate dragging? Or anything else I haven't thought of? | wxPython: Handling drag-and-drop in a parent object - problem with event propagation | 0.099668 | 0 | 0 | 1,099 |
1,878,353 | 2009-12-10T02:49:00.000 | 3 | 0 | 0 | 0 | python,qt,pyqt4 | 1,879,368 | 1 | false | 0 | 1 | There is no signal emitted on first display, instead, you will have to intercept the first resizeEvent or paintEvent by overloading these methods (as you don't want to initialize from the __init__ method).
Another option would be to add your own showAndInit method, that initializes and then calls show. | 1 | 1 | 0 | I have an application in which I would like to connect whatever signal is emitted when a pyqt4 dialog is displayed in order to do execute an initial method. I don't want the method to be called in the __init__ method for a number of reasons. I've spent quite some time searching but I have yet to find an answer. I'm sure there is a simple solution that because of my inexperience I am overlooking as I can do this in wxPython. Suggestions? | What signal can be connected to an initial dialog display in pyqt4 (qt) | 0.53705 | 0 | 0 | 114 |
1,879,113 | 2009-12-10T06:52:00.000 | 4 | 0 | 0 | 1 | python,enterprise | 1,879,157 | 5 | false | 1 | 0 | The larger your investment in an existing technology is, the more expensive it is to move away from it. COBOL is perhaps the best example here.
That investment isn't just in porting existing solutions, but also in retraining or hiring new staff so that you have the skill sets to build and support the new technologies even while still maintaining your legacy solutions.
Add to that the fact that for most large Multinational Corporations, software isn't their core business. As long as it functions effectively and fulfills the business need, they don't tend to care so much about the 'details'.
You need to be able to offer some pretty compelling benefits to overcome this kind of inertia.
Sad but true. | 3 | 9 | 0 | This will not be a "programming" question but more technology / platform related question. I'm trying to figure out whether Python can be a suitable Java alternative for enterprise / web applications.
Which are the ideal cases where you would prefer to use Python instead of Java? How would a typical Python web application (databases/sessions/concurrency) perform as compared to a typical Java application? How do specific Python frameworks square up against Java based frameworks (Spring, SEAM, Grails etc.)?
For businesses, switching from the Java infrastructure to a Python infrastructure .. is it too hard/expensive/resource intensive/not viable? Also shed some light on the business case for providing a Python + Google AppEngine based solution to the end customer. Will it be cost effective in an typical scenario?
Sorry if I am asking too wide a question, I would have liked to keep it specific, but I need your help to evaluate Python as a whole from the perspectives of the programmers, service providing company and end business customer.
For an SME, a Python/GoogleAppEngine based technology stack is a clear scalable and affordable platform. But what about a large MNC that already has a lot invested in Java.
Thank you so much. I am researching this myself and will gladly share my conclusions here!
Thank you,
Srirangan | A business Case for Enterprise Python | 0.158649 | 0 | 0 | 2,483 |
1,879,113 | 2009-12-10T06:52:00.000 | 0 | 0 | 0 | 1 | python,enterprise | 1,880,411 | 5 | false | 1 | 0 | There is -- almost -- no usable "Business Case" for any technology choice.
"what about a large MNC that already has a lot invested in Java" Ask around. See if there's a business case for Java.
I doubt you'll find anything. Most companies drift into technology choices slowly.
There was no business case for COBOL -- it was the only game in town in the olden days.
There is rarely a business case for Java. What usually happens is that some visionary individual started building the first web site (probably in Perl). The "web thing" gained traction, and some vision individual started building web sites in Java. Eventually, the success of those small teams indicated to others that Java had advantages over COBOL.
Managers say the words "make a business case", but watch what they actually do. They listen to (1) their peers, (2) successful people.
To make the "business case" for Python, you have to be that visionary individual.
1) Use Python.
2) Be successful.
3) Share your successes.
4) Be prepared to explain that your success is due to your tools, not your personal level of genius and charisma. | 3 | 9 | 0 | This will not be a "programming" question but more technology / platform related question. I'm trying to figure out whether Python can be a suitable Java alternative for enterprise / web applications.
Which are the ideal cases where you would prefer to use Python instead of Java? How would a typical Python web application (databases/sessions/concurrency) perform as compared to a typical Java application? How do specific Python frameworks square up against Java based frameworks (Spring, SEAM, Grails etc.)?
For businesses, switching from the Java infrastructure to a Python infrastructure .. is it too hard/expensive/resource intensive/not viable? Also shed some light on the business case for providing a Python + Google AppEngine based solution to the end customer. Will it be cost effective in an typical scenario?
Sorry if I am asking too wide a question, I would have liked to keep it specific, but I need your help to evaluate Python as a whole from the perspectives of the programmers, service providing company and end business customer.
For an SME, a Python/GoogleAppEngine based technology stack is a clear scalable and affordable platform. But what about a large MNC that already has a lot invested in Java.
Thank you so much. I am researching this myself and will gladly share my conclusions here!
Thank you,
Srirangan | A business Case for Enterprise Python | 0 | 0 | 0 | 2,483 |
1,879,113 | 2009-12-10T06:52:00.000 | 1 | 0 | 0 | 1 | python,enterprise | 2,506,203 | 5 | false | 1 | 0 | The answer to your question is yes. Python can be well suited for Enterprise because python is a language which has raw power, flexible and can be glued with other programming languages. What enterprise really requires is a language which does everything and i feel python is already enterprise ready. If you want examples then i believe there can be no bigger example than google. Google is running python internally and externally for its business critical applications. The only problem with python is that it is not very well recognized by top MNC company and we as a python programmer find hard time convincing the management team. I guess you will face the same issue. But i guarantee you once you get your feet wet in python, you will understand its true power | 3 | 9 | 0 | This will not be a "programming" question but more technology / platform related question. I'm trying to figure out whether Python can be a suitable Java alternative for enterprise / web applications.
Which are the ideal cases where you would prefer to use Python instead of Java? How would a typical Python web application (databases/sessions/concurrency) perform as compared to a typical Java application? How do specific Python frameworks square up against Java based frameworks (Spring, SEAM, Grails etc.)?
For businesses, switching from the Java infrastructure to a Python infrastructure .. is it too hard/expensive/resource intensive/not viable? Also shed some light on the business case for providing a Python + Google AppEngine based solution to the end customer. Will it be cost effective in an typical scenario?
Sorry if I am asking too wide a question, I would have liked to keep it specific, but I need your help to evaluate Python as a whole from the perspectives of the programmers, service providing company and end business customer.
For an SME, a Python/GoogleAppEngine based technology stack is a clear scalable and affordable platform. But what about a large MNC that already has a lot invested in Java.
Thank you so much. I am researching this myself and will gladly share my conclusions here!
Thank you,
Srirangan | A business Case for Enterprise Python | 0.039979 | 0 | 0 | 2,483 |
1,879,872 | 2009-12-10T09:42:00.000 | 2 | 0 | 0 | 0 | jquery,python,ajax,django,django-templates | 1,879,991 | 3 | false | 1 | 0 | Since you're already using an AJAX post, why don't you return the data from that and insert it into the div? The view that accepts the post can return a rendered template or JSON, and your javascript can insert it in the callback. | 1 | 8 | 0 | I am building a chat application. So far I am adding chat messages with jquery $.post() and this works fine.
Now I need to retrieve the latest chat message from the table and append the list on the chat page.
I am new to Django, so please go slow.
So how do I get data from the chat table back to the chat page?
Thanks in advance! | DJANGO : Update div with AJAX | 0.132549 | 0 | 0 | 5,349 |
1,879,914 | 2009-12-10T09:50:00.000 | 1 | 0 | 0 | 0 | python,string,unpack | 1,880,427 | 5 | false | 0 | 0 | Is this the best way of doing this or is there a better way
It is likely that there will be strings with other formats which will require a different unpacking scheme
field1 = struct.unpack('B',data[0])
field2 = struct.unpack('B',data[1])
field3 = struct.unpack('!I',data[2:6])
field4 = struct.unpack('!H',data[6:8])
field5 = struct.unpack('!H',data[8:10])
field6 = struct.unpack('!H',data[10:12])
field7 = struct.unpack('!H',data[12:14])
field8 = struct.unpack('20s',data[14:38])
field9 = struct.unpack('!I',data[38:42])
field10 = struct.unpack('B',data[42])
Regards | 1 | 5 | 0 | What would the best way of unpacking a python string into fields
I have data received from a tcp socket, it is packed as follows, I believe it will be in a string from the socket recv function
It has the following format
uint8 - header
uint8 - length
uint32 - typeID
uint16 -param1
uint16 -param2
uint16 -param3
uint16 -param4
char[24] - name string
uint32 - checksum
uint8 - footer
(I also need to unpack other packets with different formats to the above)
How do I unpack these?
I am new to python, have done a bit of 'C'. If I was using 'C' I would probably use a structure, would this be the way to go with Python?
Regards
X | Decoding packed data into a structure | 0.039979 | 0 | 1 | 11,515 |
1,880,746 | 2009-12-10T12:42:00.000 | 0 | 0 | 0 | 1 | python,apache,upgrade,sys.path | 1,881,774 | 3 | false | 0 | 0 | On RH box Apache probably runs as root user. Login as root and see which version of python root sees.
HIH
..richie | 2 | 2 | 0 | On a Red hat box, I upgraded Python from 2.3 to 2.6.4 and changed the symlink to python so when I type in python the 2.6.4 interpreter comes up.
However my .py file works from the command-line, but not in the browser. It seemed like a sys.path issue so I opened the file in a browser and printed out sys.path.
Surprisingly, my sys.path is different when called from a browser than when called from a command-line. Because the paths are all referring to 2.3, I believe Apache is picking up Python 2.3 rather than the new 2.6.4 version I installed.
How do I make Apache use Python 2.6.4? | How to upgrade the version of Python used by Apache? | 0 | 0 | 0 | 2,824 |
1,880,746 | 2009-12-10T12:42:00.000 | 1 | 0 | 0 | 1 | python,apache,upgrade,sys.path | 1,882,006 | 3 | false | 0 | 0 | Apache isn't calling python directly, so the path is irrelevant. You will probably want to build yourself a new mod_wsgi to link against python 2.6.4. | 2 | 2 | 0 | On a Red hat box, I upgraded Python from 2.3 to 2.6.4 and changed the symlink to python so when I type in python the 2.6.4 interpreter comes up.
However my .py file works from the command-line, but not in the browser. It seemed like a sys.path issue so I opened the file in a browser and printed out sys.path.
Surprisingly, my sys.path is different when called from a browser than when called from a command-line. Because the paths are all referring to 2.3, I believe Apache is picking up Python 2.3 rather than the new 2.6.4 version I installed.
How do I make Apache use Python 2.6.4? | How to upgrade the version of Python used by Apache? | 0.066568 | 0 | 0 | 2,824 |
1,881,851 | 2009-12-10T15:41:00.000 | 0 | 0 | 0 | 0 | python,c | 1,881,867 | 7 | false | 0 | 0 | take a look at module struct ? | 1 | 1 | 1 | I have a python code computing a matrix, and I would like to use this matrix (or array, or list) from C code.
I wanted to pickle the matrix from the python code, and unpickle it from c code, but I could not find documentation or example on how to do this.
I found something about marshalling data, but nothing about unpickling from C.
Edit :
Commenters Peter H asked if I was working with numpy arrays. The answer is yes. | How to unpickle from C code | 0 | 0 | 0 | 1,690 |
1,883,098 | 2009-12-10T18:39:00.000 | 0 | 0 | 0 | 0 | python,django,excel | 1,937,261 | 4 | false | 1 | 0 | You need to use Excel to calculate the results? I mean, maybe you could run the Excel sheet from OpenOffice and use a pyUNO macro, which is somehow "native" python.
A different approach will be to create a macro to generate some more friendly code to python, if you want Excel to perform the calculation is easy you end up with a very slow process. | 1 | 2 | 0 | I have an Excel spreadsheet with calculations I would like to use in a Django web application. I do not need to present the spreadsheet as it appears in Excel. I only want to use the formulae embedded in it. What is the best way to do this? | Importing Excel sheets, including formulae, into Django | 0 | 1 | 0 | 1,592 |
1,883,118 | 2009-12-10T18:41:00.000 | 4 | 1 | 0 | 0 | python,portability | 1,883,501 | 7 | false | 0 | 0 | If you deal with binary file formats in Python, note that the struct and array modules uses machine dependent size and endianness. struct can be used portably by always using < or > in the format string. array can't. It will probably be portable for arrays of bytes, but the documentation makes no such guarantee. | 4 | 4 | 0 | I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.
Please post one gotcha (with its fix) per comment. | Big List Of Portability in Python | 0.113791 | 0 | 0 | 2,875 |
1,883,118 | 2009-12-10T18:41:00.000 | 2 | 1 | 0 | 0 | python,portability | 1,883,350 | 7 | false | 0 | 0 | Getting away from the syntax side of things, I think the biggest thing to watch out for is that typically when people think of python, they might not think of all the libraries it is composed of.
Many python packages depend on C libraries which may or may not be cross platform compatible. In addition, Python runs under Java through Jython, and .Net through IronPython. Unless libraries are written in pure python, they will not, in many cases, work on anything other than the C based version of python. | 4 | 4 | 0 | I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.
Please post one gotcha (with its fix) per comment. | Big List Of Portability in Python | 0.057081 | 0 | 0 | 2,875 |
1,883,118 | 2009-12-10T18:41:00.000 | 1 | 1 | 0 | 0 | python,portability | 1,883,137 | 7 | false | 0 | 0 | I'll start off:
Windows uses backslashes for path separators --> '\'
Unix uses forward slashes for path separators --> '/'
The os module comes with os.sep, which contains the path separator for the current platform that the script is being run on. Use os.sep instead of forward or back slashes. os.path.join will join two or more path components this way. | 4 | 4 | 0 | I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.
Please post one gotcha (with its fix) per comment. | Big List Of Portability in Python | 0.028564 | 0 | 0 | 2,875 |
1,883,118 | 2009-12-10T18:41:00.000 | 2 | 1 | 0 | 0 | python,portability | 1,883,817 | 7 | false | 0 | 0 | Some modules are not cross-platform. Two that come to mind are both curses (Linux) and msvcrt (Windows). The fix to this simple problem is simply not to use them but find an alternative instead. | 4 | 4 | 0 | I thought it would be a good idea to compile a list of things to watch out for when making a Python app portable. There are a lot of subtle 'gotchas' in portability that are only discovered through experience and thorough testing; there needs to be some sort of list addressing the more common ones.
Please post one gotcha (with its fix) per comment. | Big List Of Portability in Python | 0.057081 | 0 | 0 | 2,875 |
1,883,322 | 2009-12-10T19:21:00.000 | 9 | 0 | 0 | 0 | python,django,design-patterns,django-models,django-managers | 1,883,526 | 4 | false | 1 | 0 | I always place mine in managers.py. If you have a circular import issue remember that a) You can reference the model class for a manager at self.model, and b) You can do imports inside of functions. | 3 | 25 | 0 | This is a pretty simple django patterns question. My manager code usually lives in models.py, but what happens when models.py is really huge? Is there any other alternative pattern to letting your manager code live in models.py for maintainability and to avoid circular imports?
A question may be asked as to why models.py is so huge, but let's just assume it's size and breadth of utility is justified. | Where should django manager code live? | 1 | 0 | 0 | 4,377 |
1,883,322 | 2009-12-10T19:21:00.000 | 32 | 0 | 0 | 0 | python,django,design-patterns,django-models,django-managers | 1,883,460 | 4 | true | 1 | 0 | I prefer to keep my models in models.py and managers in managers.py (forms in forms.py) all within the same app. For more generic managers, I prefer to keep them in core.managers if they can be re-used for other apps. In some of our larger apps with models/modelname.py that will contains a manager and the model code which doesn't seem bad. | 3 | 25 | 0 | This is a pretty simple django patterns question. My manager code usually lives in models.py, but what happens when models.py is really huge? Is there any other alternative pattern to letting your manager code live in models.py for maintainability and to avoid circular imports?
A question may be asked as to why models.py is so huge, but let's just assume it's size and breadth of utility is justified. | Where should django manager code live? | 1.2 | 0 | 0 | 4,377 |
1,883,322 | 2009-12-10T19:21:00.000 | 4 | 0 | 0 | 0 | python,django,design-patterns,django-models,django-managers | 1,883,342 | 4 | false | 1 | 0 | What I did when building Django apps was to create a [modelname].py file with just the specific model code, manager code and sometimes form code and used an __init__.py file to import then all in the models directory. This helped me atleast in keeping it managable. | 3 | 25 | 0 | This is a pretty simple django patterns question. My manager code usually lives in models.py, but what happens when models.py is really huge? Is there any other alternative pattern to letting your manager code live in models.py for maintainability and to avoid circular imports?
A question may be asked as to why models.py is so huge, but let's just assume it's size and breadth of utility is justified. | Where should django manager code live? | 0.197375 | 0 | 0 | 4,377 |
1,883,455 | 2009-12-10T19:41:00.000 | 8 | 1 | 0 | 0 | java,python | 1,883,690 | 9 | false | 0 | 1 | Java and C# will be less of a step away from Python than would C or C++ because Java, C#, and Python all have automatic memory management. A good Java book is Thinking in Java by Bruce Eckel. It starts at an introductory level, but also has a lot of depth.
The big difference with the language coming from Python is the fact that all variables are typed. The other hard thing with Java has to do with the bewildering array of Java APIs out there. The fact that you are interested in Android is an advantage here. After becoming comfortable with the core language, I suggest you start learning the Android API and focus on becoming an Android expert. I think Android will be a growing market for a while.
Good luck! | 5 | 20 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | Learn Java from Python background | 1 | 0 | 0 | 18,209 |
1,883,455 | 2009-12-10T19:41:00.000 | 0 | 1 | 0 | 0 | java,python | 1,883,538 | 9 | false | 0 | 1 | I don't think you should use a special way to learn Java because you know Python. Just start with HelloWorld.java and move on step by step. Your basic skills in programming will help you. | 5 | 20 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | Learn Java from Python background | 0 | 0 | 0 | 18,209 |
1,883,455 | 2009-12-10T19:41:00.000 | 0 | 1 | 0 | 0 | java,python | 1,884,743 | 9 | false | 0 | 1 | I suppose one could ease his/her way into .NET and Java by starting with IronPython and Jython respectively. This will not teach you the new language syntax but open up respective libraries so you can explore what is "out there", learn development tools, build process etc. Syntax is by far the easiest to switch but the know-how and best practices in each language are not. | 5 | 20 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | Learn Java from Python background | 0 | 0 | 0 | 18,209 |
1,883,455 | 2009-12-10T19:41:00.000 | 0 | 1 | 0 | 0 | java,python | 1,883,705 | 9 | false | 0 | 1 | 1) It depends what you would do with an "hireable" language. For instance, if you were interested in programming web applications and distributed/client/server app, Java would be a good choice.
C# is maybe a bit less client / server oriented, and maybe more valuable for small non IT companies and for most retail software companies.
C and C++ are still great languages, but are more "system", embeded and "critical apps" oriented. And they are not suitable to be runned on differents mobile phones.
2) The best way to learn java, according to me, is firstable to learn the basics, then look for more specialized stuff like J2ME and Android software framework. | 5 | 20 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | Learn Java from Python background | 0 | 0 | 0 | 18,209 |
1,883,455 | 2009-12-10T19:41:00.000 | 9 | 1 | 0 | 0 | java,python | 1,883,585 | 9 | false | 0 | 1 | I would take a project you've implemented in Python and try converting it to Java. Since you already know basic programming fundamentals, it'll probably be easier if you take things you know how to do and figure out how you'd do the same sort of operations in Java (or whatever new language you want to learn).
In the end, the only way to learn to write code, is to write more code. | 5 | 20 | 0 | I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.
Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead? | Learn Java from Python background | 1 | 0 | 0 | 18,209 |
1,885,594 | 2009-12-11T03:19:00.000 | 6 | 0 | 0 | 0 | python,django,hosting,shared,vps | 1,885,629 | 6 | false | 1 | 0 | Django runs on GoogleAppEngine but php doesn't.
Your Django code will have to use Google's datastore models instead of Django's usual ORM, so there is some tie in to GAE - if you decide you want to host your own app later on it could be quite a lot of work.
If you go with a VPS obviously you can run Django and php together, but you'll need to choose a webserve, maybe a firewall, maybe load balancing later on.
Clicks per day isn't really useful, you need to know how many clicks per second you get at peak time.
Cheap hosting providers will provide less help than expensive ones.
Is one VPS going to be enough? What is the impact if it goes down? It's harder to do major upgrades if you only have one server.
With a VPS you need to back your data up somewhere. The hosting may do offsite backups for you, but it's a good idea to have some yourself too.
I don't know how easy it is to backup your data from GAE, but it's probably a good idea if the data is valuable. | 3 | 12 | 0 | I am new to web development and everything involved with it. Im finishing my website in django and i will soon have to find a hosting and deploy it. I heard there are vps or shared hosting types. So here are the questions:
1. How many visits/clicks per day make it worth choosing vps? shared?
2. How hard is it to tune and maintain a vps on your own if you're new to everything!
3. If i ask hosting providers to help me deploy my site - will they help? (shared, vps)
4. Is vps with 256mb memory much faster than shared hosting?
5. If i want to host many sites on one hosting - is vps more suitable for that?
6. Can i host php, django and other stuff on one hosting simultaniously?
7. Should i know something else to make a decision? | Django: vps or shared hosting? | 1 | 0 | 0 | 5,421 |
1,885,594 | 2009-12-11T03:19:00.000 | 3 | 0 | 0 | 0 | python,django,hosting,shared,vps | 1,885,597 | 6 | false | 1 | 0 | Should i know something else to make a decision?
Django (albeit a subset) runs on Google AppEngine:
free for starters and pay as you grow.
auto-scale
resilient (backups are "automatic" i.e. datastore)
The drawback of course is you only have Python and Java as options... | 3 | 12 | 0 | I am new to web development and everything involved with it. Im finishing my website in django and i will soon have to find a hosting and deploy it. I heard there are vps or shared hosting types. So here are the questions:
1. How many visits/clicks per day make it worth choosing vps? shared?
2. How hard is it to tune and maintain a vps on your own if you're new to everything!
3. If i ask hosting providers to help me deploy my site - will they help? (shared, vps)
4. Is vps with 256mb memory much faster than shared hosting?
5. If i want to host many sites on one hosting - is vps more suitable for that?
6. Can i host php, django and other stuff on one hosting simultaniously?
7. Should i know something else to make a decision? | Django: vps or shared hosting? | 0.099668 | 0 | 0 | 5,421 |
1,885,594 | 2009-12-11T03:19:00.000 | 7 | 0 | 0 | 0 | python,django,hosting,shared,vps | 1,886,390 | 6 | true | 1 | 0 | I've been using Webfaction for shared hosting of Django. The price is pretty decent, they have good forums, and have a nice web-based interface to help get you setup. Despite the web interface, it doesn't impede you from having full control over your site form the command line. You can host all sorts of things, from Django to Rails, to PHP, and mysql. For smaller sites, it works nicely. I'm not sure how the performance works under high load, but you can always start small and upgrade to a vps. I've never had direct contact with the support personel there, but the documentation seems good. I don't mean for this to sound like a plug, but it's been pretty good for shared hosting. If you have any questions about it, I'll be glad to answer. | 3 | 12 | 0 | I am new to web development and everything involved with it. Im finishing my website in django and i will soon have to find a hosting and deploy it. I heard there are vps or shared hosting types. So here are the questions:
1. How many visits/clicks per day make it worth choosing vps? shared?
2. How hard is it to tune and maintain a vps on your own if you're new to everything!
3. If i ask hosting providers to help me deploy my site - will they help? (shared, vps)
4. Is vps with 256mb memory much faster than shared hosting?
5. If i want to host many sites on one hosting - is vps more suitable for that?
6. Can i host php, django and other stuff on one hosting simultaniously?
7. Should i know something else to make a decision? | Django: vps or shared hosting? | 1.2 | 0 | 0 | 5,421 |
1,886,090 | 2009-12-11T06:00:00.000 | 12 | 0 | 1 | 0 | python,multithreading,python-multithreading,exit-code | 1,891,891 | 13 | false | 0 | 0 | If you were calling join() to wait for the thread to complete, you could simply attach the result to the Thread instance itself and then retrieve it from the main thread after the join() returns.
On the other hand, you don't tell us how you intend to discover that the thread is done and that the result is available. If you already have a way of doing that, it will probably point you (and us, if you were to tell us) to the best way of getting the results out. | 1 | 69 | 0 | How do I get a thread to return a tuple or any value of my choice back to the parent in Python? | Return value from thread | 1 | 0 | 0 | 97,583 |
1,886,192 | 2009-12-11T06:29:00.000 | 0 | 1 | 1 | 0 | python,pylons | 1,894,559 | 4 | false | 0 | 0 | You should check in development.ini. Most developers are smart enough to realize that if they want to run your application they need to make some tweaks. The development.ini will serve as a template. A file that has the database configured incorrectly is still useful since I can see that the system is trying to connect to the database and failing.
Later on you will be making files such as development.ini, staging.ini, and production.ini. This will help when you move environments. | 4 | 1 | 0 | I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.
I'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.
What do real-world Pylons applications do with this file? | Should Pylons' development.ini be checked in? | 0 | 0 | 0 | 358 |
1,886,192 | 2009-12-11T06:29:00.000 | 2 | 1 | 1 | 0 | python,pylons | 1,891,883 | 4 | false | 0 | 0 | On a team development, we make an effort to ensure everyone has a common development environment, or we make adjustments to things (like database URLs) to allow people on different environments (we do Mac, Windows, and Linux) to share all files.
And our Pylons development.ini files are committed to subversion, just like everything else. | 4 | 1 | 0 | I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.
I'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.
What do real-world Pylons applications do with this file? | Should Pylons' development.ini be checked in? | 0.099668 | 0 | 0 | 358 |
1,886,192 | 2009-12-11T06:29:00.000 | 2 | 1 | 1 | 0 | python,pylons | 1,886,486 | 4 | true | 0 | 0 | You could check it in as sample.ini for example so that everyone can copy to their own development.ini and modify as needed | 4 | 1 | 0 | I'm learning about Pylons and I've read a few tutorials, but none of them have addressed collaboration practices. Starting on a practice project. I'd like to keep my code in a revision-control system (Git, specifically) as if it were an open-source project with multiple developers, in order to practice that aspect of Pylons development as well.
I'm wondering what I should do with the development.ini file that was generated by Paster as part of my new application. On one hand, it contains lots of settings that other develpers wouldn't want to have to recreate by hand, so it seems like it ought to be stored in my Git repository so that other developers can access it. On the other hand, some of the settings, such as the database connection URL, are specific to one person's development environment and wouldn't make sense to share with others.
What do real-world Pylons applications do with this file? | Should Pylons' development.ini be checked in? | 1.2 | 0 | 0 | 358 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.