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,632,179 | 2010-04-13T18:35:00.000 | 4 | 0 | 1 | 0 | python,module,keyword | 2,632,500 | 3 | false | 0 | 0 | You can have a directory with a name that is a Python keyword storing your Python code. This directory should not be used as a package, since package names should be valid Python identifiers. | 2 | 3 | 0 | Am I allowed to have a directory named 'import' containing Python code? Or will the import command fail to parse it as a result? Is there any way around that? | Can Python directory names be keywords? E.g. 'import'? | 0.26052 | 0 | 0 | 1,766 |
2,632,179 | 2010-04-13T18:35:00.000 | 0 | 0 | 1 | 0 | python,module,keyword | 2,632,321 | 3 | false | 0 | 0 | Or will the import command fail to parse it as a result?
It will indeed fail. | 2 | 3 | 0 | Am I allowed to have a directory named 'import' containing Python code? Or will the import command fail to parse it as a result? Is there any way around that? | Can Python directory names be keywords? E.g. 'import'? | 0 | 0 | 0 | 1,766 |
2,632,466 | 2010-04-13T19:11:00.000 | 0 | 0 | 0 | 0 | c++,python,binding | 2,632,489 | 4 | false | 0 | 1 | In short, yes. A binding is just that, an interface to a library or program written in another language, though it need not be generated using SWIG.
SWIG is just a tool for automatic generation of the same... | 4 | 6 | 0 | I always see people mention that "Python binding" and "C Sharp binding" etc. when I am actually using their C++ libraries. What does binding mean? If the library is written in C, and does Python binding means that they use SWIG kind of tool to mock a Python interface?
Newbie in this field, and any suggestion will be we... | What does binding mean exactly? | 0 | 0 | 0 | 1,840 |
2,632,466 | 2010-04-13T19:11:00.000 | 2 | 0 | 0 | 0 | c++,python,binding | 2,632,491 | 4 | true | 0 | 1 | When someone talks about something like a "C# binding" of a library, they are indicating that you and API is being provided in C# for a library written in a different language. This may or may not involve an autogeneration tool like SWIG. | 4 | 6 | 0 | I always see people mention that "Python binding" and "C Sharp binding" etc. when I am actually using their C++ libraries. What does binding mean? If the library is written in C, and does Python binding means that they use SWIG kind of tool to mock a Python interface?
Newbie in this field, and any suggestion will be we... | What does binding mean exactly? | 1.2 | 0 | 0 | 1,840 |
2,632,466 | 2010-04-13T19:11:00.000 | 0 | 0 | 0 | 0 | c++,python,binding | 2,632,492 | 4 | false | 0 | 1 | You're right, for a general library, a "binding" essentially means "easily callable from". The binding may or may not have been created with SWIG, that's just one way to do it. | 4 | 6 | 0 | I always see people mention that "Python binding" and "C Sharp binding" etc. when I am actually using their C++ libraries. What does binding mean? If the library is written in C, and does Python binding means that they use SWIG kind of tool to mock a Python interface?
Newbie in this field, and any suggestion will be we... | What does binding mean exactly? | 0 | 0 | 0 | 1,840 |
2,632,466 | 2010-04-13T19:11:00.000 | 0 | 0 | 0 | 0 | c++,python,binding | 2,632,493 | 4 | false | 0 | 1 | If the library is written in C, and
does Python binding means that they
use SWIG kind of tool to mock a Python
interface?
Yes, you are right. That will be called a Python binding of the respective library. | 4 | 6 | 0 | I always see people mention that "Python binding" and "C Sharp binding" etc. when I am actually using their C++ libraries. What does binding mean? If the library is written in C, and does Python binding means that they use SWIG kind of tool to mock a Python interface?
Newbie in this field, and any suggestion will be we... | What does binding mean exactly? | 0 | 0 | 0 | 1,840 |
2,633,029 | 2010-04-13T20:38:00.000 | 0 | 1 | 0 | 1 | python,android,ase,android-scripting | 5,914,317 | 1 | true | 1 | 0 | The newer versions of ASE now include a function call to create these identifiers. | 1 | 2 | 0 | I am working on am Android Scripting Environment (ASE) script in Python to replicate an iPhone app.
I need a device UID of some sort. My thoughts where a salted MD5 hash of the MAC address or device phone number, but I can't figure out how to access either of those using the Python APIs within ASE.
What can I do to cre... | How to get a Device Specific UID using Python in ASE on Android? | 1.2 | 0 | 0 | 234 |
2,633,302 | 2010-04-13T21:20:00.000 | 1 | 0 | 0 | 0 | c++,python,c | 2,645,336 | 3 | false | 0 | 0 | The crawler is very likely written in C or C++, at least backrub's crawler was written in one of these.
Be aware that the crawler only takes a snapshot of the page, then stores it in a temporary database for later processing. The indexing and other attached algorithms will extract the data, for example the image refere... | 2 | 0 | 0 | Does anyone know any more details about google's web-crawler (aka GoogleBot)? I was curious about what it was written in (I've made a few crawlers myself and am about to make another) and if it parses images and such. I'm assuming it does somewhere along the line, b/c the images in images.google.com are all resized. ... | Google Bot information? | 0.066568 | 0 | 1 | 400 |
2,633,302 | 2010-04-13T21:20:00.000 | 0 | 0 | 0 | 0 | c++,python,c | 2,633,356 | 3 | true | 0 | 0 | Officially allowed languages at Google, I think, are Python/C++/Java.
The bot likely uses all 3 for different tasks. | 2 | 0 | 0 | Does anyone know any more details about google's web-crawler (aka GoogleBot)? I was curious about what it was written in (I've made a few crawlers myself and am about to make another) and if it parses images and such. I'm assuming it does somewhere along the line, b/c the images in images.google.com are all resized. ... | Google Bot information? | 1.2 | 0 | 1 | 400 |
2,633,900 | 2010-04-13T23:28:00.000 | 0 | 0 | 0 | 0 | python | 2,634,849 | 3 | false | 0 | 1 | I checked out pyglet, and saw that it works well for static per pixel collision, when the image is not manipulated too much; however, I'm not sure how well it works with a dynamic image.
In short, I'm looking for a library that's able to quickly display a buffer of pixels. This buffer will be constantly changing, so fa... | 1 | 2 | 0 | So I'm going through the beginning stages of producing a game in Python, and I'm looking for a library that is able to manipulate pixels and blit them relatively fast.
My first thought was pygame, as it deals in pure 2D surfaces, but it only allows pixel access through pygame.get_at(), pygame.set_at() and pygame.get_bu... | Python pixel manipulation library | 0 | 0 | 0 | 2,106 |
2,634,119 | 2010-04-14T00:24:00.000 | 0 | 0 | 0 | 0 | python,macos,opengl,wxpython,pyqt | 2,999,881 | 4 | false | 0 | 1 | Use an App like Picasa (now available on mac). Use AppleScript through Python to control it from your application.
Failing that, use PyObjC to create Cocoa image display component and dialogs, and so on. | 2 | 3 | 0 | Frustrated by lack of a simple ACDSee equivalent for OS X, I'm looking to hack one up for myself. I'm looking for a gui library that accommodates:
Full screen image display
High quality image fit-to-screen (for display)
Low memory usage
Fast display
Reasonable learning curve (the simpler the better)
Looks like there ... | Python: OSX Library for fast full screen jpg/png display | 0 | 0 | 0 | 1,562 |
2,634,119 | 2010-04-14T00:24:00.000 | 0 | 0 | 0 | 0 | python,macos,opengl,wxpython,pyqt | 2,647,147 | 4 | false | 0 | 1 | it's not an answer to your coding question but for (a big part of) the lack of ACDsee equivalent (requires OSX 10.5+):
Simple list/thubmnail display of images in a directory: Finder.app
Sort by name/size/type: Finder.app will do name & type, not image size (but does file size)
Ability to view images full screen: quick... | 2 | 3 | 0 | Frustrated by lack of a simple ACDSee equivalent for OS X, I'm looking to hack one up for myself. I'm looking for a gui library that accommodates:
Full screen image display
High quality image fit-to-screen (for display)
Low memory usage
Fast display
Reasonable learning curve (the simpler the better)
Looks like there ... | Python: OSX Library for fast full screen jpg/png display | 0 | 0 | 0 | 1,562 |
2,634,394 | 2010-04-14T01:57:00.000 | 5 | 0 | 1 | 0 | python | 2,634,412 | 5 | false | 1 | 0 | It is absolutely proper to do so. A module groups related functionality. If that functionality is implemented in several classes (e.g., Tree, Node, Leaf) then it is appropriate to place them together.
A module is more closely associated with a Java package than a Java class. You can also implement a module as a folder... | 2 | 42 | 0 | I'm very new to Python (I'm coming from a JAVA background) and I'm wondering if anyone could help me with some of the Python standards. Is it a normal or "proper" practice to put multiple class in a module? I have been working with Django and started with the tutorials and they place their database model classes in the... | Multiple classes in a Python module | 0.197375 | 0 | 0 | 44,756 |
2,634,394 | 2010-04-14T01:57:00.000 | 8 | 0 | 1 | 0 | python | 2,634,436 | 5 | false | 1 | 0 | When in doubt, just look at Python's standard libraries :)
For example, the standard calendar module contains 31 classes. So yes, it is ok. | 2 | 42 | 0 | I'm very new to Python (I'm coming from a JAVA background) and I'm wondering if anyone could help me with some of the Python standards. Is it a normal or "proper" practice to put multiple class in a module? I have been working with Django and started with the tutorials and they place their database model classes in the... | Multiple classes in a Python module | 1 | 0 | 0 | 44,756 |
2,634,552 | 2010-04-14T02:44:00.000 | 13 | 0 | 1 | 0 | python,operator-overloading | 2,634,723 | 3 | true | 0 | 0 | The problem with the container using the objects' __str__ would be the total ambiguity -- what would it mean, say, if print L showed [1, 2]? L could be ['1, 2'] (a single item list whose string item contains a comma) or any of four 2-item lists (since each item can be a string or int). The ambiguity of type is common... | 1 | 11 | 0 | I've noticed that when an instance with an overloaded __str__ method is passed to the print function as an argument, it prints as intended. However, when passing a container that contains one of those instances to print, it uses the __repr__ method instead. That is to say, print(x) displays the correct string represent... | Using __str__ representation for printing objects in containers | 1.2 | 0 | 0 | 16,792 |
2,635,433 | 2010-04-14T06:57:00.000 | 1 | 0 | 1 | 1 | python,linux | 2,636,146 | 4 | false | 0 | 0 | You could create an rpm easily using checkinstall. Search for checkinstall in google and download it. It will allow you to create an rpm and set the options. | 1 | 8 | 0 | I wrote a Python program. I would like to add to it an installation script that will set up everything necessary - like desktop icon, entry in the menu, home directory file, etc.
I'm working on Linux (ubuntu). When a Python program is installed, what needs to happen in general? I know that it probably depends on the n... | Installing a Python program on Linux | 0.049958 | 0 | 0 | 4,519 |
2,635,933 | 2010-04-14T08:35:00.000 | 0 | 1 | 0 | 0 | python,boost | 2,636,724 | 2 | false | 0 | 1 | You could try putting -lpython26 when linking | 2 | 2 | 0 | I'm trying to use boost.python library in a C++ project (Windows + VS9) but it always tries to link against pyton25.lib.
Is it possible to link with version 2.6.x of python?
thanks | boost python version | 0 | 0 | 0 | 712 |
2,635,933 | 2010-04-14T08:35:00.000 | 1 | 1 | 0 | 0 | python,boost | 2,636,711 | 2 | false | 0 | 1 | You need to recompile boost-python library pointing Boost.Build to needed python version.
P.S. This heals a problem of undefined references while linking with library needed. I beleive you've already turned of autolinking. | 2 | 2 | 0 | I'm trying to use boost.python library in a C++ project (Windows + VS9) but it always tries to link against pyton25.lib.
Is it possible to link with version 2.6.x of python?
thanks | boost python version | 0.099668 | 0 | 0 | 712 |
2,637,480 | 2010-04-14T12:56:00.000 | 2 | 0 | 1 | 0 | python,list | 2,637,826 | 5 | false | 0 | 0 | Based on Marcelo's solution:
[name for cnt,name in enumerate(names) if (name != names[0] or cnt > 0)] | 1 | 3 | 0 | I have list in python which has following entries
name-1
name-2
name-3
name-4
name-1
name-2
name-3
name-4
name-1
name-2
name-3
name-4
I would like remove name-1 from list except its first appearance -- resultant list should look like
name-1
name-2
name-3
name-4
name-2
name-3
name-4
name-2
name-3
name-4
How to achie... | parsing list in python | 0.07983 | 0 | 0 | 5,759 |
2,638,327 | 2010-04-14T14:46:00.000 | 0 | 0 | 1 | 0 | python,eclipse,interactive | 2,640,761 | 2 | true | 0 | 0 | If you run it as a debug operation in Eclipse, you should be able to set a breakpoint, and you can then examine variables, etc. But you can evaluate random python scripts via the watch functionality. | 1 | 0 | 0 | Let's consider 3 situations:
1) I write a pyhon module in Eclipse (pydev) and run it Ctrl-F11. The module runs and I don't have any control or access (AFAIK) to the module variables and functions.
2) I have defined a python interpreter as an external tool in Eclipse, so I can run it within Eclipse. It works fine, but i... | Python and Eclipse: How to use interactive console after running a module, with the module variables and functions | 1.2 | 0 | 0 | 2,456 |
2,638,490 | 2010-04-14T15:04:00.000 | 0 | 1 | 0 | 0 | python,c,sockets,buffer,send | 2,638,568 | 3 | false | 0 | 0 | Unless you're sending a truly huge amount of data, you're probably better off using one buffer. If you use a geometric progression for growing your buffer size, the number of allocations becomes an amortized constant, and the time to allocate the buffer will generally follow. | 3 | 5 | 0 | I'm playing around with sockets in C/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.
My ideas:
use a send call for every header. Pros: No memory allocation needed. Cons: many send calls -- probably error prone; error management should be rather complica... | What is faster: multiple `send`s or using buffering? | 0 | 0 | 1 | 867 |
2,638,490 | 2010-04-14T15:04:00.000 | 0 | 1 | 0 | 0 | python,c,sockets,buffer,send | 2,638,599 | 3 | false | 0 | 0 | A send() call implies a round-trip to the kernel (the part of the OS which deals with the hardware directly). It has a unit cost of about a few hundred clock cycles. This is harmless unless you are trying to call send() millions of times.
Usually, buffering is about calling send() only once in a while, when "enough dat... | 3 | 5 | 0 | I'm playing around with sockets in C/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.
My ideas:
use a send call for every header. Pros: No memory allocation needed. Cons: many send calls -- probably error prone; error management should be rather complica... | What is faster: multiple `send`s or using buffering? | 0 | 0 | 1 | 867 |
2,638,490 | 2010-04-14T15:04:00.000 | 3 | 1 | 0 | 0 | python,c,sockets,buffer,send | 2,639,059 | 3 | true | 0 | 0 | Because of the way TCP congestion control works, it's more efficient to send data all at once. TCP maintains a window of how much data it will allow to be "in the air" (sent but not yet acknowledged). TCP measures the acknowledgments coming back to figure out how much data it can have "in the air" without causing con... | 3 | 5 | 0 | I'm playing around with sockets in C/Python and I wonder what is the most efficient way to send headers from a Python dictionary to the client socket.
My ideas:
use a send call for every header. Pros: No memory allocation needed. Cons: many send calls -- probably error prone; error management should be rather complica... | What is faster: multiple `send`s or using buffering? | 1.2 | 0 | 1 | 867 |
2,640,072 | 2010-04-14T18:40:00.000 | 2 | 0 | 0 | 0 | python,django,excel,html-table | 2,640,085 | 3 | false | 1 | 0 | Use CSV. There's a module in Python ("csv") to generate it, and excel can read it natively. | 1 | 5 | 0 | I have an HTML table that I'd like to be able to export to an Excel file. I already have an option to export the table into an IQY file, but I'd prefer something that didn't allow the user to refresh the data via Excel. I just want a feature that takes a snapshot of the table at the time the user clicks the link/button... | Django/Python: Save an HTML table to Excel | 0.132549 | 0 | 0 | 9,613 |
2,640,880 | 2010-04-14T20:41:00.000 | 4 | 0 | 0 | 0 | python,installation,download,tkinter | 2,640,895 | 3 | true | 0 | 1 | Any recent version of Python should come with Tkinter support. To my knowledge, you shouldn't need to install anything else. | 1 | 0 | 0 | Where can I download this programm? | Installation of Tkinter | 1.2 | 0 | 0 | 324 |
2,642,282 | 2010-04-15T01:57:00.000 | 5 | 1 | 1 | 0 | python,unit-testing,doctest | 2,643,423 | 6 | false | 0 | 0 | There's a concrete example in the Python standard library that persuades me that doctests alone aren't always enough, namely the decimal module. It has over 60000 individual testcases (in Lib/test/decimaltestdata); if all those were rewritten as doctests, the decimal module would become very unwieldy indeed. It's p... | 3 | 12 | 0 | A fellow developer on a project I am on believes that doctests are as good as unit-tests, and that if a piece of code is doctested, it does not need to be unit-tested. I do not believe this to be the case. Can anyone provide some solid, ideally cited, examples either for or against the argument that doctests replace th... | Does Python doctest remove the need for unit-tests? | 0.16514 | 0 | 0 | 3,655 |
2,642,282 | 2010-04-15T01:57:00.000 | 4 | 1 | 1 | 0 | python,unit-testing,doctest | 2,643,550 | 6 | false | 0 | 0 | doctests are great for some uses
working and up to date documentation
sample tests embeded in docstrings
spikes or design phases when classes API is not really clear
unit tests are better in differents cases:
when you need clear and somewhat complex setup/teardown
when trying to get better coverage of all cases, inc... | 3 | 12 | 0 | A fellow developer on a project I am on believes that doctests are as good as unit-tests, and that if a piece of code is doctested, it does not need to be unit-tested. I do not believe this to be the case. Can anyone provide some solid, ideally cited, examples either for or against the argument that doctests replace th... | Does Python doctest remove the need for unit-tests? | 0.132549 | 0 | 0 | 3,655 |
2,642,282 | 2010-04-15T01:57:00.000 | 0 | 1 | 1 | 0 | python,unit-testing,doctest | 16,453,043 | 6 | false | 0 | 0 | I think this is the wrong way to think about doctests. Doctests are documentation. They complement regular unit tests. Think of doctests as documentation examples that happen to be tested. The doctests should be there to illustrate the function to human users. The unit tests should test all the code, even the corner ca... | 3 | 12 | 0 | A fellow developer on a project I am on believes that doctests are as good as unit-tests, and that if a piece of code is doctested, it does not need to be unit-tested. I do not believe this to be the case. Can anyone provide some solid, ideally cited, examples either for or against the argument that doctests replace th... | Does Python doctest remove the need for unit-tests? | 0 | 0 | 0 | 3,655 |
2,642,364 | 2010-04-15T02:24:00.000 | 0 | 0 | 0 | 0 | php,.net,python,ajax,frameworks | 2,642,409 | 4 | false | 1 | 0 | Two approaches to this problem generally. One is for the framework to try and do it all, like Microsoft's ASP.NET with its Ajax toolkit. This includes server side controls that produce Ajax functionality with all client- and server-side code generated for you. For example, their UpdatePanel control allows for partial p... | 1 | 8 | 0 | AJAX is a pain in the ass because it essentially means you'll have to write two sets of similarish code: one for browsers with JavaScript enabled and those without.
Not only this, but you have to connect JavaScript events to hook into your models and display the results.
And if all that weren't bad enough, you need to ... | A web framework where AJAX was not an after thought | 0 | 0 | 0 | 495 |
2,643,081 | 2010-04-15T06:03:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine | 34,367,657 | 5 | false | 1 | 0 | Not enough points to provide a comment on the answers above hence the stand alone answer. If you delete the ini files as per the other answers the pathways to your projects in the launcher will likely also be gone. In my case however I simply moved the ini files out of the C:\Users\your username\Google directory and th... | 3 | 6 | 0 | the error is :
Errors occurred
See the logfile 'D:\Program Files\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe.log' for details
Why? | google app engine error ,and i can't open it now.(python) | 0 | 0 | 0 | 6,342 |
2,643,081 | 2010-04-15T06:03:00.000 | 3 | 0 | 0 | 1 | python,google-app-engine | 31,897,510 | 5 | false | 1 | 0 | Solution:
Note: The wrong directories are stated above.
Go to C:\Users\your username\Google directory.
Delete google_appengine_launcher.ini and google_appengine_projects.ini
Appengine should now start successfully, absent error message. | 3 | 6 | 0 | the error is :
Errors occurred
See the logfile 'D:\Program Files\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe.log' for details
Why? | google app engine error ,and i can't open it now.(python) | 0.119427 | 0 | 0 | 6,342 |
2,643,081 | 2010-04-15T06:03:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine | 17,596,077 | 5 | false | 1 | 0 | yeah just like RyanW mentioned the link, Delete the .ini files viz. google_appengine_launcher.ini & google_appengine_projects.ini in the user Directory in folder named Google. | 3 | 6 | 0 | the error is :
Errors occurred
See the logfile 'D:\Program Files\Google\google_appengine\launcher\GoogleAppEngineLauncher.exe.log' for details
Why? | google app engine error ,and i can't open it now.(python) | 0.07983 | 0 | 0 | 6,342 |
2,643,321 | 2010-04-15T07:07:00.000 | 15 | 0 | 0 | 0 | python,web-applications | 2,643,669 | 6 | true | 1 | 0 | For the context, I work at a large private bank in Switzerland, writing Enterprise applications on the J2EE stack.
There are plenty of "Production Ready" web frameworks in Python. And there are plenty of large Python-based websites out there.
That said, I think Python is a poor choice for an Enterprisy application. It ... | 1 | 14 | 0 | I heard lots of good opinions about Python language. They say it's mature, expressive etc... I'm looking for production-ready enterprise application frameworks in Python. By "production ready" I mean :
supports objective-relational mapping with caching and declarative desciption (like JPA, Hibernate etc..)
controls or... | Is there a production ready web application framework in Python? | 1.2 | 0 | 0 | 5,358 |
2,643,721 | 2010-04-15T08:23:00.000 | 0 | 0 | 0 | 0 | python,django,apache,login,debugging | 2,645,668 | 5 | false | 1 | 0 | I would guess that this is related to errors in admin classes requiring the devserver to be restarted to continue.
As nothing is being reportedm I would try removing all of your admin.py definitions and just use the basic admin.site.register(SomeModel) for everything and seeing if it still happens, then add them back i... | 4 | 2 | 0 | Short Story: I get locked out of my Django app when Debug is set to False.
Long story:
Case 1 (the first time it happened):
I enter my login info, but It just redirects to the login page.
I restart the server, try to login, and it works fine, I get in.
a few hours later I come back, log out, try to log back in and I ... | I can't login to my Django app when debug is set to False | 0 | 0 | 0 | 1,621 |
2,643,721 | 2010-04-15T08:23:00.000 | 1 | 0 | 0 | 0 | python,django,apache,login,debugging | 2,644,182 | 5 | false | 1 | 0 | Do you have a custom 500 error handler set up? Is that doing something weird with the session, perhaps? | 4 | 2 | 0 | Short Story: I get locked out of my Django app when Debug is set to False.
Long story:
Case 1 (the first time it happened):
I enter my login info, but It just redirects to the login page.
I restart the server, try to login, and it works fine, I get in.
a few hours later I come back, log out, try to log back in and I ... | I can't login to my Django app when debug is set to False | 0.039979 | 0 | 0 | 1,621 |
2,643,721 | 2010-04-15T08:23:00.000 | 0 | 0 | 0 | 0 | python,django,apache,login,debugging | 6,030,163 | 5 | false | 1 | 0 | Make sure the urls.py file imports everything from django.conf.urls.defaults.
You may have explicitly imported certain methods such as patterns and include (as I did to combat PyDev's 'wild import' warning messages).
As a result, crucial statements that assign Django's default handlers to 404 and 500 HTTP error codes ... | 4 | 2 | 0 | Short Story: I get locked out of my Django app when Debug is set to False.
Long story:
Case 1 (the first time it happened):
I enter my login info, but It just redirects to the login page.
I restart the server, try to login, and it works fine, I get in.
a few hours later I come back, log out, try to log back in and I ... | I can't login to my Django app when debug is set to False | 0 | 0 | 0 | 1,621 |
2,643,721 | 2010-04-15T08:23:00.000 | 1 | 0 | 0 | 0 | python,django,apache,login,debugging | 57,435,530 | 5 | false | 1 | 0 | My problem was if I set SESSION_COOKIE_SECURE = True then I can't login in http mode.
I had to change it to SESSION_COOKIE_SECURE = False
Maybe you had this too? | 4 | 2 | 0 | Short Story: I get locked out of my Django app when Debug is set to False.
Long story:
Case 1 (the first time it happened):
I enter my login info, but It just redirects to the login page.
I restart the server, try to login, and it works fine, I get in.
a few hours later I come back, log out, try to log back in and I ... | I can't login to my Django app when debug is set to False | 0.039979 | 0 | 0 | 1,621 |
2,644,221 | 2010-04-15T09:47:00.000 | 3 | 0 | 1 | 0 | python,list,tuples | 2,645,203 | 6 | false | 0 | 0 | [[int(i) for i in x.strip(" []").split(",")] for x in s.strip('[]').split("],")]
a list comprehension in a list comprehension...
but that will melt your brain | 1 | 12 | 0 | If a user types in [[0,0,0], [0,0,1], [1,1,0]] and press enter,
the program should convert this string to several lists;
one list holding [0][0][0], other for [0][0][1], and the last list for [1][1][0]
Does python have a good way to handle this? | How can I convert this string to list of lists? | 0.099668 | 0 | 0 | 24,352 |
2,645,749 | 2010-04-15T13:41:00.000 | 7 | 0 | 1 | 0 | python,typechecking | 2,646,481 | 4 | false | 0 | 0 | I'd like a way to make sure a is a list, before looping through
Document the function. | 1 | 23 | 0 | What is the easiest way to check if something is a list?
A method doSomething has the parameters a and b. In the method, it will loop through the list a and do something. I'd like a way to make sure a is a list, before looping through - thus avoiding an error or the unfortunate circumstance of passing in a string then ... | Check if something is a list | 1 | 0 | 0 | 20,048 |
2,646,983 | 2010-04-15T16:07:00.000 | 2 | 0 | 0 | 0 | python,proxy,tcp,sockets,socks | 2,714,593 | 3 | false | 0 | 0 | It is pretty simple - after you send the HTTP request: CONNECT example.com:1234 HTTP/1.0\r\nHost: example.com:1234\r\n<additional headers incl. authentication>\r\n\r\n, the server responds with HTTP/1.0 200 Connection established\r\n\r\n and then (after the double line ends) you can communicate just as you would commun... | 1 | 3 | 0 | I am little stumped: I have a simple messenger client program (pure python, sockets), and I wanted to add proxy support (http/s, socks), however I am a little confused on how to go about it. I am assuming that the connection on the socket level will be done to the proxy server, at which point the headers should contain... | Python, implementing proxy support for a socket based application (not urllib2) | 0.132549 | 0 | 1 | 2,236 |
2,647,088 | 2010-04-15T16:20:00.000 | 1 | 1 | 1 | 0 | python,python-import | 2,647,367 | 3 | false | 0 | 0 | In absence of more information, I would say you have a circular import that you aren't working around. The simplest, most obvious fix is to not put anything in mydir/__init__.py that you want to use from any module inside mydir. So, move your get_hash function to another module inside the mydir package, and import that... | 2 | 2 | 0 | I've done what I shouldn't have done and written 4 modules (6 hours or so) without running any tests along the way.
I have a method inside of /mydir/__init__.py called get_hash(), and a class inside of /mydir/utils.py called SpamClass.
/mydir/utils.py imports get_hash() from /mydir/__init__.
/mydir/__init__.py imports... | Python - import error | 0.066568 | 0 | 0 | 493 |
2,647,088 | 2010-04-15T16:20:00.000 | 2 | 1 | 1 | 0 | python,python-import | 2,647,459 | 3 | false | 0 | 0 | To add to what the others have said, another good approach to avoiding circular import problems is to avoid from module import stuff.
If you just do standard import module at the top of each script, and write module.stuff in your functions, then by the time those functions run, the import will have finished and the mod... | 2 | 2 | 0 | I've done what I shouldn't have done and written 4 modules (6 hours or so) without running any tests along the way.
I have a method inside of /mydir/__init__.py called get_hash(), and a class inside of /mydir/utils.py called SpamClass.
/mydir/utils.py imports get_hash() from /mydir/__init__.
/mydir/__init__.py imports... | Python - import error | 0.132549 | 0 | 0 | 493 |
2,647,105 | 2010-04-15T16:23:00.000 | 14 | 0 | 1 | 0 | python,ctypes,cython | 2,648,095 | 4 | true | 0 | 0 | Ignore everyone elses' answer for now. The first thing you should learn to use is the profiler. Python comes with a profile/cProfile; you should learn how to read the results and analyze where the real bottlenecks is. The goal of optimization is three-fold: reduce the time spent on each call, reduce the number of calls... | 4 | 8 | 0 | I'm having a lot of fun learning Python by writing a genetic programming type of application.
I've had some great advice from Torsten Marek, Paul Hankin and Alex Martelli on this site.
The program has 4 main functions:
generate (randomly) an expression tree.
evaluate the fitness of the tree
crossbreed
mutate
As all ... | I need to speed up a function. Should I use cython, ctypes, or something else? | 1.2 | 0 | 0 | 2,763 |
2,647,105 | 2010-04-15T16:23:00.000 | 0 | 0 | 1 | 0 | python,ctypes,cython | 2,649,773 | 4 | false | 0 | 0 | Try to work your fitness function so that it will support memoization. This will replace all calls that are duplicates of previous calls with a quick dict lookup. | 4 | 8 | 0 | I'm having a lot of fun learning Python by writing a genetic programming type of application.
I've had some great advice from Torsten Marek, Paul Hankin and Alex Martelli on this site.
The program has 4 main functions:
generate (randomly) an expression tree.
evaluate the fitness of the tree
crossbreed
mutate
As all ... | I need to speed up a function. Should I use cython, ctypes, or something else? | 0 | 0 | 0 | 2,763 |
2,647,105 | 2010-04-15T16:23:00.000 | 0 | 0 | 1 | 0 | python,ctypes,cython | 2,647,189 | 4 | false | 0 | 0 | Another great option is boost::python which lets you easily wrap C or C++.
Of these possibilities though, since you have python code already written, cython is probably a good thing to try first. Perhaps you won't have to rewrite any code to get a speedup. | 4 | 8 | 0 | I'm having a lot of fun learning Python by writing a genetic programming type of application.
I've had some great advice from Torsten Marek, Paul Hankin and Alex Martelli on this site.
The program has 4 main functions:
generate (randomly) an expression tree.
evaluate the fitness of the tree
crossbreed
mutate
As all ... | I need to speed up a function. Should I use cython, ctypes, or something else? | 0 | 0 | 0 | 2,763 |
2,647,105 | 2010-04-15T16:23:00.000 | 3 | 0 | 1 | 0 | python,ctypes,cython | 2,647,245 | 4 | false | 0 | 0 | Cython is the quickest to get the job done, either by writing your algorithm directly in Cython, or by writing it in C and bind it to python with Cython.
My advice: learn Cython. | 4 | 8 | 0 | I'm having a lot of fun learning Python by writing a genetic programming type of application.
I've had some great advice from Torsten Marek, Paul Hankin and Alex Martelli on this site.
The program has 4 main functions:
generate (randomly) an expression tree.
evaluate the fitness of the tree
crossbreed
mutate
As all ... | I need to speed up a function. Should I use cython, ctypes, or something else? | 0.148885 | 0 | 0 | 2,763 |
2,647,288 | 2010-04-15T16:48:00.000 | 4 | 0 | 1 | 0 | python | 2,647,445 | 6 | false | 0 | 0 | Magic that works but not always. For example, when metaclasses are abused to create a DSL. Such DSL could be suitable for most tasks but breaks horribly on a complex (unexpected by author) one. | 3 | 4 | 0 | My impression of Python from the short time I've been developing with it is that it's incredible powerful and flexible, but I can't help but feel like "with great power comes great responsibility." So while I've read numerous blog posts about simple and elegant Python snippets that solve a problems, I wonder if there ... | What are the most frustrating Python hacks to unwind, rewrite, etc.? | 0.132549 | 0 | 0 | 1,012 |
2,647,288 | 2010-04-15T16:48:00.000 | 4 | 0 | 1 | 0 | python | 2,647,563 | 6 | false | 0 | 0 | Using eval or exec on user input may be the most common abuse of Python features. | 3 | 4 | 0 | My impression of Python from the short time I've been developing with it is that it's incredible powerful and flexible, but I can't help but feel like "with great power comes great responsibility." So while I've read numerous blog posts about simple and elegant Python snippets that solve a problems, I wonder if there ... | What are the most frustrating Python hacks to unwind, rewrite, etc.? | 0.132549 | 0 | 0 | 1,012 |
2,647,288 | 2010-04-15T16:48:00.000 | 4 | 0 | 1 | 0 | python | 2,651,847 | 6 | true | 0 | 0 | Excessive usage of from module import *.
Having a lot of such imports at the module you don't know where each variable came from and have to look though all imported modules. Searching doesn't help much in this case. | 3 | 4 | 0 | My impression of Python from the short time I've been developing with it is that it's incredible powerful and flexible, but I can't help but feel like "with great power comes great responsibility." So while I've read numerous blog posts about simple and elegant Python snippets that solve a problems, I wonder if there ... | What are the most frustrating Python hacks to unwind, rewrite, etc.? | 1.2 | 0 | 0 | 1,012 |
2,647,723 | 2010-04-15T17:48:00.000 | 16 | 0 | 0 | 0 | python,string,urllib2 | 35,367,453 | 4 | false | 1 | 0 | In python3, it should be changed to urllib.request.openurl('http://www.example.com/').read().decode('utf-8'). | 1 | 7 | 0 | I'm using urllib2 to open a url. Now I need the html file as a string. How do I do this? | urllib2 to string | 1 | 0 | 1 | 17,378 |
2,647,790 | 2010-04-15T18:00:00.000 | 7 | 1 | 1 | 0 | python,unit-testing,exception-handling,runtime-error,code-coverage | 2,648,113 | 4 | false | 0 | 0 | The problem here is that malformed external input crashed your program. The solution is to exhaustively unit test possible input scenarios at the boundaries of your code. You say your unit tests are 'extensive', but you clearly hadn't tested for this possibility. Code coverage is a useful tool, but it's important to re... | 2 | 4 | 0 | I recently came across a simple but nasty bug.
I had a list and I wanted to find the smallest member in it. I used Python's built-in min().
Everything worked great until in some strange scenario the list was empty (due to strange user input I could not have anticipated). My application crashed with a ValueError (BTW - ... | Python Pre-testing for exceptions when coverage fails | 1 | 0 | 0 | 784 |
2,647,790 | 2010-04-15T18:00:00.000 | 4 | 1 | 1 | 0 | python,unit-testing,exception-handling,runtime-error,code-coverage | 2,647,972 | 4 | false | 0 | 0 | Even in Java/C#, a class of exceptions the RuntimeError are unchecked and will not be detected by the compiler (that's why they're called RuntimeError not CompileError).
In python, certain exceptions such as KeyboardInterrupt are particularly hairy since it can be raised practically at any arbitrary point in the progra... | 2 | 4 | 0 | I recently came across a simple but nasty bug.
I had a list and I wanted to find the smallest member in it. I used Python's built-in min().
Everything worked great until in some strange scenario the list was empty (due to strange user input I could not have anticipated). My application crashed with a ValueError (BTW - ... | Python Pre-testing for exceptions when coverage fails | 0.197375 | 0 | 0 | 784 |
2,647,862 | 2010-04-15T18:11:00.000 | 2 | 0 | 1 | 0 | python,import | 2,647,882 | 3 | false | 0 | 0 | Look at the foolib.__file__. | 1 | 5 | 0 | I'm trying to modify a python library that I downloaded and am using. But the changes I'm making aren't doing anything. So I suspect that python is importing a different copy of this library from somewhere else on the filesystem. So...
When I run import foolib in python, how can I tell where on the filesystem it's g... | How can I tell what directory an imported library comes from in python? | 0.132549 | 0 | 0 | 298 |
2,648,121 | 2010-04-15T18:53:00.000 | 2 | 0 | 1 | 0 | python,computer-science | 2,648,174 | 5 | false | 0 | 0 | This is the traditional meaning of "function" in the mathematical sense. What you're describing, more than anything else, should be called a function. To distinguish it from a function that has side effects, you can also call it a "pure function" — this means the function will always return the same result given the sa... | 5 | 3 | 0 | I was wondering what language to use when talking about a function that takes in a specific object, acts on it and returns something else. Clearly they're functions, but I was wondering if there's a more specific term.
A couple examples of Python built-in functions that fit this spec are: 'len', 'dir', 'vars'
I thought... | What are 'len', 'dir', 'vars' named? | 0.07983 | 0 | 0 | 246 |
2,648,121 | 2010-04-15T18:53:00.000 | 2 | 0 | 1 | 0 | python,computer-science | 2,648,167 | 5 | false | 0 | 0 | They're unary functions, since they have a single parameter, but they're nothing more special than that. | 5 | 3 | 0 | I was wondering what language to use when talking about a function that takes in a specific object, acts on it and returns something else. Clearly they're functions, but I was wondering if there's a more specific term.
A couple examples of Python built-in functions that fit this spec are: 'len', 'dir', 'vars'
I thought... | What are 'len', 'dir', 'vars' named? | 0.07983 | 0 | 0 | 246 |
2,648,121 | 2010-04-15T18:53:00.000 | 1 | 0 | 1 | 0 | python,computer-science | 2,648,158 | 5 | false | 0 | 0 | I'd call them intrinsic functions. | 5 | 3 | 0 | I was wondering what language to use when talking about a function that takes in a specific object, acts on it and returns something else. Clearly they're functions, but I was wondering if there's a more specific term.
A couple examples of Python built-in functions that fit this spec are: 'len', 'dir', 'vars'
I thought... | What are 'len', 'dir', 'vars' named? | 0.039979 | 0 | 0 | 246 |
2,648,121 | 2010-04-15T18:53:00.000 | 5 | 0 | 1 | 0 | python,computer-science | 2,648,144 | 5 | false | 0 | 0 | Call them functions. That's something everyone will understand. You could also call them subroutines, methods, or procedures, but sometimes those have specific and different meanings in different languages. But "Function" is something most people will understand, no matter then language (even though there may be slight... | 5 | 3 | 0 | I was wondering what language to use when talking about a function that takes in a specific object, acts on it and returns something else. Clearly they're functions, but I was wondering if there's a more specific term.
A couple examples of Python built-in functions that fit this spec are: 'len', 'dir', 'vars'
I thought... | What are 'len', 'dir', 'vars' named? | 0.197375 | 0 | 0 | 246 |
2,648,121 | 2010-04-15T18:53:00.000 | 6 | 0 | 1 | 0 | python,computer-science | 2,648,135 | 5 | true | 0 | 0 | There isn't really a generic term for these kinds of functions, although Python internally uses 'inquiry' for this kind of function. I rarely see them described as anything other than just plain 'function', though. | 5 | 3 | 0 | I was wondering what language to use when talking about a function that takes in a specific object, acts on it and returns something else. Clearly they're functions, but I was wondering if there's a more specific term.
A couple examples of Python built-in functions that fit this spec are: 'len', 'dir', 'vars'
I thought... | What are 'len', 'dir', 'vars' named? | 1.2 | 0 | 0 | 246 |
2,649,882 | 2010-04-16T00:34:00.000 | 3 | 0 | 1 | 0 | python,user-interface | 2,649,957 | 5 | false | 0 | 1 | Yes, you can use PyQt, or PySide (another Qt binding), or wxPython. They all support native look & feel.
There's also PyGTK, but gtk apps don't to look so native ..
I personally prefer Qt, so I'd suggest PyQt. If you have issues with the GPL, then you can use PySide (LGPL). | 1 | 16 | 0 | I haven't gotten far enough into Python to make GUIs yet, so I thought I'd ask here. Can a python app be made with the windows default style GUI, or will it have its own style? The only screenshots I've seen of a python app running with a GUI had this ugly win95 look to it. | Can a native-looking GUI be made with Python | 0.119427 | 0 | 0 | 6,722 |
2,650,014 | 2010-04-16T01:21:00.000 | 6 | 0 | 0 | 1 | python,database,google-app-engine,global | 2,650,039 | 1 | true | 1 | 0 | The datastore is the only place you can have guaranteed-persistent data that are also modifiable. So you can have a single large object, or several smaller ones (with a name attribute and others), depending on your desired access patterns -- but live in the datastore it must. You can use memcache for faster cache tha... | 1 | 1 | 0 | I'm looking for a way to keep the equivalent of persistent global variables in app engine (python). What I'm doing is creating a global kind that I initialize once (i.e. when I reset all my database objects when I'm testing). I have things in there like global counters, or the next id to assign certain kinds I create... | google app engine persistent globals | 1.2 | 0 | 0 | 595 |
2,650,073 | 2010-04-16T01:41:00.000 | 2 | 1 | 0 | 0 | python,c++,encryption,cryptography | 2,650,311 | 1 | false | 0 | 1 | The C++ libraries seem to have dependencies to hundreds of files.
I don't know much about Python, but that is absolutely normal for C++. I'd recommend Crypto++ -- it's a great easy to use library, and it's public domain, meaning you won't have any license problems with it.
EDIT: Keep in mind a large library with lots o... | 1 | 1 | 0 | I'm looking to do some basic encryption of server messages which would be encrypted with C++ and decrypted using Python server side. I was wondering if anyone knew if there were good solutions that were simpler or more lightweight than Keyczar. I see that supports both C++ and python, but would using Crypto++ and PyC... | Lightweight cryptography toolkit(s) for C++ and Python | 0.379949 | 0 | 0 | 942 |
2,650,106 | 2010-04-16T01:52:00.000 | 1 | 0 | 0 | 0 | python,django,django-models,django-admin | 2,656,270 | 4 | false | 1 | 0 | I like the idea of not making users remember a username, but I think a better solution to that is to have their email address be their user name. Is it fair for you to assume in your specific application that no two users will have the same first and last name? If that's not a fair assumption, how will your system hand... | 2 | 1 | 0 | i want to authenticate users using firstname and lastname
This is the code i am using
user = auth.authenticate(first_name=firstname,last_name=lastname,password=password)
it keep coming up with NoneType: None
i have checked the firstname and lastname plus password seen to be correct?
what i am doing wrong? thanks | Django, How authenticate user with first name and last name? | 0.049958 | 0 | 0 | 1,594 |
2,650,106 | 2010-04-16T01:52:00.000 | 2 | 0 | 0 | 0 | python,django,django-models,django-admin | 2,650,166 | 4 | false | 1 | 0 | Building a little from @T. Stone's idea. Why not have them register with their First and Last name and you just concatenate them together and use that as their username?. And everytime you have them login you setup your view to combine the two fields again and use that string.
You won't be able to use some of the aut... | 2 | 1 | 0 | i want to authenticate users using firstname and lastname
This is the code i am using
user = auth.authenticate(first_name=firstname,last_name=lastname,password=password)
it keep coming up with NoneType: None
i have checked the firstname and lastname plus password seen to be correct?
what i am doing wrong? thanks | Django, How authenticate user with first name and last name? | 0.099668 | 0 | 0 | 1,594 |
2,650,189 | 2010-04-16T02:25:00.000 | 0 | 0 | 0 | 0 | python,django,authentication | 2,650,293 | 3 | false | 1 | 0 | To T. Stone's point, end users are notorious for passing links around -- ESPECIALLY those in an intraweb environment. Having something that authenticated the user automatically means that I can almost guarantee that you're going to have at least one person logged in as somebody else.
There are better ways, of course,... | 1 | 3 | 0 | In my web app I would like to be able to email self-authenticating links to users. These links will contain a unique token (uuid). When they click the link the token being present in the query string will be enough to authenticate them and they won't have to enter their username and password.
What's the best way to do ... | Self Authenticating Links in Django | 0 | 0 | 0 | 1,274 |
2,650,499 | 2010-04-16T03:57:00.000 | 0 | 0 | 0 | 1 | python,mysql,google-app-engine,bulk-load | 2,662,880 | 3 | false | 1 | 0 | If you're using Pentaho BI Server as your data source, why don't you consider using Pentaho Data Integration (ETL tool) to move the data over? At the very least PDI automate any movement of data between your data source and any AppEngine bulk loader tool (it can easily trigger any app with a shell step). | 1 | 0 | 0 | I'm from Brazil and study at FATEC (college located in Brazil).
I'm trying to learn about AppEngine.
Now, I'm trying to load a large database from MySQL to AppEngine to perform some queries, but I don't know how i can do it. I did some testing with CSV files,but is there any way to perform the direct import from MySQL?... | MySQL to AppEngine | 0 | 1 | 0 | 1,278 |
2,650,591 | 2010-04-16T04:21:00.000 | 0 | 0 | 0 | 0 | python,pygtk | 2,788,540 | 3 | false | 0 | 1 | gtk.TextView is "rich", in that it can display all types of formatting and even embedded widgets.
If you want the functionality of editing rich text, you will have to write something yourself, though others have tried in applications like BloGTK. From which you could steal codes. | 1 | 1 | 0 | I would like to include a rich text editor in a pygtk drawing area for an application i am developing. The editor ( a small resizable widget ) should be able to move around the drawing area like a rectangle. I am not sure how to start as I am pretty new to PyGTK. thank you ! | Py GTK Drawing area and Rich Text Editor | 0 | 0 | 0 | 2,291 |
2,651,466 | 2010-04-16T07:58:00.000 | 2 | 1 | 1 | 0 | python | 2,651,534 | 2 | false | 0 | 0 | Look for the subprocess module. It is the recommended way to invoke processes from within Python. The os.system function is a viable alternative sometimes, if your needs are very simple (no pipes, simple arguments, etc.) | 2 | 0 | 0 | i have this encryption algorithm written in C++ , but the values that has to be encrypted are being taken input and stored in a file by a python program . Thus how can i call this c++ program from python? | how to call a c++ file from python without using any of the spam bindings? | 0.197375 | 0 | 0 | 83 |
2,651,466 | 2010-04-16T07:58:00.000 | 0 | 1 | 1 | 0 | python | 2,651,490 | 2 | false | 0 | 0 | The os.system function will invoke an arbitrary command-line from python. | 2 | 0 | 0 | i have this encryption algorithm written in C++ , but the values that has to be encrypted are being taken input and stored in a file by a python program . Thus how can i call this c++ program from python? | how to call a c++ file from python without using any of the spam bindings? | 0 | 0 | 0 | 83 |
2,652,146 | 2010-04-16T10:26:00.000 | 5 | 1 | 0 | 0 | python,virtualbox,xpcom | 2,655,522 | 3 | false | 0 | 0 | I would generally recommend against either one. If you need to use virtualization programmatically, take a look at libvirt, which gives you cross platform and cross hypervisor support; which lets you do kvm/xen/vz/vmware later on.
That said, the SOAP api is using two extra abstraction layers (the client and server side... | 1 | 9 | 0 | what is the advantage of using a python virtualbox API instead of using XPCOM? | What is the advantage of using Python Virtualbox API? | 0.321513 | 0 | 1 | 14,030 |
2,652,394 | 2010-04-16T11:09:00.000 | 0 | 0 | 0 | 0 | python,google-app-engine,google-cloud-datastore | 2,656,720 | 2 | false | 1 | 0 | If it's really just a list of tuples / two "columns", could you just use an alternating list and a ListProperty? This would be fine if the data had a consistent dimension, was small, and didn't require indexing.
e.g. To encode the example you gave in a list do:
# i forget if mixed types are allowed, but you get the i... | 1 | 2 | 0 | I need to store some data that looks a little like this:
xyz 123
abc 456
hij 678
rer 838
Now I would just store it as a traditional string and integer model, and put in the datastore. But the data changes regularly, and is ONLY relevant when looked at as a COLLECTION. So it needs to be store as either a list of lists... | Storing a list of objects in GAE | 0 | 0 | 0 | 296 |
2,653,079 | 2010-04-16T12:59:00.000 | 1 | 0 | 0 | 0 | python,file,urllib,file-type | 2,653,447 | 3 | false | 0 | 0 | I suspect you may be optimising prematurely here.
Most modern systems will cache files in memory for a significant period of time before they flush them to disk, so if you write the data to a temporary file, read it back in, then close and delete the file you may find that there's no significant disc traffic (unless it... | 1 | 2 | 0 | PdfFileReader reads the content from a pdf file to create an object.
I am querying the pdf from a cdn via urllib.urlopen(), this provides me a file like object, which has no seek. PdfFileReader, however uses seek.
What is the simple way to create a PdfFileReader object from a pdf downloaded via url.
Now, what can I do ... | Inexpensive ways to add seek to a filetype object | 0.066568 | 0 | 1 | 275 |
2,654,425 | 2010-04-16T16:02:00.000 | 2 | 1 | 1 | 0 | python,ruby,lambda,restriction | 3,209,231 | 5 | false | 0 | 0 | Instead of f=lambda s:pass you can do f=lambda s:None. | 2 | 6 | 0 | I was going over some pages from WikiVS, that I quote from:
because lambdas in Python are restricted to expressions and cannot
contain statements
I would like to know what would be a good example (or more) where this restriction would be, preferably compared to the Ruby language.
Thank you for your answers, commen... | Restrictons of Python compared to Ruby: lambda's | 0.07983 | 0 | 0 | 2,261 |
2,654,425 | 2010-04-16T16:02:00.000 | 1 | 1 | 1 | 0 | python,ruby,lambda,restriction | 2,654,789 | 5 | false | 0 | 0 | lambda is simply a shortcut way in Python to define a function that returns a simple expression.
This isn't a restriction in any meaningful way. If you need more than a single expression then just use a function: there is nothing you can do with a lambda that you cannot do with a function.
The only disadvantages to usi... | 2 | 6 | 0 | I was going over some pages from WikiVS, that I quote from:
because lambdas in Python are restricted to expressions and cannot
contain statements
I would like to know what would be a good example (or more) where this restriction would be, preferably compared to the Ruby language.
Thank you for your answers, commen... | Restrictons of Python compared to Ruby: lambda's | 0.039979 | 0 | 0 | 2,261 |
2,654,484 | 2010-04-16T16:11:00.000 | 1 | 0 | 1 | 0 | python,function,variables,global-variables | 2,654,582 | 2 | true | 0 | 0 | If you want to share data between functions then create a class and turn the functions into methods on the class. | 2 | 0 | 0 | in python, how can i access the variables of one function into another function, is it possible, i tried the global variable method but that doesn't work for me.
can someone help me, how to access the variables from one function to another function. | access variables of other functions | 1.2 | 0 | 0 | 1,692 |
2,654,484 | 2010-04-16T16:11:00.000 | 0 | 0 | 1 | 0 | python,function,variables,global-variables | 2,654,647 | 2 | false | 0 | 0 | Don't try to do this. Explicit is better than implicit - if your function needs access to certain variables, pass them in. If it needs to change a value in the calling function, return the new value. | 2 | 0 | 0 | in python, how can i access the variables of one function into another function, is it possible, i tried the global variable method but that doesn't work for me.
can someone help me, how to access the variables from one function to another function. | access variables of other functions | 0 | 0 | 0 | 1,692 |
2,654,689 | 2010-04-16T16:43:00.000 | 0 | 0 | 0 | 0 | python,django,profiles | 2,657,984 | 4 | false | 1 | 0 | Thank you all for your answers! I know that django dev documentation mentions user profiles, but does it very briefly (roughly few lines) and links to djangobook containing information about user profiles, but... to its first version, covering django 0.96. The second version of djangobook, covering django 1.0 (that is ... | 1 | 3 | 0 | I am writing simple site that requires users and profiles to be handled. The first initial thought is to use django's build in user handling, but then the user model is too narrow and does not contain fields that I need. The documentation mentions user profiles, but user profiles section has been removed from djangoboo... | Django - how to write users and profiles handling in best way? | 0 | 0 | 0 | 2,938 |
2,654,834 | 2010-04-16T17:04:00.000 | 4 | 1 | 1 | 0 | python,stream | 2,654,886 | 4 | true | 0 | 0 | You said that your script "calls a bunch of functions" so I'm assuming that they're python functions accessible from your program. I'm also assuming you're using print to generate the output in all these functions. If that's the case, you can just replace sys.stdout with a StringIO.StringIO which will intercept all the... | 1 | 7 | 0 | I've got a python script that calls a bunch of functions, each of which writes output to stdout. Sometimes when I run it, I'd like to send the output in an e-mail (along with a generated file). I'd like to know how I can capture the output in memory so I can use the email module to build the e-mail.
My ideas so far w... | Capturing stdout within the same process in Python | 1.2 | 0 | 0 | 4,960 |
2,655,643 | 2010-04-16T19:32:00.000 | 0 | 0 | 1 | 1 | python,readline,readlines,ungetc | 2,878,464 | 6 | false | 0 | 0 | The question was initially prompted by my need to build a lexical analyzer.
getc() and ungetc() are useful at first (to get the read bugs out the way and
to build the state machine) After the state machine is done,
getc() and ungetc() become a liability as they take too long to read
directly from storage.
When the s... | 1 | 2 | 0 | Some file read (readlines()) functions in Python
copy the file contents to memory (as a list)
I need to process a file that's too large to
be copied in memory and as such need to use
a file pointer (to access the file one byte
at a time) -- as in C getc().
The additional requirement I have is that
I'd like to rewin... | ungetc in Python | 0 | 0 | 0 | 2,250 |
2,655,747 | 2010-04-16T19:52:00.000 | 0 | 0 | 0 | 0 | python,mouseevent,rollover,vpython | 2,718,009 | 3 | false | 0 | 1 | scene.mouse.getclick will tell you where the mouse was when it was last clicked. This is different from scene.mouse.clicked which tells you if someone clicked.
There is no correspoding way to see if someone had their mouse over a particular object. One thing you can do is use a while loop that continually checks scene.... | 2 | 2 | 0 | Is there something similar to scene.mouse.getclick in the visual module (VPython)?
I need it for a rollover.
Thanks in advance.
EDIT: I need a function for doing something when the mouse moves inside a special area without clicking. | mouse rollover event in Python (VPython) | 0 | 0 | 0 | 594 |
2,655,747 | 2010-04-16T19:52:00.000 | 1 | 0 | 0 | 0 | python,mouseevent,rollover,vpython | 2,726,099 | 3 | true | 0 | 1 | As mentioned by mathmike, it would seem that you could use scene.mouse.pick to get the object that is currently under the mouse, and as for the 'scene-position', I think scene.mouse.pickpos is what you're looking for - if not, you should be able to calculate it from the global mouse position (through getEvent()).
Othe... | 2 | 2 | 0 | Is there something similar to scene.mouse.getclick in the visual module (VPython)?
I need it for a rollover.
Thanks in advance.
EDIT: I need a function for doing something when the mouse moves inside a special area without clicking. | mouse rollover event in Python (VPython) | 1.2 | 0 | 0 | 594 |
2,657,036 | 2010-04-17T02:52:00.000 | 4 | 0 | 0 | 0 | .net,python,user-interface,ironpython,pyqt | 3,042,547 | 5 | false | 0 | 1 | Per my play with both PyQt (as interface to Qt) and IronPython (as an interface to WinForms) the bag is mixed.
Both are basically "bindings" for underlying platforms. PyQt is practically "autogenerated" from Qt's API and slightly more "mature" as a wrapper because of significant use on Linux.
IronPython goes a little ... | 5 | 8 | 0 | I'm new in using Python. I would like to develop Windows GUI Application using Python. After some research, I found that I have 2 options:-
IronPython + .NET Framework
Python + PyQt
May I know which one is better for Windows Application development? Which option has more features (e.g. database support, etc)?
Other t... | "IronPython + .NET" vs "Python + PyQt". Which one is better for Windows App development? | 0.158649 | 0 | 0 | 5,960 |
2,657,036 | 2010-04-17T02:52:00.000 | 5 | 0 | 0 | 0 | .net,python,user-interface,ironpython,pyqt | 2,668,271 | 5 | false | 0 | 1 | I faced the same issue and have, with misgivings, decided to go with IronPython/C#/.Net. I liked Qt but got cold feet when it was sold to Nokia because I just wasn't sure Nokia's goals in owning Qt were consistent with my needs for a windows UI. That said, Nokia has made some positive moves by combining separate plat... | 5 | 8 | 0 | I'm new in using Python. I would like to develop Windows GUI Application using Python. After some research, I found that I have 2 options:-
IronPython + .NET Framework
Python + PyQt
May I know which one is better for Windows Application development? Which option has more features (e.g. database support, etc)?
Other t... | "IronPython + .NET" vs "Python + PyQt". Which one is better for Windows App development? | 0.197375 | 0 | 0 | 5,960 |
2,657,036 | 2010-04-17T02:52:00.000 | 3 | 0 | 0 | 0 | .net,python,user-interface,ironpython,pyqt | 2,658,657 | 5 | false | 0 | 1 | PyQt is a great library, but .NET is the best way to go for Windows. That is because you can use any GUI controls that C# would be able to use in Python. Furthermore, in addition to WinForms, IronPython can be used to create WPF applications, which look good.
The main difference is the features, and PyQt has more cro... | 5 | 8 | 0 | I'm new in using Python. I would like to develop Windows GUI Application using Python. After some research, I found that I have 2 options:-
IronPython + .NET Framework
Python + PyQt
May I know which one is better for Windows Application development? Which option has more features (e.g. database support, etc)?
Other t... | "IronPython + .NET" vs "Python + PyQt". Which one is better for Windows App development? | 0.119427 | 0 | 0 | 5,960 |
2,657,036 | 2010-04-17T02:52:00.000 | 1 | 0 | 0 | 0 | .net,python,user-interface,ironpython,pyqt | 2,657,263 | 5 | false | 0 | 1 | I haven't used IronPython with .NET, but I have written a lot of PyQt code. From my experience, PyQt is a great library. It is a very well executed bindings to Qt, which is a very well known and widely used library.
Since it's standard Python you're writing, you can enjoy all the Python standard library which gives you... | 5 | 8 | 0 | I'm new in using Python. I would like to develop Windows GUI Application using Python. After some research, I found that I have 2 options:-
IronPython + .NET Framework
Python + PyQt
May I know which one is better for Windows Application development? Which option has more features (e.g. database support, etc)?
Other t... | "IronPython + .NET" vs "Python + PyQt". Which one is better for Windows App development? | 0.039979 | 0 | 0 | 5,960 |
2,657,036 | 2010-04-17T02:52:00.000 | 3 | 0 | 0 | 0 | .net,python,user-interface,ironpython,pyqt | 2,657,059 | 5 | false | 0 | 1 | First, there are lots more than 2 options (python has more GUI libraries than you can shake a stick at), but let's go on your premise for a minute. "Better" being subjective begs the question: "what do you want to learn?"
If the goal is Windows GUI Applications development, than I'd go with .Net. .Net is well respecte... | 5 | 8 | 0 | I'm new in using Python. I would like to develop Windows GUI Application using Python. After some research, I found that I have 2 options:-
IronPython + .NET Framework
Python + PyQt
May I know which one is better for Windows Application development? Which option has more features (e.g. database support, etc)?
Other t... | "IronPython + .NET" vs "Python + PyQt". Which one is better for Windows App development? | 0.119427 | 0 | 0 | 5,960 |
2,657,627 | 2010-04-17T07:26:00.000 | 1 | 0 | 1 | 0 | python,magic-methods | 5,201,056 | 7 | false | 0 | 0 | While the reason is mostly historic, there are some peculiarities in Python's len that make the use of a function instead of a method appropriate.
Some operations in Python are implemented as methods, for example list.index and dict.append, while others are implemented as callables and magic methods, for example str a... | 3 | 105 | 0 | I've been playing around with Python recently, and one thing I'm finding a bit odd is the extensive use of 'magic methods', e.g. to make its length available, an object implements a method, def __len__(self), and then it is called when you write len(obj).
I was just wondering why objects don't simply define a len(self)... | Why does Python use 'magic methods'? | 0.028564 | 0 | 0 | 30,752 |
2,657,627 | 2010-04-17T07:26:00.000 | 4 | 0 | 1 | 0 | python,magic-methods | 2,657,834 | 7 | false | 0 | 0 | They are not really "magic names". It's just the interface an object has to implement to provide a given service. In this sense, they are not more magic than any predefined interface definition you have to reimplement. | 3 | 105 | 0 | I've been playing around with Python recently, and one thing I'm finding a bit odd is the extensive use of 'magic methods', e.g. to make its length available, an object implements a method, def __len__(self), and then it is called when you write len(obj).
I was just wondering why objects don't simply define a len(self)... | Why does Python use 'magic methods'? | 0.113791 | 0 | 0 | 30,752 |
2,657,627 | 2010-04-17T07:26:00.000 | 21 | 0 | 1 | 0 | python,magic-methods | 2,657,649 | 7 | false | 0 | 0 | From the Zen of Python:
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
This is one of the reasons - with custom methods, developers would be free to choose a different method name, like getLength(), length(), getlength() or whatsoev... | 3 | 105 | 0 | I've been playing around with Python recently, and one thing I'm finding a bit odd is the extensive use of 'magic methods', e.g. to make its length available, an object implements a method, def __len__(self), and then it is called when you write len(obj).
I was just wondering why objects don't simply define a len(self)... | Why does Python use 'magic methods'? | 1 | 0 | 0 | 30,752 |
2,658,026 | 2010-04-17T10:22:00.000 | 0 | 1 | 1 | 0 | python,unit-testing,datetime,testing,time | 2,658,048 | 6 | false | 0 | 0 | there might be few ways of doing this, like creating the orders (with the current timestamp) and then changing that value in the DB directly by some external process (assuming data is in the DB).
I'll suggest something else. Have you though about running your application in a virtual machine, setting the time to say Fe... | 1 | 24 | 0 | When I write with business logic, my code often depends on the current time. For example the algorithm which looks at each unfinished order and checks if an invoice should be sent (which depends on the no of days since the job was ended). In these cases creating an invoice is not triggered by an explicit user action bu... | How to change the date/time in Python for all modules? | 0 | 0 | 0 | 12,107 |
2,658,779 | 2010-04-17T14:58:00.000 | 0 | 0 | 1 | 0 | python,pythonpath,pyscripter | 13,216,653 | 4 | false | 0 | 1 | I just copied python26.dll from my python folder to pyscripter folder and it worked well... dont know it that is a good way to do it... | 3 | 5 | 0 | I installed PyScript to try it out but it just wont start. It only gives me the error:
"Error126: Could not open Dll "python26.dll" followed by:
"Python could not be properly initialized. We must quit."
I think this may have something to do with the PYTHONPATH but since I'm a newbie and dont know what it is or exactly ... | How do I make PyScripter work? Says it cant find python26.dll | 0 | 0 | 0 | 22,256 |
2,658,779 | 2010-04-17T14:58:00.000 | 0 | 0 | 1 | 0 | python,pythonpath,pyscripter | 23,843,782 | 4 | false | 0 | 1 | I finally got it working by (a) not changing the directory it gets installed in to something else...just left it in c:/programfiles/pyscripter ...and (B) going into the pyscripter folder and in the lib folder extracting the rpyc folder so that there is another rpyc folder inside the lib folder that isnt compressed! hop... | 3 | 5 | 0 | I installed PyScript to try it out but it just wont start. It only gives me the error:
"Error126: Could not open Dll "python26.dll" followed by:
"Python could not be properly initialized. We must quit."
I think this may have something to do with the PYTHONPATH but since I'm a newbie and dont know what it is or exactly ... | How do I make PyScripter work? Says it cant find python26.dll | 0 | 0 | 0 | 22,256 |
2,658,779 | 2010-04-17T14:58:00.000 | 0 | 0 | 1 | 0 | python,pythonpath,pyscripter | 2,658,872 | 4 | false | 0 | 1 | Install python. should solve all your problems.. | 3 | 5 | 0 | I installed PyScript to try it out but it just wont start. It only gives me the error:
"Error126: Could not open Dll "python26.dll" followed by:
"Python could not be properly initialized. We must quit."
I think this may have something to do with the PYTHONPATH but since I'm a newbie and dont know what it is or exactly ... | How do I make PyScripter work? Says it cant find python26.dll | 0 | 0 | 0 | 22,256 |
2,660,291 | 2010-04-17T22:24:00.000 | 1 | 0 | 0 | 1 | python,scripting,drag-and-drop,arguments | 2,660,314 | 3 | false | 0 | 0 | This really is independent of python. It depends entirely on which file browser you're using and how it supports drag and drop. | 2 | 4 | 0 | I am writing a simple Python script with no GUI. I want to be able to drag and drop multiple files onto my python script and have access to their absolute paths inside of the script. How do I do this in Mac, Linux, and windows? For times sake, just Mac will be fine for now.
I've googled this question and only found one... | In python, how do I drag and drop 1 or more files onto my script as arguments with absolute path? (for windows, linux, and mac) | 0.066568 | 0 | 0 | 3,985 |
2,660,291 | 2010-04-17T22:24:00.000 | 1 | 0 | 0 | 1 | python,scripting,drag-and-drop,arguments | 2,660,293 | 3 | false | 0 | 0 | Usually when you drag a file onto a script/executable, the OS passes the path to that file as a command-line argument. Check sys.argv | 2 | 4 | 0 | I am writing a simple Python script with no GUI. I want to be able to drag and drop multiple files onto my python script and have access to their absolute paths inside of the script. How do I do this in Mac, Linux, and windows? For times sake, just Mac will be fine for now.
I've googled this question and only found one... | In python, how do I drag and drop 1 or more files onto my script as arguments with absolute path? (for windows, linux, and mac) | 0.066568 | 0 | 0 | 3,985 |
2,660,316 | 2010-04-17T22:31:00.000 | 1 | 0 | 0 | 1 | javascript,python,google-app-engine,comet | 2,660,540 | 3 | false | 1 | 0 | The App Engine roadmap has Comet support, otherwise you will have some difficulty achieving this. | 1 | 3 | 0 | I'm creating a web application on Google AppEngine where I want the user to be notified a quickly as possible after certain events occour. The problem is similar to say a chat server in that I need something happening on one connection (someone is writing a message in a chat room) to propagate to a number of other conn... | How can I implement "real time" messaging on Google AppEngine? | 0.066568 | 0 | 0 | 554 |
2,661,069 | 2010-04-18T03:56:00.000 | 1 | 0 | 1 | 0 | python-3.x | 8,859,319 | 3 | false | 0 | 0 | Pexpect has not been ported to python3, and apparently the author has no plans on doing so.
I tried converting it with the python 2to3 program, but could not get it to work. | 2 | 2 | 0 | i have installed pexpect with the following command "python setup.py install" but when i try to run a program it says "AttributeError: 'module' object has no attribute 'spawn'". how to settle the matter? | pexpect install problem | 0.066568 | 0 | 0 | 1,337 |
2,661,069 | 2010-04-18T03:56:00.000 | 2 | 0 | 1 | 0 | python-3.x | 4,926,558 | 3 | false | 0 | 0 | It looks like pexpect wasn't ported yet to python 3 (quite a late answer, but still usable for people googling here) | 2 | 2 | 0 | i have installed pexpect with the following command "python setup.py install" but when i try to run a program it says "AttributeError: 'module' object has no attribute 'spawn'". how to settle the matter? | pexpect install problem | 0.132549 | 0 | 0 | 1,337 |
2,661,778 | 2010-04-18T09:39:00.000 | 2 | 0 | 0 | 0 | python,tags,machine-learning,nlp,nltk | 2,661,789 | 5 | false | 0 | 0 | A very simple solution to the problem would be:
count the occurences of each word in the text
consider the most frequent terms as the key phrases
have a black-list of 'stop words' to remove common words like the, and, it, is etc
I'm sure there are cleverer, stats based solutions though.
If you need a solution to use ... | 1 | 50 | 1 | I am curious if there is an algorithm/method exists to generate keywords/tags from a given text, by using some weight calculations, occurrence ratio or other tools.
Additionally, I will be grateful if you point any Python based solution / library for this.
Thanks | tag generation from a text content | 0.07983 | 0 | 0 | 28,812 |
2,662,595 | 2010-04-18T14:46:00.000 | 1 | 0 | 1 | 0 | python,html,screen-scraping,hyperlink | 2,663,277 | 1 | true | 0 | 0 | Ways out.
Parallelise
Profile your code to see where the bottleneck is. The result are often surprising.
Use a single regexp (concatenate using |) rather than multiple ones. | 1 | 2 | 0 | I have around 5 GB of html data which I want to process to find links to a set of websites and perform some additional filtering. Right now I use simple regexp for each site and iterate over them, searching for matches. In my case links can be outside of "a" tags and be not well formed in many ways(like "\n" in the mid... | Extract anything that looks like links from large amount of data in python | 1.2 | 0 | 1 | 156 |
2,662,852 | 2010-04-18T15:57:00.000 | 0 | 0 | 0 | 1 | python,command-line,time | 5,870,949 | 2 | false | 0 | 0 | You can use the timeit module to time code snippets (say, a function that launches external commands using subprocess module as described in the answer above) and save the data to a csv file. You can do statistics on the csv data using a stats module or externally using Excel/ LogParser/ R etc.
Another approach is to u... | 1 | 1 | 0 | I want to run the 'time' unix command from a Python script, to time the execution of a non Python app. I would use the os.system method.
Is there any way to save the output of this in Python? My goal is to run the app several times, save their execution times and then do some statistics on them.
Thank You | Python run command line (time) | 0 | 0 | 0 | 1,310 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.