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,453,952 | 2009-09-21T10:52:00.000 | 7 | 0 | 1 | 0 | python,module,standard-library | 1,456,440 | 16 | false | 0 | 0 | I'd go for a few modules which make the most sense to a typical computer user/programmer performing typical computer tasks. That way, there's the largest chance that they might actually use python on their own time.
In my opinion, the operations most people will likely perform are file operations, for example going over every file in a directory and performing some action on it.
Therefore, I'd say the modules: os and os.path are probably the most important, and also mention glob, fnmatch and shutil. Also, subprocess might be very useful too, since it tends to get used in the above mentioned context.
Lastly, I'd go with optparse, since that will get them into very quickly making usable, programmer-friendly programs, which hopefully will also encourage them to actually write programs that other people want to use. | 11 | 55 | 0 | I am teaching a graduate level Python class at the University of Paris, and the students need to be introduced to the standard library. I want to discuss with them about some of the most important standard modules.
What modules do you think are absolute musts? Even though responses probably vary depending on your field (web programming, science, etc.), I feel that some modules are commonly needed: math, sys, re, os, os.path, logging,… and maybe: collections, struct,…
What modules would you suggest I present, in a 1 or 2 hour slot? | Most useful Python modules from the standard library? | 1 | 0 | 0 | 24,060 |
1,453,952 | 2009-09-21T10:52:00.000 | 5 | 0 | 1 | 0 | python,module,standard-library | 1,454,053 | 16 | false | 0 | 0 | I would add urllib2 to the list. | 11 | 55 | 0 | I am teaching a graduate level Python class at the University of Paris, and the students need to be introduced to the standard library. I want to discuss with them about some of the most important standard modules.
What modules do you think are absolute musts? Even though responses probably vary depending on your field (web programming, science, etc.), I feel that some modules are commonly needed: math, sys, re, os, os.path, logging,… and maybe: collections, struct,…
What modules would you suggest I present, in a 1 or 2 hour slot? | Most useful Python modules from the standard library? | 0.062419 | 0 | 0 | 24,060 |
1,453,952 | 2009-09-21T10:52:00.000 | 33 | 0 | 1 | 0 | python,module,standard-library | 1,453,974 | 16 | false | 0 | 0 | I'd offer itertools and functools. These modules operate over abstractions that are found everywhere in programming, so I think they are useful to study. Among more practical things, xml modules (xml.dom, xml.sax) can be very useful. | 11 | 55 | 0 | I am teaching a graduate level Python class at the University of Paris, and the students need to be introduced to the standard library. I want to discuss with them about some of the most important standard modules.
What modules do you think are absolute musts? Even though responses probably vary depending on your field (web programming, science, etc.), I feel that some modules are commonly needed: math, sys, re, os, os.path, logging,… and maybe: collections, struct,…
What modules would you suggest I present, in a 1 or 2 hour slot? | Most useful Python modules from the standard library? | 1 | 0 | 0 | 24,060 |
1,455,642 | 2009-09-21T17:09:00.000 | 0 | 0 | 0 | 0 | python,sqlite,pysqlite | 1,455,663 | 4 | false | 0 | 0 | If you don't have root privileges, I would recommend installing a more recent version of Python in your home directory and then adding your local version to your PATH. It seems easier to go that direction than to try to make sqlite work with an old version of Python.
You will also be doing yourself a favor by using a recent version of Python, because you'll have access to the numerous recent improvements in the language. | 2 | 0 | 0 | I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message:
error: command 'gcc' failed with exit status 1
As far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably).
Does anybody know how to build sqlite for Python 2.4?
As another option I could try to install higher version of Python. However I do not have root privileges. Does anybody know what will be the easiest way to solve the problem (build SQLite fro Python 2.4, or install newer version of Python)? I have to mention that I would not like to overwrite the old version version of Python.
Thank you in advance. | How to build sqlite for Python 2.4? | 0 | 0 | 0 | 2,825 |
1,455,642 | 2009-09-21T17:09:00.000 | 0 | 0 | 0 | 0 | python,sqlite,pysqlite | 2,805,287 | 4 | false | 0 | 0 | I had the same trouble with gcc failing with Ubuntu Karmic. I fixed this by installing the python-dev package. In my case, I'm working with python2.4, so I installed the python2.4-dev package. The python-dev package should work for python2.6. | 2 | 0 | 0 | I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message:
error: command 'gcc' failed with exit status 1
As far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably).
Does anybody know how to build sqlite for Python 2.4?
As another option I could try to install higher version of Python. However I do not have root privileges. Does anybody know what will be the easiest way to solve the problem (build SQLite fro Python 2.4, or install newer version of Python)? I have to mention that I would not like to overwrite the old version version of Python.
Thank you in advance. | How to build sqlite for Python 2.4? | 0 | 0 | 0 | 2,825 |
1,456,269 | 2009-09-21T19:10:00.000 | -3 | 1 | 1 | 0 | python,git | 2,180,936 | 11 | false | 0 | 0 | For the record, none of the aforementioned Git Python libraries seem to contain a "git status" equivalent, which is really the only thing I would want since dealing with the rest of the git commands via subprocess is so easy. | 3 | 177 | 0 | What are people's experiences with any of the Git modules for Python? (I know of GitPython, PyGit, and Dulwich - feel free to mention others if you know of them.)
I am writing a program which will have to interact (add, delete, commit) with a Git repository, but have no experience with Git, so one of the things I'm looking for is ease of use/understanding with regards to Git.
The other things I'm primarily interested in are maturity and completeness of the library, a reasonable lack of bugs, continued development, and helpfulness of the documentation and developers.
If you think of something else I might want/need to know, please feel free to mention it. | Python Git Module experiences? | -0.054491 | 0 | 0 | 120,684 |
1,456,269 | 2009-09-21T19:10:00.000 | 0 | 1 | 1 | 0 | python,git | 1,478,107 | 11 | false | 0 | 0 | The git interaction library part of StGit is actually pretty good. However, it isn't broken out as a separate package but if there is sufficient interest, I'm sure that can be fixed.
It has very nice abstractions for representing commits, trees etc, and for creating new commits and trees. | 3 | 177 | 0 | What are people's experiences with any of the Git modules for Python? (I know of GitPython, PyGit, and Dulwich - feel free to mention others if you know of them.)
I am writing a program which will have to interact (add, delete, commit) with a Git repository, but have no experience with Git, so one of the things I'm looking for is ease of use/understanding with regards to Git.
The other things I'm primarily interested in are maturity and completeness of the library, a reasonable lack of bugs, continued development, and helpfulness of the documentation and developers.
If you think of something else I might want/need to know, please feel free to mention it. | Python Git Module experiences? | 0 | 0 | 0 | 120,684 |
1,456,269 | 2009-09-21T19:10:00.000 | 18 | 1 | 1 | 0 | python,git | 1,458,963 | 11 | false | 0 | 0 | Maybe it helps, but Bazaar and Mercurial are both using dulwich for their Git interoperability.
Dulwich is probably different than the other in the sense that's it's a reimplementation of git in python. The other might just be a wrapper around Git's commands (so it could be simpler to use from a high level point of view: commit/add/delete), it probably means their API is very close to git's command line so you'll need to gain experience with Git. | 3 | 177 | 0 | What are people's experiences with any of the Git modules for Python? (I know of GitPython, PyGit, and Dulwich - feel free to mention others if you know of them.)
I am writing a program which will have to interact (add, delete, commit) with a Git repository, but have no experience with Git, so one of the things I'm looking for is ease of use/understanding with regards to Git.
The other things I'm primarily interested in are maturity and completeness of the library, a reasonable lack of bugs, continued development, and helpfulness of the documentation and developers.
If you think of something else I might want/need to know, please feel free to mention it. | Python Git Module experiences? | 1 | 0 | 0 | 120,684 |
1,456,373 | 2009-09-21T19:27:00.000 | 11 | 0 | 1 | 0 | python | 1,456,390 | 15 | false | 0 | 0 | Two hash maps is actually probably the fastest-performing solution assuming you can spare the memory. I would wrap those in a single class - the burden on the programmer is in ensuring that two the hash maps sync up correctly. | 3 | 116 | 0 | I'm doing this switchboard thing in python where I need to keep track of who's talking to whom, so if Alice --> Bob, then that implies that Bob --> Alice.
Yes, I could populate two hash maps, but I'm wondering if anyone has an idea to do it with one.
Or suggest another data structure.
There are no multiple conversations. Let's say this is for a customer service call center, so when Alice dials into the switchboard, she's only going to talk to Bob. His replies also go only to her. | Two way/reverse map | 1 | 0 | 0 | 62,169 |
1,456,373 | 2009-09-21T19:27:00.000 | 1 | 0 | 1 | 0 | python | 1,457,749 | 15 | false | 0 | 0 | The kjbuckets C extension module provides a "graph" data structure which I believe gives you what you want. | 3 | 116 | 0 | I'm doing this switchboard thing in python where I need to keep track of who's talking to whom, so if Alice --> Bob, then that implies that Bob --> Alice.
Yes, I could populate two hash maps, but I'm wondering if anyone has an idea to do it with one.
Or suggest another data structure.
There are no multiple conversations. Let's say this is for a customer service call center, so when Alice dials into the switchboard, she's only going to talk to Bob. His replies also go only to her. | Two way/reverse map | 0.013333 | 0 | 0 | 62,169 |
1,456,373 | 2009-09-21T19:27:00.000 | 5 | 0 | 1 | 0 | python | 1,456,389 | 15 | false | 0 | 0 | No, there is really no way to do this without creating two dictionaries. How would it be possible to implement this with just one dictionary while continuing to offer comparable performance?
You are better off creating a custom type that encapsulates two dictionaries and exposes the functionality you want. | 3 | 116 | 0 | I'm doing this switchboard thing in python where I need to keep track of who's talking to whom, so if Alice --> Bob, then that implies that Bob --> Alice.
Yes, I could populate two hash maps, but I'm wondering if anyone has an idea to do it with one.
Or suggest another data structure.
There are no multiple conversations. Let's say this is for a customer service call center, so when Alice dials into the switchboard, she's only going to talk to Bob. His replies also go only to her. | Two way/reverse map | 0.066568 | 0 | 0 | 62,169 |
1,457,104 | 2009-09-21T21:55:00.000 | 110 | 0 | 0 | 1 | python,nose | 1,579,787 | 7 | false | 0 | 0 | The other thing which always gets me with nose is that it won't run tests in executable files. I'm not exactly sure why that would make a difference across Mac/Ubuntu, but it's worth a shot.
Make sure that the scripts didn't somehow get chmod +x'd on the Mac… And if they did, fix them with chmod -x $(find tests/ -name '*.py'). | 2 | 54 | 0 | Is there any reason why Nose wouldn't be able to find tests in Ubuntu 9.04?
I'm using nose 0.11.1 with python 2.5.4.
I can run tests only if I explicitly specify the filename.
If I don't specify the filename it just says, 0 tests.
The same project runs tests fine on my Mac, so I'm quite stumped! | Nose unable to find tests in ubuntu | 1 | 0 | 0 | 20,517 |
1,457,104 | 2009-09-21T21:55:00.000 | 2 | 0 | 0 | 1 | python,nose | 47,909,167 | 7 | false | 0 | 0 | Use the -all-modules and it will find all the tests.
nosetests --all-modules ./tests | 2 | 54 | 0 | Is there any reason why Nose wouldn't be able to find tests in Ubuntu 9.04?
I'm using nose 0.11.1 with python 2.5.4.
I can run tests only if I explicitly specify the filename.
If I don't specify the filename it just says, 0 tests.
The same project runs tests fine on my Mac, so I'm quite stumped! | Nose unable to find tests in ubuntu | 0.057081 | 0 | 0 | 20,517 |
1,457,308 | 2009-09-21T22:56:00.000 | 2 | 0 | 1 | 0 | python,import | 1,457,700 | 4 | false | 0 | 0 | That's why you have parameters.
It's not the job of c.py to determine who imported it.
It's the job of a.py or b.py to pass the variable __name__ to the functions or classes in c.py. | 1 | 5 | 0 | How do I find the name of the file that is the "importer", within the imported file?
If a.py and b.py both import c.py, is there anyway that c.py can know the name of the file importing it? | How do I find the name of the file that is the importer, within the imported file? | 0.099668 | 0 | 0 | 714 |
1,458,087 | 2009-09-22T04:23:00.000 | 5 | 0 | 0 | 0 | python,sockets | 1,458,109 | 2 | false | 0 | 0 | SOCK_DGRAM means you want to send packets by UDP -- no order guarantee, no guarantee of reception, no guarantee of lack of repetition. SOCK_STREAM would imply TCP -- no packet boundary guarantee, but (unless the connection's dropped;-) guarantee of order, reception, and no duplication. TCP/IP, the networking model that won the heart and soul of every live practitioned and made the Internet happen, is not compliant to ISO/OSI -- a standard designed at the drafting table and never really winning in the real world.
The Internet as she lives and breathes is TCP/IP all the way. Don't rely on tests done on a low-latency local network as in ANY way representative of what will happen out there in the real world. Welcome to the real world, BTW, and, good luck (you'll need some!-). | 2 | 2 | 0 | I am sending packets from one pc to other. I am using python socket socket.socket(socket.AF_INET, socket.SOCK_DGRAM ). Do we need to take care of order in which packets are received ?
In ISO-OSI model layers below transport layer handle all packets communication. Do all ISO-OSI layers present in the program ? Or some of them present in operating system ?
On localhost I get all packets in order.
Will it make any difference over internet ? | Python socket programming and ISO-OSI model | 0.462117 | 0 | 1 | 2,274 |
1,458,087 | 2009-09-22T04:23:00.000 | 4 | 0 | 0 | 0 | python,sockets | 1,458,734 | 2 | true | 0 | 0 | To answer your immediate question, if you're using SOCK_STREAM, then you're actually using TCP, which is an implementation of the transport layer which does take care of packet ordering and integrity for you. So it sounds like that's what you want to use. SOCK_DGRAM is actually UDP, which doesn't take care of any integrity for you.
Do we need to take care of order in which packets are received ? In ISO-OSI model layers below transport layer handle all packets communication. Do all ISO-OSI layers present in the program ?
Just to clear this up, in the ISO-OSI model, all the layers below the transport layer handle sending of a single packet from one computer to the other, and don't "understand" the concept of packet ordering (it doesn't apply to them).
In this model, there is another layer (the session layer, above the transport layer) which is responsible for defining the session behavior. It is this layer which decides whether to have things put in place to prevent reordering, to ensure integrity, and so on.
In the modern world, the ISO-OSI model is more of an idealistic template, rather than an actual model. TCP/IP is the actual implementation which is used almost everywhere.
In TCP/IP, the transport layer is the one that has the role of defining whether there is any session behavior or not. | 2 | 2 | 0 | I am sending packets from one pc to other. I am using python socket socket.socket(socket.AF_INET, socket.SOCK_DGRAM ). Do we need to take care of order in which packets are received ?
In ISO-OSI model layers below transport layer handle all packets communication. Do all ISO-OSI layers present in the program ? Or some of them present in operating system ?
On localhost I get all packets in order.
Will it make any difference over internet ? | Python socket programming and ISO-OSI model | 1.2 | 0 | 1 | 2,274 |
1,458,690 | 2009-09-22T07:53:00.000 | 0 | 1 | 0 | 0 | c#,python,outlook,ms-word,mapi | 1,483,115 | 2 | false | 0 | 0 | OK, to answer my own question. I need to build a DLL with "MAPISendDocuments" and/or "MAPISendMail" functions defined.
This DLL can have any name, and is referenced in the registry at HKLM/Software/Clients/Mail/MyMailApp/DLLPath.
Found examples using Delphi... | 1 | 1 | 0 | Microsoft Word has "send as attachment" functionality which creates a new message in Outlook with the document attached.
I would like to replace Outlook with a custom mail agent, but I do not know how to achieve this. Now my mail agent is simply a program that runs, and takes a file name as parameter.
As far as I know, "send as attachment" is using some DLL/API called MAPI. I would need to change my app so that it does not simply accept file name arguments, but can receive MAPI(?) calls MS Word uses when "sending as attachment".
Further, I need to change the default mail agent by creating my own MAPI32.dll stub which simply redirects to my app.
I'd appreciate if anyone had more info on how this could be achieved! | How to create a MAPI32.dll stub to be able to "send as attachment" from MS Word? | 0 | 0 | 0 | 3,109 |
1,458,829 | 2009-09-22T08:41:00.000 | 1 | 0 | 0 | 0 | python,django,django-urls,django-middleware | 1,460,317 | 3 | true | 1 | 0 | I think this really depends on your problem and what exactly you are trying to do.
You cannot change the URL without redirecting the user, as you cannot modify the URL on a page without a reload. Basically a redirect is a response telling the user to move on, there is no way to actually change the URL. Note that even if you do it in something like JavaScript you basically do the same as a redirect, so it can't be done client or server side.
I think it might help if you explain to us why you need to pass this information via the URL. Why not store data in the session?
I guess you could add the data to the request object but that doesn't add it to the URL. | 2 | 3 | 0 | I don't know if it's possible but I'd like to add few parameters at the end of the URL using middleware. Can it be done without redirect after modyfing requested URL?
ie.
user clicks: .../some_link
and middleware rewrites it to: .../some_link?par1=1&par2=2
Other way is to modify reponse and replace every HTML link but it's not something I'd like to do.
Thanks | Modify address in Django middleware | 1.2 | 0 | 0 | 1,984 |
1,458,829 | 2009-09-22T08:41:00.000 | 0 | 0 | 0 | 0 | python,django,django-urls,django-middleware | 1,458,950 | 3 | false | 1 | 0 | You can do whatever you like in the middleware. You have access to the request object, you can get the URL and redirect to a new one if you want.
My question would be, why do you want to do this? If you need to keep information about the request, the proper place to do this is in the session. | 2 | 3 | 0 | I don't know if it's possible but I'd like to add few parameters at the end of the URL using middleware. Can it be done without redirect after modyfing requested URL?
ie.
user clicks: .../some_link
and middleware rewrites it to: .../some_link?par1=1&par2=2
Other way is to modify reponse and replace every HTML link but it's not something I'd like to do.
Thanks | Modify address in Django middleware | 0 | 0 | 0 | 1,984 |
1,462,565 | 2009-09-22T20:57:00.000 | 0 | 0 | 0 | 0 | python,header,pysqlite | 1,462,623 | 3 | false | 0 | 0 | pysqlite needs to compiled/build before you can use it. This requires C language header files (*.H) which come with the source code of sqllite itself.
i.e. sqllite and pysqlite are two different things. Did you install sqlite prior to trying and build pysqllte ? (or maybe you did, but did you do so just with the binaries; you need the source package (or at least its headers) for pysqlite purposes. | 2 | 12 | 0 | I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them.
However, I have no ideas what these headers are (where I can find them, what they are doing and how to install them).
Can anybody, pleas, help me with that? | What are sqlite development headers and how to install them? | 0 | 1 | 0 | 17,278 |
1,462,565 | 2009-09-22T20:57:00.000 | 7 | 0 | 0 | 0 | python,header,pysqlite | 5,671,345 | 3 | false | 0 | 0 | For me this worked (Redhat/CentOS):
$ sudo yum install sqlite-devel | 2 | 12 | 0 | I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them.
However, I have no ideas what these headers are (where I can find them, what they are doing and how to install them).
Can anybody, pleas, help me with that? | What are sqlite development headers and how to install them? | 1 | 1 | 0 | 17,278 |
1,462,986 | 2009-09-22T22:32:00.000 | 1 | 1 | 1 | 0 | python,module,variables,lazy-loading,itunes | 1,463,036 | 8 | false | 0 | 0 | If that variable lived in a class rather than a module, then you could overload getattr, or better yet, populate it in init. | 1 | 41 | 0 | I'm trying to find a way to lazily load a module-level variable.
Specifically, I've written a tiny Python library to talk to iTunes, and I want to have a DOWNLOAD_FOLDER_PATH module variable. Unfortunately, iTunes won't tell you where its download folder is, so I've written a function that grabs the filepath of a few podcast tracks and climbs back up the directory tree until it finds the "Downloads" directory.
This takes a second or two, so I'd like to have it evaluated lazily, rather than at module import time.
Is there any way to lazily assign a module variable when it's first accessed or will I have to rely on a function? | Lazy module variables--can it be done? | 0.024995 | 0 | 0 | 14,915 |
1,464,923 | 2009-09-23T09:27:00.000 | 1 | 0 | 1 | 0 | python,arrays,perl | 1,466,626 | 8 | false | 0 | 0 | @array = qw(1 2 3 4 5 6 7 8 9);
print @array[(grep { ($_ + 1) % 3 == 0 } (1..$#array))]; | 1 | 6 | 0 | How can I do a for() or foreach() loop in Python and Perl, respectively, that only prints every third index? I need to move every third index to a new array. | How can I print only every third index in Perl or Python? | 0.024995 | 0 | 0 | 5,473 |
1,464,961 | 2009-09-23T09:34:00.000 | 0 | 0 | 0 | 0 | python,amazon-s3,boto | 7,366,501 | 6 | false | 0 | 0 | Note that the 'copy' method on the Key object has a "preserve_acl" parameter (False by default) that will copy the source's ACL to the destination object. | 3 | 17 | 0 | I have a file contained in a key in my S3 bucket. I want to create a new key, which will contain the same file. Is it possible to do without downloading that file?
I'm looking for a solution in Python (and preferably boto library). | How to clone a key in Amazon S3 using Python (and boto)? | 0 | 0 | 1 | 9,405 |
1,464,961 | 2009-09-23T09:34:00.000 | 4 | 0 | 0 | 0 | python,amazon-s3,boto | 1,466,148 | 6 | false | 0 | 0 | Browsing through boto's source code I found that the Key object has a "copy" method. Thanks for your suggestion about CopyObject operation. | 3 | 17 | 0 | I have a file contained in a key in my S3 bucket. I want to create a new key, which will contain the same file. Is it possible to do without downloading that file?
I'm looking for a solution in Python (and preferably boto library). | How to clone a key in Amazon S3 using Python (and boto)? | 0.132549 | 0 | 1 | 9,405 |
1,464,961 | 2009-09-23T09:34:00.000 | 2 | 0 | 0 | 0 | python,amazon-s3,boto | 1,465,978 | 6 | false | 0 | 0 | S3 allows object by object copy.
The CopyObject operation creates a copy of an object when you specify the key and bucket of a source object and the key and bucket of a target destination.
Not sure if boto has a compact implementation. | 3 | 17 | 0 | I have a file contained in a key in my S3 bucket. I want to create a new key, which will contain the same file. Is it possible to do without downloading that file?
I'm looking for a solution in Python (and preferably boto library). | How to clone a key in Amazon S3 using Python (and boto)? | 0.066568 | 0 | 1 | 9,405 |
1,465,036 | 2009-09-23T09:53:00.000 | 25 | 0 | 1 | 1 | python,centos,rpath | 1,465,105 | 15 | false | 0 | 0 | No, that's it. You might want to make sure you have all optional library headers installed too so you don't have to recompile it later. They are listed in the documentation I think.
Also, you can install it even in the standard path if you do make altinstall. That way it won't override your current default "python". | 1 | 87 | 0 | I have a shell that runs CentOS.
For a project I'm doing, I need python 2.5+, but centOS is pretty dependent on 2.4.
From what I've read, a number of things will break if you upgrade to 2.5.
I want to install 2.5 separately from 2.4, but I'm not sure how to do it. So far I've downloaded the source tarball, untarred it, and did a ./configure --prefix=/opt which is where I want it to end up. Can I now just make, make install ? Or is there more? | Install python 2.6 in CentOS | 1 | 0 | 0 | 189,056 |
1,465,302 | 2009-09-23T10:56:00.000 | 2 | 0 | 1 | 0 | python,api | 1,465,505 | 2 | false | 0 | 0 | First, look at modules on pypi. Download several that are related to what you're doing so you can see exactly what the state of the art is.
For example, look at easy_install for an example of something like what you're proposing.
After looking at other modules, write yours to look like theirs.
Then publish information on your blog.
When people show an interest, post it to SourceForge or something similar. This will allow you to get started slowly.
When people start using it, you'll know exactly what kind of maintenance you need to do.
Then, when demand ramps up, you can create the pypi information required to publish it on pypi.
Finally, when it becomes so popular that people demand it be added to Python as a standard part of the library, many other folks will be involved in helping you mature your offering. | 1 | 4 | 0 | What steps would be necessary, and what kind of maintenance would be expected if I wanted to contribute a module to the Python standard API? For example I have a module that encapsulates automated update functionality similar to Java's JNLP. | What is involved in adding to the standard Python API? | 0.197375 | 0 | 1 | 129 |
1,465,769 | 2009-09-23T12:47:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,dns,subdomain | 1,480,797 | 5 | false | 1 | 0 | You can't do this, because you don't own no-ip.org. In order to use a domain with App Engine, you have to set up Google Apps on the domain, and in order to do that, you must own the domain.
As mentioned in the comments, buying your own domain is your best option. | 1 | 0 | 0 | I'd like to run an appengine app on a subdomain
like something.no-ip.org instead of something.appspot.com
is this doable? If so, can you please help me understand? :)
Thank you so much for your help! | appengine and no-ip.org | 0.039979 | 0 | 0 | 875 |
1,465,846 | 2009-09-23T13:01:00.000 | 7 | 0 | 0 | 0 | python,mysql,django,osx-snow-leopard | 6,537,345 | 8 | false | 1 | 0 | On MAC OS X 10.6, Install the package as usual. The dynamic import error occurs because of wrong DYLD path. Export the path and open up a python terminal.
$ sudo python setup.py clean
$ sudo python setup.py build
$ sudo python setup.py install
$ export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
$python
import MySQLdb
Now import MySQLdb should work fine.
You may also want to manually remove the build folder, before build and install. The clean command does not do a proper task of cleaning up the build files. | 1 | 7 | 0 | I am trying to get started on working with Python on Django I am by profession a PHP developer and have been told to set up django and python on my current apache and mysql setup however I am having trouble getting the Mysqldb module for python to work, I must of followed about 6 different set of instructions, I am running snow leopard and have mysql installed natively it is not part of MAMP or similar. Please can some tell me where I need to start and what steps I need to follew I would be most grateful.
Thanks | Install mysqldb on snow leopard | 1 | 1 | 0 | 7,786 |
1,466,917 | 2009-09-23T15:55:00.000 | 4 | 0 | 0 | 0 | python,abap,sap-basis,pyrfc | 1,467,921 | 7 | false | 0 | 0 | Sap is NOT a database server.
But with the Python SAP RFC module you can query most table quite easily. It is using some sap unsupported function ( that all the world is using). And this function has some limitation on field size and datatypes. | 2 | 36 | 0 | Can Python be used to query a SAP database? | Query SAP database from Python? | 0.113791 | 1 | 0 | 48,208 |
1,466,917 | 2009-09-23T15:55:00.000 | 1 | 0 | 0 | 0 | python,abap,sap-basis,pyrfc | 59,210,473 | 7 | false | 0 | 0 | Python is one of the most used object-oriented programming languages which is very easy to code and understand.
In order to use Python with SAP, we need to install Python SAP RFC module which is known as PyRFC. One of its available methods is RFC_READ_TABLE which can be called to read data from a table in SAP database.
Also, the PyRFC package provides various bindings which can be utilized to make calls either way. We can use to make calls either from ABAP modules to Python modules or the other way round. One can define equivalent SAP data types which are used in data exchange.
Also, we can create Web Service in Python which can be used for inter-communication. SAP NetWeaver is fully compatible with web services either state full or stateless. | 2 | 36 | 0 | Can Python be used to query a SAP database? | Query SAP database from Python? | 0.028564 | 1 | 0 | 48,208 |
1,467,827 | 2009-09-23T18:31:00.000 | 1 | 0 | 1 | 0 | python,jython,pydev | 1,849,587 | 2 | false | 0 | 0 | If you have a machine with more than one processor you could try starting eclipse/pydev with the options -vmargs -XX:+UseParallelGC You could also try different JVMs to see if any of them give better performance. | 2 | 3 | 0 | i'm working with pydev + jython.great ide , but quite slow when i try to run a jython program.
this is probably something due to libraries load time.
What can i do to speed it up ?
Thanks ,
yaniv | How do i make Pydev + jython to startup faster when running a script? | 0.099668 | 0 | 0 | 1,594 |
1,467,827 | 2009-09-23T18:31:00.000 | 2 | 0 | 1 | 0 | python,jython,pydev | 1,902,449 | 2 | false | 0 | 0 | Jython startup time is slow ... there's a lot to bootup!
Everytime you run a Jython script from scratch, it will incur the same Jython startup time cost.
Hence, the reason Jython, Java, and Python are not great for CGI invocations. Hence, the reason for mod_python in Apache.
The key is to start-up Jython once and reuse it. But this is not always possible especially during development because your modules are always changing and Jython does not recognize these changes automatically.
Jython needs a way to know which modules have changed for automatic reloads. This is not built into Jython and you'll have to rely on some other third party library to help with this. The concept is to remove from 'sys.modules' the modules which have changed. A simple solution is to just clear all the modules from sys.modules - which will cause all modules to be reloaded. This is obviously, not the most efficient solution.
Another tip is to only import modules that your module needs at the time that it 'really' needs them. If you import every module at the top of your modules, that will increase your module import cost. So, refactor imports to within methods/functions where they are needed and where it 'makes sense'. Of course, if your method/function is computation heavy and is used frequently, it does not make sence to import modules within that method/function.
Hopefully, that helps you out! | 2 | 3 | 0 | i'm working with pydev + jython.great ide , but quite slow when i try to run a jython program.
this is probably something due to libraries load time.
What can i do to speed it up ?
Thanks ,
yaniv | How do i make Pydev + jython to startup faster when running a script? | 0.197375 | 0 | 0 | 1,594 |
1,468,314 | 2009-09-23T20:20:00.000 | 1 | 0 | 0 | 1 | python,documentation,cross-platform,chm | 1,809,732 | 2 | false | 1 | 0 | wxHtmlHelpController doesn't support any scripting within pages, nor does it support css. | 1 | 0 | 0 | I am looking for a help viewer like Windows CHM that basically provides support for
adding content in HTML format
define Table of Contents
decent search
It should work on Windows, Mac and Linux. Bonus points for also having support for generating a "plain HTML/javascript" version that can be viewed in any browser (albeit without search support).
Language preference: Python | Cross-platform help viewer with search functionality | 0.099668 | 0 | 0 | 231 |
1,469,770 | 2009-09-24T04:26:00.000 | 1 | 1 | 0 | 0 | python,django,apache,fastcgi,lighttpd | 1,470,459 | 4 | false | 1 | 0 | Doesn't answer you question, but do you already use caching for your site? Like memcached? This might give you a better performance gain than going through the mess of switching webservers. | 1 | 3 | 0 | I am currently running a high-traffic python/django website using Apache and mod_wsgi. I'm hoping that there's a faster webserver configuration out there, and I've heard a fair number of recommendations for lighttpd and fastcgi. Is this setup faster than apache+mod_wsgi for serving dynamic django pages (I'm already convinced that lighttpd can server static files better)? The benchmarks online are either poorly conducted or inconclusive so I'm looking for some personal anecdotes. What architectural benefits does lighttpd + fastcgi provide? I understand that lighttpd uses epoll, and that a fastcgi process will be multithreaded. Also, having two separate processes, one for lighttpd and one for the python interpreter, will be largely beneficial.
I am aware of tornado and its ability to handle thousands of file descriptors with much fewer threads using epoll and callbacks. However, I'd prefer to stick with django for now.
Thanks,
Ken | Better webserver performance for Python Django: Apache mod_wsgi or Lighttpd fastcgi | 0.049958 | 0 | 0 | 3,952 |
1,470,453 | 2009-09-24T08:45:00.000 | 0 | 0 | 1 | 0 | python,wxpython,cpu-usage | 1,470,720 | 4 | false | 0 | 0 | This isn't very practical at a language-agnostic level. Take away the language and all you have left is a load of machine code instructions sprinkled around with system calls. You could use strace on Linux or ProcessExplorer on Windows to try and guess what is going on from those system calls, but it would make far more sense to just use a profiler. If you do have access to the language, then there are a variety of things you could do (extra logging, random pausing in the debugger) but in that situation the profiler is still your best tool. | 1 | 0 | 0 | I have a wxPython app which has many worker threads, idle event cycles, and many other such event handling code which can consume CPU, for now when app is not being interacted with consumes about 8-10% CPU.
Question:
Is there a tool which can tell which part/threads of my app is consuming most CPU? If there are no such generic tools, I am willing to know the approaches you usually take to tackle such scenarios? e.g. disabling part of app, trace etc
Edit: May be my question's language is ambiguous, I do not want to know which function or code block in my code takes up most resources, for that I can use profiler.
What I want to know is when I run my app, and I see cpu usage it is 8-10%, now is there a way to know what different parts, threads of my app are using up that 10% cpu?
Basically at that instant i want to know which part(s) of code is running? | How to check which part of app is consuming CPU? | 0 | 0 | 0 | 2,070 |
1,471,707 | 2009-09-24T13:32:00.000 | 2 | 0 | 0 | 0 | python,django | 1,472,013 | 2 | false | 1 | 0 | They way Django works is pretty much how Python works. At default the folder you create when you run django-admin.py startproject name is added to your python path. That means that anything you put into there you can get to. But you have to mind that when you write the app into the installed app list. If you have an app at project/apps/appname, you would have to write 'app.appname' in the installed apps list.
Now there are some ways to go about adding 3rd party apps located somewhere else to your project. You can either add them to your python path, put in your python path, or make a link to your python path. However, you can also add a sys.path.insert(...) in your manage.py file where you add the folder of your liking to your python path. Doing this will allow you to add folders to your python path for that project only, and will keep your python path more clean. | 1 | 0 | 0 | I run into this problem pretty consistently... keep in mind I am quite new to Django and a total Python amateur.
It seems that, for example, whenever I check out my Django project on a new computer after a clean install of Python and Django, it can never find the project/apps I create or copy in.
So right now I have an app that is working, and I downloaded a 3rd party Django module and installed it into my app directory, include it in my settings, and the web server quits because it cannot find the module.
This is the first time I've imported an third party module. In the past when it couldn't find modules I created, I would just rename the folder and run "manage.py startapp appname", delete the folder it created, and name my original folder back, boom, problem solved...
But that's obviously a hack, I am wondering if anyone can explain the the heck is going on here and how best to approach it.
I can't be the only one who has run into this, but I couldn't find any other questions on this site that seemed to match my issue.
Happens on both OS X and Windows 7. | Copying modules into Django, "No module named [moduleName]" | 0.197375 | 0 | 0 | 1,933 |
1,471,994 | 2009-09-24T14:16:00.000 | 122 | 0 | 1 | 0 | python,python-3.x,setup.py,pypi,python-packaging | 1,472,439 | 10 | false | 1 | 0 | setup.py is Python's answer to a multi-platform installer and make file.
If you’re familiar with command line installations, then make && make install translates to python setup.py build && python setup.py install.
Some packages are pure Python, and are only byte compiled. Others may contain native code, which will require a native compiler (like gcc or cl) and a Python interfacing module (like swig or pyrex). | 1 | 1,389 | 0 | Can anyone please explain what setup.py is and how it can be configured or used? | What is setup.py? | 1 | 0 | 0 | 905,751 |
1,473,888 | 2009-09-24T20:13:00.000 | 9 | 0 | 0 | 0 | python,django | 1,473,979 | 2 | true | 1 | 0 | There's currently no way of performing validation in model save methods. This is however being developed, as a separate model-validation branch, and should be merged into trunk in the next few months.
In the meantime, you need to do the validation at the form level. It's quite simple to create a ModelForm subclass with a clean() method which does your remote call and raises the exception accordingly, and use this both in the admin and as the basis for your other forms. | 1 | 12 | 0 | I need to raise an exception in a model's save method. I'm hoping that an exception exists that will be caught by any django ModelForm that uses this model including the admin forms.
I tried raising django.forms.ValidationError, but this seems to be uncaught by the admin forms. The model makes a remote procedure call at save time, and it's not known until this call if the input is valid.
Thanks, Pete | Raising ValidationError from django model's save method? | 1.2 | 0 | 0 | 13,039 |
1,475,637 | 2009-09-25T05:55:00.000 | 12 | 0 | 0 | 0 | java,python,binding | 1,475,717 | 6 | false | 0 | 1 | Interpreters Written in C89 with Reflection, Who Knew?
I have a feeling you are looking for an explanation of the mechanism and not a link to the API or instructions on how to code it. So, as I understand it . . .
The main interpreter is typically written in C and is dynamically linked. In a dynamically linked environment, even C89 has a certain amount of reflective behavior. In particular, the dlopen(3) and dlsym(3) calls will load a dynamic (typically ELF) library and look up the address of a symbol named by a string. Give that address, the interpreter can call a function. Even if statically linked, the interpreter can know the address of C functions whose names are compiled into it.
So then, it's just a simple matter of having the interpreted code tell the interpreter to call a particular native function in a particular native library.
The mechanism can be modular. An extension library for the interpreter, written in the script, can itself invoke the bare hooks for dlopen(3) and dlsym(3) and hook up to a new library that the interpreter never knew about.
For passing simple objects by value, a few prototype functions will typically allow various calls. But for structured data objects (imagine stat(2)) the wrapper module needs to know the layout of the data. At some point, either when packaging the extension module or when installing it, a C interface module includes the appropriate header files and in conjunction with handwritten code constructs an interface object. This is why you may need to install something like libsqlite3-dev even if you already had sqlite3 on your system; only the -dev package has the .h files needed to recompile the linkage code.
I suppose we could sum this up by saying: "it's done with brute force and ignorance". :-) | 1 | 16 | 0 | I'm far from a python expert but I hear this one all the time, about its C/C++ bindings. How does this concept work, and how does Python (and Java) bind to C-based APIs like OpenGL? This stuff has always been a mystery to me. | How do you bind a language (python, for example) to another (say, C++)? | 1 | 0 | 0 | 3,183 |
1,477,626 | 2009-09-25T14:28:00.000 | 1 | 0 | 1 | 0 | python,video,video-library | 1,481,018 | 5 | true | 0 | 0 | If you want your code to be REAL FAST, use C++ (or parallel fortran).
However in your application, 99% of the runtime isn't going to be in YOUR code, it's going to be in GUI libraries, OS calls, waiting for user interaction, calling libraries (written in C) to open video files and make thumbnails, that kind of stuff.
So using C++ will make your code 100 times faster, and your application will, as a result, be 1% faster, which is utterly useless. And if you write it in C++ you'll need months, whereas using Python you'll be finished much faster and have lots more fun.
Using C++ could even make it a lot slower, because in Python you can very easily build more scalable algorithms by using super powerful primitives like hashes, sets, generators, etc, try several algorithms in 5 minutes to see which one is the best, import a library which already does 90% of the work, etc.
Write it in Python. | 4 | 0 | 0 | I am thinking of creating a video library software which keep track of all my videos and keep track of videos that I already haven't watched and stats like this. The stats will be specific to each user using the software.
My question is, is python appropriate to create this software or do I need something like c++. | Would python be an appropriate choice for a video library for home use software | 1.2 | 0 | 0 | 247 |
1,477,626 | 2009-09-25T14:28:00.000 | 6 | 0 | 1 | 0 | python,video,video-library | 1,477,754 | 5 | false | 0 | 0 | Python is perfectly appropriate for such tasks - indeed the most popular video site, YouTube, is essentially programmed in Python (using, of course, lower-level components called from Python for such tasks as web serving, relational db, video transcoding -- there are plenty of such reusable opensource components for all these kinds of tasks, but your application's logic flow and all application-level logic can perfectly well be in Python).
Just yesterday evening, at the local Python interest group meeting in Mountain View, we had new members who just moved to Silicon Valley exactly to take Python-based jobs in the video industry, and they were saying that professional level video handing in the industry is also veering more and more towards Python -- stalwarts like Pixar and ILM had been using Python forever, but in the last year or two it's been a flood of Python adoption in the industry. | 4 | 0 | 0 | I am thinking of creating a video library software which keep track of all my videos and keep track of videos that I already haven't watched and stats like this. The stats will be specific to each user using the software.
My question is, is python appropriate to create this software or do I need something like c++. | Would python be an appropriate choice for a video library for home use software | 1 | 0 | 0 | 247 |
1,477,626 | 2009-09-25T14:28:00.000 | 1 | 0 | 1 | 0 | python,video,video-library | 1,477,733 | 5 | false | 0 | 0 | Yes. Python is much easier to use than c++ for something like this. You may want to use it as a front-end to a DB such as sqlite3 | 4 | 0 | 0 | I am thinking of creating a video library software which keep track of all my videos and keep track of videos that I already haven't watched and stats like this. The stats will be specific to each user using the software.
My question is, is python appropriate to create this software or do I need something like c++. | Would python be an appropriate choice for a video library for home use software | 0.039979 | 0 | 0 | 247 |
1,477,626 | 2009-09-25T14:28:00.000 | 1 | 0 | 1 | 0 | python,video,video-library | 1,478,325 | 5 | false | 0 | 0 | Of course you can use almost any programming language for almost any task. But after noting that, it's also obvious that different languages are also differently well adapted for different tasks.
C/C++ are languages that are very "hardware friendly". Basically, the languages are just one abstraction level above assembler, with C's use of pointers etc. C++ is almost like a (semi-)portable object oriented assembler, if one wants to be funny. :) This makes C/C++ fast and good at talking to hardware.
But those same features become mis-features in other cases. The pointers make it possible to walk all over the memory and unless you are careful you will leak memory all over the place. So I would say (and now C people will get angry) that C/C++ in fact are directly inappropriate for what you want to do.
You want a language that are higher, does more things like memory management automatically and invisibly. There are many to choose from there, but without a doubt Python is eminently suited for this. Python has the last couple of years emerged as The New Cool Language to write these kind of softwares in, and much multimedia software such as Freevo and the already mentioned Moovida are written in Python. | 4 | 0 | 0 | I am thinking of creating a video library software which keep track of all my videos and keep track of videos that I already haven't watched and stats like this. The stats will be specific to each user using the software.
My question is, is python appropriate to create this software or do I need something like c++. | Would python be an appropriate choice for a video library for home use software | 0.039979 | 0 | 0 | 247 |
1,479,035 | 2009-09-25T19:02:00.000 | 4 | 0 | 1 | 0 | python,file,undo | 1,479,049 | 5 | false | 0 | 0 | Try to write to your files lazily: Don't write until you are finally certain you need to do it. | 1 | 3 | 0 | What is the best way to undo the writing to a file? If I'm going through a loop and writing one line at a time, and I want to undo the previous write and replace it with something else, how do I go about doing that? Any ideas?
Thanks in advance! | Python: undo write to file | 0.158649 | 0 | 0 | 3,715 |
1,479,454 | 2009-09-25T20:33:00.000 | 0 | 1 | 1 | 0 | python,ironpython | 1,480,581 | 5 | false | 0 | 0 | If you'd like to disable certain built-in modules I'd suggest filing a feature request over at ironpython.codeplex.com. This should be an easy enough thing to implement.
Otherwise you could simply look at either Importer.cs and disallow the import there or you could simply delete ClrModule.cs from IronPython and re-build (and potentially remove any references to it). | 3 | 4 | 0 | I'm setting up a web application to use IronPython for scripting various user actions and I'll be exposing various business objects ready for accessing by the script. I want to make it impossible for the user to import the CLR or other assemblies in order to keep the script's capabilities simple and restricted to the functionality I expose in my business objects.
How do I prevent the CLR and other assemblies/modules from being imported? | IronPython - How to prevent CLR (and other modules) from being imported | 0 | 0 | 0 | 996 |
1,479,454 | 2009-09-25T20:33:00.000 | 0 | 1 | 1 | 0 | python,ironpython | 59,887,790 | 5 | false | 0 | 0 | In case anyone comes across this thread from google still (like i did)
I managed to disable 'import clr' in python scripts by commenting out the line
//[assembly: PythonModule("clr", typeof(IronPython.Runtime.ClrModule))]
in ClrModule.cs, but i'm not convinced this is a full solution to preventing unwanted access, since you will still need to override things like the file builtin. | 3 | 4 | 0 | I'm setting up a web application to use IronPython for scripting various user actions and I'll be exposing various business objects ready for accessing by the script. I want to make it impossible for the user to import the CLR or other assemblies in order to keep the script's capabilities simple and restricted to the functionality I expose in my business objects.
How do I prevent the CLR and other assemblies/modules from being imported? | IronPython - How to prevent CLR (and other modules) from being imported | 0 | 0 | 0 | 996 |
1,479,454 | 2009-09-25T20:33:00.000 | 1 | 1 | 1 | 0 | python,ironpython | 1,479,480 | 5 | true | 0 | 0 | You'll have to search the script for the imports you don't want them to use, and reject the script in toto if it contains any of them.
Basically, just reject the script if it contains Assembly.Load, import or AddReference. | 3 | 4 | 0 | I'm setting up a web application to use IronPython for scripting various user actions and I'll be exposing various business objects ready for accessing by the script. I want to make it impossible for the user to import the CLR or other assemblies in order to keep the script's capabilities simple and restricted to the functionality I expose in my business objects.
How do I prevent the CLR and other assemblies/modules from being imported? | IronPython - How to prevent CLR (and other modules) from being imported | 1.2 | 0 | 0 | 996 |
1,480,431 | 2009-09-26T04:23:00.000 | 7 | 0 | 1 | 0 | python,image-processing,video-processing | 1,480,450 | 4 | true | 0 | 0 | Do you mean opencv can't connect to your webcam or can't read video files recorded by it?
Have you tried saving the video in an other format?
OpenCV is probably the best supported python image processing tool | 2 | 13 | 1 | I need to:
Open a video file
Iterate over the frames of the file as images
Do some analysis in this image frame of the video
Draw in this image of the video
Create a new video with these changes
OpenCV isn't working for my webcam, but python-gst is working. Is this possible using python-gst?
Thank you! | Most used Python module for video processing? | 1.2 | 0 | 0 | 12,979 |
1,480,431 | 2009-09-26T04:23:00.000 | 0 | 0 | 1 | 0 | python,image-processing,video-processing | 1,497,418 | 4 | false | 0 | 0 | Just build a C/C++ wrapper for your webcam and then use SWIG or SIP to access these functions from Python. Then use OpenCV in Python that's the best open sourced computer vision library in the wild.
If you worry for performance and you work under Linux, you could download free versions of Intel Performance Primitives (IPP) that could be loaded at runtime with zero effort from OpenCV. For certain algorithms you could get a 200% boost of performances, plus automatic multicore support for most of time consuming functions. | 2 | 13 | 1 | I need to:
Open a video file
Iterate over the frames of the file as images
Do some analysis in this image frame of the video
Draw in this image of the video
Create a new video with these changes
OpenCV isn't working for my webcam, but python-gst is working. Is this possible using python-gst?
Thank you! | Most used Python module for video processing? | 0 | 0 | 0 | 12,979 |
1,480,453 | 2009-09-26T04:51:00.000 | 12 | 1 | 0 | 0 | python,phpmyadmin | 1,480,549 | 4 | false | 0 | 0 | You can use phpMyAdmin for python project, because phpMyAdmin is meant for MySQL databases. If you are using MySQL, then regardless of whether you are using PHP or python, you can use phpMyAdmin. | 1 | 33 | 0 | Is there a python equivalent of phpMyAdmin?
Here's why I'm looking for a python version of phpmyadmin: While I agree that phpmyadmin really rocks, I don't want to run php on my server. I'd like to move from apache2-prefork to apache2-mpm-worker. Worker blows the doors off of prefork for performance, but php5 doesn't work with worker. (Technically it does, but it's far more complicated.) The extra memory and performance penalty for having php on this server is large to me. | phpMyAdmin equivalent in python? | 1 | 1 | 0 | 23,600 |
1,480,490 | 2009-09-26T05:28:00.000 | 1 | 0 | 1 | 0 | c++,python,multithreading,python-c-api,python-embedding | 1,515,293 | 6 | false | 0 | 0 | I don't think you are the first person to want to do this, unfortunately I believe it is not possible. Are you able to run the python interperters as separate processes and use RPC? | 3 | 9 | 0 | I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.
Can I wrap Python interpreter in to a c++ class and get services from two or more class instances? | Python interpreter as a c++ class | 0.033321 | 0 | 0 | 3,558 |
1,480,490 | 2009-09-26T05:28:00.000 | 4 | 0 | 1 | 0 | c++,python,multithreading,python-c-api,python-embedding | 1,480,578 | 6 | false | 0 | 0 | You can, but I'd recommend you not to re-implement a Python interpreter when there is a standard implementation. Use boost::python to interface with Python. | 3 | 9 | 0 | I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.
Can I wrap Python interpreter in to a c++ class and get services from two or more class instances? | Python interpreter as a c++ class | 0.132549 | 0 | 0 | 3,558 |
1,480,490 | 2009-09-26T05:28:00.000 | 0 | 0 | 1 | 0 | c++,python,multithreading,python-c-api,python-embedding | 1,518,878 | 6 | false | 0 | 0 | You can let the python interpreter live outside of your application memory space. Just embed the interpreter in a DLL.
You can set up & save python contexts to simulate two different interpreters. | 3 | 9 | 0 | I am working on embedding python in to c++. In some peculiar case I require two separate instances of the interpreter in same thread.
Can I wrap Python interpreter in to a c++ class and get services from two or more class instances? | Python interpreter as a c++ class | 0 | 0 | 0 | 3,558 |
1,481,309 | 2009-09-26T14:17:00.000 | 0 | 0 | 1 | 0 | python,apache,windows-xp | 1,481,329 | 2 | false | 0 | 0 | If you are starting Python today, why tackle web development immediately? I'd start off with "hello world" in the console. | 1 | 2 | 0 | I am starting python today. It will be my pleasure to have your help. | how to configure apache on XP for python 2.6.2 and what do you prefer, python with framework/without? | 0 | 0 | 0 | 121 |
1,482,282 | 2009-09-26T21:55:00.000 | 15 | 0 | 0 | 0 | java,python,hadoop | 1,482,294 | 3 | true | 1 | 0 | Java is less dynamic than Python and more effort has been put into its VM, making it a faster language. Python is also held back by its Global Interpreter Lock, meaning it cannot push threads of a single process onto different core.
Whether this makes any significant difference depends on what you intend to do. I suspect both languages will work for you. | 1 | 53 | 0 | I am working on a project using Hadoop and it seems to natively incorporate Java and provide streaming support for Python. Is there is a significant performance impact to choosing one over the other? I am early enough in the process where I can go either way if there is a significant performance difference one way or the other. | Java vs Python on Hadoop | 1.2 | 0 | 0 | 40,609 |
1,482,627 | 2009-09-27T02:19:00.000 | 0 | 0 | 0 | 0 | python,sqlalchemy,pylons | 1,483,061 | 3 | false | 0 | 0 | Just import your other table's modules in your init.py, and use metadata object from models.meta in other files. Pylons default setup_app function creates all tables found in metadata object from model.meta after importing it. | 3 | 3 | 0 | I'm using SQLAlchemy and I can create tables that I have defined in /model/__init__.py but I have defined my classes, tables and their mappings in other files found in the /model directory.
For example I have a profile class and a profile table which are defined and mapped in /model/profile.py
To create the tables I run:
paster setup-app development.ini
But my problem is that the tables that I have defined in /model/__init__.py are created properly but the table definitions found in /model/profile.py are not created. How can I execute the table definitions found in the /model/profile.py so that all my tables can be created?
Thanks for the help! | Creating tables with pylons and SQLAlchemy | 0 | 1 | 0 | 1,155 |
1,482,627 | 2009-09-27T02:19:00.000 | 5 | 0 | 0 | 0 | python,sqlalchemy,pylons | 1,528,312 | 3 | false | 0 | 0 | I ran into the same problem with my first real Pylons project. The solution that worked for me was this:
Define tables and classes in your profile.py file
In your __init__.py add from profile import * after your def init_model
I then added all of my mapper definitions afterwards. Keeping them all in the init file solved some problems I was having relating between tables defined in different files.
Also, I've since created projects using the declarative method and didn't need to define the mapping in the init file. | 3 | 3 | 0 | I'm using SQLAlchemy and I can create tables that I have defined in /model/__init__.py but I have defined my classes, tables and their mappings in other files found in the /model directory.
For example I have a profile class and a profile table which are defined and mapped in /model/profile.py
To create the tables I run:
paster setup-app development.ini
But my problem is that the tables that I have defined in /model/__init__.py are created properly but the table definitions found in /model/profile.py are not created. How can I execute the table definitions found in the /model/profile.py so that all my tables can be created?
Thanks for the help! | Creating tables with pylons and SQLAlchemy | 0.321513 | 1 | 0 | 1,155 |
1,482,627 | 2009-09-27T02:19:00.000 | 0 | 0 | 0 | 0 | python,sqlalchemy,pylons | 1,485,719 | 3 | false | 0 | 0 | If you are using declarative style, be sure to use Base.meta for tables generation. | 3 | 3 | 0 | I'm using SQLAlchemy and I can create tables that I have defined in /model/__init__.py but I have defined my classes, tables and their mappings in other files found in the /model directory.
For example I have a profile class and a profile table which are defined and mapped in /model/profile.py
To create the tables I run:
paster setup-app development.ini
But my problem is that the tables that I have defined in /model/__init__.py are created properly but the table definitions found in /model/profile.py are not created. How can I execute the table definitions found in the /model/profile.py so that all my tables can be created?
Thanks for the help! | Creating tables with pylons and SQLAlchemy | 0 | 1 | 0 | 1,155 |
1,482,953 | 2009-09-27T06:50:00.000 | 3 | 0 | 0 | 0 | python,ruby,game-engine | 1,483,914 | 3 | false | 1 | 0 | I have worked a little bit with Panda3D, and it is a competent professional 3D engine. I haven't really worked with any of the other engines, though. If you are trying to start out with some 3D programming, I would recommend Blender3D because it is coupled with free 3D modeling software, which makes it easier to get models into your code. With Panda3D you will need to download and install an extension to allow you to export 3D models from software into a format the engine can recognize.
I have only used Panda3D, so I cannot compare the merits of the engines. From my basic knowledge (very basic), I would say that Blender3D is a good start. | 2 | 4 | 0 | Are there any 3d game engines for these ? | 3d game engines for Ruby or Python? | 0.197375 | 0 | 0 | 1,768 |
1,482,953 | 2009-09-27T06:50:00.000 | 1 | 0 | 0 | 0 | python,ruby,game-engine | 11,091,017 | 3 | false | 1 | 0 | Personally, i like to use pygame. Its easy, free and fast. | 2 | 4 | 0 | Are there any 3d game engines for these ? | 3d game engines for Ruby or Python? | 0.066568 | 0 | 0 | 1,768 |
1,483,024 | 2009-09-27T07:31:00.000 | 1 | 0 | 0 | 0 | python,mysql | 1,483,154 | 5 | false | 0 | 0 | What it needs is the client library and headers that come with the server, since it just a Python wrapper (which sits in _mysql.c; and DB-API interface to that wrapper in MySQLdb package) over original C MySQL API. | 3 | 1 | 0 | I been working on finding out how to install MySQLdb module for Python on Mac. And all pathes finally come cross to have MySQL installed since there is a mysql_config needed for the module. But I don't understand why it has to be needed?
MySQLdb suppose to be a client module for the client who wants to connect to the server. But now I have to first install a server on the client in order to connect to another server? | Why MySQLdb for Mac has to have MySQL installed to install? | 0.039979 | 1 | 0 | 432 |
1,483,024 | 2009-09-27T07:31:00.000 | 1 | 0 | 0 | 0 | python,mysql | 1,483,030 | 5 | false | 0 | 0 | I'm not sure about the specifics of MySQLdb, but most likely it needs header information to compile/install. It uses the location of mysql_config to know where the appropriate headers would be. The MySQL Gem for Ruby on Rails requires the same thing, even though it simply connects to the MySQL server. | 3 | 1 | 0 | I been working on finding out how to install MySQLdb module for Python on Mac. And all pathes finally come cross to have MySQL installed since there is a mysql_config needed for the module. But I don't understand why it has to be needed?
MySQLdb suppose to be a client module for the client who wants to connect to the server. But now I have to first install a server on the client in order to connect to another server? | Why MySQLdb for Mac has to have MySQL installed to install? | 0.039979 | 1 | 0 | 432 |
1,483,024 | 2009-09-27T07:31:00.000 | 1 | 0 | 0 | 0 | python,mysql | 1,483,305 | 5 | false | 0 | 0 | Just to clarify what the other answerers have said: you don't need to install a MySQL server, but you do need to install the MySQL client libraries. However, for whatever reasons, MySQL don't make a separate download available for just the client libraries, as they do for Linux. | 3 | 1 | 0 | I been working on finding out how to install MySQLdb module for Python on Mac. And all pathes finally come cross to have MySQL installed since there is a mysql_config needed for the module. But I don't understand why it has to be needed?
MySQLdb suppose to be a client module for the client who wants to connect to the server. But now I have to first install a server on the client in order to connect to another server? | Why MySQLdb for Mac has to have MySQL installed to install? | 0.039979 | 1 | 0 | 432 |
1,483,685 | 2009-09-27T14:31:00.000 | 1 | 0 | 0 | 0 | python | 1,483,720 | 6 | false | 1 | 0 | Obfuscation is false security. And the only thing worse than no security is false security. Why would you obfuscate a web app anyways?
Python is compiled to bytecode and run on a virtual machine, but usually distributed as source code.
Unless you really plan to run your webapp on "pretty much every web host" that question doesn't matter. There are many good hosts that support python and django. | 3 | 3 | 0 | Just looking into python from a .net background.
Is python compiled like .net?
If yes, can it be obfuscated and is it more or less secure than .net compiled code that is obfuscated?
does pretty much every web host (unix) support django and python? | python _+ django, is it compiled code? | 0.033321 | 0 | 0 | 7,736 |
1,483,685 | 2009-09-27T14:31:00.000 | 2 | 0 | 0 | 0 | python | 1,483,820 | 6 | false | 1 | 0 | You shouldn't have to worry about obfuscating your code, specially since it's going to run on your server.
You are not supposed to put your code in a public directory anyway. The right thing to do with django (as oposed to PHP) is to make the code accessible by the webserver, but not by the public.
And if your server's security has been breached, then you have other things to worry about... | 3 | 3 | 0 | Just looking into python from a .net background.
Is python compiled like .net?
If yes, can it be obfuscated and is it more or less secure than .net compiled code that is obfuscated?
does pretty much every web host (unix) support django and python? | python _+ django, is it compiled code? | 0.066568 | 0 | 0 | 7,736 |
1,483,685 | 2009-09-27T14:31:00.000 | 0 | 0 | 0 | 0 | python | 1,483,846 | 6 | false | 1 | 0 | Code obfuscation in .NET are mostly a question of changing variable names to make it harder to understand the disassembled code. Yes, you can do those techniques with CPython too.
Now, why ever you would want to is another question completely. It doesn't actually provide you with any security, and does not prevent anybody from stealing your software. | 3 | 3 | 0 | Just looking into python from a .net background.
Is python compiled like .net?
If yes, can it be obfuscated and is it more or less secure than .net compiled code that is obfuscated?
does pretty much every web host (unix) support django and python? | python _+ django, is it compiled code? | 0 | 0 | 0 | 7,736 |
1,484,293 | 2009-09-27T19:48:00.000 | 4 | 0 | 0 | 0 | python,django,unit-testing,nose | 1,484,428 | 1 | true | 1 | 0 | You do need DJANGO_SETTINGS_MODULE defined in order to run core.py -- why don't you just export DJANGO_SETTINGS_MODULE=whatever in your bash session before starting nose? | 1 | 2 | 0 | I'm trying to do TDD with PyMock, but I keep getting error when I use Nose and execute core.py from command line:
"ERROR: Failure: ImportError (Settings cannot be imported, because environment variable DJA
NGO_SETTINGS_MODULE is undefined.)"
If I remove "from cms.models import Entry" from the unit test module I created, everything works fine, but I need to mock functionality in django module cms.models.Entry that I created.
What am I doing wrong? Can this be done? | How do I use PyMock and Nose with Django models? | 1.2 | 0 | 0 | 1,276 |
1,484,658 | 2009-09-27T22:32:00.000 | 0 | 0 | 0 | 0 | python,simulation | 1,486,960 | 8 | false | 0 | 0 | Just use Stackless Python, create tasklets, connect them with channels, and everything will work. It is extremely simple. | 3 | 6 | 0 | I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other. | How to build a mini-network of small programs feeding each other data? | 0 | 0 | 0 | 1,261 |
1,484,658 | 2009-09-27T22:32:00.000 | 0 | 0 | 0 | 0 | python,simulation | 1,484,763 | 8 | false | 0 | 0 | Two things come to mind:
1- You could write one or more daemons with Twisted Python. (Be warned, twisted can get a little overwhelming , since its an event-driven async system ). Each daemon can bind to a port and make itself available to other daemons. Alternately, you could just run everything within one daemon, and just have each "process" that you script fire at a different interval.. and talk to one another through bound ports as well.
2- You could use a single event driven core -- there are a few --, and just fork a bunch of processes or threads for each task. | 3 | 6 | 0 | I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other. | How to build a mini-network of small programs feeding each other data? | 0 | 0 | 0 | 1,261 |
1,484,658 | 2009-09-27T22:32:00.000 | 5 | 0 | 0 | 0 | python,simulation | 1,484,705 | 8 | true | 0 | 0 | Stick with traditional simulation structures, at least at first
Is it your goal to write an asynchronous system as an exercise? If so, then I guess you have to implement at least a multi-threaded if not multi-process or network system.
But if it's really a simulation, and what you want are the analysis results, implementing an actual distributed model would be a horribly complex approach that is likely to yield far less data than an abstract simulation would, that is, the simulation itself doesn't have to be a network of asynchronous actors communicating. That would just be a good way to make the problem so hard it won't get solved.
I say, stick with the traditional simulation architecture.
The Classic Discrete Event Simulation
The way this works is that as a central data structure you have a sorted collection of pending events. The events are naturally sorted by increasing time.
The program has a main loop, where it takes the next (i.e., the lowest-valued) event out of the collection, advances the simulation clock to the time of this event, and then calls any task-specific processing associated with the event.
But, you ask, what if something was supposed to happen in the time delta that the simulator just jumped across? Well, by definition, there was nothing. If an individual element of the simulation needed something to happen in that interval, it was responsible for allocating an event and inserting it into the (sorted) collection.
While there are many packages and programs out there that are geared to simulation, the guts of a simulation are not that hard, and it's perfectly reasonable to write it up from scratch in your favorite language.
Have fun! | 3 | 6 | 0 | I'm trying to simulate a real-time network where nodes are consumers and producers of different rates. How would I quickly implement a sample of this with Python? I was imagining that I'd write a simple program for each node, but I'm not sure how to connect them to each other. | How to build a mini-network of small programs feeding each other data? | 1.2 | 0 | 0 | 1,261 |
1,487,450 | 2009-09-28T14:45:00.000 | 1 | 1 | 0 | 1 | python,date,scripting | 1,487,702 | 1 | true | 0 | 0 | I would suggest using Python. You'll need the following functions:
os.listdir gives you the directory contents, as a list of strings
time.strptime(name, "%d-%m-%y") will try to parse such a string, and return a time tuple. You get a ValueError exception if parsing fails.
time.mktime will convert a time tuple into seconds since the epoch.
time.time returns seconds since the epoch
the smtplib module can send emails, assuming you know what SMTP server to use. Alternatively, you can run /usr/lib/sendmail, through the subprocess module (assuming /usr/lib/sendmail is correctly configured) | 1 | 0 | 0 | I would like to write a small script that does the following (and that I can then run using my crontab):
Look into a directory that contains directories whose names are in some date format, e.g. 30-10-09.
Convert the directory name to the date it represents (of course, I could put this information as a string into a file in these directories, that doesn't matter to me).
Compare each date with the current system time and find the one that has a specific time difference to the current system date, e.g. less than two days.
Then, do something with the files in that directory (e.g., paste them together and send an email).
I know a little bash scripting, but I don't know whether bash can itself handle this. I think I could do this in R, but the server where this needs to run doesn't have R.
I'm curious anyway to learn a little bit of either Python or Ruby (both of which are on the server).
Can someone point me in the right direction what might be the best way to do this? | Time difference between system date and string, e.g. from directory name? | 1.2 | 0 | 0 | 289 |
1,487,582 | 2009-09-28T15:08:00.000 | 2 | 0 | 0 | 0 | python,sockets,udp | 1,487,619 | 3 | false | 0 | 0 | What you receive from the udp socket is a byte string -- that's all the "type of object or class name" that's actually there. If the byte string was built as a serialized object (e.g. via pickle, or maybe marshal etc) then you can deserialize it back to an object (using e.g. pickle.loads) and then introspect to your heart's content. But most byte strings were built otherwise and will raise exceptions when you try to loads from them;-).
Edit: the OP's edit mentions the string is "a serialized object" but still doesn't say what serialization approach produced it, and that makes all the difference. pickle (and for a much narrower range of type marshal) place enough information on the strings they produce (via the .dumps functions of the modules) that their respective loads functions can deserialize back to the appropriate type; but other approaches (e.g., struct.pack) do not place such metadata in the strings they produce, so it's not feasible to deserialize without other, "out of bands" so to speak, indications about the format in use. So, o O.P., how was that serialized string of bytes produced in the first place...? | 2 | 1 | 0 | Is it possible to extract type of object or class name from message received on a udp socket in python using metaclasses/reflection ?
The scenario is like this:
Receive udp buffer on a socket.
The UDP buffer is a serialized binary string(a message). But the type of message is not known at this time. So can't de-serialize into appropriate message.
Now, my ques is Can I know the classname of the seraialized binary string(recvd as UDP buffer) so that I can de-serialize into appropriate message and process further.
Thanks in Advance. | Type of object from udp buffer in python using metaclasses/reflection | 0.132549 | 0 | 1 | 642 |
1,487,582 | 2009-09-28T15:08:00.000 | 0 | 0 | 0 | 0 | python,sockets,udp | 1,487,602 | 3 | false | 0 | 0 | Updated answer after updated question:
"But the type of message is not known at this time. So can't de-serialize into appropriate message."
What you get is a sequence of bytes. How that sequence of types should be interpreted is a question of how the protocol looks. Only you know what protocol you use. So if you don't know the type of message, then there is nothing you can do about it. If you are to receive a stream of data an interpret it, you must know what that data means, otherwise you can't interpret it.
It's as simple as that.
"Now, my ques is Can I know the classname of the seraialized binary string"
Yes. The classname is "str", as all strings. (Unless you use Python 3, in which case you would not get a str but a binary). The data inside that str has no classname. It's just binary data. It means whatever the sender wants it to mean.
Again, I need to stress that you should not try to make this into a generic question. Explain exactly what you are trying to do, not generically, but specifically. | 2 | 1 | 0 | Is it possible to extract type of object or class name from message received on a udp socket in python using metaclasses/reflection ?
The scenario is like this:
Receive udp buffer on a socket.
The UDP buffer is a serialized binary string(a message). But the type of message is not known at this time. So can't de-serialize into appropriate message.
Now, my ques is Can I know the classname of the seraialized binary string(recvd as UDP buffer) so that I can de-serialize into appropriate message and process further.
Thanks in Advance. | Type of object from udp buffer in python using metaclasses/reflection | 0 | 0 | 1 | 642 |
1,488,372 | 2009-09-28T17:41:00.000 | 14 | 0 | 0 | 0 | python,c,string,fgets | 1,488,403 | 4 | false | 0 | 0 | Python strings' strip method removes both trailing and leading whitespace. The two halves of the problem are very different when working on a C "string" (array of char, \0 terminated).
For trailing whitespace: set a pointer (or equivalently index) to the existing trailing \0. Keep decrementing the pointer until it hits against the start-of-string, or any non-white character; set the \0 to right after this terminate-backwards-scan point.
For leading whitespace: set a pointer (or equivalently index) to the start of string; keep incrementing the pointer until it hits a non-white character (possibly the trailing \0); memmove the rest-of-string so that the first non-white goes to the start of string (and similarly for everything following). | 1 | 6 | 0 | I started on a little toy project in C lately and have been scratching my head over the best way to mimic the strip() functionality that is part of the python string objects.
Reading around for fscanf or sscanf says that the string is processed upto the first whitespace that is encountered.
fgets doesn't help either as I still have newlines sticking around.
I did try a strchr() to search for a whitespace and setting the returned pointer to '\0' explicitly but that doesn't seem to work. | Mimic Python's strip() function in C | 1 | 0 | 0 | 14,808 |
1,489,355 | 2009-09-28T21:02:00.000 | 1 | 1 | 1 | 0 | python,perl,transitions | 1,489,635 | 5 | false | 0 | 0 | In python $_ does not exist except in the python shell and variables with global scope are frowned upon.
In practice this has two major effects:
In Python you can't use regular expressions as naturally as Perl, s0 matching each iterated $_ and similarly catching matches is more cumbersome
Python functions tend to be called explicitly or have default variables
However these differences are fairly minor when one considers that in Python just about everything becomes a class. When I used to do Perl I thought of "carving"; in Python I rather feel I am "composing".
Python doesn't have the idiomatic richness of Perl and I think it is probably a mistake to attempt to do the translation. | 1 | 6 | 0 | Perl habits die hard. Variable declaration, scoping, global/local is different between the 2 languages. Is there a set of recommended python language idioms that will render the transition from perl coding to python coding less painful.
Subtle variable misspelling can waste an extraordinary amount of time.
I understand the variable declaration issue is quasi-religious among python folks
I'm not arguing for language changes or features, just a reliable bridge between
the 2 languages that will not cause my perl habits sink my python efforts.
Thanks. | Managing Perl habits in a Python environment | 0.039979 | 0 | 0 | 539 |
1,489,599 | 2009-09-28T22:01:00.000 | 0 | 1 | 1 | 1 | python,python-module,pythonpath | 62,773,911 | 10 | false | 0 | 0 | If using conda, you can get the env prefix using os.environ["CONDA_PREFIX"]. | 1 | 447 | 0 | How do I find out which directories are listed in my system’s PYTHONPATH variable, from within a Python script (or the interactive shell)? | How do I find out my PYTHONPATH using Python? | 0 | 0 | 0 | 822,516 |
1,489,931 | 2009-09-29T00:02:00.000 | 0 | 0 | 0 | 0 | python,flash,twisted | 1,490,530 | 2 | false | 0 | 0 | I find out that the default delimiter for line, use by Twisted is '\r\n'. It can be overwrite in a your children class with:
LineOnlyReceiver.delimiter = '\n' | 2 | 1 | 0 | I've develop a chat server using Twisted framework in Python. It works fine with a Telnet client. But when I use my flash client problem appear...
(the flash client work find with my old php chat server, I rewrote the server in python to gain performance)
The connexion is establish between the flash client and the twisted server: XMLSocket .onConnect return TRUE. So it's not a problem of permission with the policy file.
I'm not able to send any message from Flash clien with XMLSOCket function send(), nothing is receive on th server side. I tried to end those message with '\n' or '\n\0' or '\0' without succes.
You have any clue? | Chat server with Twisted framework in python can't receive data from flash client | 0 | 0 | 1 | 927 |
1,489,931 | 2009-09-29T00:02:00.000 | 1 | 0 | 0 | 0 | python,flash,twisted | 1,729,776 | 2 | true | 0 | 0 | Changing LineOnlyReceiver.delimiter is a pretty bad idea, since that changes the delivery for all instances of LineOnlyReceiver (unless they've changed it themselves on a subclass or on the instance). If you ever happen to use any such code, it will probably break.
You should change delimiter by setting it on your LineOnlyReceiver subclass, since it's your subclass that has this requirement. | 2 | 1 | 0 | I've develop a chat server using Twisted framework in Python. It works fine with a Telnet client. But when I use my flash client problem appear...
(the flash client work find with my old php chat server, I rewrote the server in python to gain performance)
The connexion is establish between the flash client and the twisted server: XMLSocket .onConnect return TRUE. So it's not a problem of permission with the policy file.
I'm not able to send any message from Flash clien with XMLSOCket function send(), nothing is receive on th server side. I tried to end those message with '\n' or '\n\0' or '\0' without succes.
You have any clue? | Chat server with Twisted framework in python can't receive data from flash client | 1.2 | 0 | 1 | 927 |
1,489,949 | 2009-09-29T00:09:00.000 | 2 | 1 | 0 | 0 | python,xml,elementtree | 1,490,057 | 5 | false | 0 | 0 | Yeah, I don't believe it's possible, sorry. ElementTree provides a simpler interface to (non-namespaced) element-centric XML processing than DOM, but the price for that is that it doesn't support the whole XML infoset.
There is no apparent way to represent the content that lives outside the root element (comments, PIs, the doctype and the XML declaration), and these are also discarded at parse time. (Aside: this appears to include any default attributes specified in the DTD internal subset, which makes ElementTree strictly-speaking a non-compliant XML processor.)
You can probably work around it by subclassing or monkey-patching the Python native ElementTree implementation's write() method to call _write on your extra PIs before _writeing the _root, but it could be a bit fragile.
If you need support for the full XML infoset, probably best stick with DOM. | 1 | 6 | 0 | I'm trying to create XML using the ElementTree object structure in python. It all works very well except when it comes to processing instructions. I can create a PI easily using the factory function ProcessingInstruction(), but it doesn't get added into the elementtree. I can add it manually, but I can't figure out how to add it above the root element where PI's are normally placed. Anyone know how to do this? I know of plenty of alternative methods of doing it, but it seems that this must be built in somewhere that I just can't find. | ElementTree in Python 2.6.2 Processing Instructions support? | 0.07983 | 0 | 1 | 4,332 |
1,490,559 | 2009-09-29T04:23:00.000 | 6 | 0 | 0 | 0 | python,django,url,slug,collision | 1,492,882 | 4 | true | 1 | 0 | One thing I never liked about the unique slug fields/methods is that if you have a lot of clashes for a single title, you'll end up running several queries to try and determine an available slug. I know you mentioned you don't want to show the id for non-clashing slugs, but, as far as performance, I think it's the better route to take. To make the URL a little nicer looking, I prefer also to embed the id before the slug, so that a URL takes the form of www.example.com/reviews/1/the-best-thing-ever. | 2 | 7 | 0 | I'm currently working on a toy project in Django.
Part of my app allows users to leave reviews. I'd like to take the title of the review and slugify it to create a url.
So, if a user writes a review called "The best thing ever!", the url would be something like: www.example.com/reviews/the-best-thing-ever.
That's all well and good, but what is the best way to handle case where two users pick the same title? I don't want to make the title required to be unique.
I've thought about adding the review id in the url somewhere, but I'd like to avoid that extra info for any urls that don't collide.
Any ideas? | Django slugified urls - how to handle collisions? | 1.2 | 0 | 0 | 3,203 |
1,490,559 | 2009-09-29T04:23:00.000 | 0 | 0 | 0 | 0 | python,django,url,slug,collision | 2,340,063 | 4 | false | 1 | 0 | I would (in the form validation) just check to see if the slug is used, and then add something to it, either a number "my-cool-idea_2" or the actual id | 2 | 7 | 0 | I'm currently working on a toy project in Django.
Part of my app allows users to leave reviews. I'd like to take the title of the review and slugify it to create a url.
So, if a user writes a review called "The best thing ever!", the url would be something like: www.example.com/reviews/the-best-thing-ever.
That's all well and good, but what is the best way to handle case where two users pick the same title? I don't want to make the title required to be unique.
I've thought about adding the review id in the url somewhere, but I'd like to avoid that extra info for any urls that don't collide.
Any ideas? | Django slugified urls - how to handle collisions? | 0 | 0 | 0 | 3,203 |
1,490,841 | 2009-09-29T06:15:00.000 | 2 | 1 | 1 | 0 | python,ruby,performance,memory-management | 1,491,010 | 5 | false | 0 | 0 | If you are using Python for CPU intensive algorithmic tasks I suggest use Numpy/Scipy to speed up your numerical calculations and use the Psyco JIT compiler for everything else. Your speeds can approach that of much lower-level languages if you use optimized components. | 1 | 1 | 0 | I have a memory and CPU intensive problem to solve and I need to benchmark the different solutions in ruby and python on different platforms.
To do the benchmark, I need to measure the time taken and the memory occupied by objects (not the entire program, but a selected list of objects) in both python and ruby.
Please recommend ways to do it, and also let me know if it is possible to do it without using OS specify tools like (Task Manager and ps). Thanks!
Update: Yes, I know that both Python and Ruby are not strong in performance and there are better alternatives like c, c++, Java etc. I am actually more interested in comparing the performance of Python and Ruby. And please no fame-wars. | Comparing performance between ruby and python code | 0.07983 | 0 | 0 | 1,564 |
1,493,550 | 2009-09-29T16:12:00.000 | 3 | 0 | 0 | 1 | python,workflow,business-process-management | 1,493,731 | 2 | true | 0 | 0 | Oh yes, tons. But most of them depend on a specific framework. DCWorkflow is integrated with Zopes CMF, for example. hurry.workflow is for Zope 3, etc. SpiffWorkflow presumes sql-alchemy, etc. This is because you need to have something to apply the workflow to, and that means you need to make some basic assumptions on the objects you use.
Hurry.workflow is probably one of the more independent ones, but it still assumes both that you use the Persistence library (and therefore in practice ZODB), and zope3's security model.
So you probably need to expand a bit on your requirements here... | 1 | 7 | 0 | Let's say you are building a Python-based web app that requires some workflow management such as that in jBPM or Windows Workflow Foundation. Is there a library that offers this in the Python world? | Embeddable Workflow/BPM Library For Python? | 1.2 | 0 | 0 | 9,645 |
1,494,146 | 2009-09-29T18:22:00.000 | 5 | 0 | 1 | 0 | python | 1,494,172 | 4 | false | 0 | 0 | define a method in your class with __getitem__(key) and __setitem__(key, value) | 1 | 3 | 0 | I feel like this question has already been asked and answered, yet I couldn't find anything on-topic, so excuse me if it is so. I want to define the behaviour of [] brackets when applied to class, similar to def []=() construct in ruby, so that calling Python obj['foo'] would actually call some [](self, what) method. How can I do that? | How to define [] for class in Python? | 0.244919 | 0 | 0 | 272 |
1,494,231 | 2009-09-29T18:41:00.000 | 1 | 0 | 1 | 0 | javascript,c++,python,timestamp | 1,494,464 | 5 | false | 0 | 0 | Under WIN32, you can use SystemTimeToFileTime.
FILETIME is a 64-bit unsigned integer that counts the number of 100-nanosecond intervals since January 1, 1601 (UTC).
You can convert two timestamps to FILETIME. You can convert it to ULARGE_INTEGER (t.dwLowDateTime + t.dwHighDateTime << 32), and do regular arithmetics to measure the interval. | 2 | 3 | 0 | I'm trying to find to accurately count the number of seconds since Jan 1, 1850 to the present in a couple of languages (JavaScript, C++, and Python [don't even ask, I stopped asking these questions long ago]).
Problem is the platforms store timestamps as 32-bit signed integers, so I can't get a timestamp for dates older than 1901 to easily subtract the present timestamp from etc.. So how do I do what I want to do? | How to get a timestamp older than 1901 | 0.039979 | 0 | 0 | 913 |
1,494,231 | 2009-09-29T18:41:00.000 | 3 | 0 | 1 | 0 | javascript,c++,python,timestamp | 1,494,286 | 5 | false | 0 | 0 | The portable, language-agnostic approach:
Step 1. Count the number of seconds between 01/01/1850 00:00 and 01/01/1901 00:00. Save this number somewhere (call it M)
Step 2. Use available language functionality to count the number of seconds between 01/01/1901 00:00 and whatever other date and time you want.
Step 3. Return the result from Step 2 + M. Remember to cast the result as a long integer if necessary. | 2 | 3 | 0 | I'm trying to find to accurately count the number of seconds since Jan 1, 1850 to the present in a couple of languages (JavaScript, C++, and Python [don't even ask, I stopped asking these questions long ago]).
Problem is the platforms store timestamps as 32-bit signed integers, so I can't get a timestamp for dates older than 1901 to easily subtract the present timestamp from etc.. So how do I do what I want to do? | How to get a timestamp older than 1901 | 0.119427 | 0 | 0 | 913 |
1,494,524 | 2009-09-29T19:41:00.000 | 0 | 0 | 0 | 0 | python,django,authentication | 1,494,572 | 3 | false | 1 | 0 | Modify things slightly so that users have a category prefix on their username? You haven't given us much info on what you want to do, it's possible that your needs might be met by using the sites framework, or simply two separate django installs.
If what you're trying to do is make the user login page and the admin login page separate, just use the built in framework as detailed in the docs to create a "user" login page and leave the admin one alone. If you're worried that users will somehow start editing admin login stuff, don't be, they won't unless you let them. | 1 | 8 | 0 | I've recently started learning/using django; I'm trying to figure out a way to have two separate authentications systems for administrators and users. Rather than create a whole new auth system, I'd like to leverage django's built-in functionality (i.e. session management, @login_required decorator, etc.).
Specifically, I want to have two separate login tables - one for admins, one for users. The admin login table should be the default table that django generates with its default fields (ie. id, username, email, is_staff, etc.). The user table, on the other hand, I want to have only 5 fields - id, email, password, first_name, last_name. Furthermore, I want to use django built-in session management for both login tables and the @login_required decorator for their respective views. Lastly, I want two separate and distinct login forms for admins and users.
Anyone have any suggestions on how I can achieve my goal or know of any articles/examples that could help me along? | Separate Admin/User authentication system in Django | 0 | 0 | 0 | 3,543 |
1,494,696 | 2009-09-29T20:17:00.000 | 13 | 0 | 1 | 0 | python,boolean,pass-by-value | 1,494,728 | 5 | true | 0 | 0 | Python variables are not "references" in the C++ sense. Rather, they are simply local names bound to an object at some arbitrary location in memory. If that object is itself mutable, changes to it will be visible in other scopes that have bound a name to the object. Many primitive types (including bool, int, str, and tuple) are immutable however. You cannot change their value in-place; rather, you assign a new value to the same name in your local scope.
In fact, almost any time* you see code of the form foo = X, it means that the name foo is being assigned a new value (X) within your current local namespace, not that a location in memory named by foo is having its internal pointer updated to refer instead to the location of X.
*- the only exception to this in Python is setter methods for properties, which may allow you to write obj.foo = X and have it rewritten in the background to instead call a method like obj.setFoo(X). | 3 | 10 | 0 | I sent a reference to a bool object, and I modified it within a method. After the method finished its execution, the value of the bool outside the method was unchanged.
This leads me to believe that Python's bools are passed by value. Is that true? What other Python types behave that way? | Are Python's bools passed by value? | 1.2 | 0 | 0 | 6,888 |
1,494,696 | 2009-09-29T20:17:00.000 | 0 | 0 | 1 | 0 | python,boolean,pass-by-value | 1,494,730 | 5 | false | 0 | 0 | In short, there are no variables in Python; there are objects (Like True and False, the bools happen to be immutable), and names. Names are what you call variables, but names belong to a scope, you can't normally change names other than the local names. | 3 | 10 | 0 | I sent a reference to a bool object, and I modified it within a method. After the method finished its execution, the value of the bool outside the method was unchanged.
This leads me to believe that Python's bools are passed by value. Is that true? What other Python types behave that way? | Are Python's bools passed by value? | 0 | 0 | 0 | 6,888 |
1,494,696 | 2009-09-29T20:17:00.000 | 1 | 0 | 1 | 0 | python,boolean,pass-by-value | 1,495,889 | 5 | false | 0 | 0 | The thing to remember is that there is no way in Python for a function or a method to rebind a name in the calling namespace. When you write "I sent a reference to a bool object, and I modified it within a method", what you actually did (I am guessing) was to rebind the parameter name (to which the bool value was bound by the call) inside the method body. | 3 | 10 | 0 | I sent a reference to a bool object, and I modified it within a method. After the method finished its execution, the value of the bool outside the method was unchanged.
This leads me to believe that Python's bools are passed by value. Is that true? What other Python types behave that way? | Are Python's bools passed by value? | 0.039979 | 0 | 0 | 6,888 |
1,496,039 | 2009-09-30T03:51:00.000 | 0 | 0 | 1 | 0 | python,wrapper,openaccess | 1,496,242 | 3 | false | 0 | 0 | Is your concept very similar to Microsoft Access? Generally programmers tend not to write such programs because they produce such horrible code that the authors themselves would never want to use their program. | 1 | 1 | 0 | With my luck this question will be closed too quickly. I see a tremendous possibility for a python application that basically is like a workbook. Imagine if you will that instead of writing code you select from a menu of choices. For example, the File menu would have an open command that lets the user navigate to a file or directory of file or a webpage, even a list of web pages and specify those as the things that will be the base for the next actions.
Then you have a find menu. The menu would allow easy access to the various parsing tools, regular expression and string tools so you can specify the thing you want to find within the files.
Another menu item could allow you to create queries to interact with database objects.
I could go on and on. As the language becomes more higher level then these types of features become easier to implement. There is a tremendous advantage to developing something like this. How much time is spent reinventing the wheel for mundane tasks? Programmers have functions that they have built to do many mundane tasks but what about democratizing the power offered by a tool like Python.
I have people in my office all of the time asking how to solve problems that seem intractable to them, but when I show them how with a few lines of code their problem is solvable except for the edge cases they become amazed. I deflect their gratitude with the observation that it is not really that hard except for being able to construct the right google search to identify the right package or library to solve the problem. There is nothing amazing about my ability to use lxml and sets to pull all bolded sections from a collection of say 12,000 documents and compare across time and across unique identifiers in the collection how those bolded sections have evolved/changed or converged. The amazing piece is that someone wrote the libraries to do these things.
What is the advantage to the community for something like this. Imagine if you would an interface that looks like a workbook but interacts with an app-store. So if you want to pull something from html file you go to the app store and buy a plug-in that handles the work. If the workbook is built robustly enough it could be licensed to a machine, the 'apps' would be tied to a particular workbook.
Just imagine the creativity that could be unleashed by users if they could get over the feeling that access to this power is difficult. You guys may not see this but I see Python being so close to being able to port to something like a workbook framework. Weren't the early spreadsheet programs nothing more than a frame around some Fortran libraries that had been ported to C?
Comments or is there such an application and I have not found it. | How close is Python to being able to wrap it in a workbook type skin? | 0 | 0 | 0 | 160 |
1,496,067 | 2009-09-30T04:04:00.000 | 1 | 0 | 0 | 0 | python,django | 1,496,616 | 2 | false | 1 | 0 | Here is already suggestion to store data in the database, e.g. bsddb.btopen() or any RDBMS.
Take a look at heapq.merge() and bisect.insort() or use one of B-tree implementations if you'd like to merge data in memory. | 1 | 0 | 0 | Having great luck working with single-source feed parsing in Universal Feed Parser, but now I need to run multiple feeds through it and generate chronologically interleaved output (not RSS). Seems like I'll need to iterate through URLs and stuff every entry into a list of dictionaries, then sort that by the entry timestamps and take a slice off the top. That seems do-able, but pretty expensive resource-wise (I'll cache it aggressively for that reason).
Just wondering if there's an easier way - an existing library that works with feedparser to do simple aggregation, for example. Sample code? Gotchas or warnings? Thanks. | Aggregating multiple feeds with Universal Feed Parser | 0.099668 | 0 | 1 | 1,280 |
1,496,842 | 2009-09-30T08:47:00.000 | 1 | 0 | 0 | 1 | python,windows | 1,497,789 | 4 | false | 0 | 0 | Also you can try win32 module for Python. | 1 | 2 | 0 | I'm programming in Python with a wrapper of the kernel32 dll, so I can use any functions of this dll, like GetLogicalDrives(), for instance. I'm trying to obtain the information of the physical drives, even if they are not mounted. I've seen a question similar to this, but I need the information of the not mounted drives. All methods I've seen need a directory or a file in the device, but if it's not mounted, I can't have one, so the question is:
Is there a method which can provide me a list of the physical drives in the system, even if they are not mounted?
I have to say that using the Windows Registry, I've obtained the number of physical drives in "HKEY_LOCAL_MACHINE\Hardware\Devicemap\Scsi\Scsi Port x", because inside of this key, you can see the number of drives, including cd-rom devices or floppy devices. But I need size of the not mounted devices also, so... | how to obtain physical drives in Windows | 0.049958 | 0 | 0 | 5,364 |
1,498,009 | 2009-09-30T13:11:00.000 | 0 | 0 | 1 | 0 | python,oop | 1,498,033 | 5 | false | 0 | 0 | I see no problem with that, it happens all the time. Do you have a specific problem you're trying to solve or just asking a general question without a context? | 4 | 4 | 0 | I just started to use the object oriented programming in Python. I wander if it is OK if I create a method of a class which use objects from another class. In other words, when I call a method of the first class I give an object from the second class as one of the arguments. And then, the considered methods (of the first class) can manipulate by the object from the second class (to get its attributes or use its methods). Is it allowed in Python? Is it not considered as a bad programming style?
Is it OK if I instantiate objects from the second class withing a method of the first class. In other words, if I call a method from the first class it instantiate objects fro the second class.
Thank you in advance for any help. | Is it OK if objects from different classes interact with each other? | 0 | 0 | 0 | 2,279 |
1,498,009 | 2009-09-30T13:11:00.000 | 8 | 0 | 1 | 0 | python,oop | 1,498,030 | 5 | true | 0 | 0 | If you're talking about passing an instance of one object to the method of a another one, then yes of course it's allowed! And it's considered fine practice.
If you want to know more about good object oriented coding, may I offer some suggested readings:
Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John M. Vlissides
Known as the Gang Of Four book, this lays out a number of design patterns that seem to show up in object oriented code time and time again. This is a good place to go for ideas on how to handle certain problems in a good object oriented way.
Another good one:
Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant , William Opdyke, Don Roberts
This is a great book for learning what NOT to do when writing object oriented code, and how to fix it to make it better when you do encounter it. It offers a list of code smells that suggest bad object oriented code and a reference section of refactorings that provide instructions on how to fix those smells and make them more object oriented. | 4 | 4 | 0 | I just started to use the object oriented programming in Python. I wander if it is OK if I create a method of a class which use objects from another class. In other words, when I call a method of the first class I give an object from the second class as one of the arguments. And then, the considered methods (of the first class) can manipulate by the object from the second class (to get its attributes or use its methods). Is it allowed in Python? Is it not considered as a bad programming style?
Is it OK if I instantiate objects from the second class withing a method of the first class. In other words, if I call a method from the first class it instantiate objects fro the second class.
Thank you in advance for any help. | Is it OK if objects from different classes interact with each other? | 1.2 | 0 | 0 | 2,279 |
1,498,009 | 2009-09-30T13:11:00.000 | 1 | 0 | 1 | 0 | python,oop | 1,498,152 | 5 | false | 0 | 0 | The answer is that it os MORE than OK, it's in fact the whole point.
What is not "OK" is when objects start fiddling with the internals of each other. You can prevent this from happening accidentally, by calling things that are meant to be internal with a leading underscore (or two, which makes it internal also for subclasses). This works as a little marker for other programmers that you aren't supposed to use it, and that it's not official API and can change. | 4 | 4 | 0 | I just started to use the object oriented programming in Python. I wander if it is OK if I create a method of a class which use objects from another class. In other words, when I call a method of the first class I give an object from the second class as one of the arguments. And then, the considered methods (of the first class) can manipulate by the object from the second class (to get its attributes or use its methods). Is it allowed in Python? Is it not considered as a bad programming style?
Is it OK if I instantiate objects from the second class withing a method of the first class. In other words, if I call a method from the first class it instantiate objects fro the second class.
Thank you in advance for any help. | Is it OK if objects from different classes interact with each other? | 0.039979 | 0 | 0 | 2,279 |
1,498,009 | 2009-09-30T13:11:00.000 | 1 | 0 | 1 | 0 | python,oop | 1,498,085 | 5 | false | 0 | 0 | What you're talking about is fine. In fact most data types (string, int, boolean, etc.) in Python are objects, so pretty much every method works in the way you described. | 4 | 4 | 0 | I just started to use the object oriented programming in Python. I wander if it is OK if I create a method of a class which use objects from another class. In other words, when I call a method of the first class I give an object from the second class as one of the arguments. And then, the considered methods (of the first class) can manipulate by the object from the second class (to get its attributes or use its methods). Is it allowed in Python? Is it not considered as a bad programming style?
Is it OK if I instantiate objects from the second class withing a method of the first class. In other words, if I call a method from the first class it instantiate objects fro the second class.
Thank you in advance for any help. | Is it OK if objects from different classes interact with each other? | 0.039979 | 0 | 0 | 2,279 |
1,498,155 | 2009-09-30T13:32:00.000 | 5 | 1 | 0 | 1 | python,c,embedded,fuzzy-logic | 1,498,739 | 6 | false | 0 | 0 | Make it work, then make it work fast. | 6 | 5 | 0 | I'm looking at implementing a fuzzy logic controller based on either PyFuzzy (Python) or FFLL (C++) libraries.
I'd prefer to work with python but am unsure if the performance will be acceptable in the embedded environment it will work in (either ARM or embedded x86 proc both ~64Mbs of RAM).
The main concern is that response times are as fast as possible (an update rate of 5hz+ would be ideal >2Hz is required). The system would be reading from multiple (probably 5) sensors from an RS232 port and provide 2/3 outputs based on the results of the fuzzy evaluation.
Should I be concerned that Python will be too slow for this task? | Performance of Python worth the cost? | 0.16514 | 0 | 0 | 1,593 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.