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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3,515,673 | 2010-08-18T18:59:00.000 | 3 | 0 | 1 | 1 | python,installation,uninstallation | 53,206,032 | 14 | false | 0 | 0 | It's actually quite simple.
When you installed it, you must have done it using some .exe file (I am assuming). Just run that .exe again, and then there will be options to modify Python. Just select the "Complete Uninstall" option, and the EXE will completely wipe out python for you.
Also, you might have to checkbox the "Remove Python from PATH". By default it is selected, but you may as well check it to be sure :) | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 0.042831 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 3 | 0 | 1 | 1 | python,installation,uninstallation | 71,832,157 | 14 | false | 0 | 0 | First, uninstall Python, then remove the pip packages you installed.
Uninstall Python: "Add or Remove Programs", search for Python and uninstall it.
Remove Pip packages: type in File Explorer %LOCALAPPDATA%\Programs\Python, and remove the folders you want.
This will clean up any pip package you installed. Otherwise, if you were to reinstall Python, you will find yourself with the same pip packages that you had. | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 0.042831 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 3 | 0 | 1 | 1 | python,installation,uninstallation | 69,742,157 | 14 | false | 0 | 0 | If you still have the python installer on your PC, you can double-click on it (run it, it will open the installer window), and select the "Uninstall" option. It will uninstall that python version (if the installer is for Python3.9, then Python3.9 will be uninstalled, if it is for Python3.10, then that version...) | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 0.042831 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 2 | 0 | 1 | 1 | python,installation,uninstallation | 51,663,703 | 14 | false | 0 | 0 | Uninstall the python program using the windows GUI.
Delete the containing folder e.g if it was stored in C:\python36\ make sure to delete that folder | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 0.028564 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 1 | 0 | 1 | 1 | python,installation,uninstallation | 36,202,297 | 14 | false | 0 | 0 | I know it is an old question, but I ran into this problem with 2.7 and 3.5. Though 2.7 would not show up in my default windows uninstall list, it showed up fine in the ccleaner tools tab under uninstall. Uninstalled and reinstalled afterwards and it has been smooth coding ever since. | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 0.014285 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 0 | 0 | 1 | 1 | python,installation,uninstallation | 35,889,457 | 14 | false | 0 | 0 | Windows 7 64-bit, with both Python3.4 and Python2.7 installed at some point :)
I'm using Py.exe to route to Py2 or Py3 depending on the script's needs - but I previously improperly uninstalled Python27 before.
Py27 was removed manually from C:\python\Python27 (the folder Python27 was deleted by me previously)
Upon re-installing Python27, it gave the above error you specify.
It would always back out while trying to 'remove shortcuts' during the installation process.
I placed a copy of Python27 back in that original folder, at C:\Python\Python27, and re-ran the same failing Python27 installer. It was happy locating those items and removing them, and proceeded with the install.
This is not the answer that addresses registry key issues (others mention that) but it is somewhat of a workaround if you know of previous installations that were improperly removed.
You could have some insight to this by opening "regedit" and searching for "Python27" - a registry key appeared in my command-shell Cache pointing at c:\python\python27\ (which had been removed and was not present when searching in the registry upon finding it).
That may help point to previously improperly removed installations.
Good luck! | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 0 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | 1 | 0 | 1 | 1 | python,installation,uninstallation | 3,515,850 | 14 | false | 0 | 0 | Almost all of the python files should live in their respective folders (C:\Python26 and C:\Python27). Some installers (ActiveState) will also associate .py* files and add the python path to %PATH% with an install if you tick the "use this as the default installation" box. | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | 0.014285 | 0 | 0 | 600,614 |
3,515,673 | 2010-08-18T18:59:00.000 | -1 | 0 | 1 | 1 | python,installation,uninstallation | 66,791,174 | 14 | false | 0 | 0 | Windows Start Menu > Settings > Apps > Apps & features > Select the app and click the Uninstall button | 12 | 123 | 0 | I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py install" for certain packages don't recognize the "install" parameter and other odd phenomena...
I would like to completely remove Python from my system.
I tried running the 2.7 and 2.6 msi files and choosing remove Python and then running only 2.6 and reinstalling it. Still stuff don't work.
How do I completely remove Python - from everything? (!)
I would not like to reinstall my entire machine just because of the Python install... | How to completely remove Python from a Windows machine? | -0.014285 | 0 | 0 | 600,614 |
3,516,560 | 2010-08-18T20:49:00.000 | 1 | 0 | 1 | 0 | python,c | 6,150,403 | 7 | false | 0 | 0 | As someone who has worked with Java for over 12 years, I found that picking up a problem and solving it in a new language is the best way to learn. I don't believe in reading - it wastes a huge amount of time, and you can easily end up reading for too long.
My advice is to find a problem and set off to solve it with Python. You will learn alot in the process.
Good luck | 3 | 18 | 0 | I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go.
I've seen several questions on how to learn Python, but most of them were from folks who were looking to start programming for the first time. I don't need a tutorial that will tell me what a string is, but I do need one that can tell me how to make a string in Python. Any help on some good sources to look through? Bonus points if the source is free :) | Coming from C, how should I learn Python? | 0.028564 | 0 | 0 | 22,778 |
3,516,560 | 2010-08-18T20:49:00.000 | 1 | 0 | 1 | 0 | python,c | 3,517,315 | 7 | false | 0 | 0 | Diveintopython, official docs, "Learning python" by Mark Lutz(4th edition) is one of the best books. | 3 | 18 | 0 | I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go.
I've seen several questions on how to learn Python, but most of them were from folks who were looking to start programming for the first time. I don't need a tutorial that will tell me what a string is, but I do need one that can tell me how to make a string in Python. Any help on some good sources to look through? Bonus points if the source is free :) | Coming from C, how should I learn Python? | 0.028564 | 0 | 0 | 22,778 |
3,516,560 | 2010-08-18T20:49:00.000 | 32 | 0 | 1 | 0 | python,c | 3,516,905 | 7 | true | 0 | 0 | I knew C before I knew Python. No offence intended, but I don't think that your C knowledge is that big a deal. Unless you read very, very slowly, just set out to learn Python. It won't take that long to skim through the material you're familiar with, and it's not as if a Python tutorial aimed at C programmers will make you a better Python programmer - it might teach you things in a different order, is all, and raise some specific things that you would do in C but that you should not do in Python.
Strings in Python actually are somewhat different from strings in C, and they're used differently. I strongly recommend learning them "from scratch", rather than thinking about them in terms of their differences from C strings. For one thing, in Python 2 it's best not to use Python's "string" class to represent strings: there's a separate unicode string class and for practical Python apps (pretty much anything involving user data), you need that. (Python 3 fixes this, making the str class a unicode string). You need to establish a good working practice for unicode/byte data and decode/encode.
A common mistake when learning a second programming language, is to think "I know how to program, I just need to translate what I do in C into Python". No, you don't. While it's true that an algorithm can be basically the same in different languages, the natural way to do a particular thing can be completely different in different languages. You will write better Python code if you learn to use Python idiomatically, than if you try to write Python like a C programmer. Many of the "tricks" you know that make sense in C will be either pointless or counter-productive in Python. Conversely many things that you should do happily in a typical Python program, like allocating and freeing a lot of memory, are things that in C you've probably learned to think twice about. Partly because the typical C program has different restrictions from the typical Python program, and partly because you just have to write more code and think harder to get that kind of thing right in C than you do in Python.
If you're learning the language because you urgently need to program a system/platform which has Python but doesn't have C, then writing Python programs that work like C programs is a reasonable interim measure. But that probably doesn't apply to you, and even if it did it's not the ultimate goal.
One thing you might be interested to look at because of your C experience, is the Python/C API. Python is great for many things, but it doesn't result in the fastest possible computational core of scientific apps [neither does C, probably, but let's not go into FORTRAN for now ;-)]. So if you're aiming to continue with scientific programming through your move in Python, and your programs are typically memory-bus- and CPU-bound doing immense amounts of number-crunching (billions of ops), then you might like to know how to escape into C if you ever need to. Consider it a last resort, though.
You do need to understand Python reasonably well before the Python/C API makes much sense, though.
Oh yes, and if you want to understand OOP in general, remember later on to take a look at something like Java, Objective-C, C++, or D. Python isn't just an OO language, it's a dynamic OO language. You might not realise it from comparing just C with Python, but dynamic vs static types is a completely independent issue from the OOP-ness of Python. Python objects are like hashtables that allow you to attach new fields willy-nilly, but objects in many other OO languages store data in ways which are much more like a C struct. | 3 | 18 | 0 | I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go.
I've seen several questions on how to learn Python, but most of them were from folks who were looking to start programming for the first time. I don't need a tutorial that will tell me what a string is, but I do need one that can tell me how to make a string in Python. Any help on some good sources to look through? Bonus points if the source is free :) | Coming from C, how should I learn Python? | 1.2 | 0 | 0 | 22,778 |
3,517,011 | 2010-08-18T21:49:00.000 | 1 | 1 | 0 | 1 | python,c,python-module,i2c | 3,517,141 | 5 | false | 0 | 0 | Don't use the Python C API, there are much easier alternatives, most notably cython.
cython is a Python-like language, which compiles into C code for the Python c library. Basically it's C with Python syntax and features (e.g. nice for loops, exceptions, etc.). cython is clearly the most recommendable way to write C extensions for python.
You might also want to take a look at ctypes, a module to dynamically load C libraries and call functions from them. If your i2c-code is available as shared library, you can get away with no native binding at all, which eases development and distribution. | 3 | 1 | 0 | So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.
Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo. | Extending python with C module | 0.039979 | 0 | 0 | 471 |
3,517,011 | 2010-08-18T21:49:00.000 | 0 | 1 | 0 | 1 | python,c,python-module,i2c | 3,517,152 | 5 | false | 0 | 0 | I've had good luck using ctypes. Whatever you choose, though, you may not gain any time this time but the next time around your effort will be much faster than doing the whole thing in C. | 3 | 1 | 0 | So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.
Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo. | Extending python with C module | 0 | 0 | 0 | 471 |
3,517,011 | 2010-08-18T21:49:00.000 | 2 | 1 | 0 | 1 | python,c,python-module,i2c | 3,517,190 | 5 | false | 0 | 0 | One of the first Python programs I wrote was a script that called functions from a C library, which sounds close to what you're doing. I used ctypes, and I was impressed as to how easy it was: I could access each library function from python by writing just a few lines of python (no C at all!). I'd tried the Python C API before, and it required a lot more boilerplate. I havent tried SWIG or Cython. | 3 | 1 | 0 | So I have a C program to interface with an i2c device. I need to interface to that device from python. I'm just wondering if it's worth porting the program into a python module or if the amount of effort involved in porting won't outweigh just executing the program using subprocess. I know I'm sure it's different for every application, but I'd like to know if it's even worth my time to learn the python C extensions and port this program.
Update: I have full access to the source of both the C as well as the python. But there is already substantial work done on the python side and I'd like to keep changes to that as minimal is possible, if that matters. And I'd also like to minimize the changes that have to be made to the C. It's doable, but I didn't write it and it involves a lot of by addressing that I'd rather not have to redo. | Extending python with C module | 0.07983 | 0 | 0 | 471 |
3,517,410 | 2010-08-18T22:58:00.000 | -2 | 1 | 1 | 0 | python,unit-testing,interactive,ipython | 3,517,604 | 3 | false | 0 | 0 | Are you really sure you want to do this? Your unit tests should do one thing, should be well-named, and should clearly print what failed. If you do all of that, the failure message will pinpoint what went wrong; no need to go look at it interactively. In fact, one of the big advantages of TDD is that it helps you avoid having to go into the debugger at all to diagnose problems. | 1 | 3 | 0 | I'd like to be able to enter an interactive session, preferably with IPython, if a unit test fails. Is there an easy way to do this?
edit: by "interactive session" I mean a full Python REPL rather than a pdb shell.
edit edit: As a further explanation: I'd like to be able to start an interactive session that has access to the context in which the test failure occurred. So for example, the test's self variable would be available. | drop into an interactive session to examine a failed unit test | -0.132549 | 0 | 0 | 1,014 |
3,517,841 | 2010-08-19T00:33:00.000 | 1 | 0 | 0 | 0 | python,qt,networking,pyqt,thin | 3,517,886 | 2 | true | 0 | 1 | Your desire to send "app logic" from the server to the client without sending "code" is inherently self-contradictory, though you may not realize that yet -- even if the "logic" you're sending is in some simplified ad-hoc "language" (which you don't even think of as a language;-), to all intents and purposes your Python code will be interpreting that language and thereby execute that code. You may "sandbox" things to some extent, but in the end, that's what you're doing.
To avoid hijackings and other tricks, instead, use HTTPS and validate the server's cert in your client: that will protect you from all the problems you're worrying about (if somebody can edit the app enough to defeat the HTTPS cert validation, they can edit it enough to make it run whatever code they want, without any need to send that code from a server;-).
Once you're using https, having the server send Python modules (in source form if you need to support multiple Python versions on the clients, else bytecode is fine) and the client thereby save them to disk and import / reload them, will be just fine. You'll basically be doing a variant of the classic "plugins architecture" where the "plugins" are in fact being sent from the server (instead of being found on disk in a given location). | 1 | 0 | 0 | Here is what I would like to do, and I want to know how some people with experience in this field do this:
With three POST requests I get from the http server:
widgets and layout
and then app logic (minimal)
data
Or maybe it's better to combine the first two or all three. I'm thinking of using pyqt. I think I can load .ui files. I can parse json data. I just think it would be rather dangerous to pass code over a network to be executed on the client. If someone can hijack the connection, or can change the apps setting to access a bogus server, that is nasty.
I want to do it this way because it keeps all the clients up-to-date. It's sort of like a webapp but simpler because of Qt. Essentially the "thin" app is just a minimal compiled python file that loads data from a server.
How can I do this without introducing security issues on the client? Is https good enough? Is there a way to get pyqt to run in a sandbox of sorts?
PS. I'm not stuck on Qt or python. I do like the concept though. I don't really want to use Java - server or client side. | how to implement thin client app with pyqt | 1.2 | 0 | 1 | 1,647 |
3,518,465 | 2010-08-19T03:15:00.000 | 2 | 0 | 1 | 0 | dll,types,ironpython | 3,518,530 | 1 | true | 0 | 0 | For import you need to know the namespaces or type names if not in a namespace to import them. But you can do "test = clr.LoadAssemblyFromFileWithPath(...)" which will return an assembly object. In IronPython assembly objects support dotting through them so you could then access the namespaces/types directly from that object. | 1 | 2 | 0 | import clr
clr.AddReferenceToFileAndPath(r'E:\MyDocuments\Surface Extension\Samples\test.dll')
But, How to watch the types in the test.dll.
import test
I got :
error: No module named test
Shold I must know the types in the test.dll?? | How to watch the types in dll? | 1.2 | 0 | 0 | 156 |
3,519,565 | 2010-08-19T07:14:00.000 | 0 | 0 | 1 | 0 | python,regex,indexing | 61,329,622 | 3 | false | 0 | 0 | This should solve your issue
pattern=r"(?=(\"[^\"]+\"|'[^']+'))"
Then use the following to get all overlapping indices,
indicesTuple=[(mObj.start(1),mObj.end(1)-1) for mObj in re.finditer(pattern,input)] | 1 | 97 | 0 | I'm parsing strings that could have any number of quoted strings inside them (I'm parsing code, and trying to avoid PLY). I want to find out if a substring is quoted, and I have the substrings index. My initial thought was to use re to find all the matches and then figure out the range of indexes they represent.
It seems like I should use re with a regex like \"[^\"]+\"|'[^']+' (I'm avoiding dealing with triple quoted and such strings at the moment). When I use findall() I get a list of the matching strings, which is somewhat nice, but I need indexes.
My substring might be as simple as c, and I need to figure out if this particular c is actually quoted or not. | Find the indexes of all regex matches? | 0 | 0 | 0 | 111,929 |
3,520,672 | 2010-08-19T10:07:00.000 | 1 | 0 | 0 | 0 | python,scipy | 3,520,715 | 2 | false | 0 | 0 | Yes. Those integrals (I'll assume they're area integrals over a region in 2D space) can be calculated using an appropriate quadrature rule.
You can also use Green's theorem to convert them into contour integrals and use Gaussian quadrature to integrate along the path. | 2 | 1 | 1 | (Couldn't upload the picture showing the integral as I'm a new user.) | Can scipy calculate (double) integrals with complex-valued integrands (real and imaginary parts in integrand)? | 0.099668 | 0 | 0 | 571 |
3,520,672 | 2010-08-19T10:07:00.000 | 0 | 0 | 0 | 0 | python,scipy | 3,526,740 | 2 | false | 0 | 0 | Thanks duffymo!
I am calculating Huygens-Fresnel diffraction integrals: plane and other wave diffraction through circular (2D) apertures in polar coordinates.
As far as the programming goes: Currently a lot of my code is in Mathematica. I am considering changing to one of: scipy, java + flanagan math library, java + apache commons math library, gnu scientific library, or octave.
My first candidate for evaluation is scipy, but if it cannot handle complex-valued integrands, then I have to change my plans for the weekend... | 2 | 1 | 1 | (Couldn't upload the picture showing the integral as I'm a new user.) | Can scipy calculate (double) integrals with complex-valued integrands (real and imaginary parts in integrand)? | 0 | 0 | 0 | 571 |
3,521,548 | 2010-08-19T12:05:00.000 | 0 | 0 | 0 | 0 | python,local,wsgi | 4,376,995 | 3 | false | 1 | 0 | Earlier today I saw exactly what you're asking for -- a way to call WSGI through an API without actually connecting over the network. However, it shouldn't be that hard.
On a side note, you might want to look at PySide, of particular interest to you may be the ability to bind python elements to DOM events, so if you're just looking to trigger python code that's an even shorter route.
If you give some more detail on what you're hoping to achieve we might be able to dial it in for you. | 1 | 8 | 0 | Disclaimer: I'm not very familiar with any of the things mentioned in the question title.
Would it be possible to use a browser control (like Webkit) as a frontend for a WSGI app (using a framework like Flask) without starting a local WSGI server?
Basically the requests and responses are managed by a middle layer between the HTML UI and the WSGI backend. A certain URI could mean "Local", for instance "local://" or something similar, and will be routed to the embedded WSGI app with all the original headers etc.
You will lose any features that a normal WSGI server provides unless you implement it yourself or somehow embed a server that is also usable via an API instead of real HTTP requests.
Now that I think of it, this is the only real requirement: A WSGI server that is callable via an API and not just real HTTP requests.
I know the usefulness of this is questionable (and maybe doesn't even make sense). My question is whether this is at all possible?
EDIT: Here's another way of putting it:
I want a single codebase to be both a web app and a desktop app, using an HTML frontend and a Python backend. I don't want to run a server on any port for the desktop app. What's the easiest way to achieve this? | Embedded WSGI backend for Python desktop app using webkit | 0 | 0 | 0 | 921 |
3,522,372 | 2010-08-19T13:42:00.000 | 78 | 0 | 1 | 0 | python,path,directory,nlp,nltk | 3,903,787 | 7 | false | 0 | 0 | Just change items of nltk.data.path, it's a simple list. | 2 | 96 | 0 | How to config nltk data directory from code? | How to config nltk data directory from code? | 1 | 0 | 0 | 63,097 |
3,522,372 | 2010-08-19T13:42:00.000 | 0 | 0 | 1 | 0 | python,path,directory,nlp,nltk | 56,460,309 | 7 | false | 0 | 0 | Another solution is to get ahead of it.
try
import nltk
nltk.download()
When the window box pops up asking if you want to download the corpus , you can specify there which directory it is to be downloaded to. | 2 | 96 | 0 | How to config nltk data directory from code? | How to config nltk data directory from code? | 0 | 0 | 0 | 63,097 |
3,522,380 | 2010-08-19T13:43:00.000 | 0 | 0 | 1 | 0 | python,python-3.x | 3,522,548 | 7 | false | 0 | 0 | I would say to teach Python 2.*, as while Python 3 is the new hotness, there are very few supported libraries yet, and the vast majority of resources on the web are for older Python versions. | 6 | 7 | 0 | Which is more suited as the platform for a first course in computing: Python 2 or Python 3? Reason for asking your opinion: Python 2 is used in the vast majority of installations worlwide, but Python 3 is the coming thing. | Python 2 or Python 3 as the student's first language | 0 | 0 | 0 | 476 |
3,522,380 | 2010-08-19T13:43:00.000 | 0 | 0 | 1 | 0 | python,python-3.x | 3,522,512 | 7 | false | 0 | 0 | Python 2. Unfortunately library support for python 3 is dismal. | 6 | 7 | 0 | Which is more suited as the platform for a first course in computing: Python 2 or Python 3? Reason for asking your opinion: Python 2 is used in the vast majority of installations worlwide, but Python 3 is the coming thing. | Python 2 or Python 3 as the student's first language | 0 | 0 | 0 | 476 |
3,522,380 | 2010-08-19T13:43:00.000 | 4 | 0 | 1 | 0 | python,python-3.x | 3,522,458 | 7 | false | 0 | 0 | I would say that it depends on your curriculum. If you are going to be using/showing some open source libraries, you may have issues with some of them working on 3, so in that case go with 2. If you're just showing the language itself and having your students write everything from scratch without the use of any external libraries, I would say go with 3. | 6 | 7 | 0 | Which is more suited as the platform for a first course in computing: Python 2 or Python 3? Reason for asking your opinion: Python 2 is used in the vast majority of installations worlwide, but Python 3 is the coming thing. | Python 2 or Python 3 as the student's first language | 0.113791 | 0 | 0 | 476 |
3,522,380 | 2010-08-19T13:43:00.000 | 0 | 0 | 1 | 0 | python,python-3.x | 3,522,531 | 7 | false | 0 | 0 | For a student, my recomendation is python 2.x, because older it is, easier you find code exapmles and usage of pythonic functions. If you choose to study python 3, you may have problem finding code examples and help.
Also there is much more python 2.x expert than 3.0. | 6 | 7 | 0 | Which is more suited as the platform for a first course in computing: Python 2 or Python 3? Reason for asking your opinion: Python 2 is used in the vast majority of installations worlwide, but Python 3 is the coming thing. | Python 2 or Python 3 as the student's first language | 0 | 0 | 0 | 476 |
3,522,380 | 2010-08-19T13:43:00.000 | 3 | 0 | 1 | 0 | python,python-3.x | 3,522,941 | 7 | false | 0 | 0 | Frankly, I think you have a great opportunity to teach your students a valuable lesson: keeping their skills up-to-date while daily dealing with "older" code. This is a simple reality in life they'll have to grasp if they want to be successful programmers (heck, it's likely true for most jobs).
Here's how I would approach this: teach them 2.x as the primary language of the course. The majority of Python libraries will not be compatible with 3.x and the programming concepts aren't terribly different between the two major versions. During the course, however, give them assignments which require them to investigate Python 3, learning what's different and why. Take a little time to teach them about migration tools and some of the basic concepts for updating an older code base. For an entry-level class, you might also consider giving them a basic, 2.5 program, and have them manually update it to 3.1. | 6 | 7 | 0 | Which is more suited as the platform for a first course in computing: Python 2 or Python 3? Reason for asking your opinion: Python 2 is used in the vast majority of installations worlwide, but Python 3 is the coming thing. | Python 2 or Python 3 as the student's first language | 0.085505 | 0 | 0 | 476 |
3,522,380 | 2010-08-19T13:43:00.000 | 0 | 0 | 1 | 0 | python,python-3.x | 3,522,722 | 7 | false | 0 | 0 | id say python 2, python 2 has been around for a while and is very mature, with a lot of libraries and modules and major frameworks available for it. Python 3 is very new, and doesnt have many libraries yet. I guess this will be the scenario for a couple of years. | 6 | 7 | 0 | Which is more suited as the platform for a first course in computing: Python 2 or Python 3? Reason for asking your opinion: Python 2 is used in the vast majority of installations worlwide, but Python 3 is the coming thing. | Python 2 or Python 3 as the student's first language | 0 | 0 | 0 | 476 |
3,522,584 | 2010-08-19T14:07:00.000 | 1 | 0 | 1 | 0 | python,web-services,sandbox | 4,007,217 | 5 | false | 0 | 0 | You definitely don't want to test with live data first. In order to build the integration test, you should first mock your dependencies and use I/O sets you control. Having expected input and output is very important. Building those unit tests will help you immensely when doing your integration testing.
As for your specific question, you can use a proxy to intercept the data or decorate your calling function to add logging. Take a look at Aspect Oriented Programming (AOP) for more information on interceptors.
If you are using WSGI, you can write a middleware piece to handle the interception and logging. Take a look at CherryPy's wsgiserver.py module for help with that; Django also uses middleware and their docs might be able to help regarding middleware. | 3 | 4 | 0 | I'm building an integration test for a web application that has multiple interdependent services. All of them depend on a shared resource in order to run correctly. I'd like to make sure that the data in the system is sane when its live so I'm leveraging a live service. I'm using Python to build it and this is my idea on how to sandbox the services:
build a test runner using multiprocessing's BaseManager
chroot jail each of the services, run them as a background service
have a listener respond to incoming connections from the services and spit out the data
Does this seem sane? Other ideas include running each service as a process or make each service have its own python virtualenv to run in. | Sandboxing web services with Python | 0.039979 | 0 | 0 | 308 |
3,522,584 | 2010-08-19T14:07:00.000 | 0 | 0 | 1 | 0 | python,web-services,sandbox | 4,044,514 | 5 | false | 0 | 0 | Perhaps you should take a step back and ask a few questions first.
What is the most important part to have tested?
How difficult is it to setup that test?
Is the cost of setting up the test worth getting the test results?
Can I have most of what I wanted tested with a simpler test?
Any way you go I would use a fixture based on live data and expectation of what that data becomes. This allows our test to be deterministic and therefore automated.
If the most important piece is a portion of logic, that can be tested via a unit test with known input/output and mocks.
If the testing the integration part is really the most important then I would try and strike a balance between mocking out as many moving pieces as I felt comfortable doing in order to make a more manageable test.
The more networked resources you use the more complex a system, and the more tests it should have. You have to think about timing issues, service uptime, timeouts, error states, etc. You can also fall into a trap of creating a test which is nondeterministic. If your assertion ends up looking for differences in timings, rely on particular timings, or rely on an unreliable service which breaks alot; than you may end up with a test which is worthless because of the amount of "noise" from false positive breaks.
If you want to drive towards using a continuous integration model you'll also need consider the complexities of having to manage (startup and shutdown) or multiple process with each test run. In general you get a easier test to manage if you can have the test be the single process running and the other "processes" be the function calls to the appropriate starting points in the code. | 3 | 4 | 0 | I'm building an integration test for a web application that has multiple interdependent services. All of them depend on a shared resource in order to run correctly. I'd like to make sure that the data in the system is sane when its live so I'm leveraging a live service. I'm using Python to build it and this is my idea on how to sandbox the services:
build a test runner using multiprocessing's BaseManager
chroot jail each of the services, run them as a background service
have a listener respond to incoming connections from the services and spit out the data
Does this seem sane? Other ideas include running each service as a process or make each service have its own python virtualenv to run in. | Sandboxing web services with Python | 0 | 0 | 0 | 308 |
3,522,584 | 2010-08-19T14:07:00.000 | 0 | 0 | 1 | 0 | python,web-services,sandbox | 3,591,657 | 5 | false | 0 | 0 | The third possibility is the easiest - avoid any locking issues by having your own daemon be the intermediate and have it be the only process with direct access to the resource, and all other processes need to go through it to get access. | 3 | 4 | 0 | I'm building an integration test for a web application that has multiple interdependent services. All of them depend on a shared resource in order to run correctly. I'd like to make sure that the data in the system is sane when its live so I'm leveraging a live service. I'm using Python to build it and this is my idea on how to sandbox the services:
build a test runner using multiprocessing's BaseManager
chroot jail each of the services, run them as a background service
have a listener respond to incoming connections from the services and spit out the data
Does this seem sane? Other ideas include running each service as a process or make each service have its own python virtualenv to run in. | Sandboxing web services with Python | 0 | 0 | 0 | 308 |
3,522,641 | 2010-08-19T14:13:00.000 | 2 | 0 | 0 | 0 | python,windows,http | 3,522,672 | 2 | true | 0 | 0 | Without any code sample I can only assume that your server is listening on some private interface like localhost/127.0.0.1 and not something that is connected to the rest of your network. | 2 | 0 | 0 | I have written a small HTTP server and everything is working fine locally, but I am not able to connect to the server from any other computer, including other computers on the network. I'm not sure if it is a server problem, or if I just need to make some adjustments to Windows. I turned the firewall off, so that can't be the probelm.
I am using Python 2.6 on Windows 7. | Python Server Help | 1.2 | 0 | 1 | 213 |
3,522,641 | 2010-08-19T14:13:00.000 | 0 | 0 | 0 | 0 | python,windows,http | 3,522,734 | 2 | false | 0 | 0 | Some things to check:
Can you connect to the server via your machine's IP instead of localhost? I.e. if your machine is 1.2.3.4 in the network and the server is listening on port 8080, can you see it by opening a browser to http://1.2.3.4:8080 on the same machine?
Can you do (1) from another machine? (just a sanity check...)
Do other servers work throughout the network? I.e. if you run a simple FTP server (like Filezilla server) on the machine, can you FTP to it from other machines?
Can you ping one machine from another?
Do you still have firewalls running? (i.e. default Windows firewall) | 2 | 0 | 0 | I have written a small HTTP server and everything is working fine locally, but I am not able to connect to the server from any other computer, including other computers on the network. I'm not sure if it is a server problem, or if I just need to make some adjustments to Windows. I turned the firewall off, so that can't be the probelm.
I am using Python 2.6 on Windows 7. | Python Server Help | 0 | 0 | 1 | 213 |
3,524,168 | 2010-08-19T16:55:00.000 | 7 | 0 | 1 | 0 | python | 3,524,212 | 6 | false | 0 | 0 | I think it depends on the module. For example, Django has a VERSION variable that you can get from django.VERSION, sqlalchemy has a __version__ variable that you can get from sqlalchemy.__version__. | 2 | 47 | 0 | I'm trying to get the version number of a specific few modules that I use. Something that I can store in a variable. | How do I get a python module's version number through code? | 1 | 0 | 0 | 73,190 |
3,524,168 | 2010-08-19T16:55:00.000 | 35 | 0 | 1 | 0 | python | 3,524,247 | 6 | true | 0 | 0 | Generalized answer from Matt's, do a dir(YOURMODULE) and look for __version__, VERSION, or version. Most modules like __version__ but I think numpy uses version.version | 2 | 47 | 0 | I'm trying to get the version number of a specific few modules that I use. Something that I can store in a variable. | How do I get a python module's version number through code? | 1.2 | 0 | 0 | 73,190 |
3,524,236 | 2010-08-19T17:02:00.000 | 1 | 0 | 0 | 0 | python,database,django,sqlite | 3,524,305 | 2 | false | 1 | 0 | if you don't provide full path, it will use the current directory of settings.py,
and if you wish to specify static path you can specify it like: c:/projects/project1/my_proj.db
or in case you want to make it dynamic then you can use os.path module
so os.path.dirname(file) will give you the path of settings.py and accordingly you can alter the path for your database like os.path.join(os.path.dirname(file),'my_proj.db') | 1 | 5 | 0 | I'm in the settings.py module, and I'm supposed to add the directory to the sqlite database. How do I know where the database is and what the full directory is?
I'm using Windows 7. | Trouble setting up sqlite3 with django! :/ | 0.099668 | 1 | 0 | 3,575 |
3,525,005 | 2010-08-19T18:29:00.000 | 2 | 0 | 0 | 0 | python,wxpython | 3,525,652 | 1 | false | 0 | 1 | If you put a wx.Panel as the only child of the ScrolledWindow and put the other widgets on the panel, then it should work automatically. You could also use ScrolledPanel instead. | 1 | 3 | 0 | I made a frame that asks the user to put in a bunch of information in several text control fields. How can I make it so that when you hit the 'tab' key your cursor moves to the next text control? | wxPython: switching text control focus on tab press | 0.379949 | 0 | 0 | 595 |
3,526,629 | 2010-08-19T21:59:00.000 | 0 | 0 | 0 | 0 | python,mysql,batch-file | 3,527,732 | 1 | false | 0 | 0 | If all of your tables' records had timestamps, you could identify "the values that have changed in the server" -- otherwise, it's not clear how you plan to do that part (which has nothing to do with insert or update, it's a question of "selecting things right").
Once you have all the important values, somecursor.executemany will let you apply them all as a batch. Depending on your indexing it may be faster to put them into a non-indexed auxiliary temporary table, then insert/update from all of that table into the real one (before dropping the aux/temp one), the latter of course being a single somecursor.execute.
You can reduce wall-clock time for the whole job by using one (or a few) threads to do the selects and put the results onto a Queue.Queue, and a few worker threads to apply results plucked from the queue into the internal/local server. (Best balance of reading vs writing threads is best obtained by trying a few and measuring -- writing per se is slower than reading, but your bandwidth to your local server may be higher than to the other one, so it's difficult to predict).
However, all of this is moot unless you do have a strategy to identify "the values that have changed in the server", so it's not necessarily very useful to enter into more discussion about details "downstream" from that identification. | 1 | 1 | 0 | I'm working with two databases, a local version and the version on the server. The server is the most up to date version and instead of recopying all values on all tables from the server to my local version,
I would like to enter each table and only insert/update the values that have changed, from server, and copy those values to my local version.
Is there some simple method to handling such a case? Some sort of batch insert/update? Googl'ing up the answer isn't working and I've tried my hand at coding one but am starting to get tied up in error handling..
I'm using Python and MySQLDB... Thanks for any insight
Steve | Python + MySQLDB Batch Insert/Update command for two of the same databases | 0 | 1 | 0 | 1,035 |
3,526,748 | 2010-08-19T22:19:00.000 | 6 | 0 | 0 | 1 | python,django,postgresql | 3,529,637 | 2 | true | 1 | 0 | Only one thing I could think of that will kill automatically a process on Linux - the OOM killer. What's in the system logs? | 1 | 7 | 0 | Sometimes, when fetching data from the database either through the python shell or through a python script, the python process dies, and one single word is printed to the terminal: Killed
That's literally all it says. It only happens with certain scripts, but it always happens for those scripts. It consistently happens with this one single query that takes a while to run, and also with a south migration that adds a bunch of rows one-by-one to the database.
My initial hunch was that a single transaction was taking too long, so I turned on autocommit for Postgres. Didn't solve the problem.
I checked the Postgres logs, and this is the only thing in there:
2010-08-19 22:06:34 UTC LOG: could not receive data from client: Connection reset by peer
2010-08-19 22:06:34 UTC LOG: unexpected EOF on client connection
I've tried googling, but as you might expect, a one-word error message is tough to google for.
I'm using Django 1.2 with Postgres 8.4 on a single Ubuntu 10.4 rackspace cloud VPS, stock config for everything. | Why do some Django ORM queries end abruptly with the message "Killed"? | 1.2 | 1 | 0 | 1,944 |
3,530,851 | 2010-08-20T12:34:00.000 | 3 | 1 | 0 | 0 | python,imap,pop3,imaplib,poplib | 3,566,252 | 2 | true | 0 | 0 | The In-Reply-To header of the child should have the value of the Message-Id header of the parent(s). | 2 | 0 | 0 | I've develop webmail client for any mail server.
I want to implement message conversion for it — for example same emails fwd/reply/reply2all should be shown together like gmail does...
My question is: what's the key to find those emails which are either reply/fwd or related to the original mail.... | How to maintain mail conversion (reply / forward / reply to all like gmail) of email using Python pop/imap lib? | 1.2 | 0 | 1 | 1,161 |
3,530,851 | 2010-08-20T12:34:00.000 | 2 | 1 | 0 | 0 | python,imap,pop3,imaplib,poplib | 3,530,868 | 2 | false | 0 | 0 | Google just seems to chain messages based on the subject line (so does Apple Mail by the way.) | 2 | 0 | 0 | I've develop webmail client for any mail server.
I want to implement message conversion for it — for example same emails fwd/reply/reply2all should be shown together like gmail does...
My question is: what's the key to find those emails which are either reply/fwd or related to the original mail.... | How to maintain mail conversion (reply / forward / reply to all like gmail) of email using Python pop/imap lib? | 0.197375 | 0 | 1 | 1,161 |
3,531,430 | 2010-08-20T13:47:00.000 | 2 | 0 | 1 | 0 | python,string | 3,531,457 | 5 | false | 0 | 0 | Either escape it as "\\" or use raw strings like so: r"\". | 1 | 1 | 0 | I have problem with refering to special symbol in string:
I have: path='C:\dir\dir1\dir2\filename.doc'
and I want filename.
When I try: filename=path[path.rfind("\"):-4]
then interpreter says it's an error line right from "\" since is treated as a comment. | How to refer to "\" sign in python string | 0.07983 | 0 | 0 | 275 |
3,532,417 | 2010-08-20T15:34:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine,pickle | 5,152,644 | 2 | false | 1 | 0 | The key advantages of using Django are its ORM and template system. The ORM is not very useful with datastore because of its non-relational nature and the template system is available as part of the app engine to be used with webapp.
I have had good success with using webapp and django templates for our project. | 2 | 2 | 0 | I am porting a Python investing application to Google App Engine. Every market that you can trade in is a plugin: for example the stocks trading and FOREX trading are all plugins.
The application stores the portfolio (which is a Portfolio class instance containing the active investments (class instances) and history) as a pickle. However you can't write to the disk, and it seems a bit crude to use pickles in the Datastore as a blob, and pickles are also slow and CPU intensive (no cPickle).
Does anyone have any ideas how I can store all the current investments, and the history to the datastore without using large and intensive pickles?
Thank you
Ps. webapp or Django? | Store python classes as pickles in GAE? | 0 | 0 | 0 | 366 |
3,532,417 | 2010-08-20T15:34:00.000 | 1 | 0 | 0 | 1 | python,google-app-engine,pickle | 3,532,598 | 2 | false | 1 | 0 | The best solution would be to use the Datastore data models, but you'll have to rewrite parts of your app. Using Pickle for data persistance, especially involving much data, is not a good pratice. | 2 | 2 | 0 | I am porting a Python investing application to Google App Engine. Every market that you can trade in is a plugin: for example the stocks trading and FOREX trading are all plugins.
The application stores the portfolio (which is a Portfolio class instance containing the active investments (class instances) and history) as a pickle. However you can't write to the disk, and it seems a bit crude to use pickles in the Datastore as a blob, and pickles are also slow and CPU intensive (no cPickle).
Does anyone have any ideas how I can store all the current investments, and the history to the datastore without using large and intensive pickles?
Thank you
Ps. webapp or Django? | Store python classes as pickles in GAE? | 0.099668 | 0 | 0 | 366 |
3,532,947 | 2010-08-20T16:40:00.000 | 1 | 0 | 1 | 0 | python,regex | 3,532,984 | 7 | false | 1 | 0 | You probably want to match a non-digit before and after your string of 5 digits, like [^0-9]([0-9]{5})[^0-9]. Then you can capture the inner group (the actual string you want). | 3 | 29 | 0 | I'm attempting to string match 5-digit coupon codes spread throughout a HTML web page. For example, 53232, 21032, 40021 etc... I can handle the simpler case of any string of 5 digits with [0-9]{5}, though this also matches 6, 7, 8... n digit numbers. Can someone please suggest how I would modify this regular expression to match only 5 digit numbers? | Python Regular Expression Match All 5 Digit Numbers but None Larger | 0.028564 | 0 | 0 | 93,863 |
3,532,947 | 2010-08-20T16:40:00.000 | 3 | 0 | 1 | 0 | python,regex | 3,532,981 | 7 | false | 1 | 0 | A very simple way would be to match all groups of digits, like with r'\d+', and then skip every match that isn't five characters long when you process the results. | 3 | 29 | 0 | I'm attempting to string match 5-digit coupon codes spread throughout a HTML web page. For example, 53232, 21032, 40021 etc... I can handle the simpler case of any string of 5 digits with [0-9]{5}, though this also matches 6, 7, 8... n digit numbers. Can someone please suggest how I would modify this regular expression to match only 5 digit numbers? | Python Regular Expression Match All 5 Digit Numbers but None Larger | 0.085505 | 0 | 0 | 93,863 |
3,532,947 | 2010-08-20T16:40:00.000 | 16 | 0 | 1 | 0 | python,regex | 3,532,978 | 7 | false | 1 | 0 | full string: ^[0-9]{5}$
within a string: [^0-9][0-9]{5}[^0-9] | 3 | 29 | 0 | I'm attempting to string match 5-digit coupon codes spread throughout a HTML web page. For example, 53232, 21032, 40021 etc... I can handle the simpler case of any string of 5 digits with [0-9]{5}, though this also matches 6, 7, 8... n digit numbers. Can someone please suggest how I would modify this regular expression to match only 5 digit numbers? | Python Regular Expression Match All 5 Digit Numbers but None Larger | 1 | 0 | 0 | 93,863 |
3,533,064 | 2010-08-20T16:54:00.000 | 1 | 0 | 0 | 1 | python,orm,mongodb,mongoengine,mongokit | 3,553,262 | 1 | true | 0 | 0 | We are running a production site using Mongodb for the backend (no direct queries to Mongo, we have a search layer in between). We wrote our own business / object layer, i suppose it just seemed natural enough for the programmers to write in the custom logic. We did separate the database and business layers, but they just didn't see a need to go for a separate library. As the software keeps evolving I think it makes sense. We have 15 million records. | 1 | 2 | 0 | I've been diving into MongoDB with kind help of MongoKit and MongoEngine, but then I started thinking whether the data mappers are necessary here. Both mappers I mentioned enable one to do simple things without any effort. But is any effort required to do simple CRUD? It appears to me that in case of NoSQL the mappers just substitute one api with another (but of course there is data validation, more strict schema, automatic referencing/dereferencing)
Do you use Data Mappers in your applications? How big are they (apps)? Why yes, why no?
Thanks | Do you use data mappers with MongoDB? | 1.2 | 1 | 0 | 366 |
3,533,759 | 2010-08-20T18:27:00.000 | 7 | 1 | 1 | 1 | python,c,performance | 3,533,838 | 14 | false | 0 | 0 | Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
Yes.
The noticeable differences are these
There's much less Python code.
The Python code is much easier to read.
Python supports really nice unit testing, so the Python code tends to be higher quality.
You can write the Python code more quickly, since there are fewer quirky language features. No preprocessor, for example, really saves a lot of hacking around. Super-experience C programmers hardly notice it. But all that #include sandwich stuff and making the .h files correct is remarkably time-consuming.
Python can be easier to package and deploy, since you don't need a big fancy make script to do a build. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 1 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | 0 | 1 | 1 | 1 | python,c,performance | 15,903,255 | 14 | false | 0 | 0 | C is definitely faster than Python because Python is written in C.
C is middle level language and hence faster but there not much a great difference between C & Python regarding executable time it takes.
but it is really very easy to write code in Python than C and it take much shorter time to write code and learn Python than C.
Because its easy to write its easy to test also. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 0 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | -1 | 1 | 1 | 1 | python,c,performance | 3,539,538 | 14 | false | 0 | 0 | The excess time to write the code in C compared to Python will be exponentially greater than the difference between C and Python execution speed. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | -0.014285 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | -1 | 1 | 1 | 1 | python,c,performance | 3,536,830 | 14 | false | 0 | 0 | You will find C is much slower. Your developers will have to keep track of memory allocation, and use libraries (such as glib) to handle simple things such as dictionaries, or lists, which python has built-in.
Moreover, when an error occurs, your C program will typically just crash, which means you'll need to get the error to happen in a debugger. Python would give you a stack trace (typically).
Your code will be bigger, which means it will contain more bugs. So not only will it take longer to write, it will take longer to debug, and will ship with more bugs. This means that customers will notice the bugs more often.
So your developers will spend longer fixing old bugs and thus new features will get done more slowly.
In the mean-time, your competitors will be using a sensible programming language and their products will be increasing in features and usability, rapidly yours will look bad. Your customers will leave and you'll go out of business. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | -0.014285 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | 0 | 1 | 1 | 1 | python,c,performance | 3,534,845 | 14 | false | 0 | 0 | Across all programs, it isn't really possible to say whether things will be quicker or slower on average in Python or C.
For the programs that I've implemented in both languages, using similar algorithms, I've seen no improvement (and sometimes a performance degradation) for string- and IO-heavy code, when reimplementing python code in C. The execution time is dominated by allocation and manipulation of strings (which functionality python implements very efficiently) and waiting for IO operations (which incurs the same overhead in either language), so the extra overhead of python makes very little difference.
But for programs that do even simple operations on image files, say (images being large enough for processing time to be noticeable compared to IO), C is enormously quicker. For this sort of task the bulk of the time running the python code is spent doing Python Stuff, and this dwarfs the time spent on the underlying operations (multiply, add, compare, etc.). When reimplemented as C, the bureaucracy goes away, the computer spends its time doing real honest work, and for that reason the thing runs much quicker.
It's not uncommon for the python code to run in (say) 5 seconds where the C code runs in (say) 0.05. So that's a 100x increase -- but in absolute terms, this is not so big a deal. It takes so much less longer to write python code than it does to write C code that your program would have to be run some huge number of times to turn a time profit. I often reimplement in C, for various reasons, but if you don't have this requirement then it's probably not worth bothering. You won't get that part of your life back, and next year computers will be quicker. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 0 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | 1 | 1 | 1 | 1 | python,c,performance | 3,534,210 | 14 | false | 0 | 0 | It really depends a lot on what your doing and if the algorithm in question is available in Python via a natively compiled library. If it is, then I believe you'll be looking at performance numbers close enough that Python is most likely your answer -- assuming it's your preferred language. If you must implement the algorithm yourself, depending on the amount of logic required and the size of your data set, C/C++ may be the better option. It's hard to provide a less nebulous answer without more information. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 0.014285 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | 4 | 1 | 1 | 1 | python,c,performance | 3,534,052 | 14 | false | 0 | 0 | If your text files that you are sorting and parsing are large, use C. If they aren't, it doesn't matter. You can write poor code in any language though. I have seen simple code in C for calculating areas of triangles run 10x slower than other C code, because of poor memory management, use of structures, pointers, etc.
Your I/O algorithm should be independent of your compute algorithm. If this is the case, then using C for the compute algorithm can be much faster. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 0.057081 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | 4 | 1 | 1 | 1 | python,c,performance | 3,533,974 | 14 | false | 0 | 0 | The first rule of computer performance questions: Your mileage will vary. If small performance differences are important to you, the only way you will get valid information is to test with your configuration, your data, and your benchmark. "Small" here is, say, a factor of two or so.
The second rule of computer performance questions: For most applications, performance doesn't matter -- the easiest way to write the app gives adequate performance, even when the problem scales. If that is the case (and it is usually the case) don't worry about performance.
That said:
C compiles down to machine executable and thus has the potential to execute as at least as fast as any other language
Python is generally interpreted and thus may take more CPU than a compiled language
Very few applications are "CPU bound." I/O (to disk, display, or memory) is not greatly affected by compiled vs interpreted considerations and frequently is a major part of computer time spent on an application
Python works at a higher level of abstraction than C, so your development and debugging time may be shorter
My advice: Develop in the language you find the easiest with which to work. Get your program working, then check for adequate performance. If, as usual, performance is adequate, you're done. If not, profile your specific app to find out what is taking longer than expected or tolerable. See if and how you can fix that part of the app, and repeat as necessary.
Yes, sometimes you might need to abandon work and start over to get the performance you need. But having a working (albeit slow) version of the app will be a big help in making progress. When you do reach and conquer that performance goal you'll be answering performance questions in SO rather than asking them. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 0.057081 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | 10 | 1 | 1 | 1 | python,c,performance | 3,533,800 | 14 | false | 0 | 0 | In general IO bound work will depend more on the algorithm then the language. In this case I would go with Python because it will have first class strings and lots of easy to use libraries for manipulating files, etc. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 1 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | 11 | 1 | 1 | 1 | python,c,performance | 3,534,125 | 14 | false | 0 | 0 | C will absolutely crush Python in almost any performance category, but C is far more difficult to write and maintain and high performance isn't always worth the trade off of increased time and difficulty in development.
You say you're doing things like text file processing, but what you omit is how much text file processing you're doing. If you're processing 10 million files an hour, you might benefit from writing it in C. But if you're processing 100 files an hour, why not use python? Do you really need to be able to process a text file in 10ms vs 50ms? If you're planning for the future, ask yourself, "Is this something I can just throw more hardware at later?"
Writing solid code in C is hard. Be sure you can justify that investment in effort. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 1 | 0 | 0 | 14,463 |
3,533,759 | 2010-08-20T18:27:00.000 | 37 | 1 | 1 | 1 | python,c,performance | 3,533,877 | 14 | true | 0 | 0 | Use python until you have a performance problem. If you ever have one figure out what the problem is (often it isn't what you would have guessed up front). Then solve that specific performance problem which will likely be an algorithm or data structure change. In the rare case that your problem really needs C then you can write just that portion in C and use it from your python code. | 11 | 13 | 0 | Working on different projects I have the choice of selecting different programming languages, as long as the task is done.
I was wondering what the real difference is, in terms of performance, between writing a program in Python, versus doing it in C.
The tasks to be done are pretty varied, e.g. sorting textfiles, disk access, network access, textfile parsing.
Is there really a noticeable difference between sorting a textfile using the same algorithm in C versus Python, for example?
And in your experience, given the power of current CPU's (i7), is it really a noticeable difference (Consider that its a program that doesnt bring the system to its knees). | Performance differences between Python and C | 1.2 | 0 | 0 | 14,463 |
3,534,127 | 2010-08-20T19:17:00.000 | 6 | 0 | 0 | 0 | python,user-interface,gtk,pygtk | 3,534,190 | 2 | true | 0 | 1 | The row-activated signal is sent when a GTK TreeView row is double-clicked. | 1 | 5 | 0 | I'm displaying some data as a TreeView. How can I detect a click on a particular tree-view cell, so that I know which column of which row was clicked on?
This is what I want to do, so maybe there's a better way: Part of the data is a series of True/False values indicating a particular set of options. For example, the options might be picking any of the options "Small, Medium, Large, X-Large" to be display. If the user selects "Small" and "Large", then the cell should display "Small, Large". I don't want to give each a separate column since there are actually like 20 options, and only 2 or 3 will be selected at any point.
When the user clicks on the cell, I want to display a pop-up with a bunch of checkboxes. The user can then select what s/he wants and submit the changes, at which point the cell's value should be updated.
The easiest way I thought of doing this would be to just detect a click (or a double-click) on the cell. Then I could pop up the window, and have the submit button of the window do what I want. | gtk: detect click on a cell in a TreeView | 1.2 | 0 | 0 | 4,742 |
3,535,535 | 2010-08-20T23:30:00.000 | 1 | 0 | 0 | 0 | python,logging,pylons | 3,537,529 | 2 | false | 1 | 0 | For custom error handling i think you should look at ErrorHandler and StatusCodeRedirect (from pylons.middleware) and maybe make your own class based on them? | 1 | 0 | 0 | I want to log 404 and 500 errors in a pylons app before they redirect to my custom error message (/error/document).
My problem is that since Pylons does the redirect, I am unable to determine the page on which the error occurred inside the error controller. So without building a parser for the paster.log I don't know a good way to selectively log just the few relevant pieces of data I want: url, referring page, and stack trace.
Ideally, I would like to access the page the error occurred on, the referring page, as well as the full stack trace and throw that into a couchdb for some quick and easy reports. | Pylons - catching errors before redirect to document/error for logging | 0.099668 | 0 | 0 | 316 |
3,538,430 | 2010-08-21T18:16:00.000 | 2 | 1 | 0 | 0 | python,email,smtp,mime,pop3 | 3,538,453 | 2 | true | 0 | 0 | It has all the components you need, in a more modular and flexible arrangement than you appear to envisage -- the standard library's email package deals with the message once you have received it, and separate modules each deal with means of sending and receiving, such as pop, smtp, imap. SSL is an option for each of them (if the counterpart, e.g. mail server, supports it, of course), being basically just "a different kind of socket".
Have you looked at the rich online docs for all of these standard library modules? | 1 | 0 | 0 | Does python have a full fledged email library with things for pop, smtp, pop3 with ssl, mime?
I want to create a web mail interface that pulls emails from email servers, and then shows the emails, along with attachments, can display the sender, subject, etc. (handles all the encoding issues etc).
It's one thing to be available in the libraries and another for them to be production ready. I'm hoping someone who has used them to pull emails w/attachments etc. in a production environment can comment on this. | Does python have a robust pop3, smtp, mime library where I could build a webmail interface? | 1.2 | 0 | 1 | 513 |
3,538,724 | 2010-08-21T20:00:00.000 | 0 | 0 | 1 | 0 | python | 3,539,344 | 2 | false | 0 | 0 | Actually, I thought it was from the standard library. On inspection, it is from enthought.traits.api.Instance. It holds a reference to an object instance. If you pass a specific class to the constructor (e.g. Instance(MyClass) ), it does validation to make sure you pass the correct class. | 2 | 3 | 0 | var = Instance(object)? | What does Instance() do in Python assignments? | 0 | 0 | 0 | 174 |
3,538,724 | 2010-08-21T20:00:00.000 | 4 | 0 | 1 | 0 | python | 3,538,730 | 2 | false | 0 | 0 | It calls the __call__() method. | 2 | 3 | 0 | var = Instance(object)? | What does Instance() do in Python assignments? | 0.379949 | 0 | 0 | 174 |
3,538,769 | 2010-08-21T20:09:00.000 | 0 | 0 | 0 | 0 | python,user-interface,pygtk,tkinter,glade | 3,538,804 | 3 | false | 0 | 1 | Those actions are not that difficult. All you really need for that is hit detection, which is not hard (is the cursor over the correct area? Okay, perform the operation then). The harder part is finding an appropriate canvas widget for the toolkit in use. | 1 | 7 | 0 | What Python-related code (PyGTK, Glade, Tkinter, PyQT, wxPython, Cairo, ...) could you easily use to create a GUI to do some or all of the following?
Part of the GUI has an immovable square grid.
The user can press a button to create a resizable rectangle.
The user can drag the rectangle anywhere on the grid, and it will snap to the grid. | How do you draw a grid and rectangles in Python? | 0 | 0 | 0 | 5,729 |
3,539,120 | 2010-08-21T21:44:00.000 | 25 | 0 | 0 | 0 | python,django,cython | 3,539,136 | 6 | false | 1 | 0 | Well, yes, but most things a web app does won't really benefit from this sort of change unless you have firm proof that it will. Profile twice, optimize once. | 3 | 38 | 0 | Is it possible to optimize speed of a mission critical application developed in Django with Cython?
Recently I have read on the internet, that Cython can turn a Python code to C like speed. Is this possible with Django? | Using Cython with Django. Does it make sense? | 1 | 0 | 0 | 16,714 |
3,539,120 | 2010-08-21T21:44:00.000 | 1 | 0 | 0 | 0 | python,django,cython | 52,422,538 | 6 | false | 1 | 0 | It depends if you have heavy processes on the backend side. In my case it could improve one of the processes and speed it up ~5 times. I had a function that rework large XML files that is inputed by the user and save the output into database. telling Cython that in some places the input or output is string did the 5x speed up magic. | 3 | 38 | 0 | Is it possible to optimize speed of a mission critical application developed in Django with Cython?
Recently I have read on the internet, that Cython can turn a Python code to C like speed. Is this possible with Django? | Using Cython with Django. Does it make sense? | 0.033321 | 0 | 0 | 16,714 |
3,539,120 | 2010-08-21T21:44:00.000 | 35 | 0 | 0 | 0 | python,django,cython | 3,539,374 | 6 | true | 1 | 0 | Is it possible to optimize speed of a mission critical application developed in Django with Cython
It's doubtful.
Most of a web application response time is the non-HTML elements that must be downloaded separately. The usual rule of thumb is 8 static files per HTML page. (.CSS, .JS, images, etc.)
Since none of that static content comes from Django, most of your web application's time-line is Apache (or Nginx or some other server software outside Django).
When looking at just the time to produce the HTML, you'll find that most of the time is spent waiting for the database (even if it's in-memory SQLite, you'll see that the database tends to dominate the timeline)
When you're through making Apache and the database go fast, then -- and only then -- you can consider the Python elements.
Bottom Line. Don't waste any of your time on making Django and Python go faster. | 3 | 38 | 0 | Is it possible to optimize speed of a mission critical application developed in Django with Cython?
Recently I have read on the internet, that Cython can turn a Python code to C like speed. Is this possible with Django? | Using Cython with Django. Does it make sense? | 1.2 | 0 | 0 | 16,714 |
3,540,288 | 2010-08-22T05:23:00.000 | 1 | 0 | 1 | 0 | python | 3,540,307 | 11 | false | 0 | 0 | Seek to a random position, read a line and discard it, then read another line. The distribution of lines won't be normal, but that doesn't always matter. | 1 | 51 | 0 | Is there a built-in method to do it? If not how can I do this without costing too much overhead? | How do I read a random line from one file? | 0.01818 | 0 | 0 | 98,440 |
3,540,368 | 2010-08-22T05:54:00.000 | 2 | 1 | 1 | 1 | python,ipython,execfile | 3,540,375 | 2 | true | 0 | 0 | Functions create a new scope. execfile() runs the script in the current scope. What you are doing will not work. | 1 | 2 | 0 | I'm working from inside an ipython shell and often need to reload the script files that contain my functions-under-construction.
Inside my main.py I have:
def myreload():
execfile("main.py")
execfile("otherfile.py")
Calling myreload() works fine if I have already ran in the same ipython session the execfile commands directly.
However, for some reason, if the session is fresh and I just called execfile("main.py"), then myreload() doesn't actually make the functions from inside otherfile.py available. It doesn't throw any error though.
Any ideas? | Python shell and execfile scope | 1.2 | 0 | 0 | 2,290 |
3,540,805 | 2010-08-22T08:53:00.000 | 0 | 0 | 0 | 1 | python,android,django | 3,541,193 | 2 | false | 1 | 0 | Do you want it to run on a tablet or a hand-held device? Are netbooks okay?
There are plenty netbooks that run Ubuntu, on which you should be able to run python. I also remember that the sharp zaurus handheld devices were able to run Zope for example (be it very, very slowly)
In general, smaller, embedded systems (i.e. pandora) run versions of OpenWRT that use ipkg, and I think there are django packages for OpenWRT, so that may be an option as well. | 1 | 3 | 0 | I want to run a django app on a hand-held device. It'll need to run Python (obviously) and will write its data to an SQLite database.
Are there any tablets available that will let me do this? Specifically, if I bought an Android tablet, would I have to/be able to install linux instead, or would I be able to run it under Android? | Is it possible to run linux on hand-held tablets? | 0 | 0 | 0 | 395 |
3,542,095 | 2010-08-22T15:46:00.000 | 6 | 1 | 1 | 0 | python,filter | 3,542,173 | 5 | false | 0 | 0 | If all the students are running the same version of Python (e.g. at a computer lab), you can distribute pyc files. This is just obfuscation, but it will deter casual users. | 2 | 1 | 0 | I'm a school teacher who spent the summer writing a vocab training program in python that uses text available from wikipedia and gutenberg. Now all I have to do is figure out a way to filter out curse words so that I can distribute to students.
Normally I would just have an array (list) of those curse words and do a simple filter. The problem though is that the py file itself it openable by these students, seeing those words. If I put it in a separate file, somehow encrypted, then they could just delete that file and the output wouldn't be filtered.
Any ideas for workarounds? | How to "hide" curse words in a py file? | 1 | 0 | 0 | 674 |
3,542,095 | 2010-08-22T15:46:00.000 | 1 | 1 | 1 | 0 | python,filter | 3,542,374 | 5 | false | 0 | 0 | Why not distribute the compiled python .*pyc files instead? They could still lookup the strings if they wanted, but it will likely deter casual browsing of the file, which may be sufficient for your needs. | 2 | 1 | 0 | I'm a school teacher who spent the summer writing a vocab training program in python that uses text available from wikipedia and gutenberg. Now all I have to do is figure out a way to filter out curse words so that I can distribute to students.
Normally I would just have an array (list) of those curse words and do a simple filter. The problem though is that the py file itself it openable by these students, seeing those words. If I put it in a separate file, somehow encrypted, then they could just delete that file and the output wouldn't be filtered.
Any ideas for workarounds? | How to "hide" curse words in a py file? | 0.039979 | 0 | 0 | 674 |
3,542,426 | 2010-08-22T17:11:00.000 | 0 | 0 | 1 | 1 | python,windows,winapi,console | 3,603,987 | 1 | true | 0 | 0 | Version Information are stored as a resource in the executable. You cannot change them during runtime. | 1 | 0 | 0 | I have multiple python processes running in their console output windows. I can set their console title via win32api.SetConsoleTitle(). Thats nice, but it would be even nicer to set some versioninfo strings (like description/company name/version) during runtime as that would allow me to easier differentiate between the (generic) python proceses in the taskmanager/process-explorer.
Has anybody ever done something like that.
thnx, dirkse | windows/python manipulate versioninfo during runtime | 1.2 | 0 | 0 | 169 |
3,542,723 | 2010-08-22T18:22:00.000 | 1 | 0 | 0 | 0 | python,django,content-management-system,django-admin,feincms | 3,777,528 | 1 | false | 1 | 0 | Sure -- there's nothing stopping you from adding a ForeignKey or a ManyToManyField to the MediaFile model to one of your own models. Note that you'll have a hard time limiting the media files to only images. Maybe limit_choices_to will help though. | 1 | 6 | 0 | I'm using Django and FeinCMS on a project. I'm currently using FeinCMS for all the pages on the site. But I also have another separate model that handles very simple stock for the site too. This stock model has the usual fields (name, description, etc) but I also want it to have photos.
Because FeinCMS has a media library already, I would like to technically use that to have the photos with my stock model. I could just normally do a Photo model and ManyToManyField that, but I'm curious to know if I can ManyToManyField with the FeinCMS media library?
I know with FeinCMS you can use the item editor on any other model, but I'm not sure that's the right way to go about it. If it's the only way to do this, then that will have to be it.
Many thanks | Django and FeinCMS: A way to use the Media Library in other normal models? | 0.197375 | 0 | 0 | 717 |
3,543,193 | 2010-08-22T20:19:00.000 | 2 | 1 | 0 | 0 | php,python,ruby,perl,benchmarking | 3,543,230 | 3 | false | 0 | 0 | The best thing to do would be to create your own benchmarks for the specific tasks you are interested in. Pick languages that you like working in and then write benchmarks for the system you will be using and the task you will be performing. If you are very concerned about speed I would also recommend looking at the individual operations and how to optimize them in each of the languages (examples: argument order, memory usage...) | 1 | 0 | 0 | Does anyone know where I could find reviews or reports on tasks that people implemented in two or more scripting languages to see which was more suited to a specific job? I want to know which languages are best suited to which types of operation so that I can make the most of them.
"Types of operation" could be sockets, the file system, logic evaluation, regex, or drawing.
I'm mostly interested in Python, PHP, Perl, and Ruby. | Benchmarks of scripting languages doing the same task? | 0.132549 | 0 | 0 | 1,097 |
3,543,833 | 2010-08-22T23:05:00.000 | 0 | 0 | 1 | 0 | python | 60,114,979 | 10 | false | 0 | 0 | Isn't the easiest way to create a class contining all the needed variables?
Then you have one object with all curretn variables, and if you need you can overwrite this variable? | 3 | 104 | 0 | I am looking for something similar to 'clear' in Matlab: A command/function which removes all variables from the workspace, releasing them from system memory. Is there such a thing in Python?
EDIT: I want to write a script which at some point clears all the variables. | How do I clear all variables in the middle of a Python script? | 0 | 0 | 0 | 381,886 |
3,543,833 | 2010-08-22T23:05:00.000 | 4 | 0 | 1 | 0 | python | 52,326,585 | 10 | false | 0 | 0 | In Spyder one can configure the IPython console for each Python file to clear all variables before each execution in the Menu Run -> Configuration -> General settings -> Remove all variables before execution. | 3 | 104 | 0 | I am looking for something similar to 'clear' in Matlab: A command/function which removes all variables from the workspace, releasing them from system memory. Is there such a thing in Python?
EDIT: I want to write a script which at some point clears all the variables. | How do I clear all variables in the middle of a Python script? | 0.07983 | 0 | 0 | 381,886 |
3,543,833 | 2010-08-22T23:05:00.000 | 0 | 0 | 1 | 0 | python | 55,055,041 | 10 | false | 0 | 0 | In the idle IDE there is Shell/Restart Shell. Cntrl-F6 will do it. | 3 | 104 | 0 | I am looking for something similar to 'clear' in Matlab: A command/function which removes all variables from the workspace, releasing them from system memory. Is there such a thing in Python?
EDIT: I want to write a script which at some point clears all the variables. | How do I clear all variables in the middle of a Python script? | 0 | 0 | 0 | 381,886 |
3,544,331 | 2010-08-23T02:17:00.000 | 7 | 0 | 1 | 0 | python,file,text,diff,compare | 3,544,342 | 5 | true | 0 | 0 | If order matters, try the comm utility. If order doesn't matter, sort file1 file2 | uniq -u. | 1 | 10 | 0 | I have two 3GB text files, each file has around 80 million lines. And they share 99.9% identical lines (file A has 60,000 unique lines, file B has 80,000 unique lines).
How can I quickly find those unique lines in two files? Is there any ready-to-use command line tools for this? I'm using Python but I guess it's less possible to find a efficient Pythonic method to load the files and compare.
Any suggestions are appreciated. | Quickly find differences between two large text files | 1.2 | 0 | 0 | 17,368 |
3,544,378 | 2010-08-23T02:32:00.000 | -3 | 0 | 1 | 1 | python,linux,ubuntu,python-2.x | 3,544,394 | 6 | false | 0 | 0 | Do you still have the source directory where you compiled Python before? If so, you can CD into that directory and run sudo make uninstall.
If you don't have it still, you could re-create it by going through the build steps again--download, extract, configure, and make--but end with sudo make uninstall instead of sudo make install, of course. | 2 | 51 | 0 | I've installed python 2.6 from source, and somehow later mistakenly installed another python 2.6 from a package manager too.
I can't find a way to uninstall a python that was built from source, is this possible/easy?
Running ubuntu 10.04. | Uninstall python built from source? | -0.099668 | 0 | 0 | 69,854 |
3,544,378 | 2010-08-23T02:32:00.000 | 0 | 0 | 1 | 1 | python,linux,ubuntu,python-2.x | 3,544,396 | 6 | false | 0 | 0 | In the future it may be prudent to use sudo checkinstall. | 2 | 51 | 0 | I've installed python 2.6 from source, and somehow later mistakenly installed another python 2.6 from a package manager too.
I can't find a way to uninstall a python that was built from source, is this possible/easy?
Running ubuntu 10.04. | Uninstall python built from source? | 0 | 0 | 0 | 69,854 |
3,545,230 | 2010-08-23T06:42:00.000 | 2 | 0 | 0 | 0 | python,linux,mouse,mouse-cursor,wiimote | 9,583,583 | 8 | false | 0 | 1 | Open your terminal and goto cd /usr/share/pyshared/twisted/protocols/mice
may this __init__.py mouseman.py python script will work for you,check them out. | 1 | 40 | 0 | I'm currently in the process of making my Nintendo Wiimote (Kinda sad actually) to work with my computer as a mouse. I've managed to make the nunchuk's stick control actually move the mouse up and down, left and right on the screen! This was so exciting. Now I'm stuck.
I want to left/right click on things via python when I press A, When I went to do a search, All it came up with was tkinter?
So my question is, What do I call to make python left/right click on the desktop, and if it's possible, maybe provide a snippet?
Thank you for your help!
NOTE: I guess I forgot to mention that this is for Linux. | Simulate Mouse Clicks on Python | 0.049958 | 0 | 0 | 65,052 |
3,545,690 | 2010-08-23T08:06:00.000 | 15 | 0 | 1 | 0 | python,performance,decorator | 3,546,120 | 3 | true | 0 | 0 | The overhead added by using a decorator should be just one extra function call.
The work being done by the decorator isn't part of the overhead as your alternative is to add the equivalent code to the decorated object.
So it's possible that the decorate function takes twice as long to run, but that's because the decorator is doing some important work that takes roughly the same time to fun as the undecorated function. | 2 | 21 | 0 | I've been playing around with a timing decorator for my pylons app to provide on the fly timing info for specific functions. I've done this by creating a decorator & simply attaching it to any function in the controller I want timed.
It's been pointed out however that decorators could add a fair amount of overhead to the call, and that they run 2-3x slower than an undecorated function.
Firstly, I would expect that executing a decorated function would take a smite longer than an undecorated one, but I would expect that overhead to be in the thousandths of seconds & be negligible compared to a SQL insert call. The decorator itself does simple simple timing calculations using time.time() & some very simple aggregation.
Do decorators add significant overhead to a system? I can't find anything to back that up. | How much overhead do decorators add to Python function calls | 1.2 | 0 | 0 | 5,433 |
3,545,690 | 2010-08-23T08:06:00.000 | 2 | 0 | 1 | 0 | python,performance,decorator | 3,548,038 | 3 | false | 0 | 0 | Do decorators add significant overhead to a system? I can't find anything to back that up.
They add almost no measurable overhead. Zero.
It's important to note that the decorator runs once to create the decorated function.
Once.
The decorated function has two parts to it.
whatever decoration was added. This is not overhead.
plus the original function. This is not overhead.
There's no real overhead at all. You might -- with some care -- be able to measure the overhead of one extra function call-and-return as part of a decorated function, but that's almost unmeasurably small. And it's probably far less than an alternative design that doesn't use decoration. | 2 | 21 | 0 | I've been playing around with a timing decorator for my pylons app to provide on the fly timing info for specific functions. I've done this by creating a decorator & simply attaching it to any function in the controller I want timed.
It's been pointed out however that decorators could add a fair amount of overhead to the call, and that they run 2-3x slower than an undecorated function.
Firstly, I would expect that executing a decorated function would take a smite longer than an undecorated one, but I would expect that overhead to be in the thousandths of seconds & be negligible compared to a SQL insert call. The decorator itself does simple simple timing calculations using time.time() & some very simple aggregation.
Do decorators add significant overhead to a system? I can't find anything to back that up. | How much overhead do decorators add to Python function calls | 0.132549 | 0 | 0 | 5,433 |
3,547,534 | 2010-08-23T12:33:00.000 | 32 | 0 | 1 | 0 | python,encoding | 3,548,031 | 6 | false | 1 | 0 | In Python 2: Normal strings (Python 2.x str) don't have an encoding: they are raw data.
In Python 3: These are called "bytes" which is an accurate description, as they are simply sequences of bytes, which can be text encoded in any encoding (several are common!) or non-textual data altogether.
For representing text, you want unicode strings, not byte strings. By "unicode strings", I mean unicode instances in Python 2 and str instances in Python 3. Unicode strings are sequences of unicode codepoints represented abstractly without an encoding; this is well-suited for representing text.
Bytestrings are important because to represent data for transmission over a network or writing to a file or whatever, you cannot have an abstract representation of unicode, you need a concrete representation of bytes. Though they are often used to store and represent text, this is at least a little naughty.
This whole situation is complicated by the fact that while you should turn unicode into bytes by calling encode and turn bytes into unicode using decode, Python will try to do this automagically for you using a global encoding you can set that is by default ASCII, which is the safest choice. Never depend on this for your code and never ever change this to a more flexible encoding--explicitly decode when you get a bytestring and encode if you need to send a string somewhere external. | 4 | 18 | 0 | i know that django uses unicode strings all over the framework instead of normal python strings. what encoding are normal python strings use ? and why don't they use unicode? | What encoding do normal python strings use? | 1 | 0 | 0 | 18,945 |
3,547,534 | 2010-08-23T12:33:00.000 | 1 | 0 | 1 | 0 | python,encoding | 3,547,580 | 6 | false | 1 | 0 | Python 2.x strings are 8-bit, nothing more. The encoding may vary (though ASCII is assumed). I guess the reasons are historical. Few languages, especially languages that date back to the last century, use unicode right away.
In Python 3, all strings are unicode. | 4 | 18 | 0 | i know that django uses unicode strings all over the framework instead of normal python strings. what encoding are normal python strings use ? and why don't they use unicode? | What encoding do normal python strings use? | 0.033321 | 0 | 0 | 18,945 |
3,547,534 | 2010-08-23T12:33:00.000 | 4 | 0 | 1 | 0 | python,encoding | 3,552,681 | 6 | false | 1 | 0 | what encoding are normal python
strings use?
In Python 3.x
str is Unicode. This may be either UTF-16 or UTF-32 depending on whether your Python interpreter was built with "narrow" or "wide" Unicode characters.
The Windows version of CPython uses UTF-16. On Unix-like systems, UTF-32 tends to be preferred.
In Python 2.x
str is a byte string type like C char. The encoding isn't defined by the language, but is whatever your locale's default encoding is. Or whatever the MIME charset of the document you got off the Internet is. Or, if you get a string from a function like struct.pack, it's binary data, and doesn't meaningfully have a character encoding at all.
unicode strings in 2.x are equivalent to str in 3.x.
and why don't they use unicode?
Because Python (slightly) predates Unicode. And because Guido wanted to save all the major backwards-incompatible changes for 3.0. Strings in 3.x do use Unicode by default. | 4 | 18 | 0 | i know that django uses unicode strings all over the framework instead of normal python strings. what encoding are normal python strings use ? and why don't they use unicode? | What encoding do normal python strings use? | 0.132549 | 0 | 0 | 18,945 |
3,547,534 | 2010-08-23T12:33:00.000 | -2 | 0 | 1 | 0 | python,encoding | 3,547,565 | 6 | false | 1 | 0 | Before Python 3.0, string encoding was ascii by default, but could be changed. Unicode string literals were u"...". This was silly. | 4 | 18 | 0 | i know that django uses unicode strings all over the framework instead of normal python strings. what encoding are normal python strings use ? and why don't they use unicode? | What encoding do normal python strings use? | -0.066568 | 0 | 0 | 18,945 |
3,549,833 | 2010-08-23T16:57:00.000 | 23 | 0 | 1 | 0 | python,multithreading,memory-model | 3,549,940 | 1 | true | 0 | 0 | There is no formal model for Python's threading (hey, after all, there wasn't one for Java's for years... hopefully, one will also eventually be written for Python).
In practice, no Python implementation performs any advanced optimization such as statement reordering or temporarily treating shared variables as thread-local ones -- and you can count on these semantics constraints even though they are not formally assured.
CPython in particular, as @Rawheiser's mention, uses a global interpreter lock; other implementations (PyPy, IronPython, Jython, ...) do not (so they can use multiple cores effectively with a threading model, while CPython requires multi-processing for the same purpose), so you should not count on that if you want to write code that's portable throughout Python implementations. (So, you shouldn't count on the "atomicity" of operations that only happen to be atomic in CPython because of the GIL, such as dictionary accesses -- in other Python implementations, multiple threads might be modifying a dict at once and cause errors unless you protect the dict with a lock or the like). | 1 | 26 | 0 | Does python threading expose issues of memory visibility and statement reordering as Java does? Since I can't find any reference to a "Python Memory Model" or anything like that, despite the fact that lots of people are writing multithreaded Python code, I'm guessing that these gotchas don't exist here. No volatile keyword, for instance. But it doesn't seem to be stated explicitly anywhere that, for instance, a change in a variable in one thread is immediately visible to all other threads.
Maybe this stuff is all very obvious to Python programmers, but as a fearful Java programmer, I require a little extra reassurance :) | python threading: memory model and visibility | 1.2 | 0 | 0 | 11,806 |
3,550,336 | 2010-08-23T18:05:00.000 | 11 | 0 | 1 | 0 | python | 3,550,500 | 4 | true | 0 | 0 | @Joe Kington's solutions works if there is a __dict__ (some objects, including builtins, don't have one) and __eq__ works for all values of both dicts (a badly written __eq__ mayraise exceptions etc). But it is horribly unpythonic. It doesn't even handle nominal subtypes properly... much less structural subtypes (i.e. types that you can use in place/for duck-typing). Do not do this.
But usually you're better off with a hand-tailored __eq__ method that only compares some attributes that are significant. E.g. Rational should only compare numerator and denominator, nothing more. | 2 | 18 | 0 | Is there any way to check if two objects have the same values, other than to iterate through their attributes and manually compare their values? | Comparing two objects | 1.2 | 0 | 0 | 28,508 |
3,550,336 | 2010-08-23T18:05:00.000 | -3 | 0 | 1 | 0 | python | 3,550,408 | 4 | false | 0 | 0 | object1.__dict__ == object2.__dict__ Should be all you need, I think...
Edit: vars(object1) == vars(object2) is perhaps a bit more pythonic, though @delnan makes a valid point about objects (e.g. ints) that don't have a __dict__. I disagree that a custom __eq__ is a better approach for simple cases, though... Sometimes it's not worth the effort to go beyond quick and dirty, if quick and dirty perfectly does what you need, i.m.h.o. | 2 | 18 | 0 | Is there any way to check if two objects have the same values, other than to iterate through their attributes and manually compare their values? | Comparing two objects | -0.148885 | 0 | 0 | 28,508 |
3,552,928 | 2010-08-24T01:22:00.000 | 3 | 1 | 0 | 0 | python,timeout,mechanize | 3,553,063 | 3 | false | 0 | 0 | If you're using Python 2.6 or better, and a correspondingly updated version of mechanize, mechanize.urlopen should accept a timeout=... optional argument which seems to be what you're looking for. | 1 | 15 | 0 | How do i set a timeout value for python's mechanize? | how do i set a timeout value for python's mechanize? | 0.197375 | 0 | 0 | 9,833 |
3,555,065 | 2010-08-24T09:21:00.000 | 2 | 0 | 0 | 0 | python,image,wxpython | 3,557,437 | 1 | false | 0 | 1 | I don't think a dialog is a good choice for a growing list of images, but if you have a good argument for that...
Anyway, you should be able to display your images using the wx.StaticBitmap widget. To add another one, use your sizer's Add method, then call the dialog's Layout() method and maybe its Refresh() method. If you plan on displaying many images, then you'll probably want to look at the ScrolledPanel or the ScrolledWindow widgets. | 1 | 1 | 0 | I want to add images to wx.Dialog (and then sizer) some like wx.ImageList and display it dynamically.
But I don't want to change already displayed image, I want to add next.
How can I resolve this problem? | How to add images/bitmaps to wx.Dialog | 0.379949 | 0 | 0 | 883 |
3,555,485 | 2010-08-24T10:30:00.000 | 1 | 0 | 0 | 0 | python | 5,845,120 | 2 | false | 0 | 0 | There is a package named roscraco that configure and extract information from some consumer level routers. It's available on PyPi. | 2 | 1 | 0 | i want to do router configuration using python , but dont want to use any application level protocol to configure it . Is it possible to deal it on a hardware level ? Please do tell if the question is vague or if it needs more explanation , then I would put more details on as to what I have my doubt in | is it possible to write python scripts which can do router configuration without telnetting into the router? | 0.099668 | 0 | 1 | 616 |
3,555,485 | 2010-08-24T10:30:00.000 | 1 | 0 | 0 | 0 | python | 3,555,720 | 2 | false | 0 | 0 | The title of your question by itself makes some sense.
The body of your question doesn't make sense.
is it possible to write python scripts which can do router configuration without telnetting into the router?
Yes, depending on the platform. You maybe able to use a variety of other methods to configure the router that do not include telnet. E.g. xml-rpc, ssh + interactive, scp config file or fragments, snmp to induce upload config file, etc.
Is it possible to deal it on a hardware level?
You're in the realms of nanotech microscopy and seriously invalidating the warranty on your router. | 2 | 1 | 0 | i want to do router configuration using python , but dont want to use any application level protocol to configure it . Is it possible to deal it on a hardware level ? Please do tell if the question is vague or if it needs more explanation , then I would put more details on as to what I have my doubt in | is it possible to write python scripts which can do router configuration without telnetting into the router? | 0.099668 | 0 | 1 | 616 |
3,556,027 | 2010-08-24T11:41:00.000 | 0 | 1 | 0 | 1 | python,user-interface,bash | 3,556,046 | 4 | false | 0 | 0 | basically, all bash does is start other programs (and do symbolic math on the command line). So no, you're going to have to involve some other program. | 1 | 3 | 0 | I have some bash scripts, some simple ones to copy, search, write lines to files and so on.
I am an Ubuntu. and I've searched in google, but it seems that everybody is doing that on python.
I could do these on python, but since I am not a python programmer, I just know the basics.
I have no idea of how calling a sh script from a GUI written on python.
If someone has a link or something to say, please drop a line.
regards,
Mario | Is there a way of having a GUI for bash scripts? | 0 | 0 | 0 | 2,093 |
3,556,266 | 2010-08-24T12:12:00.000 | 1 | 0 | 0 | 0 | python,urllib2 | 31,354,580 | 4 | false | 0 | 0 | e.g.:
urllib2.urlopen('ORIGINAL LINK').geturl()
urllib2.urlopen(urllib2.Request('ORIGINAL LINK')).geturl() | 2 | 22 | 0 | I'm using the urllib2.urlopen method to open a URL and fetch the markup of a webpage. Some of these sites redirect me using the 301/302 redirects. I would like to know the final URL that I've been redirected to. How can I get this? | How can I get the final redirect URL when using urllib2.urlopen? | 0.049958 | 0 | 1 | 34,914 |
3,556,266 | 2010-08-24T12:12:00.000 | 4 | 0 | 0 | 0 | python,urllib2 | 3,556,295 | 4 | false | 0 | 0 | The return value of urllib2.urlopen has a geturl() method which should return the actual (i.e. last redirect) url. | 2 | 22 | 0 | I'm using the urllib2.urlopen method to open a URL and fetch the markup of a webpage. Some of these sites redirect me using the 301/302 redirects. I would like to know the final URL that I've been redirected to. How can I get this? | How can I get the final redirect URL when using urllib2.urlopen? | 0.197375 | 0 | 1 | 34,914 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.