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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2,187,610 | 2010-02-02T20:53:00.000 | 0 | 0 | 0 | 0 | python,web.py | 2,205,554 | 3 | false | 1 | 0 | A killer app isn't necessarily defined by whether it makes the framework/language famous. The Killer 'App' is an application that disrupts its industry in such a way that the rules or status quo of that industry is changed forever. E.g. the iPhone.
It is 'killer' because it 'kills' off market leaders in its industry.
A by-product of a killer app is that the technology used to bring it to market gets a fair amount of media attention. This is inevitably happens because the majority of developers(in our case) who operate in the killer app's industry want to be up on the latest trends/concepts/etc...
In the iPhone's case: It has sold millions; meaning the iPhone is a cash cow; therefore developers flock; developers need to then know what technology to use; more developers=more attention; etc...
Obviously this is a short summary on what generally happens.
Anyway... Pylons is pretty good. Its gaining quite a bit of attention because it is easily customizable, robust and focused on doing what is necessary which is rapid development.
There is also Turbo Gears, but the latest version is built on Pylons anyway.
Hope this helps. | 1 | 4 | 0 | A killer app is an app that make a library or framework famous. I think web.py is quite famous, but I don't know any big, widely used app written in web.py.
Could you point out any? I've head that the first version of youtube.com was coded using web.py but I'd like you to mention an open source one so I can see its code. | Which is web.py killer app? | 0 | 0 | 0 | 3,386 |
2,187,821 | 2010-02-02T21:24:00.000 | 5 | 1 | 0 | 0 | php,python | 2,187,885 | 9 | false | 0 | 0 | print and pprint are great for built-in data types or classes which define a sane object representation. If you want a full dump of arbitrary objects, you'll have to roll your own. That is not that hard: simply create a recursive function with the base case being any non-container built-in data type, and the recursive case applying the function to each item of a container or each attribute of the object, which can be gotten using dir() or the inspect module. | 1 | 87 | 0 | Or is there a better way to quickly output the contents of an array (multidimensional or what not). Thanks. | What is the equivalent of php's print_r() in python? | 0.110656 | 0 | 0 | 77,118 |
2,187,998 | 2010-02-02T21:53:00.000 | 8 | 1 | 1 | 0 | php,python,perl,integration,phpbb | 2,188,027 | 3 | false | 0 | 0 | You can always call the python or perl interpreter from within PHP! Minimalistic interchange is possible by means of passing command line arguments and capturing stdout (exec or passthru are related php functions).
However, I don't think its's a good idea - using two interpreters instead of one doubles the overall runtime overhead and startup time. | 2 | 2 | 0 | I'm going to help my friend in a improve of his phpBB board, but I want to make somethings there in Python or Perl. But it's possible to integrate these languages with PHP? | Integrating Python or Perl with PHP | 1 | 0 | 0 | 848 |
2,187,998 | 2010-02-02T21:53:00.000 | 8 | 1 | 1 | 0 | php,python,perl,integration,phpbb | 2,188,168 | 3 | false | 0 | 0 | I'd say that the only reasonable way of doing that is if you are making a separate service, that you talk to via Ajax or XML or something like that. Everything else is more trouble than it's worth. | 2 | 2 | 0 | I'm going to help my friend in a improve of his phpBB board, but I want to make somethings there in Python or Perl. But it's possible to integrate these languages with PHP? | Integrating Python or Perl with PHP | 1 | 0 | 0 | 848 |
2,188,646 | 2010-02-02T23:50:00.000 | 5 | 0 | 0 | 0 | python,opencv,computer-vision,motion-detection | 2,352,019 | 4 | false | 0 | 0 | Nick,
What you are looking for is not people detection, but motion detection. If you tell us a lot more about what you are trying to solve/do, we can answer better.
Anyway, there are many ways to do motion detection depending on what you are going to do with the results. Simplest one would be differencing followed by thresholding while a complex one could be proper background modeling -> foreground subtraction -> morphological ops -> connected component analysis, followed by blob analysis if required. Download the opencv code and look in samples directory. You might see what you are looking for. Also, there is an Oreilly book on OCV.
Hope this helps,
Nand | 2 | 37 | 1 | I have a camera that will be stationary, pointed at an indoors area. People will walk past the camera, within about 5 meters of it. Using OpenCV, I want to detect individuals walking past - my ideal return is an array of detected individuals, with bounding rectangles.
I've looked at several of the built-in samples:
None of the Python samples really apply
The C blob tracking sample looks promising, but doesn't accept live video, which makes testing difficult. It's also the most complicated of the samples, making extracting the relevant knowledge and converting it to the Python API problematic.
The C 'motempl' sample also looks promising, in that it calculates a silhouette from subsequent video frames. Presumably I could then use that to find strongly connected components and extract individual blobs and their bounding boxes - but I'm still left trying to figure out a way to identify blobs found in subsequent frames as the same blob.
Is anyone able to provide guidance or samples for doing this - preferably in Python? | How can I detect and track people using OpenCV? | 0.244919 | 0 | 0 | 45,934 |
2,188,646 | 2010-02-02T23:50:00.000 | 2 | 0 | 0 | 0 | python,opencv,computer-vision,motion-detection | 2,190,799 | 4 | false | 0 | 0 | This is similar to a project we did as part of a Computer Vision course, and I can tell you right now that it is a hard problem to get right.
You could use foreground/background segmentation, find all blobs and then decide that they are a person. The problem is that it will not work very well since people tend to go together, go past each other and so on, so a blob might very well consist of two persons and then you will see that blob splitting and merging as they walk along.
You will need some method of discriminating between multiple persons in one blob. This is not a problem I expect anyone being able to answer in a single SO-post.
My advice is to dive into the available research and see if you can find anything there. The problem is not unsolvavble considering that there exists products which do this: Autoliv has a product to detect pedestrians using an IR-camera on a car, and I have seen other products which deal with counting customers entering and exiting stores. | 2 | 37 | 1 | I have a camera that will be stationary, pointed at an indoors area. People will walk past the camera, within about 5 meters of it. Using OpenCV, I want to detect individuals walking past - my ideal return is an array of detected individuals, with bounding rectangles.
I've looked at several of the built-in samples:
None of the Python samples really apply
The C blob tracking sample looks promising, but doesn't accept live video, which makes testing difficult. It's also the most complicated of the samples, making extracting the relevant knowledge and converting it to the Python API problematic.
The C 'motempl' sample also looks promising, in that it calculates a silhouette from subsequent video frames. Presumably I could then use that to find strongly connected components and extract individual blobs and their bounding boxes - but I'm still left trying to figure out a way to identify blobs found in subsequent frames as the same blob.
Is anyone able to provide guidance or samples for doing this - preferably in Python? | How can I detect and track people using OpenCV? | 0.099668 | 0 | 0 | 45,934 |
2,189,600 | 2010-02-03T04:03:00.000 | 0 | 0 | 0 | 0 | python,struct,endianness,flip | 2,189,625 | 4 | false | 0 | 0 | little_endian = big_endian[1] + big_endian[0] | 2 | 0 | 0 | I would like to flip from big to little endian this string:
\x00\x40
to have it like this:
\x40\x00
I guess the proper function to use would be struct.pack, but I can't find a way to make it properly work.
A small help would be very appreciated !
Thanks | flip bytes using Python's struct module | 0 | 0 | 0 | 4,488 |
2,189,600 | 2010-02-03T04:03:00.000 | 5 | 0 | 0 | 0 | python,struct,endianness,flip | 2,189,817 | 4 | false | 0 | 0 | data[::-1] works for any number of bytes. | 2 | 0 | 0 | I would like to flip from big to little endian this string:
\x00\x40
to have it like this:
\x40\x00
I guess the proper function to use would be struct.pack, but I can't find a way to make it properly work.
A small help would be very appreciated !
Thanks | flip bytes using Python's struct module | 0.244919 | 0 | 0 | 4,488 |
2,189,800 | 2010-02-03T04:56:00.000 | 427 | 0 | 1 | 0 | python,count,integer | 2,189,814 | 28 | true | 0 | 0 | If you want the length of an integer as in the number of digits in the integer, you can always convert it to string like str(133) and find its length like len(str(123)). | 2 | 324 | 0 | In Python, how do you find the number of digits in an integer? | How to find length of digits in an integer? | 1.2 | 0 | 0 | 610,171 |
2,189,800 | 2010-02-03T04:56:00.000 | 2 | 0 | 1 | 0 | python,count,integer | 2,189,821 | 28 | false | 0 | 0 | Assuming you are asking for the largest number you can store in an integer, the value is implementation dependent. I suggest that you don't think in that way when using python. In any case, quite a large value can be stored in a python 'integer'. Remember, Python uses duck typing!
Edit:
I gave my answer before the clarification that the asker wanted the number of digits. For that, I agree with the method suggested by the accepted answer. Nothing more to add! | 2 | 324 | 0 | In Python, how do you find the number of digits in an integer? | How to find length of digits in an integer? | 0.014285 | 0 | 0 | 610,171 |
2,190,075 | 2010-02-03T06:19:00.000 | 2 | 0 | 1 | 0 | python,django,multithreading,csv | 2,196,168 | 1 | true | 1 | 0 | Django is Python, so yeah you can use threads, processing etc. Look at python docs on this matter.
But, spawning threads in web environment might be not be such a good idea, try searching here for "django asynchronous" - you'll get many ideas of how to this without threading. | 1 | 0 | 0 | Is it possible to use threading when importing data from csv files to django. | django csv import threading | 1.2 | 0 | 0 | 570 |
2,190,502 | 2010-02-03T08:11:00.000 | -2 | 0 | 0 | 0 | python,screen-scraping,htmlunit,pycurl | 2,190,517 | 7 | false | 1 | 0 | I have not found anything for this. I use a combination of beautifulsoup and custom routines... | 1 | 14 | 0 | Does Python have screen scraping libraries that offer JavaScript support?
I've been using pycurl for simple HTML requests, and Java's HtmlUnit for more complicated requests requiring JavaScript support.
Ideally I would like to be able to do everything from Python, but I haven't come across any libraries that would allow me to do it. Do they exist? | Screen scraping with Python | -0.057081 | 0 | 1 | 10,580 |
2,190,711 | 2010-02-03T08:54:00.000 | 0 | 0 | 1 | 0 | python | 2,190,882 | 1 | false | 0 | 0 | You do it exactly the same way as you did before, but now with the FreeType-dev files installed. | 1 | 0 | 0 | Previously I got a suggedtion to Install the FreeType dev files and rebuild PIL again.
but I have no idea how to do it.
any help will be thanked for | Rebuilding PIL with FreeType | 0 | 0 | 0 | 318 |
2,191,695 | 2010-02-03T12:08:00.000 | 1 | 0 | 0 | 0 | python,rabbitmq,amqp,py-amqplib | 2,240,828 | 3 | true | 0 | 0 | It is currently impossible as the basic.return is sent asynchronously when a message is dropped in broker. When message was sent successfully no data is reported from server.
So pyAMQP can't listen for such messages.
I've read few threads about this problem. Possible solution were:
use txAMQP, twisted version of amqp that handles basic.return
use pyAMQP with wait with timeout. (I'm not sure if that is currently possible)
ping server frequently with synchronous commands so that pyAMQP will able to pick basic.return messages when they arrive.
Because the level of support for pyAMQP and rabbitMQ in general is quite low, we decided not to use amqp broker at all. | 1 | 2 | 0 | I'd like to make sure that my message was delivered to a queue.
To do so I'm adding the mandatory param to the basic_publish.
What else should I do to receive the basic.return message if my message wasn't successfully delivered?
I can't use channel.wait() to listen for the basic.return because when my message is successfully delivered the wait() function hangs forever. (There is no timeout)
On the other hand. When I don't call channel.wait() the channel.returned_messages will remain empty, even if the message isn't delivered.
I use py-amqplib version 0.6.
Any solution is welcome. | How to use listen on basic.return in python client of AMQP | 1.2 | 0 | 1 | 1,192 |
2,192,344 | 2010-02-03T13:53:00.000 | 3 | 0 | 1 | 0 | python | 2,195,845 | 4 | false | 0 | 0 | Because then you would have two ways to do something. | 2 | 16 | 0 | Is there a good reason why there isn't a do while flow control statement in python?
Why do people have to write while and break explicitly? | Why isn't there a do while flow control statement in python? | 0.148885 | 0 | 0 | 2,629 |
2,192,344 | 2010-02-03T13:53:00.000 | 10 | 0 | 1 | 0 | python | 2,192,371 | 4 | false | 0 | 0 | Probably because Guido didn't think it was necessary. There are a bunch of different flow-control statements you could support, but most of them are variants of each other. Frankly, I've found the do-while statement to be one of the less useful ones. | 2 | 16 | 0 | Is there a good reason why there isn't a do while flow control statement in python?
Why do people have to write while and break explicitly? | Why isn't there a do while flow control statement in python? | 1 | 0 | 0 | 2,629 |
2,192,685 | 2010-02-03T14:40:00.000 | 2 | 0 | 0 | 0 | python,django,apache | 2,193,943 | 4 | true | 1 | 0 | Ubuntu is far and away a better platform nowadays. I'm a refugee from RHEL and Fedora. Get Ubuntu 9.10, and if you'd like, spawn it on Amazon ec2 for total flexibility (i.e. launch it in about 90 seconds, play around, do what you want, delete it, and only pay a buck). Otherwise, just use Ubuntu on the desktop.
Ubuntu has Python 2.6 by default so you don't have to go out and find weird upgrade paths. Also Ubuntu has ready-to-go installations for django 1.1.1 (the latest and greatest) that integrate with Apache, etc...
In other words, with zero usage of PIP, easy_install or source installations, you can get running with Django on Ubuntu/Apache.
Once you're comfortable, PIP is the tool you should use for all non-stock python library installations as it's more up to date.
MySQL is easier than Postgres but it doesn't really matter either way.
=== edit ====
I forgot to add that I use mod_wsgi. I forgot all about it since the Ubuntu Apache installation was so easy that I hardly had to even think about it. | 2 | 1 | 0 | I am about to embark a major django project. If I install the latest stable release... is the a suggested setup ie. this OS, this RDBMS, this version of python etc?? I'm normally a CentOS man but their repos don't play too well with the django requirements... | Recommended Django setup? | 1.2 | 0 | 0 | 703 |
2,192,685 | 2010-02-03T14:40:00.000 | 1 | 0 | 0 | 0 | python,django,apache | 2,192,712 | 4 | false | 1 | 0 | We use Fedora 11, MySQL, Apache, mod_wsgi, Python 2.6. Works great. | 2 | 1 | 0 | I am about to embark a major django project. If I install the latest stable release... is the a suggested setup ie. this OS, this RDBMS, this version of python etc?? I'm normally a CentOS man but their repos don't play too well with the django requirements... | Recommended Django setup? | 0.049958 | 0 | 0 | 703 |
2,192,993 | 2010-02-03T15:21:00.000 | 0 | 0 | 1 | 0 | python,pyqt | 2,193,028 | 2 | false | 0 | 1 | You could create a thread to update the GUI constantly, just pass to it references to the graphical widgets that need to be updated | 1 | 1 | 0 | Often times when we're drawing a GUI, we want our GUI to update based on the data changing in our program. At the start of the program, let's say I've drawn my GUI based on my initial data. That data will be changing constantly, so how can I redraw my GUI constantly? | How to start a "drawing loop" in PyQt? | 0 | 0 | 0 | 1,096 |
2,193,231 | 2010-02-03T15:55:00.000 | 0 | 0 | 1 | 0 | python,shell | 2,193,294 | 4 | false | 0 | 0 | Unless there is a way of doing it on the activestate shell, no, there is no way to retrieve the exact code you've typed on the shell. At least on Linux, using the Python Shell provided by CPython there is no special way to achieve this. Maybe using iPython.
The func_code attribute is an object representing the function bytecode, the only thing you can get from this object is bytecode itself, not the "original" code. | 2 | 14 | 0 | I am working in the Python Interactive Shell (ActiveState ActivePython 2.6.4 under Windows XP). I created a function that does what I want. However, I've cleared the screen so I can't go back and look at the function definition. It is also a multiline function so the up arrow to redisplay lines is of minimal value. Is there anyway to return the actual code of the function? There are "code" and "func_code" attributes displayed by dir(), but I don't know if they contain what I need. | Display function definition in interactive shell | 0 | 0 | 0 | 22,508 |
2,193,231 | 2010-02-03T15:55:00.000 | 1 | 0 | 1 | 0 | python,shell | 2,193,405 | 4 | false | 0 | 0 | No, not really. You could write yourfunc.func_code.co_code (the actually compiled bytecode) to a file and then try using decompyle or unpyc to decompile them, but both projects are old and unmaintained, and have never supported decompiling very well.
It's infinitely easier to simply write your function to a file to start with. | 2 | 14 | 0 | I am working in the Python Interactive Shell (ActiveState ActivePython 2.6.4 under Windows XP). I created a function that does what I want. However, I've cleared the screen so I can't go back and look at the function definition. It is also a multiline function so the up arrow to redisplay lines is of minimal value. Is there anyway to return the actual code of the function? There are "code" and "func_code" attributes displayed by dir(), but I don't know if they contain what I need. | Display function definition in interactive shell | 0.049958 | 0 | 0 | 22,508 |
2,193,829 | 2010-02-03T17:15:00.000 | 2 | 0 | 1 | 0 | python,performance,architecture,comparison | 2,193,927 | 4 | false | 0 | 0 | Beautiful Code book has a nice explanation about how dicts are implemented. | 2 | 0 | 0 | Does anyone know good books that discuss the underlying architectures, in-depth analysis of CPython implementation. Something like
how list / tuple / dict implemented (and performance comparison...)
OOP discussion in Python context
Sorry if it sounds like a silly question :( | Python underlying analysis books/articles? | 0.099668 | 0 | 0 | 265 |
2,193,829 | 2010-02-03T17:15:00.000 | 2 | 0 | 1 | 0 | python,performance,architecture,comparison | 2,193,928 | 4 | false | 0 | 0 | This doesn't directly answer your question but it's useful to know nevertheless:
The source code of CPython is well-written and well-documented, and there are some PEPs that shed light on parts of the implementation. You should really try just reading it. | 2 | 0 | 0 | Does anyone know good books that discuss the underlying architectures, in-depth analysis of CPython implementation. Something like
how list / tuple / dict implemented (and performance comparison...)
OOP discussion in Python context
Sorry if it sounds like a silly question :( | Python underlying analysis books/articles? | 0.099668 | 0 | 0 | 265 |
2,194,479 | 2010-02-03T18:41:00.000 | 2 | 0 | 1 | 0 | python | 2,194,652 | 2 | false | 0 | 0 | If it looks like ugly type checking, that may be because it is. If "amount" absolutely needs to be a positive integer, and the rest of the module will fail badly if it is not, then you need to do some type checking.
The python way of doing this, though, is only to check for the actual properties that you require.
In the positive integer example, that means not checking that the value is an Int object, but checking instead that it has a value, and that the value is > 0. This lets other programmers pass your methods objects that act like numbers, without strictly constraining their type.
The same thing goes for the email example -- check that it is properly formatted (matches whatever email regex you are using), but don't insist that it is an instance of the Str class. Don't insist on anything in your validity checking except properties that you are actually going to use. | 2 | 6 | 0 | Where should I write codes for checking validity of class' properties? (For examples: "amount" should be a positive integer, "email" should be a string with correct e-mail formatting) At the setter methods, At somewhere I use that (using try/catch), or others.
If I check validity at setter methods, it may be looked ugly (like type checking). But if I check it when using it, duplicated code may appeared when it is used many times.
(Sorry for my poor English.) | Checking for properties' validity in Python classes | 0.197375 | 0 | 0 | 158 |
2,194,479 | 2010-02-03T18:41:00.000 | 4 | 0 | 1 | 0 | python | 2,194,552 | 2 | true | 0 | 0 | Definitely do it in the setter, if you need to do it at all.
First, the setter is probably called less often than the getters, so you're doing less work.
Second, you catch the problem earlier.
Third, it keeps the internal state of the object consistent. Keeping out bad data means you know that your object is "right". | 2 | 6 | 0 | Where should I write codes for checking validity of class' properties? (For examples: "amount" should be a positive integer, "email" should be a string with correct e-mail formatting) At the setter methods, At somewhere I use that (using try/catch), or others.
If I check validity at setter methods, it may be looked ugly (like type checking). But if I check it when using it, duplicated code may appeared when it is used many times.
(Sorry for my poor English.) | Checking for properties' validity in Python classes | 1.2 | 0 | 0 | 158 |
2,194,829 | 2010-02-03T19:31:00.000 | 0 | 0 | 0 | 0 | python,pyqt | 2,194,899 | 1 | false | 0 | 1 | To swap the scene just call your view's setScene() again with a different QGraphicsScene object. | 1 | 1 | 0 | QGraphicsView is often hooked up to a QGraphicsScene. What if I want to swap that QGraphicsScene for a new one? How can I accomplish this? Doing it right now is just drawing over the old one. | How to swap the QGraphicsScene from a QGraphicsView? | 0 | 0 | 0 | 249 |
2,195,203 | 2010-02-03T20:31:00.000 | 2 | 1 | 0 | 0 | python,ruby-on-rails,linux,email | 2,195,237 | 1 | true | 1 | 0 | Why does it need to be a simple mail server?
Can't you just use something like postfix which is very easy for simple configurations | 1 | 1 | 0 | I use python based as well as rails applications on ubuntu linux. We have functionalities like register, forgot password, reset password, email alerts etc features based on emails. Since now a days, we go on offline development, we want to run a local smtp & pop3 server to send and receive emails.
Emails shall be send via the our web application and we will use the email clients like thunderbird to receive emails(just to verify).
I have used jmailsrv (I have used 6 years ago, but could not locate exact package now), a java based simple email server. Are there any other light alternative for development work? | Linux development/minimal smtp and pop3 server | 1.2 | 0 | 0 | 839 |
2,195,441 | 2010-02-03T21:07:00.000 | 3 | 0 | 0 | 0 | python,opencv | 2,405,587 | 4 | true | 0 | 0 | After Step 1 (Installer) just copy the content of C:\OpenCV2.0\Python2.6\Lib\site-packages to C:\Python26\Lib\site-packages (standard installation path assumed).
That's all.
If you have a webcam installed you can try the camshift.demo in C:\OpenCV2.0\samples\python
The deprecated stuff (C:\OpenCV2.0\samples\swig_python) does not work at the moment as somebody wrote above. The OpenCV People are working on it. Here is the full picture:
31/03/10 (hopefully) Next OpenCV Official Release: 2.1.0 is due March
31st, 2010.
link://opencv.willowgarage.com/wiki/Welcome/Introduction#Announcements
04/03/10 [james]rewriting samples for new Python 5:36 PM Mar 4th
via API link://twitter.com/opencvlibrary
12/31/09 We've gotten more serious about OpenCV's software
engineering. We now have a full C++ and Python interface.
link://opencv.willowgarage.com/wiki/OpenCV%20Monthly
9/30/09 Several (actually, most) SWIG-based Python samples do not work
correctly now. The reason is this problem is being investigated and
the intermediate update of the OpenCV Python package will be released
as soon as the problem is sorted out.
link://opencv.willowgarage.com/wiki/OpenCV%20Monthly | 1 | 6 | 1 | I cannot get the example Python programs to run. When executing the Python command "from opencv import cv" I get the message "ImportError: No module named _cv". There is a stale _cv.pyd in the site-packages directory, but no _cv.py anywhere. See step 5 below.
MS Windows XP, VC++ 2008, Python 2.6, OpenCV 2.0
Here's what I have done.
Downloaded and ran the MS Windows installer for OpenCV2.0.
Downloaded and installed CMake
Downloaded and installed SWIG
Ran CMake. After unchecking "ENABLE_OPENMP" in the CMake GUI, I was able to build OpenCV using INSTALL.vcproj and BUILD_ALL.vcproj. I do not know what the difference is, so I built everything under both of those project files. The C example programs run fine.
Copied contents of OpenCV2.0/Python2.6/lib/site-packages to my installed Python2.6/lib/site-packages directory. I notice that it contains an old _cv.pyd and an old libcv.dll.a. | OpenCV 2.0 and Python | 1.2 | 0 | 0 | 16,728 |
2,195,747 | 2010-02-03T21:51:00.000 | 0 | 1 | 1 | 0 | python | 22,124,386 | 5 | false | 0 | 0 | You can use Pygpgme to create a password-protected gpg file, which is compressed.
You'll need to use the equivalent of
gpg -c myFile
or
gpg --symmetric myFile
and
gpg myFile.gpg
I don't know what the equivalents are in that Python module, but I know they've existed since version 0.2. There was a bug report before then mentioning the lack of it, but someone released a patch and they fixed it in version 0.2.
This uses symmetric encryption so you don't have to worry about keys.
You might find my post asking how to use it on UbuntuForums. Feel free to answer it if you know. | 2 | 17 | 0 | What is the Python code to create a password encrypted zip file? I'm fine with using some apt-get'able utilities using system on the command line. | Code to create a password encrypted zip file? | 0 | 0 | 0 | 51,029 |
2,195,747 | 2010-02-03T21:51:00.000 | 5 | 1 | 1 | 0 | python | 2,196,159 | 5 | false | 0 | 0 | Extraction is pretty easy, you just use zipfile.ZipFile.setpassword() which was introduced in python 2.6, however the standard python library lacks support for creating encrypted zip files.
There are commercially available libraries for Python which supports creation of encrypted and password protected zip files. If you want to use something freely available, you need to use the standard zip command line utility.
zip -e -Ppassword filename.zip fileA fileB ... | 2 | 17 | 0 | What is the Python code to create a password encrypted zip file? I'm fine with using some apt-get'able utilities using system on the command line. | Code to create a password encrypted zip file? | 0.197375 | 0 | 0 | 51,029 |
2,195,755 | 2010-02-03T21:52:00.000 | 3 | 0 | 1 | 0 | python | 2,195,789 | 5 | false | 0 | 0 | Object attributes are always accessed via a reference, so there is no way for an object attribute to shadow a builtin. | 3 | 1 | 0 | If you have a method called "set" in a class and want to create a standard builtin "set" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin "set", not the method "set"? More specifically, set() is being created in an _____exit_____ function. | Python class has method "set", how to reference builtin set type? | 0.119427 | 0 | 0 | 582 |
2,195,755 | 2010-02-03T21:52:00.000 | 2 | 0 | 1 | 0 | python | 2,195,786 | 5 | false | 0 | 0 | Usually method names are disambiguated from global names because you have to prefix self..
So self.set() invokes your class method and set() invokes the global set.
If this doesn't help, perhaps post the code you're having trouble with. | 3 | 1 | 0 | If you have a method called "set" in a class and want to create a standard builtin "set" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin "set", not the method "set"? More specifically, set() is being created in an _____exit_____ function. | Python class has method "set", how to reference builtin set type? | 0.07983 | 0 | 0 | 582 |
2,195,755 | 2010-02-03T21:52:00.000 | 2 | 0 | 1 | 0 | python | 2,195,807 | 5 | false | 0 | 0 | You can refer to built-in set as __builtins__.set. | 3 | 1 | 0 | If you have a method called "set" in a class and want to create a standard builtin "set" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin "set", not the method "set"? More specifically, set() is being created in an _____exit_____ function. | Python class has method "set", how to reference builtin set type? | 0.07983 | 0 | 0 | 582 |
2,195,791 | 2010-02-03T21:58:00.000 | 2 | 0 | 0 | 0 | python,database,django,unit-testing | 2,195,979 | 5 | true | 1 | 0 | Don't force Django to do something unnatural.
Allow it to create the test schema. It's a good thing.
From your existing schema, do an unload to create .JSON dump files of the data. These files are your "fixtures". These fixtures are used by Django to populate the test database. This is The Greatest Testing Tool Ever. Once you get your fixtures squared away, this really does work well.
Put your fixture files into fixtures directories within each app package.
Update your unit tests to name the various fixtures files that are required for that test case.
This -- in effect -- tests with an existing schema. It rebuilds, reloads and tests in a virgin database so you can be absolutely sure that it works without destroying (or even touching) live data. | 2 | 2 | 0 | Disclaimer:
I'm very new to Django. I must say that so far I really like it. :)
(now for the "but"...)
But, there seems to be something I'm missing related to unit testing. I'm working on a new project with an Oracle backend. When you run the unit tests, it immediately gives a permissions error when trying to create the schema. So, I get what it's trying to do (create a clean sandbox), but what I really want is to test against an existing schema. And I want to run the test with the same username/password that my server is going to use in production. And of course, that user is NOT going to have any kind of DDL type rights.
So, the basic problem/issue that I see boils down to this: my system (and most) want to have their "app_user" account to have ONLY the permissions needed to run. Usually, this is basic "CRUD" permissions. However, Django unit tests seem to need more than this to do a test run.
How do other people handle this? Is there some settings/work around/feature of Django that I'm not aware (please refer to the initial disclaimer).
Thanks in advance for your help.
David | DB Permissions with Django unit testing | 1.2 | 0 | 0 | 1,622 |
2,195,791 | 2010-02-03T21:58:00.000 | 2 | 0 | 0 | 0 | python,database,django,unit-testing | 2,197,772 | 5 | false | 1 | 0 | After I read David's (OP) question, I was curious about this too, but I don't see the answer I was hoping to see. So let me try to rephrase what I think at least part of what David is asking. In a production environment, I'm sure his Django models probably will not have access to create or drop tables. His DBA will probably not allow him to have permission to do this. (Let's assume this is True). He will only be logged into the database with regular user privileges. But in his development environment, the Django unittest framework forces him to have higher level privileges for the unittests instead of a regular user because Django requires it to create/drop tables for the model unittests. Since the unittests are now running at a higher privilege than will occur in production, you could argue that running the unittests in development are not 100% valid and errors could happen in production that might have been caught in development if Django could run the unittests with user privileges.
I'm curious if Django unittests will ever have the ability to create/drop tables with one user's (higher) privileges, and run the unittests with a different user's (lower) privileges. This would help more accurately simulate the production environment in development.
Maybe in practice this is really not an issue. And the risk is so minor compared to the reward that it not worth worrying about it. | 2 | 2 | 0 | Disclaimer:
I'm very new to Django. I must say that so far I really like it. :)
(now for the "but"...)
But, there seems to be something I'm missing related to unit testing. I'm working on a new project with an Oracle backend. When you run the unit tests, it immediately gives a permissions error when trying to create the schema. So, I get what it's trying to do (create a clean sandbox), but what I really want is to test against an existing schema. And I want to run the test with the same username/password that my server is going to use in production. And of course, that user is NOT going to have any kind of DDL type rights.
So, the basic problem/issue that I see boils down to this: my system (and most) want to have their "app_user" account to have ONLY the permissions needed to run. Usually, this is basic "CRUD" permissions. However, Django unit tests seem to need more than this to do a test run.
How do other people handle this? Is there some settings/work around/feature of Django that I'm not aware (please refer to the initial disclaimer).
Thanks in advance for your help.
David | DB Permissions with Django unit testing | 0.07983 | 0 | 0 | 1,622 |
2,196,621 | 2010-02-04T00:48:00.000 | 3 | 0 | 1 | 0 | python,pdf,text,extract,google-docs | 13,056,489 | 6 | false | 0 | 0 | Acrobat Professional can do the job. In the "File" menu, choose export. Then, choose Text. | 1 | 16 | 0 | How can I extract the text content (not images) from a PDF while (roughly) maintaining the style and layout like Google Docs can? | how to extract formatted text content from PDF | 0.099668 | 0 | 0 | 24,481 |
2,197,451 | 2010-02-04T05:14:00.000 | 9 | 0 | 1 | 0 | python,string,split | 2,197,605 | 8 | false | 0 | 0 | Having x.split(y) always return a list of 1 + x.count(y) items is a precious regularity -- as @gnibbler's already pointed out it makes split and join exact inverses of each other (as they obviously should be), it also precisely maps the semantics of all kinds of delimiter-joined records (such as csv file lines [[net of quoting issues]], lines from /etc/group in Unix, and so on), it allows (as @Roman's answer mentioned) easy checks for (e.g.) absolute vs relative paths (in file paths and URLs), and so forth.
Another way to look at it is that you shouldn't wantonly toss information out of the window for no gain. What would be gained in making x.split(y) equivalent to x.strip(y).split(y)? Nothing, of course -- it's easy to use the second form when that's what you mean, but if the first form was arbitrarily deemed to mean the second one, you'd have lot of work to do when you do want the first one (which is far from rare, as the previous paragraph points out).
But really, thinking in terms of mathematical regularity is the simplest and most general way you can teach yourself to design passable APIs. To take a different example, it's very important that for any valid x and y x == x[:y] + x[y:] -- which immediately indicates why one extreme of a slicing should be excluded. The simpler the invariant assertion you can formulate, the likelier it is that the resulting semantics are what you need in real life uses -- part of the mystical fact that maths is very useful in dealing with the universe.
Try formulating the invariant for a split dialect in which leading and trailing delimiters are special-cased... counter-example: string methods such as isspace are not maximally simple -- x.isspace() is equivalent to x and all(c in string.whitespace for c in x) -- that silly leading x and is why you so often find yourself coding not x or x.isspace(), to get back to the simplicity which should have been designed into the is... string methods (whereby an empty string "is" anything you want -- contrary to man-in-the-street horse-sense, maybe [[empty sets, like zero &c, have always confused most people;-)]], but fully conforming to obvious well-refined mathematical common-sense!-). | 2 | 146 | 0 | What is the point of '/segment/segment/'.split('/') returning ['', 'segment', 'segment', '']?
Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string returned from each end? | Why are empty strings returned in split() results? | 1 | 0 | 1 | 93,416 |
2,197,451 | 2010-02-04T05:14:00.000 | 6 | 0 | 1 | 0 | python,string,split | 2,197,494 | 8 | false | 0 | 0 | Well, it lets you know there was a delimiter there. So, seeing 4 results lets you know you had 3 delimiters. This gives you the power to do whatever you want with this information, rather than having Python drop the empty elements, and then making you manually check for starting or ending delimiters if you need to know it.
Simple example: Say you want to check for absolute vs. relative filenames. This way you can do it all with the split, without also having to check what the first character of your filename is. | 2 | 146 | 0 | What is the point of '/segment/segment/'.split('/') returning ['', 'segment', 'segment', '']?
Notice the empty elements. If you're splitting on a delimiter that happens to be at position one and at the very end of a string, what extra value does it give you to have the empty string returned from each end? | Why are empty strings returned in split() results? | 1 | 0 | 1 | 93,416 |
2,198,562 | 2010-02-04T09:35:00.000 | 3 | 0 | 1 | 0 | python,ruby,model-view-controller,oop | 2,198,673 | 2 | false | 1 | 0 | They don't require OOP, but they do require procedural code, as they are imperative languages, and not functional ones. You can use some functional techniques.
There are plenty of frameworks that use MVC for both languages, yes. | 2 | 0 | 0 | i know that these 2 languages require oop.
but inside the classes, could you have procedural code?
and for the mvc part, that pattern comes with their frameworks right?
nothing to do with the actual language itself? | no procedural code and non mvc in ruby and python? | 0.291313 | 0 | 0 | 116 |
2,198,562 | 2010-02-04T09:35:00.000 | 4 | 0 | 1 | 0 | python,ruby,model-view-controller,oop | 2,198,616 | 2 | true | 1 | 0 | Neither of these languages require OOP, especially Python. In Python you can write as many ordinary functions as you want, and there are plenty of modules which don't define any classes. In Ruby you can do the same thing, except instead of functions you have methods on a module.
You are correct that MVC is related to the frameworks and not to the languages themselves. | 2 | 0 | 0 | i know that these 2 languages require oop.
but inside the classes, could you have procedural code?
and for the mvc part, that pattern comes with their frameworks right?
nothing to do with the actual language itself? | no procedural code and non mvc in ruby and python? | 1.2 | 0 | 0 | 116 |
2,200,027 | 2010-02-04T13:41:00.000 | 6 | 1 | 1 | 0 | python,arrays,performance | 2,200,806 | 2 | false | 0 | 0 | If you need to alter the buffer in-place (it's not clear if you do, since you use the ambiguous term "to process"), arrays will likely be better, since strings are immutable. In Python 2.6 or better, however, bytearrays can be the best of both worlds -- mutable and rich of methods and usable with regular expressions too.
For read-only operations, strings have the edge over array (thanks to many more methods, plus extras such as regular expressions, available on them), if you're stuck with old Python versions and so cannot use bytearray. Unicode is not an issue in either case (in Python 2; in Python 3, definitely go for bytearray!-). | 1 | 3 | 0 | I am building a routine that processes disk buffers for forensic purposes. Am I better off using python strings or the array() type? My first thought was to use strings, but I'm trying to void unicode problems, so perhaps array('c') is better? | which is more efficient for buffer manipulations: python strings or array() | 1 | 0 | 0 | 681 |
2,200,742 | 2010-02-04T15:15:00.000 | 0 | 0 | 1 | 0 | python,image,png | 2,202,189 | 3 | false | 0 | 0 | THe suggested PIL does not support interlaced PNGs. It can be quite anoying when dealing with lots of PNGs from different origins.
It is possible to open them, but can only read headerinformation from them, all other operations fail. | 1 | 17 | 0 | I haven't found a standard way in Python to read images. Is there really none (because there are so many functions for so many custom stuff that I really wonder that there are no functions to read images)? Or what is it? (It should be available in the MacOSX standard installation and in most recent versions on Linux distributions.)
If there is none, what is the most common lib?
Many search results hint me to Python Imaging Library. If this is some well known Python-lib for reading images, why isn't it included in Python? | Python: default/common way to read png images | 0 | 0 | 0 | 14,554 |
2,201,580 | 2010-02-04T17:02:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine,google-cloud-datastore | 4,088,516 | 6 | false | 1 | 0 | Results of datastore count() queries
and offsets for all datastore queries
are no longer capped at 1000.
Since Version 1.3.6 | 1 | 4 | 0 | I'm building an app on GAE that needs to report on events occurring. An event has a type and I also need to report by event type.
For example, say there is an event A, B and C. They occur periodically at random. User logs in and creates a set of entities to which those events can be attributed. When the user comes back to check the status, I need to be able to tell how many events of A, B and/or C occurred during a specific time range, say a day or a month.
The 1000 limit is throwing a wrench into how I would normally do it. I don't need to retrieve all of the entities and present them to the user, but I do need to show the total count for a specific date range. Any suggestions?
I'm a bit of python/GAE noob... | Need a way to count entities in GAE datastore that meet a certain condition? (over 1000 entities) | 0.099668 | 0 | 0 | 4,016 |
2,202,991 | 2010-02-04T20:34:00.000 | 0 | 0 | 1 | 0 | python,camera,s60 | 2,203,194 | 1 | true | 1 | 0 | This is just a guess. Are you maybe getting low-res images that are suitable for sending via MMS? I would look at the API. | 1 | 0 | 0 | In my project I have to use mobile camera from my own program.
I use python with S60 platform under NOKIA 6220 Classic. It has 5mp-camera.
The problem is that photos quality are very-very low. Seems that auto-focusing doesn't work.
I'd like to know maybe anyone from you made something before. I can buy new telephone if I'll need this.
The main problem - quality of photo. I'm going to screen paper with text. | S60 camera focusing | 1.2 | 0 | 0 | 202 |
2,203,492 | 2010-02-04T21:49:00.000 | 0 | 0 | 1 | 1 | python | 2,203,707 | 2 | false | 0 | 0 | The usual problem with reload is that instances stay bound to the old version of the class. If you are not keeping old instances around, reload is simple and works very well. | 1 | 2 | 0 | I have an application that starts by loading a large pickled trie (173M) from disk and then uses it to do some processing. I'm making frequent changes to the processing part, which is inconvenient because loading the trie takes 15 minutes or so. I'm looking for a way to eliminate the repeated loading during testing, since the trie never changes.
One thing I can't do is use a smaller version of the trie.
Ideas I've had so far are memcached and turning the trie into a web service that accepts a query and returns the data I need.
What I'm looking for is the least-effort path to a situation in which I can repeatedly change and reload the processing code while maintaining access to the in-memory trie. A direct reference to the tree would be preferable since this would require minimal code changes, but really I'm looking to minimize overall effort. | Code Changes While Keeping Large Objects In Memory in Python | 0 | 0 | 0 | 128 |
2,204,087 | 2010-02-04T23:45:00.000 | 1 | 0 | 0 | 1 | c++,python,bash,linear-algebra | 2,204,122 | 3 | false | 0 | 0 | How about extracting the coeffs into a file, import to another machine and then use Excel/Matlab/whatever other program that does this for you? | 2 | 2 | 1 | I am running some calculations in an external machine and at the end I get X, Y pairs. I want to apply linear regression and obtain A, B, and R2. In this machine I can not install anything (it runs Linux) and has basic stuff installed on it, python, bash (of course), etc.
I wonder what would be the best approach to use a script (python, bash, etc) or program (I can compile C and C++) that gives me the linear regression coefficients without the need to add external libraries (numpy, etc) | Minimal linear regression program | 0.066568 | 0 | 0 | 2,428 |
2,204,087 | 2010-02-04T23:45:00.000 | 3 | 0 | 0 | 1 | c++,python,bash,linear-algebra | 2,204,124 | 3 | false | 0 | 0 | For a single, simple, known function (as in your case: a line) it is not hard to simply code a basic least square routine from scratch (but does require some attention to detail). It is a very common assignment in introductory numeric analysis classes.
So, look up least squares on wikipedia or mathworld or in a text book and go to town. | 2 | 2 | 1 | I am running some calculations in an external machine and at the end I get X, Y pairs. I want to apply linear regression and obtain A, B, and R2. In this machine I can not install anything (it runs Linux) and has basic stuff installed on it, python, bash (of course), etc.
I wonder what would be the best approach to use a script (python, bash, etc) or program (I can compile C and C++) that gives me the linear regression coefficients without the need to add external libraries (numpy, etc) | Minimal linear regression program | 0.197375 | 0 | 0 | 2,428 |
2,204,223 | 2010-02-05T00:19:00.000 | 0 | 1 | 0 | 0 | php,python,ruby | 2,204,294 | 5 | false | 1 | 0 | django on Google App Engine gets you free(up to a point) and scalable hosting | 2 | 4 | 0 | I'd like to make a website, it's not a huge project, but I'm a bit out of the web design loop. The last time I made a website was probably around 2002. I figure the web frameworks and tools have come a ways since then. It's mostly the design aspect that I'd like it to make easier. I can do the backend language in any language.
My question is:
What are some tools or web frameworks that make the design aspect of making a website easier. It could be a framework in php/python/ruby.
As far as tools go, free/open source is preferred, but I wouldn't mind looking at good commercial alternatives. | What's a good web framework and/or tool for a software developer? | 0 | 0 | 0 | 335 |
2,204,223 | 2010-02-05T00:19:00.000 | 0 | 1 | 0 | 0 | php,python,ruby | 2,204,292 | 5 | false | 1 | 0 | It really depends on a couple things:
What are you familiar with? You indicated that you've done some web development in the past. What did you use? If you were using classic ASP, then learning ASP.NET should be less of a jump for you.
What are you trying to create? If all you need are static HTML files with a tiny bit of functionality, you could try learning PHP as it's pretty quick and easy to get going. If you need light database access, then maybe Ruby on Rails will be your cup of tea.
With that being said, I'd recommend the following in no particular order (just because I've tried them and they're all pretty decent):
Ruby on Rails
ASP.NET / ASP.NET MVC
PHP | 2 | 4 | 0 | I'd like to make a website, it's not a huge project, but I'm a bit out of the web design loop. The last time I made a website was probably around 2002. I figure the web frameworks and tools have come a ways since then. It's mostly the design aspect that I'd like it to make easier. I can do the backend language in any language.
My question is:
What are some tools or web frameworks that make the design aspect of making a website easier. It could be a framework in php/python/ruby.
As far as tools go, free/open source is preferred, but I wouldn't mind looking at good commercial alternatives. | What's a good web framework and/or tool for a software developer? | 0 | 0 | 0 | 335 |
2,205,047 | 2010-02-05T04:29:00.000 | 1 | 0 | 0 | 0 | python,pylons | 2,224,250 | 1 | true | 0 | 0 | Pylons's template configures the database in config/environment.py, probably with the engine_from_config method. It finds all the config settings with a particular prefix and passes them as keyword arguments to create_engine.
You can just replace that with a few calls to sqlalchemy.create_engine() with the per-engine url, and common username, and password from your config file. | 1 | 2 | 0 | I'm trying to implement the proper architecture for multiple databases under Python + Pylons. I can't put everything in the config files since one of the database connections requires the connection info from a previous database connection (sharding).
What's the best way to implement such an infrastructure? | Multiple database connections with Python + Pylons + SQLAlchemy | 1.2 | 1 | 0 | 988 |
2,205,832 | 2010-02-05T08:19:00.000 | 2 | 1 | 1 | 0 | c#,java,.net,python,memory | 2,205,899 | 2 | true | 1 | 0 | Since you can install all of those for free and it sounds like you already have the code implemented in both .Net and Java then I suggest you benchmark the program on all four platforms (windows/linux * java/.net).
It sounds like all the heavy lifting is done in Java/C#, so I suspect the relative performance of Jython vs. IronPython is largely irrelevant. | 2 | 3 | 0 | i'm doing simulation which generates thousands of result objects.
Each object size is around 1mb, and all the result objects should be on memory to be queried for various ad hoc reports. And it takes 1~2 secs to make one result object.
So it takes more than 5 minutes to get one simulation done even though i fully use my quad-core cpu with parallel execution. And the task process takes more than 4~5 gb memory for one simulation set. The problem is, I want to run more simulation sets simultaneously and get it done more quickly.
Currently, I'm doing this job using c# and ironpython on windows vista64, quad-core cpu with 8g memory. I gonna order a new computer, 24 gb memory with better cpu and ultimately, i may buy workstation with multi cpus and more memories.
So my question is, what is the best way to utilize new hardware?
I consider one of the combinations below.
ironpython + c# on windows 64
ironpython + c# (mono) on linux 64
jython + java on windows 64
jython + java on linux 64
Simulation engine is written in c# / java, and i use python to make reports.
Which combination do you guys think is the best?
Is there no big difference between .net and java platform to handle memory consuming task?
Is there no difference between windows and linux?
I sometimes run my current c# + ironpython code on my ubuntu laptop (32bit, 2g ram) and feel that it seems pretty stable compared to windows .net env on the same spec hardware. But i dont know when the underlying hardware is pretty better.
And i welcome any kind of suggestion regardless of the choices above. | best (python) setup for cpu / memory intensive task | 1.2 | 0 | 0 | 839 |
2,205,832 | 2010-02-05T08:19:00.000 | 2 | 1 | 1 | 0 | c#,java,.net,python,memory | 2,205,986 | 2 | false | 1 | 0 | @Dave is spot on, if you really care benchmark each combination and see.
Personally I'd suggest you stick with the tool set that you are most comfortable with, be that Windows, Java, Linux, .Net or any random combination there of. Your level of productivity in maintaining and developing your software usually trumps any minor performance gain you might get from switching OS or VM. | 2 | 3 | 0 | i'm doing simulation which generates thousands of result objects.
Each object size is around 1mb, and all the result objects should be on memory to be queried for various ad hoc reports. And it takes 1~2 secs to make one result object.
So it takes more than 5 minutes to get one simulation done even though i fully use my quad-core cpu with parallel execution. And the task process takes more than 4~5 gb memory for one simulation set. The problem is, I want to run more simulation sets simultaneously and get it done more quickly.
Currently, I'm doing this job using c# and ironpython on windows vista64, quad-core cpu with 8g memory. I gonna order a new computer, 24 gb memory with better cpu and ultimately, i may buy workstation with multi cpus and more memories.
So my question is, what is the best way to utilize new hardware?
I consider one of the combinations below.
ironpython + c# on windows 64
ironpython + c# (mono) on linux 64
jython + java on windows 64
jython + java on linux 64
Simulation engine is written in c# / java, and i use python to make reports.
Which combination do you guys think is the best?
Is there no big difference between .net and java platform to handle memory consuming task?
Is there no difference between windows and linux?
I sometimes run my current c# + ironpython code on my ubuntu laptop (32bit, 2g ram) and feel that it seems pretty stable compared to windows .net env on the same spec hardware. But i dont know when the underlying hardware is pretty better.
And i welcome any kind of suggestion regardless of the choices above. | best (python) setup for cpu / memory intensive task | 0.197375 | 0 | 0 | 839 |
2,206,125 | 2010-02-05T09:20:00.000 | 1 | 0 | 0 | 0 | python | 2,206,303 | 1 | false | 0 | 0 | Probably, you've installed 32 bit library on 64 bit system. | 1 | 0 | 0 | I'm trying to use the WConio library for python, but when I import it, it gives this error:
Traceback (most recent call last):
File "WConioExample.py", line 15, in
< module>
import WConio File "d:\tools\development\python2.5\lib\site-packages\WConio.py",
line 23, in
from _WConio import * ImportError: DLL load failed with error code 193
I've installed WConio-1.5.win32-py2.5.exe and made sure the _WConio.pyd file exists. I'm using it on Win7.
I have searched for this problem, but the results were of no good use.
What can I do to solve this? | Problems using the python WConio library | 0.197375 | 0 | 0 | 1,398 |
2,206,353 | 2010-02-05T09:57:00.000 | 1 | 0 | 0 | 0 | javascript,python,django | 2,206,464 | 3 | false | 1 | 0 | I'm not familiar with django, so this might be completely incorrect.
Can you write out the variables to hidden HTML fields on the page. This will allow you to access them from JavaScript, or utilise them in form posts should you require that. | 2 | 5 | 0 | I would like some variables from my settings.py to be available in every javascript running across my project.
What is the most elegant way of achieving this?
Right now I can think of two:
write a context processor and declare those globals in a base template. All templates must extend the base template.
declare those globals in a dynamically generated .js file (by some view) and load this file using <script> tag in a base template. All templates must extend the base template.
Can I do it without a base template? | global variable from django to javascript | 0.066568 | 0 | 0 | 1,966 |
2,206,353 | 2010-02-05T09:57:00.000 | 6 | 0 | 0 | 0 | javascript,python,django | 2,206,532 | 3 | true | 1 | 0 | I would use option 1. You should use a base template in any case, and a context processor is probably the best way of getting the variables into it. | 2 | 5 | 0 | I would like some variables from my settings.py to be available in every javascript running across my project.
What is the most elegant way of achieving this?
Right now I can think of two:
write a context processor and declare those globals in a base template. All templates must extend the base template.
declare those globals in a dynamically generated .js file (by some view) and load this file using <script> tag in a base template. All templates must extend the base template.
Can I do it without a base template? | global variable from django to javascript | 1.2 | 0 | 0 | 1,966 |
2,207,110 | 2010-02-05T12:23:00.000 | 3 | 0 | 0 | 0 | python,url,video-streaming,rtsp | 2,247,454 | 4 | false | 0 | 0 | If you do not want to use a library, as suggested by synack, you can open a socket connection to the given URL and send an RTSP DESCRIEBE request. That is actually quite simple since RTSP is text-based HTTP-like. You would need to parse the response for a meaningful result, e.g look for the presence of media streams. | 2 | 4 | 0 | I am trying to verify that a video service is provided from an URL in python. I am asking does anyone know of any good libraries to use or a way to do this. I have not found much info for this on the web.
Thanks | Verify RTSP service via URL | 0.148885 | 0 | 1 | 4,091 |
2,207,110 | 2010-02-05T12:23:00.000 | 0 | 0 | 0 | 0 | python,url,video-streaming,rtsp | 2,421,464 | 4 | false | 0 | 0 | I don't believe Live555 provides a python library. However, they do provide source code that can be compiled to build openRTSP. This is a simple command-line utility that will perform the entire RTSP handshake to connect to the server and begin streaming to the client. It also can provide statistic measurements (such as jitter, number of packets lost, etc.) that can be used to measure the quality of the streaming connection. | 2 | 4 | 0 | I am trying to verify that a video service is provided from an URL in python. I am asking does anyone know of any good libraries to use or a way to do this. I have not found much info for this on the web.
Thanks | Verify RTSP service via URL | 0 | 0 | 1 | 4,091 |
2,207,562 | 2010-02-05T13:44:00.000 | 0 | 0 | 0 | 0 | python,django | 2,207,718 | 2 | false | 1 | 0 | One, popular, option would be to use something like tags. So you'd have the stuff that's common to all items, like an item ID, name, description, price. Then you'd have some more generic tags or described tags in another table, associated with those items. You could have a tag that represents the season, or automobile specifications, etc...
Of course, it really depends on how you design the system to cope with that additional information. | 1 | 1 | 0 | what i want, is to receive advices to define a re-usefull Product model, for a shopping site app, nowadays I know that the store is going to commerce with "clothing", so the product model will have a "season or collections" relationship, but in the future I should use that app to commerce with X product, e.g: "cars" which have "mechanical specifications" relationships.
So Im thinking in metamodels, creating a generic model defined by key/values, but, how to make the relationships?.
But, you are the experts community and I hope you help me to see beyond. | How to write dynamic Django models? | 0 | 0 | 0 | 580 |
2,208,828 | 2010-02-05T16:55:00.000 | 6 | 0 | 1 | 1 | python,windows,64-bit | 3,740,665 | 22 | false | 0 | 0 | Many of these proposed solutions, such as platform.architecture(), fail because their results depend on whether you are running 32-bit or 64-bit Python.
The only reliable method I have found is to check for the existence of os.environ['PROGRAMFILES(X86)'], which is unfortunately hackish. | 4 | 41 | 0 | Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files.
Many thanks | Detect 64bit OS (windows) in Python | 1 | 0 | 0 | 46,662 |
2,208,828 | 2010-02-05T16:55:00.000 | 38 | 0 | 1 | 1 | python,windows,64-bit | 2,208,869 | 22 | false | 0 | 0 | I guess you should look in os.environ['PROGRAMFILES'] for the program files folder. | 4 | 41 | 0 | Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files.
Many thanks | Detect 64bit OS (windows) in Python | 1 | 0 | 0 | 46,662 |
2,208,828 | 2010-02-05T16:55:00.000 | -2 | 0 | 1 | 1 | python,windows,64-bit | 2,208,946 | 22 | false | 0 | 0 | There should be a directory under Windows 64bit, a Folder called \Windows\WinSxS64 for 64 bit, under Windows 32bit, it's WinSxS. | 4 | 41 | 0 | Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files.
Many thanks | Detect 64bit OS (windows) in Python | -0.01818 | 0 | 0 | 46,662 |
2,208,828 | 2010-02-05T16:55:00.000 | 3 | 0 | 1 | 1 | python,windows,64-bit | 2,209,113 | 22 | false | 0 | 0 | You should be using environment variables to access this. The program files directory is stored in the environment variable PROGRAMFILES on x86 Windows, the 32-bit program files is directory is stored in the PROGRAMFILES(X86) environment variable, these can be accessed by using os.environ('PROGRAMFILES').
Use sys.getwindowsversion() or the existence of PROGRAMFILES(X86) (if 'PROGRAMFILES(X86)' in os.environ) to determine what version of Windows you are using. | 4 | 41 | 0 | Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files.
Many thanks | Detect 64bit OS (windows) in Python | 0.027266 | 0 | 0 | 46,662 |
2,211,822 | 2010-02-06T02:55:00.000 | 1 | 0 | 1 | 0 | python,syntax,variable-assignment | 2,211,832 | 4 | false | 0 | 0 | Multiple assignment is implemented as a combination of tuple packing and tuple unpacking, to my knowledge, so it should have the same effect. | 2 | 8 | 0 | I'm trying to prepare for a future in computer science, so I started with ECMAScript and I am now trying to learn more about Python. Coming from ECMAScript, seeing multiple assignments such as a, b, c = 1, 2, 3 leaves me bewildered for a moment, until I realize that there are multiple assignments going on. To make things a bit clearer, I'd really like to do (a, b, c) = (1, 2, 3) but I am not sure if this will be a measurable performance hit. From what I understand, tuples are essentially how multiple assignments work regardless, but there are a great many oddities in the world, so I try not to assume anything.
Thanks in advance | Method of Multiple Assignment in Python | 0.049958 | 0 | 0 | 4,022 |
2,211,822 | 2010-02-06T02:55:00.000 | 11 | 0 | 1 | 0 | python,syntax,variable-assignment | 2,211,828 | 4 | true | 0 | 0 | It should not have any effect on performance. The parenthesis do not make it a tuple, the comma's do. So (1,2,3) is exactly the same as 1,2,3 | 2 | 8 | 0 | I'm trying to prepare for a future in computer science, so I started with ECMAScript and I am now trying to learn more about Python. Coming from ECMAScript, seeing multiple assignments such as a, b, c = 1, 2, 3 leaves me bewildered for a moment, until I realize that there are multiple assignments going on. To make things a bit clearer, I'd really like to do (a, b, c) = (1, 2, 3) but I am not sure if this will be a measurable performance hit. From what I understand, tuples are essentially how multiple assignments work regardless, but there are a great many oddities in the world, so I try not to assume anything.
Thanks in advance | Method of Multiple Assignment in Python | 1.2 | 0 | 0 | 4,022 |
2,211,967 | 2010-02-06T03:57:00.000 | 2 | 0 | 1 | 0 | python,parsing,rule-engine,expert-system | 7,619,477 | 2 | false | 0 | 0 | It looks like you search for "grammar inference" (grammar induction) library. | 1 | 8 | 0 | I am seeking direction and attempting to label this problem:
I am attempting to build a simple inference engine (is there a better name?) in Python which will take a string and -
1 - create a list of tokens by simply creating a list of white space separated values
2 - categorise these tokens, using regular expressions
3 - Use a higher level set of rules to make decisions based on the categorisations
Example:
"90001" - one token, matches the zipcode regex, a rule exists for a string containing just a zipcode causes a certain behaviour to occur
"30 + 14" - three tokens, regexs for numerical value and mathematical operators match, a rule exists for a numerical value followed by a mathematical operator followed by another numerical value causes a certain behaviour to occur
I'm struggling with how best to do step #3, the higher level set of rules. I'm sure that some framework must exist. Any ideas? Also, how would you characterise this problem? Rule based system, expert system, inference engine, something else?
Thanks! | Building an Inference Engine in Python | 0.197375 | 0 | 0 | 3,788 |
2,211,990 | 2010-02-06T04:04:00.000 | 6 | 0 | 1 | 0 | python,generator,primes | 2,212,842 | 12 | false | 0 | 0 | Do a segmented sieve, where the size of a segment is determined by available memory or the maximal size of a bitset.
For each segment represent the numbers in some interval [n; n + segment_size) as a bit set and sieve with all prime numbers below the square root of the upper bound.
Using a bit set uses less memory than a hash table or tree data structure, because you are working with dense sets of numbers. | 1 | 68 | 0 | This is not a homework, I am just curious.
INFINITE is the key word here.
I wish to use it as for p in primes(). I believe that this is a built-in function in Haskell.
So, the answer cannot be as naive as "Just do a Sieve".
First of all, you do not know how many consecutive primes will be consumed. Well, suppose you could concoct 100 of them at a time. Would you use the same Sieve approach as well as the frequency of prime numbers formula?
I prefer non-concurrent approach.
Thank you for reading (and writing ;) )! | How to implement an efficient infinite generator of prime numbers in Python? | 1 | 0 | 0 | 30,775 |
2,213,531 | 2010-02-06T15:09:00.000 | 9 | 0 | 1 | 0 | python | 2,213,535 | 8 | true | 0 | 0 | In python it helps to think of declaring variables as binding values to names.
Try not to misspell them, or you will have new ones (assuming you are talking about assignment statements - referencing them will cause an exception).
If you are talking about instance variables, you won't be able to use them afterwards.
For example, if you had a class myclass and in its __init__ method wrote self.myvar = 0, then trying to reference self.myvare will cause an error, rather than give you a default value. | 3 | 10 | 0 | Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed.
Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?
How would you avoid such a situation? | What's the pythonic way of declaring variables? | 1.2 | 0 | 0 | 5,400 |
2,213,531 | 2010-02-06T15:09:00.000 | 5 | 0 | 1 | 0 | python | 2,213,543 | 8 | false | 0 | 0 | Python never forces you to create a variable only when you use it. You can always bind None to a name and then use the name elsewhere later. | 3 | 10 | 0 | Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed.
Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?
How would you avoid such a situation? | What's the pythonic way of declaring variables? | 0.124353 | 0 | 0 | 5,400 |
2,213,531 | 2010-02-06T15:09:00.000 | 15 | 0 | 1 | 0 | python | 2,213,663 | 8 | false | 0 | 0 | It's a silly artifact of Python's inspiration by "teaching languages", and it serves to make the language more accessible by removing the stumbling block of "declaration" entirely. For whatever reason (probably represented as "simplicity"), Python never gained an optional stricture like VB's "Option Explicit" to introduce mandatory declarations. Yes, it can be a source of bugs, but as the other answers here demonstrate, good coders can develop habits that allow them to compensate for pretty much any shortcoming in the language -- and as shortcomings go, this is a pretty minor one. | 3 | 10 | 0 | Usually declaring variables on assignment is considered a best practice in VBScript or JavaScript , for example, although it is allowed.
Why does Python force you to create the variable only when you use it? Since Python is case sensitive can't it cause bugs because you misspelled a variable's name?
How would you avoid such a situation? | What's the pythonic way of declaring variables? | 1 | 0 | 0 | 5,400 |
2,213,595 | 2010-02-06T15:27:00.000 | 1 | 0 | 0 | 0 | python,django-models | 2,213,602 | 3 | true | 1 | 0 | The default primary key will already be a unique monotonic integer (even in SQLite if you don't delete any records), so you can just use that for it. | 1 | 2 | 0 | I can't see any provision for this in the django docs, so how do people go about doing this.
My specific case is this.
I have a shopping cart, each cart instance has an invoice number field, however the invoice number is only generated if the cart goes to a paid status, so not all shopping cart instances will have an invoice number. I want all invoice numbers to be sequential with no gaps between them, so the default pk isn't perfect in this case, so I want a class variable that acts as a counter for the invoice numbers, and is accessable by all instances. | how do people normally deal with class variables in django? | 1.2 | 0 | 0 | 680 |
2,214,705 | 2010-02-06T20:59:00.000 | 1 | 0 | 0 | 0 | python,django | 2,214,882 | 2 | false | 1 | 0 | Why would you want to do this? You don't have to use it if you don't want to.
In any case, the back-reference is only a code shortcut - it's exactly equivalent to Car.objects.filter(person_id=person.id). | 1 | 1 | 0 | I know that I can use ForeignKey's related_name argument to control what the back-reference's name will be. But is it possible to avoid creating a back-reference completely?
(e.g., I have in Car a field ForeignKey(Person), and I don't want Person to have an attribute that leads backs to Car.) | Django: Making ForeignKey not create a back-reference | 0.099668 | 0 | 0 | 1,714 |
2,215,461 | 2010-02-07T01:06:00.000 | 12 | 0 | 0 | 0 | python,visualization,graphviz,pydot | 2,215,870 | 3 | false | 0 | 0 | There are several things you can do.
You can set the maximum size of your graph, using 'size' (e.g., size = "4, 8" (inches)). This fixes the size of your final layout. Unlike most other node,edge, and graph parameters in the dot language, 'size' has no default. Also, the default orientation is 'portrait', which i believe is what you want (for a graph that is taller vs. wider), but you might want to set this parameter explicitly in case it was set to 'landscape' earlier.
'Size' can be used with the 'ratio' parameter (the layout aspect ratio) to manipulate the configuration. 'Ratio' takes a float (e.g., ratio = "2.0") or 'auto' or 'fill'. (The latter tells graphviz to fill use the entire graph region alloted by 'size'.
The parameters that have the greatest effect on graph configuration are 'nodesep' and 'ranksep'. These are the minimum horizontal distance between adjacent nodes of equal 'rank', and the minimum vertical distance between adjacent ranks of nodes. The default values are 0.25 and 0.75 inches, respectively. To get the configuration you want, you will want to simultaneously increase nodesep and decrease ranksep. Gradual iteration should allow you to quickly converge on a set of values for these two parameters that gives you the configuration you want. | 1 | 13 | 0 | I am using Graphviz in Python via pydot. The diagram I am making has many clusters of directed graphs. pydot is putting them next to each other horizontally resulting in an image that is very wide. How can I tell it to output images of a maximum width so that I can scroll vertically instead? | Placing nodes vertically in Graphviz using pydot | 1 | 0 | 0 | 11,909 |
2,216,816 | 2010-02-07T13:02:00.000 | 2 | 0 | 1 | 1 | python,swig,disassembly | 2,217,220 | 4 | false | 0 | 0 | Well, after much meddling around, I managed to compile SWIGed libdisasm!
Unfortunately, it seems to crash python on incorrect (and sometimes correct) usage.
How I did it:
I compiled libdisasm.lib using Visual Studio 6, the only thing you need for this is the source code in whichever libdisasm release you use, and stdint.h and inttypes.h (The Visual C++ compatible version, google it).
I SWIGed the given libdisasm_oop.i file with the following command line
swig -python -shadow -o x86disasm_wrap.c -outdir . libdisasm_oop.i
Used Cygwin to run ./configure in the libdisasm root dir. The only real thing you get from this is config.h
I then created a new DLL project, added x86disasm_wrap.c to it, added the c:\PythonXX\libs and c:\PythonXX\Include folders to the corresponding variables, set to Release configuration (important, either this or do #undef _DEBUG before including python.h).
Also, there is a chance you'll need to fix the path to config.h.
Compiled the DLL project, and named the output _x86disasm.dll.
Place that in the same folder as the SWIG generated x86disasm.py and you're done.
Any suggestions for other, less crashy disasm libs for python? | 1 | 7 | 0 | I'm trying to create a python script that will disassemble a binary (a Windows exe to be precise) and analyze its code.
I need the ability to take a certain buffer, and extract some sort of struct containing information about the instructions in it.
I've worked with libdisasm in C before, and I found it's interface quite intuitive and comfortable.
The problem is, its Python interface is available only through SWIG, and I can't get it to compile properly under Windows.
At the availability aspect, diStorm provides a nice out-of-the-box interface, but it provides only the Mnemonic of each instruction, and not a binary struct with enumerations defining instruction type and what not.
This is quite uncomfortable for my purpose, and will require a lot of what I see as spent time wrapping the interface to make it fit my needs.
I've also looked at BeaEngine, which does in fact provide the output I need, a struct with binary info concerning each instruction, but its interface is really odd and counter-intuitive, and it crashes pretty much instantly when provided with wrong arguments.
The CTypes sort of ultimate-death-to-your-python crashes.
So, I'd be happy to hear about other solutions, which are a little less time consuming than messing around with djgcc or mingw to make SWIGed libdisasm, or writing an OOP wrapper for diStorm.
If anyone has some guidance as to how to compile SWIGed libdisasm, or better yet, a compiled binary (pyd or dll+py), I'd love to hear/have it. :)
Thanks ahead. | Disassembling with python - no easy solution? | 0.099668 | 0 | 0 | 1,298 |
2,218,637 | 2010-02-07T22:30:00.000 | 1 | 0 | 0 | 0 | python,scapy,komodoedit | 2,219,126 | 2 | false | 1 | 0 | Autocomplete in Python is a hit or miss proposition. It varies widely -- some things can be analyzed by Komodo and some can't.
If it won't autocomplete, it's probably because it relies on too many metaclass techniques that seem to baffle Komodo. | 2 | 1 | 0 | I am trying to get scapy to auto complete in komodo edit with no success, has anyone successfully done this?
Thanks,
Python New Comer | Python + Komodo Edit | 0.099668 | 0 | 0 | 654 |
2,218,637 | 2010-02-07T22:30:00.000 | 1 | 0 | 0 | 0 | python,scapy,komodoedit | 2,220,978 | 2 | false | 1 | 0 | If you're in virtualenv or have some tricky python paths you have to add additional import directories in:
Preferences -> Languages -> Python ->
Additional Python Import Directories
Komodo can't understand these things out of the box.
Also make sure you have following option enabled:
Preferences -> Code Intelligence ->
Include all files and directories from the project base directory
These steps would enable code completion to decent quality but as mentioned by S.Lott it is nearly impossible to implement full-featured auto-completion (like in Java or C#) in Python due its dynamic nature. | 2 | 1 | 0 | I am trying to get scapy to auto complete in komodo edit with no success, has anyone successfully done this?
Thanks,
Python New Comer | Python + Komodo Edit | 0.099668 | 0 | 0 | 654 |
2,219,503 | 2010-02-08T04:01:00.000 | 1 | 0 | 0 | 0 | python,matplotlib,antialiasing | 2,223,165 | 4 | true | 0 | 0 | It seems this is not possible. Some classes such as Line2D have a "set_antialiased" method, but Text lacks this. I suggest you file a feature request on the Sourceforge tracker, and send an email to the matplotlib mailing list mentioning the request. | 1 | 5 | 1 | Is there any way to turn off antialias for all text in a plot, especially the ticklabels? | Matplotlib turn off antialias for text in plot? | 1.2 | 0 | 0 | 2,659 |
2,219,514 | 2010-02-08T04:05:00.000 | 0 | 0 | 0 | 0 | python,wxpython | 2,309,469 | 1 | false | 0 | 1 | Can you put a self contained sample code and we can try to fix that.
Have you tried adding custom items which return correct height for your panel? | 1 | 0 | 0 | Is there a trick to sizing controls for wx.lib.CUstomTreeCtrl? I've been trying to create my own custom controls (just panels with sub-controls in them) and add them as items in my CustomTreeCtrl, but when the tree renders, it's as if the panels aren't expanded to the appropriate size. I can set the panel size manually by using SetSize() but if I do that, the tree doesn't seem to be aware of the size (the rows aren't scaled to the appropriate size) and the items are rendered on top of each other. I've tried to override DoGetBestSize() but it seems to not have any effect. | Sizing controls for items in wx.lib.CustomTreeCtrl | 0 | 0 | 0 | 143 |
2,219,998 | 2010-02-08T06:46:00.000 | 2 | 0 | 1 | 0 | python | 2,220,969 | 3 | false | 0 | 0 | Here is another implementation that will recursively print out all subclasses, with indentation.
def findsubclass(baseclass, indent=0):
if indent == 0:
print "Subclasses of %s are:" % baseclass.__name__
indent = indent + 1
for c in baseclass.__subclasses__():
print "-"*indent*4 + ">" + c.__name__
findsubclass(c, indent) | 1 | 21 | 0 | Suppose you have a base class A, and this class is reimplemented by B and C.
Suppose also there's a class method A.derived() that tells you which classes are reimplementing A, hence returns [B, C], and if you later on have class D(A): pass or class D(B): pass, now A.derived() returns [B,C,D].
How would you implement the method A.derived() ? I have the feeling that is not possible unless you use metaclasses. You can traverse the inheritance tree only from child to parent with the standard mechanism. To have the link in the other direction, you have to keep it "by hand", and this means overriding the traditional class declaration mechanics. | How to know all the derived classes of a parent? | 0.132549 | 0 | 0 | 4,946 |
2,220,099 | 2010-02-08T07:18:00.000 | 4 | 0 | 1 | 0 | python,tuples | 2,220,107 | 1 | true | 0 | 0 | Sql query select max(rowid) would return Tuple data like records=(1000,)
You may need to do like numerator / records[0] | 1 | 1 | 0 | TypeError: unsupported operand type(s) for /: 'tuple' and 'tuple'
I'm getting above error , while I fetched a record using query "select max(rowid) from table"
and assigned it to variable and while performing / operation is throws above message.
How to resolve this. | python tuple division | 1.2 | 1 | 0 | 1,106 |
2,220,645 | 2010-02-08T09:48:00.000 | 12 | 0 | 1 | 0 | python,python-stackless | 2,221,057 | 6 | false | 0 | 0 | Stackless Python's main benefit is the support for very lightweight coroutines. CPython doesn't support coroutines natively (although I expect someone to post a generator-based hack in the comments) so Stackless is a clear improvement on CPython when you have a problem that benefits from coroutines.
I think the main area where they excel are when you have many concurrent tasks running within your program. Examples might be game entities that run a looping script for their AI, or a web server that is servicing many clients with pages that are slow to create.
You still have many of the typical problems with concurrency correctness however regarding shared data, but the deterministic task switching makes it easier to write safe code since you know exactly where control will be transferred and therefore know the exact points at which the shared state must be up to date. | 3 | 44 | 0 | There are many questions related to Stackless Python. But none answering this my question, I think (correct me if wrong - please!). There's some buzz about it all the time so I curious to know. What would I use Stackless for? How is it better than CPython?
Yes it has green threads (stackless) that allow quickly create many lightweight threads as long as no operations are blocking (something like Ruby's threads?). What is this great for? What other features it has I want to use over CPython? | What would I use Stackless Python for? | 1 | 0 | 0 | 11,493 |
2,220,645 | 2010-02-08T09:48:00.000 | 6 | 0 | 1 | 0 | python,python-stackless | 2,279,081 | 6 | false | 0 | 0 | While I've not used Stackless itself, I have used Greenlet for implementing highly-concurrent network applications. Some of the use cases Linden Lab has put it towards are: high-performance smart proxies, a fast system for distributing commands over huge numbers of machines, and an application that does a ton of database writes and reads (at a ratio of about 1:2, which is very write-heavy, so it's spending most of its time waiting for the database to return), and a web-crawler-type-thing for internal web data. Basically any app that's expecting to have to do a lot of network I/O will benefit from being able to create a bajillion lightweight threads. 10,000 connected clients doesn't seem like a huge deal to me.
Stackless or Greenlet aren't really a complete solution, though. They are very low-level and you're going to have to do a lot of monkeywork to build an application with them that uses them to their fullest. I know this because I maintain a library that provides a networking and scheduling layer on top of Greenlet, specifically because writing apps is so much easier with it. There are a bunch of these now; I maintain Eventlet, but also there is Concurrence, Chiral, and probably a few more that I don't know about.
If the sort of app you want to write sounds like what I wrote about, consider one of these libraries. The choice of Stackless vs Greenlet is somewhat less important than deciding what library best suits the needs of what you want to do. | 3 | 44 | 0 | There are many questions related to Stackless Python. But none answering this my question, I think (correct me if wrong - please!). There's some buzz about it all the time so I curious to know. What would I use Stackless for? How is it better than CPython?
Yes it has green threads (stackless) that allow quickly create many lightweight threads as long as no operations are blocking (something like Ruby's threads?). What is this great for? What other features it has I want to use over CPython? | What would I use Stackless Python for? | 1 | 0 | 0 | 11,493 |
2,220,645 | 2010-02-08T09:48:00.000 | 6 | 0 | 1 | 0 | python,python-stackless | 2,220,658 | 6 | false | 0 | 0 | EVEOnline is largely programmed in Stackless Python. They have several dev blogs on the use of it. It seems it is very useful for high performance computing. | 3 | 44 | 0 | There are many questions related to Stackless Python. But none answering this my question, I think (correct me if wrong - please!). There's some buzz about it all the time so I curious to know. What would I use Stackless for? How is it better than CPython?
Yes it has green threads (stackless) that allow quickly create many lightweight threads as long as no operations are blocking (something like Ruby's threads?). What is this great for? What other features it has I want to use over CPython? | What would I use Stackless Python for? | 1 | 0 | 0 | 11,493 |
2,220,699 | 2010-02-08T09:56:00.000 | 53 | 0 | 1 | 0 | python,dynamic,eval,exec | 14,097,282 | 3 | false | 0 | 0 | exec is for statement and does not return anything.
eval is for expression and returns value of expression.
expression means "something" while statement means "do something". | 1 | 533 | 0 | I've been looking at dynamic evaluation of Python code, and come across the eval() and compile() functions, and the exec statement.
Can someone please explain the difference between eval and exec, and how the different modes of compile() fit in? | What's the difference between eval, exec, and compile? | 1 | 0 | 0 | 254,912 |
2,222,843 | 2010-02-08T15:58:00.000 | 10 | 0 | 1 | 0 | python,syntax,keyword,statements | 2,222,867 | 5 | true | 0 | 0 | No, you cannot add new syntax within a Python program. The only way to alter the language is to edit and recompile the grammar file and supporting C code, to obtain a new altered interpreter, compiler and runtime. | 3 | 6 | 0 | Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own.
If so, how do I do it? Can you point me to good docs on the subject? | Making your own statements | 1.2 | 0 | 0 | 1,414 |
2,222,843 | 2010-02-08T15:58:00.000 | 1 | 0 | 1 | 0 | python,syntax,keyword,statements | 2,223,039 | 5 | false | 0 | 0 | There are programming languages that let you do this (Tcl, for example), but Python isn't one of those languages. | 3 | 6 | 0 | Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own.
If so, how do I do it? Can you point me to good docs on the subject? | Making your own statements | 0.039979 | 0 | 0 | 1,414 |
2,222,843 | 2010-02-08T15:58:00.000 | 3 | 0 | 1 | 0 | python,syntax,keyword,statements | 2,222,909 | 5 | false | 0 | 0 | You can't (re)define language keywords without rewriting a compiler/interpreter/etc. What you could do perhaps is write a something like a DSL (domain-specific language) and something that translates your keyword statements into proper python statements, which might be an easier route. | 3 | 6 | 0 | Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own.
If so, how do I do it? Can you point me to good docs on the subject? | Making your own statements | 0.119427 | 0 | 0 | 1,414 |
2,223,576 | 2010-02-08T17:38:00.000 | 0 | 0 | 0 | 0 | python,design-patterns,statistics,matrix,survey | 2,224,074 | 3 | false | 0 | 0 | On the analysis, if your six questions have been posed in a way that would lead you to believe the answers will be correlated, consider conducting a factor analysis on the raw scores first. Often comparing the factors across regions or customer type has more statistical power than comparing across questions alone. Also, the factor scores are more likely to be normally distributed (they are the weighted sum of 6 observations) while the six questions alone would not. This allows you to apply t-tests based on the normal distibution when comparing factor scores.
One watchout, though. If you assign numeric values to answers - 1 = much worse, 2 = worse, etc. you are implying that the distance between much worse and worse is the same as the distance between worse and same. This is generally not true - you might really have to screw up to get a vote of "much worse" while just being a passive screw up might get you a "worse" score. So the assignment of cardinal (numerics) to ordinal (ordering) has a bias of its own.
The unequal number of participants per quarter isn't a problem - there are statistical t-tests that deal with unequal sample sizes. | 1 | 1 | 1 | I'm doing an ongoing survey, every quarter. We get people to sign up (where they give extensive demographic info).
Then we get them to answer six short questions with 5 possible values much worse, worse, same, better, much better.
Of course over time we will not get the same participants,, some will drop out and some new ones will sign up,, so I'm trying to decide how to best build a db and code (hope to use Python, Numpy?) to best allow for ongoing collection and analysis by the various categories defined by the initial demographic data..As of now we have 700 or so participants, so the dataset is not too big.
I.E.;
demographic, UID, North, south, residential. commercial Then answer for 6 questions for Q1
Same for Q2 and so on,, then need able to slice dice and average the values for the quarterly answers by the various demographics to see trends over time.
The averaging, grouping and so forth is modestly complicated by having differing participants each quarter
Any pointers to design patterns for this sort of DB? and analysis? Is this a sparse matrix? | Design pattern for ongoing survey anayisis | 0 | 0 | 0 | 1,157 |
2,223,654 | 2010-02-08T17:49:00.000 | 1 | 0 | 1 | 0 | python,multithreading | 2,223,674 | 4 | false | 0 | 0 | You cannot. Threads can't be killed from outside. The only thing you can do is add a way to ask the thread to exit. Obviously you won't be able to do this if the thread is blocked in some systemcall. | 2 | 1 | 0 | I am creating a thread in my Python app with thread.start_new_thread.
How do I stop it if it hasn't finished in three seconds time? | Stopping a thread in python | 0.049958 | 0 | 0 | 1,913 |
2,223,654 | 2010-02-08T17:49:00.000 | 1 | 0 | 1 | 0 | python,multithreading | 2,223,854 | 4 | true | 0 | 0 | If you really need to do this (e.g. the thread calls code that may hang forever) then consider rewriting your code to spawn a process with the multiprocessing module. You can then kill the process with the Process.terminate() method. You will need 2.6 or later for this, of course. | 2 | 1 | 0 | I am creating a thread in my Python app with thread.start_new_thread.
How do I stop it if it hasn't finished in three seconds time? | Stopping a thread in python | 1.2 | 0 | 0 | 1,913 |
2,223,790 | 2010-02-08T18:12:00.000 | 0 | 0 | 0 | 0 | python,identity,verification | 2,223,896 | 4 | false | 1 | 0 | You should have a look at WS-Trust.
A implementation of that is Windows Identity Foundation. But I'm sure You'll find more. | 2 | 5 | 0 | I am building a Python web application and we will need a user identity verification solution... something to verify the users identity during account registration.
I was wondering if anyone had any experience in integrating such a solution. What vendors/products out there have worked well with you? Any tips?
I don't have any experience in this matter so feel free to let me know if any additional information is required.
Thanks in advance! | Online identity verification solution | 0 | 0 | 1 | 747 |
2,223,790 | 2010-02-08T18:12:00.000 | 1 | 0 | 0 | 0 | python,identity,verification | 2,224,273 | 4 | false | 1 | 0 | There are many different ways to implement a verification system, the concept is quite simple but actually building can be a hassle, especially if you are doing it from scratch.
The best way to approach this is to find a framework that handles the aspect of verification. Turbogears and Pylons are both capable of this rather than doing it yourself or using third party apps.
Personally I have worked on commercial projects using both frameworks and was able to sort out verification quite easily.
User verification utilizes specific concepts and low level technology such as: the internet's stateless characteristic, session handling, database design, etc...
So the point I am making is that it would be better if you rather got a good, stable framework that could do the dirty work for you.
By the way what framework are you thinking of using? That would help me give a more detailed answer.
Hope this helps? | 2 | 5 | 0 | I am building a Python web application and we will need a user identity verification solution... something to verify the users identity during account registration.
I was wondering if anyone had any experience in integrating such a solution. What vendors/products out there have worked well with you? Any tips?
I don't have any experience in this matter so feel free to let me know if any additional information is required.
Thanks in advance! | Online identity verification solution | 0.049958 | 0 | 1 | 747 |
2,224,219 | 2010-02-08T19:20:00.000 | 1 | 0 | 0 | 1 | python,rss,feed | 2,253,676 | 3 | false | 1 | 0 | I found a way to work around this issue, though I am not sure if this is the optimal solution.
Instead of Minidom I have used cElementTree to parse the RSS feed. I process each "item" tag and its children in a seperate task and add these tasks to the task queue.
This has helped me avoid the DeadlineExceededError. I get the "This resource uses a lot of CPU resources" warning though.
Any idea on how to avoid the warning?
A_iyer | 1 | 4 | 0 | I am trying to build a GAE app that processes an RSS feed and stores all the data from the feed into Google Datastore. I use Minidom to extract content from the RSS feed. I also tried using Feedparser and BeautifulSoup but they did not work for me.
My app currently parses the feed and saves it in the Google datastore in about 25 seconds on my local machine. I uploaded the app and I when I tried to use it, I got the "DeadLine Exceeded Error".
I would like to know if there are any possible ways to speed up this process? The feed I use will eventually grow to have more than a 100 items over time. | RSS Feed aggregator using Google App Engine - Python | 0.066568 | 0 | 0 | 3,392 |
2,225,456 | 2010-02-08T22:43:00.000 | 5 | 1 | 1 | 0 | python | 2,225,477 | 6 | true | 0 | 0 | Try calling help on your class. | 1 | 1 | 0 | So, I know I can use dir() to get information about class members etc. What I'm looking for is a way to get a nicely formatted report on everything related to a class (the members, docstrings, inheritance hierarchy, etc.).
I want to be able to run this on the command-line so I can explore code and debug better. | Is there a way for me to get detailed formatted information on a Python class? | 1.2 | 0 | 0 | 122 |
2,226,853 | 2010-02-09T05:01:00.000 | 2 | 0 | 0 | 0 | python,audio,pcm | 2,226,925 | 6 | false | 1 | 0 | The duration is simply the number of frames divided by the number of frames per second. From your data this is: 96333 / 44100 = 2.18 seconds. | 2 | 7 | 0 | I'm trying to write a program to display PCM data. I've been very frustrated trying to find a library with the right level of abstraction, but I've found the python wave library and have been using that. However, I'm not sure how to interpret the data.
The wave.getparams function returns (2 channels, 2 bytes, 44100 Hz, 96333 frames, No compression, No compression). This all seems cheery, but then I tried printing a single frame:'\xc0\xff\xd0\xff' which is 4 bytes. I suppose it's possible that a frame is 2 samples, but the ambiguities do not end there.
96333 frames * 2 samples/frame * (1/44.1k sec/sample) = 4.3688 seconds
However, iTunes reports the time as closer to 2 seconds and calculations based on file size and bitrate are in the ballpark of 2.7 seconds. What's going on here?
Additionally, how am I to know if the bytes are signed or unsigned?
Many thanks! | Interpreting WAV Data | 0.066568 | 0 | 0 | 12,203 |
2,226,853 | 2010-02-09T05:01:00.000 | 2 | 0 | 0 | 0 | python,audio,pcm | 2,226,910 | 6 | false | 1 | 0 | Each sample is 16 bits and there 2 channels, so the frame takes 4 bytes | 2 | 7 | 0 | I'm trying to write a program to display PCM data. I've been very frustrated trying to find a library with the right level of abstraction, but I've found the python wave library and have been using that. However, I'm not sure how to interpret the data.
The wave.getparams function returns (2 channels, 2 bytes, 44100 Hz, 96333 frames, No compression, No compression). This all seems cheery, but then I tried printing a single frame:'\xc0\xff\xd0\xff' which is 4 bytes. I suppose it's possible that a frame is 2 samples, but the ambiguities do not end there.
96333 frames * 2 samples/frame * (1/44.1k sec/sample) = 4.3688 seconds
However, iTunes reports the time as closer to 2 seconds and calculations based on file size and bitrate are in the ballpark of 2.7 seconds. What's going on here?
Additionally, how am I to know if the bytes are signed or unsigned?
Many thanks! | Interpreting WAV Data | 0.066568 | 0 | 0 | 12,203 |
2,226,913 | 2010-02-09T05:18:00.000 | 0 | 0 | 0 | 1 | python,cross-platform,python-3.x | 2,239,928 | 3 | false | 1 | 0 | Help port Urwid to Python 3! That is most likely more work that just running 2to3 on it, though. | 1 | 0 | 0 | I would like it to run on Linux, OS X, and Windows (XP/Vista/7).
Thanks for any input. | Does anyone know of a Urwid like environment that is cross-platform for Python 3.x? | 0 | 0 | 0 | 322 |
2,226,935 | 2010-02-09T05:24:00.000 | 1 | 0 | 1 | 0 | python,string,integer,format,currency | 2,227,094 | 2 | true | 0 | 0 | Such formatting seems reasonable in some limited uses. But, should 1200000 be formatted as 1.2 million or 1.20 million? And isn't 456 more friendly as $456 (without the cents)?
Adding cents to large precise numbers is common in sweepstakes mailers (Ed McMann says you can win $12,000,000.00).
It seems a careful specification of what the proper output for different kinds of numbers is the larger problem. Once that's done, it would be pretty straightforward to write a formatting function. | 1 | 3 | 0 | I would like to format integers as professional looking currency strings. For example:
1200000 -> $1.2 million
456 -> $456.00
Do you know a good library for this, ideally with localization to handle European formats. | formatting currencies with Python | 1.2 | 0 | 0 | 1,211 |
2,227,141 | 2010-02-09T06:11:00.000 | 5 | 0 | 1 | 0 | python,types,arguments | 2,227,163 | 4 | false | 0 | 0 | If you mean during a certain call of the function, the function itself can get the types of its arguments by calling type on each of them (and will certainly know the type it returns).
If you mean from outside the function, no: the function can be called with arguments of any types -- some such calls will produce errors, but there's no way to know a priori which ones they will be.
Parameters can be optionally decorated in Python 3, and one possible use of such decoration is to express something about the parameters' types (and/or other constraints on them), but the language and standard library offer no guidance on how such decoration might be used. You might as well adopt a standard whereby such constraints are expressed in a structured way in the function's docstring, which would have the advantage of being applicable to any version of Python. | 1 | 8 | 0 | I'm learning python. I like to use help() or interinspect.getargspec to get information of functions in shell. But is there anyway I can get the argument/return type of function. | Get types of arguments in python | 0.244919 | 0 | 0 | 8,646 |
2,227,169 | 2010-02-09T06:17:00.000 | 6 | 0 | 1 | 0 | python,thread-safety | 2,227,210 | 4 | false | 0 | 0 | They are thread-safe as long as you don't disable the GIL in C code for the thread. | 1 | 61 | 0 | I would like to know if the Python built-in containers (list, vector, set...) are thread-safe? Or do I need to implement a locking/unlocking environment for my shared variable? | Are Python built-in containers thread-safe? | 1 | 0 | 0 | 35,828 |
2,227,537 | 2010-02-09T07:53:00.000 | 2 | 1 | 1 | 0 | python | 2,227,567 | 4 | false | 0 | 0 | First, this thread should be community wiki.
Second, iterators and generators are pretty basic Python IMHO. I agree with you on decorators and metaclasses. But I'm not a very good programmer, so I probably find this more difficult to wrap my brain around than others.
Third, I would add threading/multiprocessing to the list. That's really tricky :) | 2 | 6 | 0 | I do basic python programming and now I want to get deep into language features. I have collected/considered the following to be advanced python capabilities and learning them now.
Decorator
Iterator
Generator
Meta Class
Anything else to be added/considered to the above list? | What are features considerd as advanced python? | 0.099668 | 0 | 0 | 3,365 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.