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,921,771
2009-12-17T13:26:00.000
1
0
1
0
python,django
1,923,475
10
false
1
0
I split almost all views in my apps into a views folder (with an init.py of course). I do not, however, import all of the subviews in the init.py like some of the answers have suggested. It seems to work just fine.
4
172
0
My views.py has become too big and it's hard to find the right view. How do I split it in several files and then import it? Does it involve any speed loss? Can I do the same with models.py?
Split views.py in several files
0.019997
0
0
42,864
1,921,771
2009-12-17T13:26:00.000
1
0
1
0
python,django
32,090,920
10
false
1
0
Suppose if you have a file named: password_generator.py then inside views.py add: from password_generator import * Then you can call that module's function from views.py.
4
172
0
My views.py has become too big and it's hard to find the right view. How do I split it in several files and then import it? Does it involve any speed loss? Can I do the same with models.py?
Split views.py in several files
0.019997
0
0
42,864
1,922,254
2009-12-17T14:47:00.000
2
0
0
1
python,linux,fork,kill,pty
11,804,899
3
false
0
0
Pseudotermials are necessary for some applications that really expect a terminal. An interactive shell is one of these examples but there are many other. The pty.fork option is not there as another os.fork but as a specific API to use a pseudoterminal.
2
14
0
I'm uncertain whether to use pty.fork() or os.fork() when spawning external background processes from my app. (Such as chess engines) I want the spawned processes to die if the parent is killed, as with spawning apps in a terminal. What are the ups and downs between the two forks?
Python: when to use pty.fork() versus os.fork()
0.132549
0
0
5,805
1,922,254
2009-12-17T14:47:00.000
11
0
0
1
python,linux,fork,kill,pty
1,923,358
3
true
0
0
The child process created with os.fork() inherits stdin/stdout/stderr from parent process, while the child created with pty.fork() is connected to new pseudo terminal. You need the later when you write a program like xterm: pty.fork() in parent process returns a descriptor to control terminal of child process, so you can visually represent data from it and translate user actions into terminal input sequences. Update: From pty(7) man page: A process that expects to be connected to a terminal, can open the slave end of a pseudo-terminal and then be driven by a program that has opened the master end. Anything that is written on the master end is provided to the process on the slave end as though it was input typed on a terminal. For example, writing the interrupt character (usually control-C) to the master device would cause an interrupt signal (SIGINT) to be generated for the foreground process group that is connected to the slave. Conversely, anything that is written to the slave end of the pseudo-terminal can be read by the process that is connected to the master end.
2
14
0
I'm uncertain whether to use pty.fork() or os.fork() when spawning external background processes from my app. (Such as chess engines) I want the spawned processes to die if the parent is killed, as with spawning apps in a terminal. What are the ups and downs between the two forks?
Python: when to use pty.fork() versus os.fork()
1.2
0
0
5,805
1,922,623
2009-12-17T15:42:00.000
0
0
0
0
python,mysql
1,922,710
3
false
0
0
With no code, I can only make a guess: try not closing the cursor until you are done with that connection. I think that calling cursor() again after calling cursor.close() will just give you a reference to the same cursor, which can no longer be used for queries. I am not 100% sure if that is the intended behavior, but I haven't seen any MySQLDB examples of cursors being opened and closed within the same connection.
2
0
0
I am using MySQLdb module of python on FC11 machine. Here, i have an issue. I have the following implementation for one of our requirement: connect to mysqldb and get DB handle,open a cursor, execute a delete statement,commit and then close the cursor. Again using the DB handle above, iam performing a "select" statement one some different table using the cursor way as described above. I was able to delete few records using Step1, but step2 select is not working. It simply gives no records for step2 though there are some records available under DB. But, when i comment step1 and execute step2, i could see that step2 works fine. Why this is so? Though there are records, why the above sequence is failing to do so? Any ideas would be appreciated. Thanks!
MYSQLDB python module
0
1
0
626
1,922,623
2009-12-17T15:42:00.000
0
0
0
0
python,mysql
1,924,766
3
false
0
0
It sounds as though the first cursor is being returned back to the second step.
2
0
0
I am using MySQLdb module of python on FC11 machine. Here, i have an issue. I have the following implementation for one of our requirement: connect to mysqldb and get DB handle,open a cursor, execute a delete statement,commit and then close the cursor. Again using the DB handle above, iam performing a "select" statement one some different table using the cursor way as described above. I was able to delete few records using Step1, but step2 select is not working. It simply gives no records for step2 though there are some records available under DB. But, when i comment step1 and execute step2, i could see that step2 works fine. Why this is so? Though there are records, why the above sequence is failing to do so? Any ideas would be appreciated. Thanks!
MYSQLDB python module
0
1
0
626
1,923,054
2009-12-17T16:46:00.000
15
0
1
0
python,string,integer
1,923,085
8
false
0
0
This sounds a lot like homework, so I'll give you a couple of pieces and let you fill in the rest. To access a single character of string s, its s[x] where x is an integer index. Indices start at 0. To get the integer value of a character it is ord(c) where c is the character. To cast an integer back to a character it is chr(x). Be careful of letters close to the end of the alphabet! Edit: if you have trouble coming up with what to do for Y and Z, leave a comment and I'll give a hint.
2
16
0
I want to convert a single character of a string into an integer, add 2 to it, and then convert it back to a string. Hence, A becomes C, K becomes M, etc.
Convert string / character to integer in python
1
0
0
75,600
1,923,054
2009-12-17T16:46:00.000
1
0
1
0
python,string,integer
1,923,074
8
false
0
0
Try ord(), should do the trick :)
2
16
0
I want to convert a single character of a string into an integer, add 2 to it, and then convert it back to a string. Hence, A becomes C, K becomes M, etc.
Convert string / character to integer in python
0.024995
0
0
75,600
1,924,646
2009-12-17T21:14:00.000
0
0
0
1
python,linux,usb,dbus
1,924,715
3
false
0
0
what about using dmesg output to find out the device name (sdc1 etc...) use it right after dbus tells you something is was inserted in USB. you could do tail dmesg for example
1
2
0
I'm working on a utility that will auto mount an inserted USB stick on linux. I have tied into D-Bus to receive notification of when a device is inserted, and that works great. However, I need to determine which device in /dev is mapped to the inserted USB stick. I am getting the D-Bus notification and then scanning the USB system with pyUSB ( 0.4 ). I filter for USB_MASS_STORAGE_DEVICE classes, and I can see the device that's been added or removed. I need to mount this device so I can query it for available space and report that to our app so we can determine if enough free space exists so we can write our data. I'm using python for this task. I'm not sure what our target distro will be, only that it will be at least 2.6 edit: My question is: How do I determine which device in /dev maps to the buss-device number I get from pyUSB.
Linux USB Mapping Question
0
0
0
2,055
1,925,246
2009-12-17T23:09:00.000
7
0
1
0
python,variables
1,925,252
3
false
0
0
In Python, you don't declare variables as having any type. You just assign to them. A single variable can be assigned objects of different types in succession, if you wanted to do so. "self" is not the type but a naming convention used to refer to the current object, like "this" in Java / C++ (except in Python you could call it anything you wanted).
1
10
0
i am trying to read a tree structure file in python. I created a class to hold the tree objects. One of the members should hold the parent object. Since the parentObject member is of the same type as the class itself, I need to declare this as an empty variable of type "self". How do I do that in python? Thank you very much for your help.
declaring empty class member in python
1
0
0
27,575
1,925,360
2009-12-17T23:39:00.000
-1
0
0
0
java,python,c,rule-engine
1,925,588
10
false
0
0
In effect, Python is a rules engine. "The engine will be used as way to automate a house, like turning the light off when somebody leaves a room etc." You need sensors and controllers. You write your "rules" as ordinary Python objects. Your main "program" collects events from your sensors and sends events to your controllers. If you can read from your sensors via ordinary USB, that's even better. The marine industry uses a couple of closely related standards like NMEA 0183 and NMEA 2000 for specifying the traffic on the bus from sensor to controller. You don't need Yet Another Rules Language. You have Python.
3
6
0
I am looking for a rules engine in C or Python, but if you know a rules engine that is implemented in another language I would be glad to know about it. The engine will be used as way to automate a house, like turning the light off when somebody leaves a room etc. So no "office" rules there (aka do you rules in Excel or such). I have looked into Jess and Drools which are in Java and do a perfect job. I would like to know of others and possibly using less memory than Java does. I have heard of RuleCore in Python but couldn't really find any documentation on it (version 1.0 is available at SourceForge but it looks like they are selling v. 2.0). EDIT: By rules engine (inference engine), I mean an implementation of RETE or equivalent.
Rules Engine in C or Python
-0.019997
0
0
12,216
1,925,360
2009-12-17T23:39:00.000
0
0
0
0
java,python,c,rule-engine
1,936,813
10
false
0
0
Rulecore is indeed written partly in Python. But it does not really matter. You as an user would not see any of these implementation details anyway. The rules are purely declarative and defined using XML. The XML is sent into ruleCore CEP Server as events using a web services or JMS or other protocols.
3
6
0
I am looking for a rules engine in C or Python, but if you know a rules engine that is implemented in another language I would be glad to know about it. The engine will be used as way to automate a house, like turning the light off when somebody leaves a room etc. So no "office" rules there (aka do you rules in Excel or such). I have looked into Jess and Drools which are in Java and do a perfect job. I would like to know of others and possibly using less memory than Java does. I have heard of RuleCore in Python but couldn't really find any documentation on it (version 1.0 is available at SourceForge but it looks like they are selling v. 2.0). EDIT: By rules engine (inference engine), I mean an implementation of RETE or equivalent.
Rules Engine in C or Python
0
0
0
12,216
1,925,360
2009-12-17T23:39:00.000
0
0
0
0
java,python,c,rule-engine
2,138,573
10
false
0
0
I know ruleCore has some parts written in Python. But the API uses XML and ActiveMQ or WebServices so it is on a higher abstraction level.
3
6
0
I am looking for a rules engine in C or Python, but if you know a rules engine that is implemented in another language I would be glad to know about it. The engine will be used as way to automate a house, like turning the light off when somebody leaves a room etc. So no "office" rules there (aka do you rules in Excel or such). I have looked into Jess and Drools which are in Java and do a perfect job. I would like to know of others and possibly using less memory than Java does. I have heard of RuleCore in Python but couldn't really find any documentation on it (version 1.0 is available at SourceForge but it looks like they are selling v. 2.0). EDIT: By rules engine (inference engine), I mean an implementation of RETE or equivalent.
Rules Engine in C or Python
0
0
0
12,216
1,925,487
2009-12-18T00:12:00.000
1
1
0
0
python,django
1,925,617
3
false
0
0
It's always going to be converted to a string anyway, so why do you care what's being passed in? If you use "%s" % number or even just str(number), then it doesn't matter whether number is a string or an int.
1
2
0
I have built an XML-RPC interface in Python and I need to enforce some stricter typing. For example, passing string '10' instead of int 10. I can clean this up with some type casting and a little exception handling, but I am wondering if there is any other way of forcing type integrity such as something XML-RPC specific, a decorator, or something else.
XML-RPC method parameter data typing in Python
0.066568
0
1
220
1,925,552
2009-12-18T00:29:00.000
0
0
1
1
python,windows,registry,cygwin
2,568,441
3
false
0
0
You can use the HKEY_LOCAL_MACHINE\SOFTWARE\Cygwin\setup\rootdir value for Cygwin 1.7
1
3
0
I'm writing a cross-platform python script that needs to know if and where Cygwin is installed if the platform is NT. Right now I'm just using a naive check for the existence of the default install path 'C:\Cygwin'. I would like to be able to determine the installation path programmatically. The Windows registry doesn't appear to be an option since Cygwin no longer stores it's mount points in the registry. Because of this is it even possible to programmatically get a Cygwin installation path?
Get Cygwin installation path in a Python script
0
0
0
1,626
1,925,718
2009-12-18T01:19:00.000
2
0
1
0
python,multiprocessing
1,926,926
3
true
0
0
I have not used multiprocessing itself, but the problems presented are similar to experience I've had in two other domains: distributed systems, and object databases. Python object identity can be a blessing and a curse! As for general gotchas, it helps if the application you are refactoring can acknowledge that tasks are being handled asynchronously. If not, you will generally end up managing locks, and much of the performance you could have gained by using separate processes will be lost to waiting on those locks. I will also suggest that you spend the time to build some scaffolding for debugging across processes. Truly asynchronous processes tend to be doing much more than the mind can hold and verify -- or at least my mind! For the specific case outlined, I would manage object identity at the process border when items queued and returned. When sending a task to be processed, annotate the task with an id(), and stash the task instance in a dictionary using the id() as the key. When the task is updated/completed, retrieve the exact task back by id() from the dictionary, and apply the newly updated state to it. Now the exact task, and therefore its identity, will be maintained.
1
7
0
We're considering re-factoring a large application with a complex GUI which is isolated in a decoupled fashion from the back-end, to use the new (Python 2.6) multiprocessing module. The GUI/backend interface uses Queues with Message objects exchanged in both directions. One thing I've just concluded (tentatively, but feel free to confirm it) is that "object identity" would not be preserved across the multiprocessing interface. Currently when our GUI publishes a Message to the back-end, it expects to get the same Message back with a result attached as an attribute. It uses object identity (if received_msg is message_i_sent:) to identify returning messages in some cases... and that seems likely not to work with multiprocessing. This question is to ask what "gotchas" like this you have seen in actual use or can imagine one would encounter in naively using the multiprocessing module, especially in refactoring an existing single-process application. Please specify whether your answer is based on actual experience. Bonus points for providing a usable workaround for the problem. Edit: Although my intent with this question was to gather descriptions of problems in general, I think I made two mistakes: I made it community wiki from the start (which probably makes many people ignore it, as they won't get reputation points), and I included a too-specific example which -- while I appreciate the answers -- probably made many people miss the request for general responses. I'll probably re-word and re-ask this in a new question. For now I'm accepting one answer as best merely to close the question as far as it pertains to the specific example I included. Thanks to those who did answer!
What problems will one see in using Python multiprocessing naively?
1.2
0
0
1,382
1,925,750
2009-12-18T01:30:00.000
2
0
1
1
python,eclipse,ide,pydev
1,925,758
3
false
0
0
Open a new text file and start writing code?
2
0
0
I need major help getting started! I managed to create a new project, and add python.exe as the interpreter. But when the project is created it's blank. How do I start programming? Ugh.
Python programming on Eclipse with Pydev
0.132549
0
0
2,673
1,925,750
2009-12-18T01:30:00.000
4
0
1
1
python,eclipse,ide,pydev
1,925,760
3
true
0
0
Create PyDev project Add "Source Folder" under the project Add "Modules" to the "Source Folder" Get coding :-)
2
0
0
I need major help getting started! I managed to create a new project, and add python.exe as the interpreter. But when the project is created it's blank. How do I start programming? Ugh.
Python programming on Eclipse with Pydev
1.2
0
0
2,673
1,925,852
2009-12-18T02:07:00.000
1
0
1
0
python,eclipse,syntax,pydev
1,925,861
3
false
0
0
In Python, indentation is really important... Have you check your indentation? Also, lose the ; (don't need it). correct: print("hello") or print "hello" (for < 3.0) not correct: ...print("hello") or print "hello" (for < 3.0) where . denotes spaces.
2
13
0
My code: print "Hello World!" I even tried adding a semicolon behind, but everytime I save and run (as Python run) it says: File "E:\Software\Eclipse\Workspace\Python1\src\main.py", line 1 print "Hello World!"; SyntaxError: invalid syntax I have no idea why.
Eclipse (with Pydev) keeps throwing SyntaxError
0.066568
0
0
6,290
1,925,852
2009-12-18T02:07:00.000
35
0
1
0
python,eclipse,syntax,pydev
1,925,868
3
true
0
0
What version of Python are you using? Python 2.X has print as a keyword, but Python 3.X only has print() as a function - you'd need to use print("Hello, World!") instead.
2
13
0
My code: print "Hello World!" I even tried adding a semicolon behind, but everytime I save and run (as Python run) it says: File "E:\Software\Eclipse\Workspace\Python1\src\main.py", line 1 print "Hello World!"; SyntaxError: invalid syntax I have no idea why.
Eclipse (with Pydev) keeps throwing SyntaxError
1.2
0
0
6,290
1,925,974
2009-12-18T02:49:00.000
0
0
0
1
python,sockets,ip-address
1,926,048
2
false
0
0
quick answer - socket.getpeername() (provided that socket is a socket object, not a module) (playing around in python/ipython/idle/... interactive shell is very helpful) .. or if I read you question carefully, maybe socket.getsockname() :)
1
0
0
I need some code to get the address of the socket i just created (to filter out packets originating from localhost on a multicast network) this: socket.gethostbyname(socket.gethostname()) works on mac but it returns only the localhost IP in linux... is there anyway to get the LAN address thanks --edit-- is it possible to get it from the socket settings itself, like, the OS has to select a LAN IP to send on... can i play on getsockopt(... IP_MULTICAST_IF...) i dont know exactly how to use this though...? --- edit --- SOLVED! send_sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_LOOP, 0) putting this on the send socket eliminated packet echos to the host sending them, which eliminates the need for the program to know which IP the OS has selected to send. yay!
How to get the LAN IP that a socket is sending (linux)
0
0
1
626
1,926,019
2009-12-18T03:02:00.000
2
0
1
0
python
1,926,050
8
false
0
0
The best way to learn how to do something useful is come up with something useful you want to do. Make sure it's not way out of your league, then do research to accomplish it. That's how a lot of programmers learn languages.
4
0
0
I heard that Python is easy and powerful, but I don't know if I'm on the right track to learn it. I learn from online tutorials, I know basic maths calculation and printing strings, but how long will it take to develop something useful? I don't really know the exact uses of Python, though.
Python programming general questions
0.049958
0
0
624
1,926,019
2009-12-18T03:02:00.000
1
0
1
0
python
1,926,040
8
false
0
0
What other programming background do you have? What programming interests do you have -- web apps, numerical / scientific computations, games, ...? Python is good at many different things, for both beginners and experienced programmers, but the most fruitful approach(es) to it do depend on what you already know, and what really interests you!-)
4
0
0
I heard that Python is easy and powerful, but I don't know if I'm on the right track to learn it. I learn from online tutorials, I know basic maths calculation and printing strings, but how long will it take to develop something useful? I don't really know the exact uses of Python, though.
Python programming general questions
0.024995
0
0
624
1,926,019
2009-12-18T03:02:00.000
0
0
1
0
python
1,926,110
8
false
0
0
Bram who invented bittorrent with python says python is good for writing protocols in addition to aforementioned webapps, games and general purpose. Compared to Java python solves same problem in less code and less ways in longer development and VM time where Java has more ways solve same problem in more code and faster VM and faster development time.
4
0
0
I heard that Python is easy and powerful, but I don't know if I'm on the right track to learn it. I learn from online tutorials, I know basic maths calculation and printing strings, but how long will it take to develop something useful? I don't really know the exact uses of Python, though.
Python programming general questions
0
0
0
624
1,926,019
2009-12-18T03:02:00.000
0
0
1
0
python
1,926,200
8
false
0
0
Making a comparison between Python, and other languages would not help, as there is always somebody who would find a reason to prefer one language instead of another. If you want a scripting language that is powerful, but that it is easier to read than perl, that doesn't have a curly bracket syntax, and that allows you to learn something about object oriented programming, then Python is the language for you.
4
0
0
I heard that Python is easy and powerful, but I don't know if I'm on the right track to learn it. I learn from online tutorials, I know basic maths calculation and printing strings, but how long will it take to develop something useful? I don't really know the exact uses of Python, though.
Python programming general questions
0
0
0
624
1,927,475
2009-12-18T10:44:00.000
0
0
0
0
python,user-interface,tkinter
1,927,946
2
true
0
1
No, there isn't an option. You need to adjust your padding so that the scrollbar doesn't extend all the way to the bottom of the window. Perhaps the easiest way is to add a statusbar that extends across the bottom of the window.
2
1
0
I have a scrollbar widget that ALWAYS hides the last 15 px under the resize button, is there an option to stop this happening on mac or a padding "under" the widget option?\ thanks!
Python - Tkinter - Padding woes
1.2
0
0
204
1,927,475
2009-12-18T10:44:00.000
0
0
0
0
python,user-interface,tkinter
1,927,968
2
false
0
1
Or, you could also try switching to the place() layout manager.
2
1
0
I have a scrollbar widget that ALWAYS hides the last 15 px under the resize button, is there an option to stop this happening on mac or a padding "under" the widget option?\ thanks!
Python - Tkinter - Padding woes
0
0
0
204
1,928,087
2009-12-18T13:04:00.000
0
0
0
0
python,django,unicode
1,931,067
3
false
1
0
As Dominic has said, the generated HTML source code is correct (these are your Japanese characters translated into HTML entities), but we're not sure, if you see the same code rendered in the page (in this case, you have probably set content-type to "text/plain" instead of "text/html" - do you use render_to_response() or HttpResponse() in the corresponding view.py method?), or your Japanese is rendered correctly but you just don't like the entities in the source code. Since we don't know your Django settings and how do you render and return the page, it's difficult to provide you the solution.
1
0
0
I have both, django and mysql set to work with UTF-8. My base.html set utf-8 in head. row on my db : +----+--------+------------------------------------------------------------------+-----------------------------+-----------------------------+---------------------+ | id | psn_id | name | publisher | developer | release_date | +----+--------+------------------------------------------------------------------+-----------------------------+-----------------------------+---------------------+ | 1 | 10945- | まいにちいっしょ | Sony Computer Entertainment | Sony Computer Entertainment | 2006-11-11 00:00:00 | +----+--------+------------------------------------------------------------------+-----------------------------+-----------------------------+---------------------+ the source code generated looks like : &#12414;&#12356;&#12395;&#12385;&#12356;&#12387;&#12375;&#12423; and this is wat is displayed :/ why they are not showing the chars the way in this database?
django + mysql + UTF-8 - Chars are not displayed
0
1
0
312
1,929,018
2009-12-18T15:55:00.000
1
0
0
1
python,user-interface,glade
1,929,138
3
false
0
0
glade is only a program to build gui with gtk so when you ask for a glade object maybe you should ask for gtk widget and in this case textbuffer and textview chould be a solution or maybe treeview and liststore. subprocess.Popen has stdout and stderr arguments that can accept a file-like object. you can create an adapter that writes to the textbuffer or add items in the liststore
1
2
0
I'm writing a python application that runs several subprocesses using subprocess.Popen objects. I have a glade GUI and want to display the output of these commands (running in subprocess.Popen) in the gui in real time. Can anyone suggest a way to do this? What glade object do I need to use and how to redirect the output?
Python GUI (glade) to display output of shell process
0.066568
0
0
3,524
1,929,681
2009-12-18T17:39:00.000
1
1
0
1
python,http,mod-wsgi,tornado
1,929,711
5
false
1
0
You might consider a queuing system with AJAX notification methods. Whenever there is a request for your expensive resource, and that resource needs to be generated, add that request to the queue (if it's not already there). That queuing operation should return an ID of an object that you can query to get its status. Next you have to write a background service that spins up worker threads. These workers simply dequeue the request, generate the data, then saves the data's location in the request object. The webpage can make AJAX calls to your server to find out the progress of the generation and to give a link to the file once it's available. This is how LARGE media sites work - those that have to deal with video in particular. It might be overkill for your MP3 work however. Alternatively, look into running a couple machines to distribute the load. Your threads on Apache will still block, but atleast you won't consume resources on the web server.
3
5
0
We have a web service which serves small, arbitrary segments of a fixed inventory of larger MP3 files. The MP3 files are generated on-the-fly by a python application. The model is, make a GET request to a URL specifying which segments you want, get an audio/mpeg stream in response. This is an expensive process. We're using Nginx as the front-end request handler. Nginx takes care of caching responses for common requests. We initially tried using Tornado on the back-end to handle requests from Nginx. As you would expect, the blocking MP3 operation kept Tornado from doing its thing (asynchronous I/O). So, we went multithreaded, which solved the blocking problem, and performed quite well. However, it introduced a subtle race condition (under real world load) that we haven't been able to diagnose or reproduce yet. The race condition corrupts our MP3 output. So we decided to set our application up as a simple WSGI handler behind Apache/mod_wsgi (still w/ Nginx up front). This eliminates the blocking issue and the race condition, but creates a cascading load (i.e. Apache creates too many processses) on the server under real world conditions. We're working on tuning Apache/mod_wsgi right now, but still at a trial-and-error phase. (Update: we've switched back to Tornado. See below.) Finally, the question: are we missing anything? Is there a better way to serve CPU-expensive resources over HTTP? Update: Thanks to Graham's informed article, I'm pretty sure this is an Apache tuning problem. In the mean-time, we've gone back to using Tornado and are trying to resolve the data-corruption issue. For those who were so quick to throw more iron at the problem, Tornado and a bit of multi-threading (despite the data integrity problem introduced by threading) handles the load acceptably on a small (single core) Amazon EC2 instance.
Is there a better way to serve the results of an expensive, blocking python process over HTTP?
0.039979
0
0
495
1,929,681
2009-12-18T17:39:00.000
0
1
0
1
python,http,mod-wsgi,tornado
1,929,738
5
false
1
0
It looks like you are doing things right -- just lacking CPU power: can you determine what is the CPU loading in the process of generating these MP3? I think the next thing you have to do there is to add more hardware to render the MP3's on other machines. Or that or find a way to deliver pre-rendered MP3 (maybe you can cahce some of your media?) BTW, scaling for the web was the theme of a Keynote lecture by Jacob Kaplan-Moss on PyCon Brasil this year, and it is far from being a closed problem. The stack of technologies one needs to handle is quite impressible - (I could not find an online copy o f the presentation, though - -sorry for that)
3
5
0
We have a web service which serves small, arbitrary segments of a fixed inventory of larger MP3 files. The MP3 files are generated on-the-fly by a python application. The model is, make a GET request to a URL specifying which segments you want, get an audio/mpeg stream in response. This is an expensive process. We're using Nginx as the front-end request handler. Nginx takes care of caching responses for common requests. We initially tried using Tornado on the back-end to handle requests from Nginx. As you would expect, the blocking MP3 operation kept Tornado from doing its thing (asynchronous I/O). So, we went multithreaded, which solved the blocking problem, and performed quite well. However, it introduced a subtle race condition (under real world load) that we haven't been able to diagnose or reproduce yet. The race condition corrupts our MP3 output. So we decided to set our application up as a simple WSGI handler behind Apache/mod_wsgi (still w/ Nginx up front). This eliminates the blocking issue and the race condition, but creates a cascading load (i.e. Apache creates too many processses) on the server under real world conditions. We're working on tuning Apache/mod_wsgi right now, but still at a trial-and-error phase. (Update: we've switched back to Tornado. See below.) Finally, the question: are we missing anything? Is there a better way to serve CPU-expensive resources over HTTP? Update: Thanks to Graham's informed article, I'm pretty sure this is an Apache tuning problem. In the mean-time, we've gone back to using Tornado and are trying to resolve the data-corruption issue. For those who were so quick to throw more iron at the problem, Tornado and a bit of multi-threading (despite the data integrity problem introduced by threading) handles the load acceptably on a small (single core) Amazon EC2 instance.
Is there a better way to serve the results of an expensive, blocking python process over HTTP?
0
0
0
495
1,929,681
2009-12-18T17:39:00.000
1
1
0
1
python,http,mod-wsgi,tornado
1,937,378
5
false
1
0
Please define "cascading load", as it has no common meaning. Your most likely problem is going to be if you're running too many Apache processes. For a load like this, make sure you're using the prefork mpm, and make sure you're limiting yourself to an appropriate number of processes (no less than one per CPU, no more than two).
3
5
0
We have a web service which serves small, arbitrary segments of a fixed inventory of larger MP3 files. The MP3 files are generated on-the-fly by a python application. The model is, make a GET request to a URL specifying which segments you want, get an audio/mpeg stream in response. This is an expensive process. We're using Nginx as the front-end request handler. Nginx takes care of caching responses for common requests. We initially tried using Tornado on the back-end to handle requests from Nginx. As you would expect, the blocking MP3 operation kept Tornado from doing its thing (asynchronous I/O). So, we went multithreaded, which solved the blocking problem, and performed quite well. However, it introduced a subtle race condition (under real world load) that we haven't been able to diagnose or reproduce yet. The race condition corrupts our MP3 output. So we decided to set our application up as a simple WSGI handler behind Apache/mod_wsgi (still w/ Nginx up front). This eliminates the blocking issue and the race condition, but creates a cascading load (i.e. Apache creates too many processses) on the server under real world conditions. We're working on tuning Apache/mod_wsgi right now, but still at a trial-and-error phase. (Update: we've switched back to Tornado. See below.) Finally, the question: are we missing anything? Is there a better way to serve CPU-expensive resources over HTTP? Update: Thanks to Graham's informed article, I'm pretty sure this is an Apache tuning problem. In the mean-time, we've gone back to using Tornado and are trying to resolve the data-corruption issue. For those who were so quick to throw more iron at the problem, Tornado and a bit of multi-threading (despite the data integrity problem introduced by threading) handles the load acceptably on a small (single core) Amazon EC2 instance.
Is there a better way to serve the results of an expensive, blocking python process over HTTP?
0.039979
0
0
495
1,930,896
2009-12-18T21:55:00.000
1
0
1
0
python,class
1,931,003
4
false
0
0
I cannot use the following datatypes in defining my class: set, frozenset and dictionaries. It looks like you are going to use list. You can use list's remove method and handle exceptions in appropriate way.
1
0
0
I am defining a class where only a set of integers is used. I cannot use the following datatypes in defining my class: set, frozenset and dictionaries. i need help defining: remove(self,i): Integer i is removed from the set. An exception is raised if i is not in self. discard(self, i): integer i is removed from the set. No exception is raised if i is not in self
Python: Defining a class with only Integers Defined
0.049958
0
0
219
1,930,900
2009-12-18T21:56:00.000
0
0
1
1
python,setuptools,distutils
1,940,353
4
false
0
0
I would subclass distutils.core.Distribution and pass it with distutils.core.setup(distclass=CustomDistribution) - this gives you access to the command-line parameters in the same way that the normal setup has them, and you can do things like adjusting the extensions list in the CustomDistribution.__init__ method. But I agree with dalke, the way of distutils is full of pain...
4
6
0
I have a Python project with mutiple extension modules written in C, which talk to a third-party library. However, depending on the user's environment and options some modules should not be built, and some compiler flags should be enabled/disabled. The problem is that I have to build the list of extension modules before I call setup(), and ideally I'd like to use a distutils.Command subclass to handle the user options. Right now I have a few options: Require a "python setup.py configure" command be run before building the modules, store the information in a pickle file, and use it to generate the extensions list next time the script runs. This is how my project currently works, which seems quite silly. Manually scrape options out of sys.argv and use them to build the list. This is not a long-term solution because I will eventually want to run some scripts to check the settings before building. Subclass build_ext from distutils, do my configuration in the beginning of the run() method (possibly also using options sent via (2)) and directly modify self.distribution.ext_modules before building. I'm afraid this may confuse setuptools, however, as it may assume the list of extension modules is fixed when setup() is called. It also means that when setup() is called with a command other than build_ext the list of extension modules is empty. Is there a preferred way to do this?
Configuring extension modules with distutils/setuptools
0
0
0
2,010
1,930,900
2009-12-18T21:56:00.000
0
0
1
1
python,setuptools,distutils
6,883,355
4
false
0
0
The config command is designed to be subclassed and used by projects with requirements like yours.
4
6
0
I have a Python project with mutiple extension modules written in C, which talk to a third-party library. However, depending on the user's environment and options some modules should not be built, and some compiler flags should be enabled/disabled. The problem is that I have to build the list of extension modules before I call setup(), and ideally I'd like to use a distutils.Command subclass to handle the user options. Right now I have a few options: Require a "python setup.py configure" command be run before building the modules, store the information in a pickle file, and use it to generate the extensions list next time the script runs. This is how my project currently works, which seems quite silly. Manually scrape options out of sys.argv and use them to build the list. This is not a long-term solution because I will eventually want to run some scripts to check the settings before building. Subclass build_ext from distutils, do my configuration in the beginning of the run() method (possibly also using options sent via (2)) and directly modify self.distribution.ext_modules before building. I'm afraid this may confuse setuptools, however, as it may assume the list of extension modules is fixed when setup() is called. It also means that when setup() is called with a command other than build_ext the list of extension modules is empty. Is there a preferred way to do this?
Configuring extension modules with distutils/setuptools
0
0
0
2,010
1,930,900
2009-12-18T21:56:00.000
1
0
1
1
python,setuptools,distutils
2,376,647
4
false
0
0
Is there a preferred way to do this? From my experience working with other people's modules, I can say there is certainly not consensus on the right way to do this. I have tried and rejected subclassing bits of distutils -- I found it fragile and difficult to get working across different Python versions and different systems. For our code, after trying the types of things you are considering, I have settled on doing detection and configuration right in setup.py before the main call to setup(). This is admittedly a bit ugly, but it means that someone trying compile your stuff has one place to figure out e.g. why the include path is wrong. (And they certainly don't need to be experts on distutils internals).
4
6
0
I have a Python project with mutiple extension modules written in C, which talk to a third-party library. However, depending on the user's environment and options some modules should not be built, and some compiler flags should be enabled/disabled. The problem is that I have to build the list of extension modules before I call setup(), and ideally I'd like to use a distutils.Command subclass to handle the user options. Right now I have a few options: Require a "python setup.py configure" command be run before building the modules, store the information in a pickle file, and use it to generate the extensions list next time the script runs. This is how my project currently works, which seems quite silly. Manually scrape options out of sys.argv and use them to build the list. This is not a long-term solution because I will eventually want to run some scripts to check the settings before building. Subclass build_ext from distutils, do my configuration in the beginning of the run() method (possibly also using options sent via (2)) and directly modify self.distribution.ext_modules before building. I'm afraid this may confuse setuptools, however, as it may assume the list of extension modules is fixed when setup() is called. It also means that when setup() is called with a command other than build_ext the list of extension modules is empty. Is there a preferred way to do this?
Configuring extension modules with distutils/setuptools
0.049958
0
0
2,010
1,930,900
2009-12-18T21:56:00.000
0
0
1
1
python,setuptools,distutils
1,931,958
4
false
0
0
My own experience with changing distutils has been weak and shaky, so all I can offer are pointers. Take a look at numpy. That has an entire submodule (numpy.distutils) with ways to work with (or work around) distutils. Otherwise, ask the distutils mailing list.
4
6
0
I have a Python project with mutiple extension modules written in C, which talk to a third-party library. However, depending on the user's environment and options some modules should not be built, and some compiler flags should be enabled/disabled. The problem is that I have to build the list of extension modules before I call setup(), and ideally I'd like to use a distutils.Command subclass to handle the user options. Right now I have a few options: Require a "python setup.py configure" command be run before building the modules, store the information in a pickle file, and use it to generate the extensions list next time the script runs. This is how my project currently works, which seems quite silly. Manually scrape options out of sys.argv and use them to build the list. This is not a long-term solution because I will eventually want to run some scripts to check the settings before building. Subclass build_ext from distutils, do my configuration in the beginning of the run() method (possibly also using options sent via (2)) and directly modify self.distribution.ext_modules before building. I'm afraid this may confuse setuptools, however, as it may assume the list of extension modules is fixed when setup() is called. It also means that when setup() is called with a command other than build_ext the list of extension modules is empty. Is there a preferred way to do this?
Configuring extension modules with distutils/setuptools
0
0
0
2,010
1,931,781
2009-12-19T02:53:00.000
2
0
1
0
python
1,931,795
2
false
0
0
Its define tab size 4 spaces to text editors like vi
2
2
0
Here are the top few lines (all comments) from a python application. What do the first two comment lines indicate? Are they special markers for another app? # -*- Mode: Python -*- # vi:si:et:sw=4:sts=4:ts=4 # # Istanbul - A desktop recorder # Copyright (C) 2005 Zaheer Abbas Merali (zaheerabbas at merali dot org) # Portions Copyright (C) 2004,2005 Fluendo, S.L. (www.fluendo.com). # All rights reserved.
What is the use of strings like "-*- Mode: Python -*-" found at the top of some python files?
0.197375
0
0
700
1,931,781
2009-12-19T02:53:00.000
4
0
1
0
python
1,931,807
2
true
0
0
The first line is an emacs thing (although it may also be a vi thing). It basically tells it that it should use python-mode to read the file. You'll usually see this if the file ends in an extension other than .py. As mentioned, the second line deals with spacings.
2
2
0
Here are the top few lines (all comments) from a python application. What do the first two comment lines indicate? Are they special markers for another app? # -*- Mode: Python -*- # vi:si:et:sw=4:sts=4:ts=4 # # Istanbul - A desktop recorder # Copyright (C) 2005 Zaheer Abbas Merali (zaheerabbas at merali dot org) # Portions Copyright (C) 2004,2005 Fluendo, S.L. (www.fluendo.com). # All rights reserved.
What is the use of strings like "-*- Mode: Python -*-" found at the top of some python files?
1.2
0
0
700
1,932,200
2009-12-19T06:43:00.000
0
0
0
0
python,cryptography,aes,itar
1,932,436
2
false
0
0
i have often seen people rely on an external package for the cryptographic part: you can package your software without the cryptographic package, and tell your user that they have to download and install the cryptographic part from the original publisher. this is effectively moving the responsibility for the cryptographic part from you to your user.
1
1
0
I'm developing a python GUI application and plan on calling external program packaged with my program to do some encryption. I noticed from sites like OpenSSL that talk about export laws regarding cryptography software. If I can't package binary forms of the cryptography software with my application, how can I work around this to still be able to encrypt the output of my program?
packaging cryptography software and distributing
0
0
0
421
1,933,000
2009-12-19T14:10:00.000
5
0
0
1
python,weblogic,jython,wlst
2,258,690
2
true
1
0
I eventually found the answer. I am posting here for reference. Out of the 5 mentioned tasks, all can be performed with an offline wlst script. All of them have to be performed on the node where AdminServer is supposed to live. Now, for updating the domain information on the second node, there is an nmEnroll command in wlst which hast to be performed online So, to summarize, Execute an offline wlst script to perform all the 5 tasks mentioned in the question. This has to be done on the node (physical computer) where we want our AdminServer to run. Start nodemanager on all the nodes to be used in the cluster, Start the AdminServer on the node where we executed the domain creation script. On all the other nodes execute the script which looks like following. connect('user','password','t3://adminhost:adminport') nmEnroll('path_to_the_domain_dir')
2
3
0
I want to create a cluster with 2 managed servers on 2 different physical machines. I have following tasks to be performed (please correct me if I miss something) Domain creation. Set admin server properties and create AdminServer under SSL Create logical machines for the physical ones Create managed servers create cluster with the managed servers I have following questions. Which of the above mentioned tasks can be done offline if any ? Which of the above mentioned tasks must also be performed on the 2nd physical machine ?
Weblogic domain and cluster creation with WLST
1.2
0
0
3,100
1,933,000
2009-12-19T14:10:00.000
0
0
0
1
python,weblogic,jython,wlst
32,569,619
2
false
1
0
There are two steps missed after the step 1, you need to copy the configuration from the machine where the AdminServer is running run to the other machine in the cluster using the command pack content in Weblogic installation: 1.1 On the machine where the AdminServer is running run ./pack.shdomain=/home/oracle/config/domains/my_domain -template=/home/oracle/my_domain.jar -template_name=remote_managed -managed=true 1.2 Go on the other machines and copy the jar file produced in the previous step and run ./unpack.sh -domain=/home/oracle/config/domains/my_domain -template=/home/oracle/my_domain.jar SAML_IDP_FromScript Now you have copied all the file you need to start the NodeManager and the ManagedServers on the other machines.
2
3
0
I want to create a cluster with 2 managed servers on 2 different physical machines. I have following tasks to be performed (please correct me if I miss something) Domain creation. Set admin server properties and create AdminServer under SSL Create logical machines for the physical ones Create managed servers create cluster with the managed servers I have following questions. Which of the above mentioned tasks can be done offline if any ? Which of the above mentioned tasks must also be performed on the 2nd physical machine ?
Weblogic domain and cluster creation with WLST
0
0
0
3,100
1,933,451
2009-12-19T16:58:00.000
5
0
1
0
python,python-exec
1,933,462
11
false
0
0
Allowing these function in a context where they might run user input is a security issue, and sanitizers that actually work are hard to write.
5
40
0
I've seen this multiple times in multiple places, but never have found a satisfying explanation as to why this should be the case. So, hopefully, one will be presented here. Why should we (at least, generally) not use exec() and eval()? EDIT: I see that people are assuming that this question pertains to web servers – it doesn't. I can see why an unsanitized string being passed to exec could be bad. Is it bad in non-web-applications?
Why should exec() and eval() be avoided?
0.090659
0
0
16,115
1,933,451
2009-12-19T16:58:00.000
3
0
1
0
python,python-exec
1,933,473
11
false
0
0
Reason #1: One security flaw (ie. programming errors... and we can't claim those can be avoided) and you've just given the user access to the shell of the server.
5
40
0
I've seen this multiple times in multiple places, but never have found a satisfying explanation as to why this should be the case. So, hopefully, one will be presented here. Why should we (at least, generally) not use exec() and eval()? EDIT: I see that people are assuming that this question pertains to web servers – it doesn't. I can see why an unsanitized string being passed to exec could be bad. Is it bad in non-web-applications?
Why should exec() and eval() be avoided?
0.054491
0
0
16,115
1,933,451
2009-12-19T16:58:00.000
5
0
1
0
python,python-exec
1,933,468
11
false
0
0
Same reason you shouldn't login as root: it's too easy to shoot yourself in the foot.
5
40
0
I've seen this multiple times in multiple places, but never have found a satisfying explanation as to why this should be the case. So, hopefully, one will be presented here. Why should we (at least, generally) not use exec() and eval()? EDIT: I see that people are assuming that this question pertains to web servers – it doesn't. I can see why an unsanitized string being passed to exec could be bad. Is it bad in non-web-applications?
Why should exec() and eval() be avoided?
0.090659
0
0
16,115
1,933,451
2009-12-19T16:58:00.000
13
0
1
0
python,python-exec
1,933,555
11
false
0
0
eval() and exec() can promote lazy programming. More importantly it indicates the code being executed may not have been written at design time therefore not tested. In other words, how do you test dynamically generated code? Especially across browsers.
5
40
0
I've seen this multiple times in multiple places, but never have found a satisfying explanation as to why this should be the case. So, hopefully, one will be presented here. Why should we (at least, generally) not use exec() and eval()? EDIT: I see that people are assuming that this question pertains to web servers – it doesn't. I can see why an unsanitized string being passed to exec could be bad. Is it bad in non-web-applications?
Why should exec() and eval() be avoided?
1
0
0
16,115
1,933,451
2009-12-19T16:58:00.000
17
0
1
0
python,python-exec
1,933,723
11
false
0
0
When you need exec and eval, yeah, you really do need them. But, the majority of the in-the-wild usage of these functions (and the similar constructs in other scripting languages) is totally inappropriate and could be replaced with other simpler constructs that are faster, more secure and have fewer bugs. You can, with proper escaping and filtering, use exec and eval safely. But the kind of coder who goes straight for exec/eval to solve a problem (because they don't understand the other facilities the language makes available) isn't the kind of coder that's going to be able to get that processing right; it's going to be someone who doesn't understand string processing and just blindly concatenates substrings, resulting in fragile insecure code. It's the Lure Of Strings. Throwing string segments around looks easy and fools naïve coders into thinking they understand what they're doing. But experience shows the results are almost always wrong in some corner (or not-so-corner) case, often with potential security implications. This is why we say eval is evil. This is why we say regex-for-HTML is evil. This is why we push SQL parameterisation. Yes, you can get all these things right with manual string processing... but unless you already understand why we say those things, chances are you won't.
5
40
0
I've seen this multiple times in multiple places, but never have found a satisfying explanation as to why this should be the case. So, hopefully, one will be presented here. Why should we (at least, generally) not use exec() and eval()? EDIT: I see that people are assuming that this question pertains to web servers – it doesn't. I can see why an unsanitized string being passed to exec could be bad. Is it bad in non-web-applications?
Why should exec() and eval() be avoided?
1
0
0
16,115
1,933,621
2009-12-19T17:44:00.000
4
1
1
0
python,deep-copy
1,933,642
1
false
0
0
You basically need to override the existing __deepcopy__ method, which means temporarily setting the object's class to something different -- whether that's acceptable essentially depends on whether the "__deepcopy__ override" needs to affect only one, "top-level" object (in which case the kludge's probably OK), or if there are many objects of that class in the graph you're copying, in which case it's quite a mess. Which case obtains?
1
1
0
I have an object which defines a __deepcopy__ method. I would like a function that will deepcopy it not by the method given by it, but in the default way that objects of the class object are copied. How could I do that? I think I could try to code it but there are probably many "gotchas" I won't be thinking of. The reason I'm doing it is because I have an object class which implements a __deepcopy__ method, and that method checks for some condition, and in some cases it will deepcopy the object in a certain way, and in other cases it will deepcopy in the default object way.
Deepcopy a simple Python object
0.664037
0
0
807
1,933,784
2009-12-19T18:45:00.000
-1
0
1
0
python
1,933,816
4
false
0
0
You can clone the class via inheritance. Otherwise you are just passing around a reference to the class itself (rather than a reference to an instance of the class). Why would you want to duplicate the class anyway? It's obvious why you would want to create multiple instances of the class, but I can't fathom why you would want a duplicate class. Also, you could simply copy and paste with a new class name...
1
7
0
I have a class A and i want a class B with exactly the same capabilities. I cannot or do not want to inherit from B, such as doing class B(A):pass Still i want B to be identical to A, yet have a different i: id(A) != id(B) Watch out, i am not talking about instances but classes to be cloned.
How do you clone a class in Python?
-0.049958
0
0
5,551
1,934,088
2009-12-19T20:46:00.000
6
0
0
0
python,proxy,screen-scraping,web-crawler,squid
1,934,198
3
true
0
0
Make your crawler have a list of proxies and with each HTTP request let it use the next proxy from the list in a round robin fashion. However, this will prevent you from using HTTP/1.1 persistent connections. Modifying the proxy list will eventually result in using a new or not using a proxy. Or have several connections open in parallel, one to each proxy, and distribute your crawling requests to each of the open connections. Dynamics may be implemented by having the connetor registering itself with the request dispatcher.
1
10
0
I've got a python web crawler and I want to distribute the download requests among many different proxy servers, probably running squid (though I'm open to alternatives). For example, it could work in a round-robin fashion, where request1 goes to proxy1, request2 to proxy2, and eventually looping back around. Any idea how to set this up? To make it harder, I'd also like to be able to dynamically change the list of available proxies, bring some down, and add others. If it matters, IP addresses are assigned dynamically. Thanks :)
Rotating Proxies for web scraping
1.2
0
1
16,640
1,934,914
2009-12-20T05:03:00.000
0
0
0
1
python,django,google-app-engine
2,988,728
8
false
1
0
I am still very new to Google App engine development, but the interfaces Django provides do appear much nicer than the default. The benefits will depend on what you are using to run Django on the app engine. The Google App Engine Helper for Django allows you to use the full power of the Google App Engine with some Django functionality on the side. Django non-rel attempts to provide as much of Django's power as possible, but running on the app-engine for possible extra scalability. In particular, it includes Django models (one of Django's core features), but this is a leaky abstraction due to the differences between relational databases and bigtable. There will most likely be tradeoffs in functionality and efficiency, as well as an increased number of bugs and quirks. Of course, this might be worth it in circumstances like those described in the question, but otherwise would strongly recommend using the helper at the start as then you have the option of moving towards either pure app-engine or Django non-rel later. Also, if you do switch to Django non-rel, your increased knowledge of how app engine works will be useful if the Django abstraction ever breaks - certainly much more useful than knowledge of the quirks/workarounds for Django non-rel if you swap the other way.
5
89
0
When researching Google App Engine (GAE), it's clear that using Django is wildly popular for developing in Python on GAE. I've been scouring the web to find information on the costs and benefits of using Django, to find out why it's so popular. While I've been able to find a wide variety of sources on how to run Django on GAE and the various methods of doing so, I haven't found any comparative analysis on why Django is preferable to using the webapp framework provided by Google. To be clear, it's immediately apparent why using Django on GAE is useful for developers with an existing skillset in Django (a majority of Python web developers, no doubt) or existing code in Django (where using GAE is more of a porting exercise). My team, however, is evaluating GAE for use on an all-new project and our existing experience is with TurboGears, not Django. It's been quite difficult to determine why Django is beneficial to a development team when the BigTable libraries have replaced Django's ORM, sessions and authentication are necessarily changed, and Django's templating (if desirable) is available without using the entire Django stack. Finally, it's clear that using Django does have the advantage of providing an "exit strategy" if we later wanted to move away from GAE and need a platform to target for the exodus. I'd be extremely appreciative for help in pointing out why using Django is better than using webapp on GAE. I'm also completely inexperienced with Django, so elaboration on smaller features and/or conveniences that work on GAE are also valuable to me.
Why use Django on Google App Engine?
0
0
0
25,088
1,934,914
2009-12-20T05:03:00.000
3
0
0
1
python,django,google-app-engine
1,934,918
8
false
1
0
I have experience using Django and not GAE. From my experiences with Django it was a very simplistic setup and the deployment process was incredibly easy in terms of web projects. Granted I had to learn Python to really get a good hold on things, but at the end of the day I would use it again on a project. This was almost 2 years ago before it reached 1.0 so I my knowledge is a bit outdated. If you are worried about changing platforms, then this would be a better choice I suppose.
5
89
0
When researching Google App Engine (GAE), it's clear that using Django is wildly popular for developing in Python on GAE. I've been scouring the web to find information on the costs and benefits of using Django, to find out why it's so popular. While I've been able to find a wide variety of sources on how to run Django on GAE and the various methods of doing so, I haven't found any comparative analysis on why Django is preferable to using the webapp framework provided by Google. To be clear, it's immediately apparent why using Django on GAE is useful for developers with an existing skillset in Django (a majority of Python web developers, no doubt) or existing code in Django (where using GAE is more of a porting exercise). My team, however, is evaluating GAE for use on an all-new project and our existing experience is with TurboGears, not Django. It's been quite difficult to determine why Django is beneficial to a development team when the BigTable libraries have replaced Django's ORM, sessions and authentication are necessarily changed, and Django's templating (if desirable) is available without using the entire Django stack. Finally, it's clear that using Django does have the advantage of providing an "exit strategy" if we later wanted to move away from GAE and need a platform to target for the exodus. I'd be extremely appreciative for help in pointing out why using Django is better than using webapp on GAE. I'm also completely inexperienced with Django, so elaboration on smaller features and/or conveniences that work on GAE are also valuable to me.
Why use Django on Google App Engine?
0.07486
0
0
25,088
1,934,914
2009-12-20T05:03:00.000
0
0
0
1
python,django,google-app-engine
1,942,826
8
false
1
0
If you decide to run you app outside of GAE, you can still use Django. You won't really have that much luck with the GAE webapp
5
89
0
When researching Google App Engine (GAE), it's clear that using Django is wildly popular for developing in Python on GAE. I've been scouring the web to find information on the costs and benefits of using Django, to find out why it's so popular. While I've been able to find a wide variety of sources on how to run Django on GAE and the various methods of doing so, I haven't found any comparative analysis on why Django is preferable to using the webapp framework provided by Google. To be clear, it's immediately apparent why using Django on GAE is useful for developers with an existing skillset in Django (a majority of Python web developers, no doubt) or existing code in Django (where using GAE is more of a porting exercise). My team, however, is evaluating GAE for use on an all-new project and our existing experience is with TurboGears, not Django. It's been quite difficult to determine why Django is beneficial to a development team when the BigTable libraries have replaced Django's ORM, sessions and authentication are necessarily changed, and Django's templating (if desirable) is available without using the entire Django stack. Finally, it's clear that using Django does have the advantage of providing an "exit strategy" if we later wanted to move away from GAE and need a platform to target for the exodus. I'd be extremely appreciative for help in pointing out why using Django is better than using webapp on GAE. I'm also completely inexperienced with Django, so elaboration on smaller features and/or conveniences that work on GAE are also valuable to me.
Why use Django on Google App Engine?
0
0
0
25,088
1,934,914
2009-12-20T05:03:00.000
51
0
0
1
python,django,google-app-engine
1,934,925
8
false
1
0
Django probably isn't the right choice for you, if you're sure that GAE is right for you. The strengths of the two technologies don't align very well - you completely lose a lot of Django's wonderful orm on GAE, and if you do use it, you write code that isn't really directly suitable to bigtable and the way GAE works. The thing about GAE is that it gets the great scalability by forcing you to write code that scales easily from the ground up. You just can't do a number of things that scale poorly (of course, you can still write poorly scaling code, but you avoid some pitfalls). The tradeoff is that you really end up coding around the framework, if you use something like Django which is designed for a different environment. If you see yourself ever leaving GAE for any reason, becoming invested in the infrastructure there is a problem for you. Coding for bigtable means that it will be harder to move to a different architecture (though the apache project is working to solve this for you with the HBase component of the Hadoop project). It would still be a lot of work to transition off of GAE. What's the driving motivator behind using GAE, besides being a Google product, and a cool buzzword? Is there a reason that scaling using something like mediatemple's offering is unlikely to work well for you? Are you sure that the ways that GAE scales are right for your application? How does the cost compare to dedicated servers, if you're expecting to get to that performance realm? Can you solve your problem well using the tools GAE provides, as compared to a more traditional load-balanced server setup? All this said, unless you absolutely positively need the borderline-ridiculous scaling that GAE offers, I'd personally suggest not letting that particular service structure your choice of framework. I like Django, so I'd say you should use it, but not on GAE. Edit (June 2010): As an update to this comment sometime later: Google has announced sql-like capabilitys for GAE that aren't free, but will let you easily do things like run SQL-style commands to generate reports on your data. Additionally, there are upcoming changes to the GAE query language which will allow complex queries in a far easier fashion. Look at the videos from Google I/O 2010. Furthermore, there is work being done during the Summer of Code 2010 project which should bring no-sql support to django core, and by extension, make working with GAE significantly easier. GAE is becoming more attractive as a hosting platform. Edit (August 2011): And Google just raised the cost to most users of the platform significantly by changing the pricing structure. The lockin problem has gotten better (if your application is big enough you can deploy the apache alternatives), but for most applications, running servers or VPS deployments is cheaper. Very few people really have bigdata problems. "Oh my startup might scale someday" isn't a bigdata problem. Build stuff now and get it out the door using the standard tools.
5
89
0
When researching Google App Engine (GAE), it's clear that using Django is wildly popular for developing in Python on GAE. I've been scouring the web to find information on the costs and benefits of using Django, to find out why it's so popular. While I've been able to find a wide variety of sources on how to run Django on GAE and the various methods of doing so, I haven't found any comparative analysis on why Django is preferable to using the webapp framework provided by Google. To be clear, it's immediately apparent why using Django on GAE is useful for developers with an existing skillset in Django (a majority of Python web developers, no doubt) or existing code in Django (where using GAE is more of a porting exercise). My team, however, is evaluating GAE for use on an all-new project and our existing experience is with TurboGears, not Django. It's been quite difficult to determine why Django is beneficial to a development team when the BigTable libraries have replaced Django's ORM, sessions and authentication are necessarily changed, and Django's templating (if desirable) is available without using the entire Django stack. Finally, it's clear that using Django does have the advantage of providing an "exit strategy" if we later wanted to move away from GAE and need a platform to target for the exodus. I'd be extremely appreciative for help in pointing out why using Django is better than using webapp on GAE. I'm also completely inexperienced with Django, so elaboration on smaller features and/or conveniences that work on GAE are also valuable to me.
Why use Django on Google App Engine?
1
0
0
25,088
1,934,914
2009-12-20T05:03:00.000
0
0
0
1
python,django,google-app-engine
1,935,061
8
false
1
0
I cannot answer the question but you may want to look into web2py. It is similar to Django in many respects but its database abstraction layer works on GAE and supports most of the GAE functionality (not all but we try to catch up). In this way if GAE works for you great, if it does not, you can move your code to a different db (SQLite, MySQL, PostgreSQL, Oracle, MSSQL, FireBird, DB2, Informix, Ingres, and - soon - Sybase and MongoDB).
5
89
0
When researching Google App Engine (GAE), it's clear that using Django is wildly popular for developing in Python on GAE. I've been scouring the web to find information on the costs and benefits of using Django, to find out why it's so popular. While I've been able to find a wide variety of sources on how to run Django on GAE and the various methods of doing so, I haven't found any comparative analysis on why Django is preferable to using the webapp framework provided by Google. To be clear, it's immediately apparent why using Django on GAE is useful for developers with an existing skillset in Django (a majority of Python web developers, no doubt) or existing code in Django (where using GAE is more of a porting exercise). My team, however, is evaluating GAE for use on an all-new project and our existing experience is with TurboGears, not Django. It's been quite difficult to determine why Django is beneficial to a development team when the BigTable libraries have replaced Django's ORM, sessions and authentication are necessarily changed, and Django's templating (if desirable) is available without using the entire Django stack. Finally, it's clear that using Django does have the advantage of providing an "exit strategy" if we later wanted to move away from GAE and need a platform to target for the exodus. I'd be extremely appreciative for help in pointing out why using Django is better than using webapp on GAE. I'm also completely inexperienced with Django, so elaboration on smaller features and/or conveniences that work on GAE are also valuable to me.
Why use Django on Google App Engine?
0
0
0
25,088
1,935,290
2009-12-20T08:52:00.000
3
0
1
1
python,macos,module-search-path
1,935,323
4
true
0
0
I think by default /Library/Python/2.5/site-packages/ is part of your search path. This directory is usually used for third party libraries.
1
1
0
I'm trying to use pywn, a python library for using WordNet. I've played about with python a little under Windows, but am completely new at MacOS X stuff. I'm running under MacOS 10.5.8, so my default Python interpreter is 2.5.1 The pywn instructions say: "Put each of the .py files somewhere in your python search path." Where is the python search path defined under the default python installation in MacOS X? If I've put the pywn files in /Users/nick/programming/pywn, what is the best way of adding this to the search path? Is this the best place to put the files?
how do I add a python module on MacOS X?
1.2
0
0
28,430
1,935,636
2009-12-20T12:04:00.000
1
0
0
0
javascript,python
1,935,664
1
true
1
0
You can't pass a variable directly, as JavaScript is running on the client (browser), and Python is running on the server. You could make a XHR (AJAX) request from JavaScript to the server which would then return your values back to JS (JSON could be used here). Or you could put a hidden field to your markup that would have the value in it's "value" attribute. You could then read that with JavaScript. ps: your question really isn't related to pyfacebook but Python (or any other server side technology) in general and that has been covered here many many times.
1
0
0
I'm using pyfacebook on the backend and javascript on the client side. Now if I want to pass a variable to the javascript from pyfacebook. how would I go about doing that, any ideas?
pyfacebook and javascript query
1.2
0
0
66
1,936,080
2009-12-20T15:06:00.000
2
0
0
0
python,django
1,936,102
4
false
1
0
I think Eclipse+Pydev Plugin is a good choice!!
1
3
0
I'm not sure but I believe that Python is -next to Objective-C- somewhat natural to Mac OSX and the Xcode IDE. I might be wrong. So is it a good idea to use Xcode for Django / Python web development when I'm already a bit familiar with Xcode? Actually I only do iPhone dev with it, but now I need a website and I stumbled over Django / Python. I don't want to "fall back" to PHP again, because just everyone and his dog does that already. Want to give Django / Python a try ;)
Can I do Django & Python web development using Xcode 3.2?
0.099668
0
0
6,512
1,936,085
2009-12-20T15:07:00.000
1
1
1
0
php,python
1,936,148
3
false
0
0
One main difference is, that code formatting (indentation) influences your codes behaviour in Python. PHP is not interested in how you format your code. Furthermore PHP may be able to produce applications outside of webservers and CLIs but is definitely aimed at those two environments while Python is more "all purpose".
2
4
0
I know PHP a little. But Python is totally new for me. I only know it's something "similar", right? Or wrong? What are the differences I should know?
What are the major differences between Python and PHP?
0.066568
0
0
26,274
1,936,085
2009-12-20T15:07:00.000
16
1
1
0
php,python
1,936,138
3
false
0
0
PHP is a language that's made for the web. You can make GTK and CLI applications with PHP, but it's mainly used for websites. Python is used for a lot of stuff like websites, webservers, game frameworks, desktop and CLI application, IDEs and a lot more. There's also a huge difference in the syntax. PHP has a syntax that's like C with curly braces for loops and whitespace is ignored. Python doesn't have curly braces, instead the level of indention of blocks of code are important. Both languages are easy to learn. It just depends on what you want to do.
2
4
0
I know PHP a little. But Python is totally new for me. I only know it's something "similar", right? Or wrong? What are the differences I should know?
What are the major differences between Python and PHP?
1
0
0
26,274
1,936,190
2009-12-20T15:57:00.000
3
0
1
0
python
1,936,380
15
false
0
0
As others have mentioned, you are correct, no curly braces in Python. Also, you do not have no end or endif or endfor or anything like that (as in pascal or ruby). All code blocks are indentation based.
4
61
0
I was reading that Python does all it's "code blocks" by indentation, rather than with curly braces. Is that right? So functions, if's and stuff like that all appear without surrounding their block with curly braces?
Is it true that I can't use curly braces in Python?
0.039979
0
0
75,574
1,936,190
2009-12-20T15:57:00.000
2
0
1
0
python
15,169,048
15
false
0
0
Yes, code blocks in Python are defined by their indentation. The creators of Python were very interested in self-documenting code. They included indentation in the syntax as a way of innately enforcing good formatting practice. I programmed in Python for a few years and became quite fond of its code structure because it really is easier. Have you ever left out a closing curly brace in a large program and spent hours trying to find it? Not a problem in Python. When I left that job and had to start using PHP, I really missed the Python syntax.
4
61
0
I was reading that Python does all it's "code blocks" by indentation, rather than with curly braces. Is that right? So functions, if's and stuff like that all appear without surrounding their block with curly braces?
Is it true that I can't use curly braces in Python?
0.02666
0
0
75,574
1,936,190
2009-12-20T15:57:00.000
1
0
1
0
python
55,368,706
15
false
0
0
I will give some thoughts about this question. Admittedly at first I also thought it is strange to write code without curly braces. But after using Python for many years, I think it is a good design. First, do we really need curly braces? I mean, as a human. If you are allowed to use curly braces in Python, won't you use indentation anymore? Of course, you will still use indentation! Because you want to write readable code, and indentation is one of the key points. Second, when do we really need curly braces? As far as I think, we only strictly need curly braces when we need to minify our source code files. Like minified js files. But will you use Python in a situation that even the size of source code is sensitive? Also as far as I think, you won't. So finally, I think curly braces are somehow like ;. It is just a historical issue, with or without it, we will always use indentation in Python.
4
61
0
I was reading that Python does all it's "code blocks" by indentation, rather than with curly braces. Is that right? So functions, if's and stuff like that all appear without surrounding their block with curly braces?
Is it true that I can't use curly braces in Python?
0.013333
0
0
75,574
1,936,190
2009-12-20T15:57:00.000
12
0
1
0
python
1,936,195
15
false
0
0
Yup :) And there's (usually) a difference between 4 spaces and a tab, so make sure you standardize the usage ..
4
61
0
I was reading that Python does all it's "code blocks" by indentation, rather than with curly braces. Is that right? So functions, if's and stuff like that all appear without surrounding their block with curly braces?
Is it true that I can't use curly braces in Python?
1
0
0
75,574
1,937,286
2009-12-20T22:18:00.000
2
0
0
0
python
1,937,342
5
false
0
0
Is it worth starting with Python 3, or is it still too poorly supported with ports of modules from previous versions? depends on which modules do you want to use. twisted is a "swiss knife" for the network programming and could be a choice for your project but unfortunately it does not support python3 yet. Are there any great advantages in using Python 3 for my particular project? Would I be better off looking at using other languages instead, such as Erlang? only you can answer your question because only you know your knowledge. Using python3 instead of python2 you get all the advantages of new features the python3 brings with him and the disadvantage that non all libraries support python3 at the moment. note that python2.6 should implements most (if not all) of the features of python3 while it should be compatible with python2.5 but i did not investigated a lot in this way. both python and erlang are candidates for your needs, use what you know best and what you like most. Is there any great advantage in using a relational database within a game server? you get all the advantages and disadvantage of having a ACID storage system.
2
2
0
I'd like to get busy with a winter programming project and am contemplating writing an online word game (with a server load of up to, say, 500 users simultaneously). I would prefer it to be platform independent. I intend to use Python, which I have some experience with. For user data storage, after previous experience with MySQL, a flat database design would be preferable but not essential. Okay, now the questions: Is it worth starting with Python 3, or is it still too poorly supported with ports of modules from previous versions? Are there any great advantages in using Python 3 for my particular project? Would I be better off looking at using other languages instead, such as Erlang? Is there any great advantage in using a relational database within a game server? Are there any open source game servers' source code out there that are worthy of study before starting?
Word game server in Python, design pros and cons?
0.07983
1
0
1,430
1,937,286
2009-12-20T22:18:00.000
1
0
0
0
python
1,937,370
5
false
0
0
Related to your database choice, I'd seriously look at using Postgres instead of MySQL. In my experiance with the two Postgres has shown to be faster on most write operations while MySQL is slightly faster on the reads. However, MySQL also has many issues some of which are: Live backups are difficult at best, and impossible at worse, mostly you have to take the db offline or let it lock during the backups. In the event of having to kill the server forcefully, either by kill -9, or due to power outage, postgres generally has better resilience to table corruption. Full support for ACID compliance, and other relational db features that support for, again imho and experiance, are weak or lacking in MySQL. You can use a library such as SQLAlchemy to abstract away the db access though. This would let you test against both to see which you prefer dealing with. As far as the language choice. If you go with Python: More librarys support Python 2.x rather than Python 3.x at this time, so I'd likely stick to 2.x. Beware multi-threading gotchas with Python's GIL. Utilizing Twisted can get around this. If you go with Erlang: Erlang's syntax and idioms can be very foreign to someone who's never used it. If well written it not only scales, it SCALES. Erlang has it's own highly concurrent web server named Yaws. Erlang also has it's own highly scalable DBMS named Mnesia (Note it's not relational). So I guess your choices could be really boiled down to how much you're willing to learn to do this project.
2
2
0
I'd like to get busy with a winter programming project and am contemplating writing an online word game (with a server load of up to, say, 500 users simultaneously). I would prefer it to be platform independent. I intend to use Python, which I have some experience with. For user data storage, after previous experience with MySQL, a flat database design would be preferable but not essential. Okay, now the questions: Is it worth starting with Python 3, or is it still too poorly supported with ports of modules from previous versions? Are there any great advantages in using Python 3 for my particular project? Would I be better off looking at using other languages instead, such as Erlang? Is there any great advantage in using a relational database within a game server? Are there any open source game servers' source code out there that are worthy of study before starting?
Word game server in Python, design pros and cons?
0.039979
1
0
1,430
1,937,622
2009-12-21T00:26:00.000
-11
0
1
0
python,datetime,date
4,472,626
12
false
0
0
If you need something quick, datetime_object.date() gives you a date of a datetime object.
1
848
0
Is there a built-in method for converting a date to a datetime in Python, for example getting the datetime for the midnight of the given date? The opposite conversion is easy: datetime has a .date() method. Do I really have to manually call datetime(d.year, d.month, d.day)?
Convert date to datetime in Python
-1
0
0
523,081
1,938,609
2009-12-21T06:57:00.000
0
0
0
0
python,django,dreamhost
1,939,248
5
false
1
0
Do you have an SMTP server set up anywhere? As people have suggested here, you can easily use gmail, but you are by no means limited to using only Gmails SMTP server. You can create your own on your own hardware if you like, or you can use a number of free SMTP servers out there. I'd say the most fun would be to set up your own box and make your own SMTP server ;)
2
7
0
Greetings, Does anyone know what are the required fields to have Django send emails when a "500 Internal Server Error" happend? I am hosting my project on Dreamhost and for the life of me I can't get Django to send emails. What are the required fields when hosting on Dreamhost?
Does anyone had success getting Django to send emails when hosting on Dreamhost?
0
0
0
4,627
1,938,609
2009-12-21T06:57:00.000
0
0
0
0
python,django,dreamhost
3,738,431
5
false
1
0
One issue we seem to have found with this gmail work around, is that if you try testing by sending from a gmail account to a dreamhost email that forwards back to the same gmail, the message is dropped. This may be some weird security 'feature' that dreamhost has going.
2
7
0
Greetings, Does anyone know what are the required fields to have Django send emails when a "500 Internal Server Error" happend? I am hosting my project on Dreamhost and for the life of me I can't get Django to send emails. What are the required fields when hosting on Dreamhost?
Does anyone had success getting Django to send emails when hosting on Dreamhost?
0
0
0
4,627
1,938,831
2009-12-21T08:16:00.000
0
0
1
0
python,opengl,merge,pyopengl,line-segment
1,938,889
3
false
0
0
20K segments isn't that much. Also, you'll be lucky when you can merge 10-100 lines per frame, so the speedup by this optimization will be neglectable. The rendering process is probably slow because you create the model again and again. Use glNewList() to save all the rendering commands in an GL render list on the card and then just issue glCallList() to render it with a single command.
2
1
0
My program uses PyOpenGL (so it's Python) with psyco. I have around 21,000 line segments which I need to render in each frame of my render (unless the user zooms in, in which case line segments are culled and not sent to the card at all). This is currently taking around 1.5 seconds each frame to complete. That's just not good enough, so I'm looking at ways to reduce the number of distinct line segments. I imagine there would be cases where multiple line segments can be merged into one big line, but I honestly do not even know where to begin with this. I do have the start point and end point of each line stored, so that might help things. Note that I am able to take as long as I need to at startup, and memory usage isn't too much of a concern. Any ideas would be much appreciated.
Merging multiple line segments
0
0
0
2,174
1,938,831
2009-12-21T08:16:00.000
0
0
1
0
python,opengl,merge,pyopengl,line-segment
1,938,914
3
false
0
0
You can define an error metric for merging two line segments into one and then testing all pairs of segments and then merging them if the error is below a certain threshold. One example is this algorithm: Construct a new line segment X from the two points farthest away from each other in the two line segments A and B. Find the minimum distance to X for all points in A and B. Assign the error as the maximum of those minimum distances. Replace A and B with X if the error is below your threshold. This isn't the best algorithm, but it is easy to implement. Edit 1 Definitely try doing display lists or vertex buffer object rendering before implementing this.
2
1
0
My program uses PyOpenGL (so it's Python) with psyco. I have around 21,000 line segments which I need to render in each frame of my render (unless the user zooms in, in which case line segments are culled and not sent to the card at all). This is currently taking around 1.5 seconds each frame to complete. That's just not good enough, so I'm looking at ways to reduce the number of distinct line segments. I imagine there would be cases where multiple line segments can be merged into one big line, but I honestly do not even know where to begin with this. I do have the start point and end point of each line stored, so that might help things. Note that I am able to take as long as I need to at startup, and memory usage isn't too much of a concern. Any ideas would be much appreciated.
Merging multiple line segments
0
0
0
2,174
1,938,929
2009-12-21T08:45:00.000
0
0
0
1
python,eclipse,pydev
2,967,350
2
false
0
0
My pydev broke entirely with 1.5.3. I had to downgrade yum downgrade eclipse-pydev and keep yum from updating it ever since.
2
1
0
I installed Pydev 1.5.3 (so that I could get the merged version of Pydev Extensions in core PyDev) in an EasyEclipse 1.3.1 installation. After this, Compare with > Base revision etc. comparison operations stopped working. I had to disable the PyDev 1.5.3 and revert back to the pre-installed Pydev 1.3.13 (part of EasyEclipse 1.3.1). Has anybody faced similar problem? Is there any work-around for this?
pydev 1.5.3 not working fine with Easy Eclipse 1.3.1
0
0
0
228
1,938,929
2009-12-21T08:45:00.000
0
0
0
1
python,eclipse,pydev
2,973,340
2
true
0
0
I am now using PyDev 1.5.6 and its working fine with EasyEclipse (along with SubClipse). The issues in comparison seem to have been resolved. In fact, the file diff in 1.5.6 is looking much more beautiful than before.
2
1
0
I installed Pydev 1.5.3 (so that I could get the merged version of Pydev Extensions in core PyDev) in an EasyEclipse 1.3.1 installation. After this, Compare with > Base revision etc. comparison operations stopped working. I had to disable the PyDev 1.5.3 and revert back to the pre-installed Pydev 1.3.13 (part of EasyEclipse 1.3.1). Has anybody faced similar problem? Is there any work-around for this?
pydev 1.5.3 not working fine with Easy Eclipse 1.3.1
1.2
0
0
228
1,938,945
2009-12-21T08:50:00.000
2
1
0
0
python,api
1,939,043
3
false
0
0
There is Windows Live Contact API for Hotmail/Live mail. Yahoo Contact API for Yahoo also exists, but to this date, no AOL contact api. I would suggest you try openinviter (openinviter.com) to import contacts. Unfortunately, you will not have OAuth capabilities, but it is the best class out there and works with 90+ different email providers. Note: it is written in php, but creating a wrapper won't be too hard.
1
0
0
I've import contacts from gmail by using gdata api, and is there any apis like that for hotmail/live/Aol ?
Is there any libraries could import contacts from hotmail/live/aol account?
0.132549
0
1
637
1,940,150
2009-12-21T13:40:00.000
1
1
0
0
.net,python,xbmc
1,940,200
1
true
0
0
I believe the plugin system is based on Python. You may be able to use IronPython to run some of the plugins in XBMC, although it may not be 100% compatible. You could also take the Python code and create a COM server object in which you could use .NET interop to interface with it.
1
2
0
Is there any way to use xbmc plugins in .net? im thinking about those plugins that provide access to media content like GameTrailers and stuff like that..
Run XBMC plugins in a .net application
1.2
0
0
318
1,940,528
2009-12-21T14:51:00.000
3
0
0
0
python,django,indexing
1,940,751
2
false
1
0
I tend to create a views.py in the root of the project where I keep the index view.
1
21
0
I am working on a site currently (first one solo) and went to go make an index page. I have been attempting to follow django best practices as I go, so naturally I go search for this but couldn't a real standard in regards to this. I have seen folks creating apps to serve this purpose named various things (main, home, misc) and have seen a views.py in the root of the project. I am really just looking for what the majority out there do for this. The index page is not static, since I want to detect if the user is logged in and such. Thanks.
Django index page best/most common practice
0.291313
0
0
12,324
1,940,957
2009-12-21T16:03:00.000
0
0
0
1
python,pygtk,subprocess,glade
1,941,109
3
false
0
1
look at gtk.ScrolledWindow.set_placement. (never tried)
1
3
0
I'm writing a python application that has a glade gui. Using subprocess to execute some shell commands in the background. Using a glade GUI which has a scrolledwindow widget and a textview widget inside the scrolledwindow widget. The textview gets populated as the subprocess.Popen object run and display their stdout and stderr to this textview. My problem is that the textview is constantly populated, but stays still @ scroll position 0, 0 (top-most, left-most) I want this scrolledwindow widget to stays at bottom-most, left-most at all times... Does anyone have any idea which method I need to call scroll this thing downwards?
howto scroll a gtk.scrolledwindow object from python code
0
0
0
2,933
1,943,747
2009-12-22T01:46:00.000
6
0
1
0
python,logging
12,549,515
7
false
0
0
Here's the one piece of the puzzle that the above answers didn't mention... and then it will all make sense: the "root" logger -- which is used if you call, say, logging.info() before logging.basicConfig(level=logging.DEBUG) -- has a default logging level of WARNING. That's why logging.info() and logging.debug() don't do anything: because you've configured them not to, by... um... not configuring them. Possibly related (this one bit me): when NOT calling basicConfig, I didn't seem to be getting my debug messages, even though I set my handlers to DEBUG level. After a bit of hair-pulling, I found you have to set the level of the custom logger to be DEBUG as well. If your logger is set to WARNING, then setting a handler to DEBUG (by itself) won't get you any output on logger.info() and logger.debug().
2
52
0
It appears that if you invoke logging.info() BEFORE you run logging.basicConfig, the logging.basicConfig call doesn't have any effect. In fact, no logging occurs. Where is this behavior documented? I don't really understand.
Python logging before you run logging.basicConfig?
1
0
0
21,028
1,943,747
2009-12-22T01:46:00.000
12
0
1
0
python,logging
1,943,809
7
false
0
0
Yes. You've asked to log something. Logging must, therefore, fabricate a default configuration. Once logging is configured... well... it's configured. "With the logger object configured, the following methods create log messages:" Further, you can read about creating handlers to prevent spurious logging. But that's more a hack for bad implementation than a useful technique. There's a trick to this. No module can do anything except logging.getlogger() requests at a global level. Only the if __name__ == "__main__": can do a logging configuration. If you do logging at a global level in a module, then you may force logging to fabricate it's default configuration. Don't do logging.info globally in any module. If you absolutely think that you must have logging.info at a global level in a module, then you have to configure logging before doing imports. This leads to unpleasant-looking scripts.
2
52
0
It appears that if you invoke logging.info() BEFORE you run logging.basicConfig, the logging.basicConfig call doesn't have any effect. In fact, no logging occurs. Where is this behavior documented? I don't really understand.
Python logging before you run logging.basicConfig?
1
0
0
21,028
1,945,634
2009-12-22T10:57:00.000
11
0
1
0
python,haskell,functional-programming
1,948,986
6
false
0
0
This question highlights one of my pet peeves about the common understanding of functional programming. Having language features like closures and first-class functions do not make a language a functional programming language. Functional programming is as much about a specific style of programming as it is about specific language constructs. Python has closures, first-class functions, and yes, even a function called "map", but the language itself encourages a procedural, OOP, imperative style of programming; so even if you make use of the functional features, you're still programming imperatively. As a purely functional language, Haskell basically mandates that one program in a declarative, functional style, so hands-down, Haskell is "more functional" than Python.
3
5
0
Had learned Haskell during a Functional Programming course in school. Had found Haskell a bit difficult to work with. Have now worked a lot on Python. Python is quite easy to work with. Python does support some functional programming constructs. Was thinking of revisiting Functional Programming. What would be a better language to code? Haskell or Python? Why?
Which is a more functional programming language, Haskell or Python?
1
0
0
4,113
1,945,634
2009-12-22T10:57:00.000
7
0
1
0
python,haskell,functional-programming
1,945,742
6
false
0
0
While Python does indeed support some functional constructs, Haskell is a functional language. What you also need to consider, is that Haskell is also purely functional and lazy, two concepts that may be the cause of the difficulty you find in Haskell. If this is the case, read on. What you may want to consider, if, of course, you have the time, is learning another, less complex, functional language. I found that learning a less "aggressively functional" language before moving on to Haskell is a step worth taking. You may want to consider OCaml (Objective Caml), another functional programming language, that is not pure nor lazy. Thus, some imperative programming constructs will be available to you (references, loops, mutable arrays, etc), and you won't have to cope with the monads until you actually want to. This entirely depends on the time you are willing to spend revisiting functional programming, and on your current background in this same paradigm.
3
5
0
Had learned Haskell during a Functional Programming course in school. Had found Haskell a bit difficult to work with. Have now worked a lot on Python. Python is quite easy to work with. Python does support some functional programming constructs. Was thinking of revisiting Functional Programming. What would be a better language to code? Haskell or Python? Why?
Which is a more functional programming language, Haskell or Python?
1
0
0
4,113
1,945,634
2009-12-22T10:57:00.000
0
0
1
0
python,haskell,functional-programming
1,945,669
6
false
0
0
What Boldewyn said. Haskell is one of the most "hardcore" functional languages there is, insofar as there simply isn't any way to maintain mutable state. That said, Haskell is (unsurprisingly) wildly different from all the imperative and mixed-model languages most people come in contact with, so there would be a learning curve involved in picking it up if one came from a background of, say, VB or C(++) or Java. Python, on the other hand, features a "Functional Show and Tell" section where a handful of functional features can be test driven within an otherwise predominantly imperative environment. Thus, if in his original question, the OP's "better" meant "more functional" or "a better citizen of functional-land" (as he has since made clearer), then Haskell "wins" hands down.
3
5
0
Had learned Haskell during a Functional Programming course in school. Had found Haskell a bit difficult to work with. Have now worked a lot on Python. Python is quite easy to work with. Python does support some functional programming constructs. Was thinking of revisiting Functional Programming. What would be a better language to code? Haskell or Python? Why?
Which is a more functional programming language, Haskell or Python?
0
0
0
4,113
1,947,344
2009-12-22T16:09:00.000
0
1
0
0
python,fastcgi,lighttpd,cherrypy
1,947,457
2
false
1
0
From a system-software-writer's pointer of view: This all depends on how the meta-data about the server process is organized within your daemon (lighttpd or fcgi). Some programs are designed for one time only initialization -- MOSTLY this allows a much simpler and better performing internal programming model. Often it is very hard to program a server process reload config data in a easy way. You might have to introduce locks and external event objects (signals in UNIX). When you can synchronize the data structures by design -- i.e., only initializing once .... why complicate things by making the data model modifiable multiple times ?
1
5
0
So I'm trying to do more web development in python, and I've picked cherrypy, hosted by lighttpd w/ fastcgi. But my question is a very basic one: why do I need to restart lighttpd (or apache) every time I change my application code, or the code for an underlying library? I realize this question extends from a basic mis(i.e. poor)understanding of the fastcgi model, so I'm open to any schooling here, but I'm used to just changing a PHP file and it showing up, versus having to bounce the web server. Any elucidation/useful mockery appreciated.
fastcgi, cherrypy, and python
0
0
0
2,035
1,947,750
2009-12-22T17:06:00.000
5
0
0
0
python,mysql,prepared-statement
2,539,467
7
false
0
0
Using the SQL Interface as suggested by Amit can work if you're only concerned about performance. However, you then lose the protection against SQL injection that a native Python support for prepared statements could bring. Python 3 has modules that provide prepared statement support for PostgreSQL. For MySQL, "oursql" seems to provide true prepared statement support (not faked as in the other modules).
1
51
0
I worked on a PHP project earlier where prepared statements made the SELECT queries 20% faster. I'm wondering if it works on Python? I can't seem to find anything that specifically says it does or does NOT.
Does Python support MySQL prepared statements?
0.141893
1
0
52,874
1,947,904
2009-12-22T17:25:00.000
0
0
1
0
python,class,nested,pickle
69,507,753
7
false
0
0
This seems to work fine in newer versions of Python. I tried it in v3.8 and it was able to pickle and unpickle the nested class.
3
41
0
I have a nested class: class WidgetType(object): class FloatType(object): pass class TextType(object): pass .. and an object that refers the nested class type (not an instance of it) like this class ObjectToPickle(object): def __init__(self): self.type = WidgetType.TextType Trying to serialize an instance of the ObjectToPickle class results in: PicklingError: Can't pickle <class 'setmanager.app.site.widget_data_types.TextType'> Is there a way to pickle nested classes in python?
How can I pickle a dynamically created nested class in python?
0
0
0
24,124
1,947,904
2009-12-22T17:25:00.000
1
0
1
0
python,class,nested,pickle
1,949,236
7
false
0
0
Nadia's answer is pretty complete - it is practically not something you want to be doing; are you sure you can't use inheritance in WidgetTypes instead of nested classes? The only reason to use nested classes is to encapsulate classes working together closely, your specific example looks like an immediate inheritance candidate to me - there is no benefit in nesting WidgetType classes together; put them in a module and inherit from the base WidgetType instead.
3
41
0
I have a nested class: class WidgetType(object): class FloatType(object): pass class TextType(object): pass .. and an object that refers the nested class type (not an instance of it) like this class ObjectToPickle(object): def __init__(self): self.type = WidgetType.TextType Trying to serialize an instance of the ObjectToPickle class results in: PicklingError: Can't pickle <class 'setmanager.app.site.widget_data_types.TextType'> Is there a way to pickle nested classes in python?
How can I pickle a dynamically created nested class in python?
0.028564
0
0
24,124
1,947,904
2009-12-22T17:25:00.000
2
0
1
0
python,class,nested,pickle
1,947,965
7
false
0
0
Pickle only works with classes defined in module scope (top level). In this case, it looks like you could define the nested classes in module scope and then set them as properties on WidgetType, assuming there's a reason not to just reference TextType and FloatType in your code. Or, import the module they're in and use widget_type.TextType and widget_type.FloatType.
3
41
0
I have a nested class: class WidgetType(object): class FloatType(object): pass class TextType(object): pass .. and an object that refers the nested class type (not an instance of it) like this class ObjectToPickle(object): def __init__(self): self.type = WidgetType.TextType Trying to serialize an instance of the ObjectToPickle class results in: PicklingError: Can't pickle <class 'setmanager.app.site.widget_data_types.TextType'> Is there a way to pickle nested classes in python?
How can I pickle a dynamically created nested class in python?
0.057081
0
0
24,124
1,948,224
2009-12-22T18:21:00.000
2
0
0
0
python,excel,xlwt,pyexcelerator
20,838,509
3
false
0
0
I have the same issue, running a linux server. i'm going to check creating an ODS or XLSX file with auto-filter by other means, and then convert them with a libreoffice command line to "xls".
1
6
0
I am using Python 2.6 + xlwt module to generate excel files. Is it possible to include an autofilter in the first row with xlwt or pyExcelerator or anything else besides COM? Thanks
How to create an excel file with an autofilter in the first row with xlwt?
0.132549
1
0
6,820
1,948,396
2009-12-22T18:52:00.000
2
0
0
0
python,gtk,pygtk
1,948,993
2
true
0
1
Use gtk.Widget.modify_text and gtk.Widget.modify_base instead of fg and bg.
1
0
0
I want to make the background of a textview widget black and the foreground white. Been trying the .modify_bg and .modify_fg methods, but none affect the way this thing looks. Can anyone suggest anything or is this just not possible?
pygtk: howto change background of a gtk.TextView widget
1.2
0
0
1,612
1,950,218
2009-12-23T01:28:00.000
3
0
1
0
python
1,950,924
6
false
0
0
You have the options presented thus far: Portable Python and Py2Exe. Either can be pretty good. My suggestion: encourage your friends to install Python! As you know, it's free, and simple to install and download. If they want your application bad enough, installing Python will be a no-brainer.
1
12
0
How do I let my friends use my Python programs? They don't have python installed, but they can use command line programs. I don't have the skill to write GUI. Let, say I am writing some calculus calculator, with a lot of custom modules and files. How do I share it?
Distributing Python programs
0.099668
0
0
8,045
1,950,539
2009-12-23T03:30:00.000
0
0
1
0
python
1,950,575
5
false
0
0
The main shortcoming of software-based methods of generating lottery numbers is the fact that all random numbers generated by software are pseudo-random. This may not be a problem for your simple application, but you did ask about a 'specific mathematical philosophy'. You will have noticed that all commercial lottery systems use physical methods: balls with numbers. And behind the scenes, the numbers generated by physical lottery systems will be carefully scrutunised for indications of non-randomness and steps taken to eliminate it. As I say, this may not be a consideration for your simple application, but the overriding requirement of a true lottery (the 'specific mathematical philosophy') should be mathematically demonstrable randomness
1
0
1
I know python offers random module to do some simple lottery. Let say random.shuffle() is a good one. However, I want to build my own simple one. What should I look into? Is there any specific mathematical philosophies behind lottery? Let say, the simplest situation. 100 names and generate 20 names randomly. I don't want to use shuffle, since I want to learn to build one myself. I need some advise to start. Thanks.
python lottery suggestion
0
0
0
1,639
1,953,666
2009-12-23T16:06:00.000
3
0
1
0
python,caching,weak-references
1,953,752
1
true
0
0
Maybe I'm not understanding your question, but making a dictionary of weakly referenced values available to your code isn't really any different from making a dictionary of anything else available to your code. I would store a reference to the WeakValueDictionary on: each instance (referenced via self) a class (also referenced via self, but shared between instances) a module (global, kind of) depending on what made the most sense given the rest of your code.
1
0
0
I'm currently coding a project in python where I need a sort of cache of generic objects, I have settled on using WeakValueDictionaries for this. These generic objects are often referenced by many other non-generic objects. My main problem though is that I can't seem to wrap my head around a way of making these WeakValueDictionaries available to many different portions of the program. I would prefer not to use "global" variables if possible. Best regards FrederikNS
Building a weakref cache in python
1.2
0
0
1,227
1,953,989
2009-12-23T16:56:00.000
10
1
1
0
python,testing,ironpython,jython,boost-python
1,954,037
1
true
0
0
The short answer is: Sometimes. Some projects built on top of IronPython may not work with CPython, and some CPython modules that are written in C (e.g. NumPy) will not work with IronPython. On a similar note, while Jython implements the language specification, it has several incompatibilities with CPython (for instance, it lacks a few parts of the CPython standard library, and it can import Java standard library packages and classes, like Swing) So, yes, as long as you avoid the incompatibilities.
1
7
0
I am pretty sure that python scripts will work in all three, but I want to make sure. I have read here and there about editors that can write CPython, Jython, IronPython and I am hoping that I am looking to much into the distinction. My situation is I have 3 different api's that I want to test. Each api performs the same functionality code wise, but they are different in implementation. I am writing wrappers around each language's apis. Each wrapper should expose the exact same functionality and implementation to python using Boost::python, Jython, and IronPython. My question is, would a python script written using these exposed methods (that are common for each language) work in all three "flavors" of Python? Like I said I am pretty sure the answer is 'Of course,' but I need to make sure before I spend too much time working on this.
Are CPython, IronPython, Jython scripts compatible with each other?
1.2
0
0
1,142
1,954,840
2009-12-23T19:27:00.000
2
0
1
0
python
1,954,861
2
false
0
0
To access the method, getattr(test, test.method); this way you can bind it to a variable, return it as a function result, pass it as an argument, and so forth. To call it as well, append parenthesized arguments (just parentheses if there are no arguments), for example getattr(test, test.method)().
1
6
0
Say I have a class object named test. test has various methods, one of them is whatever() . I have a variable named method = "whatever" How can I access the method using the variable with test? Thanks!
How do I access a object's method when the method's name is in a variable?
0.197375
0
0
187
1,957,054
2009-12-24T06:36:00.000
26
1
1
0
python,compilation
1,957,814
7
false
0
0
Python, as a dynamic language, cannot be "compiled" into machine code statically, like C or COBOL can. You'll always need an interpreter to execute the code, which, by definition in the language, is a dynamic operation. You can "translate" source code in bytecode, which is just an intermediate process that the interpreter does to speed up the load of the code, It converts text files, with comments, blank spaces, words like 'if', 'def', 'in', etc in binary code, but the operations behind are exactly the same, in Python, not in machine code or any other language. This is what it's stored in .pyc files and it's also portable between architectures. Probably what you need it's not "compile" the code (which it's not possible) but to "embed" an interpreter (in the right architecture) with the code to allow running the code without an external installation of the interpreter. To do that, you can use all those tools like py2exe or cx_Freeze. Maybe I'm being a little pedantic on this :-P
2
72
0
I am new to the Python programming language. I was wondering if it is possible to compile a program to written in Python. Is it possible to convert Python scripts to some lower level programming languages which then can be compiled to binary code? A developer who is considering to code in Python might want to keep the possibility open to be able to go for binary distribution later.
Is it possible to compile a program written in Python?
1
0
0
159,831
1,957,054
2009-12-24T06:36:00.000
-3
1
1
0
python,compilation
1,957,072
7
false
0
0
python compile on the fly when you run it. Run a .py file by(linux): python abc.py
2
72
0
I am new to the Python programming language. I was wondering if it is possible to compile a program to written in Python. Is it possible to convert Python scripts to some lower level programming languages which then can be compiled to binary code? A developer who is considering to code in Python might want to keep the possibility open to be able to go for binary distribution later.
Is it possible to compile a program written in Python?
-0.085505
0
0
159,831
1,957,237
2009-12-24T07:35:00.000
0
0
0
0
python
1,966,537
3
false
0
0
i found it again. There is a rate()-function in the visual-module. you can use it in the while-loop.
2
0
0
I want to limit the calculation-speed. There was a command for rate per second. Could anybody help me? doesn't rate() work in the newer version of Python? Thanks
frames per seconds
0
0
0
1,903
1,957,237
2009-12-24T07:35:00.000
0
0
0
0
python
1,957,270
3
false
0
0
Using an event loop framework such as Twisted will allow you to schedule your next calculation in the future once you have completed the current calculation, and to sleep until that time.
2
0
0
I want to limit the calculation-speed. There was a command for rate per second. Could anybody help me? doesn't rate() work in the newer version of Python? Thanks
frames per seconds
0
0
0
1,903
1,957,255
2009-12-24T07:43:00.000
5
0
0
0
python,xmpp,twisted,google-talk
2,590,641
2
false
1
0
In this particular case, the better answer to the non-question is that you should not set the from address at all. Every server will happily fill in the blank for you, saving you from figuring out what JID your client has.
1
1
0
Okay, this isn't a question. All the examples of wokkel and twisted I have seen do not properly observe generated resources in the JID. Google talk clients built using wokkel/twisted generally break because they do not set the full JID on responses, resulting in (very hidden, low level) errors like: <message to="[email protected]" from="[email protected]/Example2C2F32A1" type="error"><body>echo: None</body><error code="400" type="modify"><bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas">If set, the 'from' attribute must be set to the user's full JID.</text></error></message> The full, server issued jid can be obtained in the protocol handler from self.parent.authenticator.jid.full() So, when sending messages, ensure you use the full jid in your from field, or some servers will not like you and you will pull all your hair out, and cry.
Why do all twisted/wokkel xmpp examples ignore the proper usage of JID in the xmpp protocol?
0.462117
0
0
1,213
1,957,396
2009-12-24T08:34:00.000
44
0
1
0
python,dictionary
1,957,403
5
true
0
0
Short answer: because they are mutable containers. If a dict was hashed, its hash would change as you changed its contents.
1
29
0
I mean why cant we put key of dict as dict? that means we can't have dictionary having key as another dictionary...
why dict objects are unhashable in python?
1.2
0
0
31,172