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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4,462,068 | 2010-12-16T14:56:00.000 | 1 | 0 | 1 | 0 | python,google-app-engine,printing | 4,649,865 | 4 | false | 0 | 0 | Are you using some sort of wsgi framework, or just trying to write pure CGI code (which is a mistake?)
You probably don't want to be using print at all here, but rather using your framework's method of adding to the response (for webapp, self.response.out.write). My guess would be that without the extra \n, you're writing all of this data to the HTTP headers, and with it you're only losing the first line of your output. | 2 | 2 | 0 | why this does not print anything:
for item in pipe.json["value"]["items"]:
print item["pubDate"]
but this does:
for item in pipe.json["value"]["items"]:
print item["pubDate"] + "\n"
p.s. the loop is running inside another loop.
p.p.s. this is running inside google app engine application.i have looked at http response and it is completely empty in the first case. | weird python print behaviour | 0.049958 | 0 | 0 | 259 |
4,462,119 | 2010-12-16T15:00:00.000 | 2 | 0 | 1 | 0 | python,hash,lookup,lookup-tables | 4,462,498 | 4 | false | 0 | 0 | A simple solution seems to be to do lookup[id(myobj)] = myotherobj instead of lookup[myobj] = myotherobj. Any commente on this approach? | 1 | 6 | 0 | I need to create a mapping from objects of my own custom class (derived from dict) to objects of another custom class. As I see it there are two ways of doing this:
I can make the objects hashable. I'm not sure how I would do this. I know I can implement __hash__() but I'm unsure how to actually calculate the hash (which should be an integer).
Since my objects can be compared I can make a list [(myobj, myotherobj)] and then implement a lookup which finds the tuple where the first item in the tuple is the same as the lookup key. Implementing this is trivial (the number of objects is small) but I want to avoid reinventing the wheel if something like this already exists in the standard library.
It seems to me that wanting to look up unhashables would be a common problem so I assume someone has already solved this problem. Any suggestions on how to implement __hash()__ for a dict-like object or if there is some other standard way of making lookup tables of unhashables? | Lookup table for unhashable in Python | 0.099668 | 0 | 0 | 682 |
4,462,678 | 2010-12-16T15:56:00.000 | 2 | 0 | 1 | 1 | python,twisted | 4,464,644 | 3 | false | 0 | 0 | No, you shouldn't use threads. You can't call LoopingCall from a thread (unless you use reactor.callFromThread), but it wouldn't help you make your code faster.
If you notice a performance problem, you may want to profile your workload, figure out where the CPU-intensive work is, and then put that work into multiple processes, spawned with spawnProcess. You really can't skip the step where you figure out where the expensive work is, though: there's no magic pixie dust you can sprinkle on your Twisted application that will make it faster. If you choose a part of your code which isn't very intensive and doesn't require blocking resources like CPU or disk, then you will discover that the overhead of moving work to a different process may outweigh any benefit of having it there. | 2 | 1 | 0 | I am running some code that has X workers, each worker pulling tasks from a queue every second. For this I use twisted's task.LoopingCall() function. Each worker fulfills its request (scrape some data) and then pushes the response back to another queue. All this is done in the reactor thread since I am not deferring this to any other thread.
I am wondering whether I should run all these jobs in separate threads or leave them as they are. And if so, is there a problem if I call task.LoopingCall every second from each thread ? | Twisted - should this code be run in separate threads | 0.132549 | 0 | 0 | 648 |
4,462,678 | 2010-12-16T15:56:00.000 | 1 | 0 | 1 | 1 | python,twisted | 4,462,745 | 3 | false | 0 | 0 | You shouldn't use threads for that. Doing it all in the reactor thread is ok. If your scraping uses twisted.web.client to do the network access, it shouldn't block, so you will go as fast as it gets. | 2 | 1 | 0 | I am running some code that has X workers, each worker pulling tasks from a queue every second. For this I use twisted's task.LoopingCall() function. Each worker fulfills its request (scrape some data) and then pushes the response back to another queue. All this is done in the reactor thread since I am not deferring this to any other thread.
I am wondering whether I should run all these jobs in separate threads or leave them as they are. And if so, is there a problem if I call task.LoopingCall every second from each thread ? | Twisted - should this code be run in separate threads | 0.066568 | 0 | 0 | 648 |
4,463,097 | 2010-12-16T16:37:00.000 | 0 | 0 | 1 | 0 | python,installation,wxwidgets,executable,py2exe | 4,467,946 | 2 | false | 0 | 1 | py2exe must bundle the Python interpreter--how else would your friends without Python use your program without it? But it does, of course.
py2exe mostly includes what needs to be included based on what is imported into your app, so if you have import sqlite3 in there, it will be included. I'd try using GUI2Exe, it makes using py2exe so much more intuitive and easier. | 1 | 0 | 0 | I have a small Python app ready that I'd like to distribute around to my friends in the company.
I have used wxWidgets for the GUI, with SQLite for the database.
I'm planning on using py2exe for packaging the entire thing.
I'd like to know if bundling the Python interpreter is required ? Does py2exe does it by default ? My friends wont have Python installed on their systems.
Are there any extra libraries that I should bundle for the GUI ?
I want this to run only on Windows, nothing else. | Do I need to bundle the Python interpreter (in py2exe) when I am distributing my app? | 0 | 0 | 0 | 725 |
4,464,853 | 2010-12-16T20:01:00.000 | 0 | 0 | 1 | 1 | python,packages | 4,465,491 | 4 | false | 0 | 0 | If it's a "self-extracting" zip file you can just change the .exe extension to .zip and then unzip it with any standard zip file handling utility...assuming you can at least download .exe files. If you can't, you might be able to rename them during the download process (i.e. via a "Save As" dialog). | 4 | 1 | 0 | Everything seems to be only available in self-extracting .exe. My company blocks executable files from being downloaded. | Is it possible to download packages for Win32 in zip format? | 0 | 0 | 0 | 309 |
4,464,853 | 2010-12-16T20:01:00.000 | 1 | 0 | 1 | 1 | python,packages | 4,464,917 | 4 | false | 0 | 0 | You could try to "easy-install" the package | 4 | 1 | 0 | Everything seems to be only available in self-extracting .exe. My company blocks executable files from being downloaded. | Is it possible to download packages for Win32 in zip format? | 0.049958 | 0 | 0 | 309 |
4,464,853 | 2010-12-16T20:01:00.000 | 0 | 0 | 1 | 1 | python,packages | 4,465,455 | 4 | false | 0 | 0 | The self-extracting exe is only necessary if the package contains C-code that needs to be compiled, and you don't have a compiler. Otherwise you can use the source package, which often is a tgz. | 4 | 1 | 0 | Everything seems to be only available in self-extracting .exe. My company blocks executable files from being downloaded. | Is it possible to download packages for Win32 in zip format? | 0 | 0 | 0 | 309 |
4,464,853 | 2010-12-16T20:01:00.000 | 1 | 0 | 1 | 1 | python,packages | 4,464,895 | 4 | false | 0 | 0 | Pretty close. Download the source - a .tar.gz archive, so you need something beyond window's built-in zip handling to unpack it - and run python setup.py install. | 4 | 1 | 0 | Everything seems to be only available in self-extracting .exe. My company blocks executable files from being downloaded. | Is it possible to download packages for Win32 in zip format? | 0.049958 | 0 | 0 | 309 |
4,465,615 | 2010-12-16T21:39:00.000 | 2 | 1 | 0 | 1 | python,emacs | 4,577,034 | 2 | true | 0 | 0 | Short answer: not without writing some missing elisp code.
Long version: In python.el, run-python adds data-directory (which on my Ubuntu 10.10 box is /usr/share/emacs/23.1/etc/ ) to $PYTHONPATH, specifically so that it can find emacs.py (as supplied by the local emacs distribution.) Then it does a (python-send-string "import emacs") and expects it to work...
It looks like the defadvice wrappers that tramp uses don't actually pass PYTHONPATH, so this doesn't work even if you have the matching emacs version on the remote system.
If you M-x customize-variable RET tramp-remote-process-environment RET
then hit one of the INS buttons and add PYTHONPATH=/usr/share/emacs/23.1/etc then hit STATE and set it to "current session" (just to test it, or "save for future sessions" if it works for you) it almost works - the complaint goes away, in any case, because the remote python can now find the remote emacs.py. If you now go back to the original question, doing python-send-buffer, you just run into a different error: No such file or directory: '/tmp/py24574XdA' because python-mode just stuffs the content into a temporary file and tells the python subprocess to load that.
You'd have to change python-send-region (the other functions call it) and particularly the way it uses make-temp-file to be tramp-aware - there's even a tramp-make-tramp-temp-file you could probably build upon. (Be sure to post it if you do...) | 1 | 5 | 0 | I'm using emacs23 with tramp to modify python scripts on a remote host.
I found that when I start the python shell within emacs it starts up
python on the remote host.
My problem is that when I then try to call python-send-buffer via C-c C-c it comes up with the error
Traceback (most recent call last):
File "", line 1, in ?
ImportError: No module named emacs
Traceback (most recent call last):
File "", line 1, in ?
NameError: name 'emacs' is not defined
Now, I must admit that I don't really know what's going on here. Is there a way for me to configure emacs so that I can evaluate the buffer on the remote host?
Many thanks.
Edit: I've followed eichin's advice and re-implemented python-send-region. See my answer below. | evaluating buffer in emacs python-mode on remote host | 1.2 | 0 | 0 | 2,594 |
4,465,636 | 2010-12-16T21:41:00.000 | 0 | 0 | 0 | 0 | python,django,http,templates,url | 4,465,784 | 3 | false | 1 | 0 | Another option is to parse plain text in some way, for example as reStructuredText (my favourite) or Markdown (Stack Overflow uses a slightly modified variant of Markdown). These will both turn valid plain text links targets into hyperlinks. This also gives you more power over what you can do; you won't need to resort to HTML to achieve some basic formatting. Note also as stated with urlize that you should only use it on plain text; it's not designed to be mixed with HTML. | 1 | 8 | 0 | When someone writes a post and copies and pastes a url in it, can Django detect it and render it as a hyperlink rather than plain text? | Does Django have a template tag that can detect URLs and turn them into hyperlinks? | 0 | 0 | 0 | 3,616 |
4,465,693 | 2010-12-16T21:49:00.000 | 4 | 0 | 1 | 0 | python | 4,465,779 | 4 | false | 0 | 0 | The only code which could possibly be simpler and clearer than what you have is int('3.5'), which doesn't work. Therefore, what you have is the simplest, clearest working code. | 3 | 2 | 0 | So far, I would do int(float('3.5'))
Any other good way to do?
Note: 3.5 is a string.
I want to use the the built-in API that specify for this sort of problem. | Python: Convert '3.5' to integer | 0.197375 | 0 | 0 | 5,486 |
4,465,693 | 2010-12-16T21:49:00.000 | 1 | 0 | 1 | 0 | python | 4,465,944 | 4 | false | 0 | 0 | Maybe int(eval('3.5')) | 3 | 2 | 0 | So far, I would do int(float('3.5'))
Any other good way to do?
Note: 3.5 is a string.
I want to use the the built-in API that specify for this sort of problem. | Python: Convert '3.5' to integer | 0.049958 | 0 | 0 | 5,486 |
4,465,693 | 2010-12-16T21:49:00.000 | 1 | 0 | 1 | 0 | python | 4,465,704 | 4 | false | 0 | 0 | All that you need is
int(3.5)
Note that this truncates; it doesn't round. | 3 | 2 | 0 | So far, I would do int(float('3.5'))
Any other good way to do?
Note: 3.5 is a string.
I want to use the the built-in API that specify for this sort of problem. | Python: Convert '3.5' to integer | 0.049958 | 0 | 0 | 5,486 |
4,465,721 | 2010-12-16T21:52:00.000 | 0 | 0 | 1 | 1 | python,epydoc | 35,426,350 | 2 | false | 0 | 0 | You can also specified the excluded file in the config file like:
exclude: my_module.my_class | 2 | 1 | 0 | I'm generating an epydoc for a library of code, and there are a few testing files scattered throughout that I'd like to not include. I could use the --exclude generation option and rename the files, but I'm wondering if there's anything I can add to the files themselves that will be interpreted by epydoc as a command not to include/parse that file. | Is there a way to exclude a specific file from epydoc generation? | 0 | 0 | 0 | 630 |
4,465,721 | 2010-12-16T21:52:00.000 | 3 | 0 | 1 | 1 | python,epydoc | 4,696,850 | 2 | true | 0 | 0 | It would seem the answer to this question is no. If you want to exclude an element, the only option is to use
--exclude=PATTERN
Which excludes modules whose dotted name matches the regular expression PATTERN | 2 | 1 | 0 | I'm generating an epydoc for a library of code, and there are a few testing files scattered throughout that I'd like to not include. I could use the --exclude generation option and rename the files, but I'm wondering if there's anything I can add to the files themselves that will be interpreted by epydoc as a command not to include/parse that file. | Is there a way to exclude a specific file from epydoc generation? | 1.2 | 0 | 0 | 630 |
4,465,959 | 2010-12-16T22:24:00.000 | 1 | 0 | 0 | 0 | python,sockets,connection,errno | 69,953,754 | 13 | false | 0 | 0 | Do nothing just wait for a couple of minutes and it will get resolved. It happens due to the slow termination of some processes, and that's why it's not even showing in the running processes list. | 5 | 127 | 0 | In my Python socket program, I sometimes need to interrupt it with Ctrl-C. When I do this, it does close the connection using socket.close().
However, when I try to reopen it I have to wait what seems like a minute before I can connect again. How does one correctly close a socket? Or is this intended? | Python [Errno 98] Address already in use | 0.015383 | 0 | 1 | 244,362 |
4,465,959 | 2010-12-16T22:24:00.000 | -2 | 0 | 0 | 0 | python,sockets,connection,errno | 67,721,945 | 13 | false | 0 | 0 | sudo pkill -9 python
try this command | 5 | 127 | 0 | In my Python socket program, I sometimes need to interrupt it with Ctrl-C. When I do this, it does close the connection using socket.close().
However, when I try to reopen it I have to wait what seems like a minute before I can connect again. How does one correctly close a socket? Or is this intended? | Python [Errno 98] Address already in use | -0.03076 | 0 | 1 | 244,362 |
4,465,959 | 2010-12-16T22:24:00.000 | 0 | 0 | 0 | 0 | python,sockets,connection,errno | 67,780,925 | 13 | false | 0 | 0 | I had the same problem (Err98 Address already in use) on a Raspberry Pi running python for a EV charging manager for a Tesla Wall Connector. The software had previously been fine but it stopped interrogating the solar inverter one day and I spent days thinking it was something I'd done in python. Turns out the root cause was the Wifi modem assigning a new dynamic IP to the solar inverter as as result of introducing a new smart TV into my home. I changed the python code to reflect the new IP address that I found from the wifi modem and bingo, the issue was fixed. | 5 | 127 | 0 | In my Python socket program, I sometimes need to interrupt it with Ctrl-C. When I do this, it does close the connection using socket.close().
However, when I try to reopen it I have to wait what seems like a minute before I can connect again. How does one correctly close a socket? Or is this intended? | Python [Errno 98] Address already in use | 0 | 0 | 1 | 244,362 |
4,465,959 | 2010-12-16T22:24:00.000 | 4 | 0 | 0 | 0 | python,sockets,connection,errno | 69,756,864 | 13 | false | 0 | 0 | For Linux,
ps aux | grep python
This will show you the error. The process number (eg.35225) containing your python file is the error.
Now,
sudo kill -9 35225
This will kill the error process and your problem will be solved. | 5 | 127 | 0 | In my Python socket program, I sometimes need to interrupt it with Ctrl-C. When I do this, it does close the connection using socket.close().
However, when I try to reopen it I have to wait what seems like a minute before I can connect again. How does one correctly close a socket? Or is this intended? | Python [Errno 98] Address already in use | 0.061461 | 0 | 1 | 244,362 |
4,465,959 | 2010-12-16T22:24:00.000 | 14 | 0 | 0 | 0 | python,sockets,connection,errno | 51,348,141 | 13 | false | 0 | 0 | A simple solution that worked for me is to close the Terminal and restart it. | 5 | 127 | 0 | In my Python socket program, I sometimes need to interrupt it with Ctrl-C. When I do this, it does close the connection using socket.close().
However, when I try to reopen it I have to wait what seems like a minute before I can connect again. How does one correctly close a socket? Or is this intended? | Python [Errno 98] Address already in use | 1 | 0 | 1 | 244,362 |
4,466,923 | 2010-12-17T01:18:00.000 | 1 | 0 | 0 | 0 | python,django | 4,468,901 | 2 | true | 1 | 0 | Just assign the dictionary directly to the request. You can do that in middleware or in your view, as you like. | 1 | 0 | 0 | I'm wondering if there's a clever pattern for request-scoping arbitrary information without resorting to either TLS or putting the information in the session.
Really, this would be for contextual attributes that I'd like to not look up more than once in a request path, but which are tied to a request invocation and there's no good reason to let them thresh around in the session.
Something like a dict that's pinned to the request where I can shove things or lazy load them. I could write a wrapper for request and swap it out in a middleware, but I figured I'd check to see what best-practice might be here? | Best way to request-scope data in Django? | 1.2 | 0 | 1 | 1,377 |
4,467,638 | 2010-12-17T04:14:00.000 | 0 | 1 | 0 | 0 | python,noise | 4,467,703 | 3 | false | 0 | 0 | use a mod function with a suitable period. there are quite a few pages around the www explaining mod functions.
just make sure it is also suitable for 3 dimensions, some mods that are suitable for 1 or 2 dimensions may not be suitable over 3. | 1 | 10 | 0 | I need a method to generate 3D simplex noise in python rather quickly. What methods are there out there to solve this problem? | Generating 3D noise quickly in python | 0 | 0 | 0 | 5,673 |
4,468,326 | 2010-12-17T06:42:00.000 | 1 | 0 | 0 | 0 | wxpython | 4,471,136 | 2 | false | 0 | 1 | I'm guessing here, but because wxPython wraps native widgets whenever possible, those widgets may or may not support the changing of certain colors. I know that's true with StaticText on some OSes. So you may want to try with the generic progress bar, PyProgress, since it's written in pure Python and can be hacked easily. | 1 | 1 | 0 | i want to change my progrssbar color to Black which is green. i think by default it is green
I am trying with
self.progress_bar.color
but doesnot reflect any change i think there will be any inbuilt method but i am unable to find it. | Want to change progress bar color to Black in wx python | 0.099668 | 0 | 0 | 1,414 |
4,470,073 | 2010-12-17T11:37:00.000 | 3 | 0 | 0 | 0 | silverlight,postgresql,silverlight-4.0,silverlight-3.0,ironpython | 4,470,466 | 1 | false | 0 | 0 | From Silverlight you cannot access a database directly (remember it's a web technology that actually runs locally on the client and the client cannot access your database directly over the internet).
To communicate with the server from Silverlight, you must create a separated WebService either with SOAP, WCF or RIA Services for example.
That Webservice will expose your data on the web. Call the WebService method to get your data from your Silverlight program.
This WebService layer will be your middle tiers that actually makes the bridge between your postgresql database and your Silverlight application. | 1 | 0 | 0 | I create hangman game with silverlight ironpython and I use data in postgresql for random word but I don't know to access data in postgresql in silverlight.
how can or should it be done?
Thanks!! | How to access PostgreSQL with Silverlight | 0.53705 | 1 | 0 | 950 |
4,470,246 | 2010-12-17T12:02:00.000 | 2 | 0 | 0 | 0 | python,opencl | 4,478,655 | 1 | true | 0 | 1 | This awfully looks like you are using __constant memory. The solution is to use __global memory instead, but you have to be careful about how you access it for best performance.
__constant memory is a special address space for often used constant values, but is restricted in size on current GPUs. | 1 | 0 | 0 | I am currently in the process of discovering OpenCL via the Python binding Clyther. So
far I am messing with a very simple script to get the sin or cos of a buffer of 65536.
Apparently 65536 is the limit for buffers on my card but say I'd have 16 million numbers in my buffer how would I go about it without constantly bringing the CPU into it to retrieve/send data?
What I have do so far is, fill buffer, run kernel, retrieve buffer, in a loop but that also
hits the CPU badly.
I looked a bit at OpenCL docs but I just failed to understand how that is achieved.
Thank you | Processing buffers bigger than 65536 in Clyther/OpenCL | 1.2 | 0 | 0 | 156 |
4,470,302 | 2010-12-17T12:08:00.000 | 11 | 1 | 1 | 1 | python | 4,470,327 | 5 | false | 0 | 0 | The inbuilt Python modules/ stdlib wherever you can, subprocess (os.system) where you must.
Reasons: Portability, maintenance, code readability just to name a few. | 4 | 2 | 0 | Which is better to use in a python automation script for following simple operations
To create a zip file and copy it or rename it to a new location.
Using python inbuilt functions or terminal commands through os.system modules is better? | Which is better? Using inbuilt python functions or os.system commands? | 1 | 0 | 0 | 211 |
4,470,302 | 2010-12-17T12:08:00.000 | 2 | 1 | 1 | 1 | python | 4,470,324 | 5 | false | 0 | 0 | I would say python ones since it'll make the script portable. But sometimes, performance and availability are of concerns. | 4 | 2 | 0 | Which is better to use in a python automation script for following simple operations
To create a zip file and copy it or rename it to a new location.
Using python inbuilt functions or terminal commands through os.system modules is better? | Which is better? Using inbuilt python functions or os.system commands? | 0.07983 | 0 | 0 | 211 |
4,470,302 | 2010-12-17T12:08:00.000 | 2 | 1 | 1 | 1 | python | 4,470,331 | 5 | false | 0 | 0 | In general I'd say use the python libraries where possible - that way it'll be more portable, e.g. you won't need to worry about different commands or command options on various systems, and also if you need to change anything it's easier to do just python code. | 4 | 2 | 0 | Which is better to use in a python automation script for following simple operations
To create a zip file and copy it or rename it to a new location.
Using python inbuilt functions or terminal commands through os.system modules is better? | Which is better? Using inbuilt python functions or os.system commands? | 0.07983 | 0 | 0 | 211 |
4,470,302 | 2010-12-17T12:08:00.000 | 0 | 1 | 1 | 1 | python | 4,470,576 | 5 | false | 0 | 0 | Using python internals command is nice, especially in terms of portability.
But at some point, you can be confused by lack of "os.kill" in Python older than 2.7 (Windows), you can be surprised by way how os.Popen is working, than you will discover win32pipe etc etc.
Personally I would suggest always a small research (do you need daemons etc) and then decide. If you don't need windows platform - using python's internals could be more efficient. | 4 | 2 | 0 | Which is better to use in a python automation script for following simple operations
To create a zip file and copy it or rename it to a new location.
Using python inbuilt functions or terminal commands through os.system modules is better? | Which is better? Using inbuilt python functions or os.system commands? | 0 | 0 | 0 | 211 |
4,470,481 | 2010-12-17T12:33:00.000 | 2 | 0 | 0 | 0 | python,sqlalchemy | 4,470,921 | 1 | true | 0 | 0 | I guess you want to filter the data with the lambda, like a WHERE clause? Well, no, functions nor lambdas cannot be turned into a SQL query. Sure, you could just fetch all the data and filter it in Python, but that completely defeats the purpose of the database.
You'll need to recreate the logic you put into the lambda with SQLAlchemy. | 1 | 2 | 0 | I need to implement a function that takes a lambda as the argument and queries the database. I use SQLAlchemy for ORM. Is there a way to pass the lambda, that my function receives, to SQLAlchemy to create a query?
Sincerely,
Roman Prykhodchenko | Can I use lambda to create a query in SQLAlchemy? | 1.2 | 1 | 0 | 1,681 |
4,471,056 | 2010-12-17T13:52:00.000 | 8 | 0 | 0 | 0 | python,windows,qt,macos,wxwidgets | 4,471,107 | 3 | false | 0 | 1 | Don't waste your time. Use wxPython, which will use the native toolkit for you. | 1 | 1 | 0 | I checked some other question and websites, and I've come to the conclusion that Python does allow (correct me if I'm wrong) you to make GUI programs using different cross-platform toolkits like Qt, wxWidgets and some others.
But what if I don't want cross-platform portability. Primary, I want to develop native application using native libraries like Cocoa for Mac, native libraries of Windows for window, GTK for GNOME and Qt for KDE apps different with different code. Different code is not an issue here. Can I do this? I just don't need cross-platform portability but I need to make native apps?
Any insights from pro programmers ? | Python and native GUI | 1 | 0 | 0 | 1,951 |
4,471,587 | 2010-12-17T14:47:00.000 | 0 | 1 | 0 | 0 | python,debugging,emacs | 4,471,792 | 1 | true | 0 | 0 | Use Emacs Lisp function setenv as in:
(setenv "PYTHONPATH" "c:/....") | 1 | 2 | 0 | I am trying to get a decent python environment using emacs. As part of this process i want to integrate pydbgr with emacs.
I have almost done it but with an issue. When i try to start a debugging session pydbgr does not found my modules when i try to import them.
If i change PYTHONPATH and then execute pydbgr from command line all works fine.
So my question is. IS there any way to change python environment so i can debug with pydbgr inside emacs?
Thanks in advance! | Unable to find modules from pydbgr in emacs | 1.2 | 0 | 0 | 101 |
4,472,257 | 2010-12-17T15:56:00.000 | 2 | 0 | 1 | 0 | java,c++,python,vim,variable-assignment | 4,472,406 | 2 | true | 0 | 0 | Use 'very magic': add \v to the expression. See :help magic. Basically, it mean that all non-alphanumeric characters have special (i.e. regular expression operator meanings) unless escaped, which means that they do not need to be escaped in your usage above. | 1 | 0 | 0 | To be honest, I actually have a solution for this, but Google search finds so many great tips for me from this site, that I had to contribute something back. Here is what I came up with. For a single line:
s/^\(\s\+\)\(.*\) = \(.*\);/\1\3 = \2;/
For multiple lines starting at the current line, add .,.+<line count>. For example:
.,.+28s/^\(\s\+\)\(.*\) = \(.*\);/\1\3 = \2;/
will substitute on the current line and the following 28 lines. This should also work for Java and Perl. For Python, omit the ending semicolon from the pattern and substitution (unless you're the sort who uses the optional semicolon).
After typing all that, I find I do have a question. Is there a way to simplify it so I don't have so many escape characters? | How do I swap the left hand and right hand sides of a C/C++ assignment statement in gvim? | 1.2 | 0 | 0 | 189 |
4,475,929 | 2010-12-18T00:38:00.000 | 0 | 0 | 0 | 0 | python | 4,476,298 | 3 | false | 0 | 0 | You could simply download the raw html with urllib2, then simply search through it. There might be easier ways but you could do this:
1:Download the source code.
2:Use strings library to split it into a list.
3:Search the first 7 characters of each section-->
4:If the first 7 characters are http://, write that to a variable.
Why do you need separate variables though? Wouldn't it be easier to save them all to a list, using list.append(URL_YOU_JUST_FOUND), every time you find another url? | 2 | 0 | 0 | How would I look for all URLs on a web page and then save them to individual variables with urllib2 In Python? | How would I look for all URLs on a web page and then save them to a individual variables with urllib2 In Python? | 0 | 0 | 1 | 97 |
4,475,929 | 2010-12-18T00:38:00.000 | 0 | 0 | 0 | 0 | python | 4,475,970 | 3 | false | 0 | 0 | You don't do it with urllib2 alone. What are you looking for is parsing urls in a web page.
You get your first page using urllib2, read its contents and then pass it through parser like Beautifulsoup or as the other poster explained, you can regex to search the contents of the page too. | 2 | 0 | 0 | How would I look for all URLs on a web page and then save them to individual variables with urllib2 In Python? | How would I look for all URLs on a web page and then save them to a individual variables with urllib2 In Python? | 0 | 0 | 1 | 97 |
4,475,930 | 2010-12-18T00:38:00.000 | 1 | 0 | 0 | 0 | python,django,facebook,gmail | 7,865,880 | 1 | false | 1 | 0 | Take a look at the pinax (http://pinaxproject.com/). They have a lot of reusable apps and one of those provide mechanism for inviting friends from openid based sites (i.e. facebook) | 1 | 3 | 0 | Super easy django app that just lets people click "Facebook", and then invite AND import their friends | Is there a Django app that can give me easy friend importing AND invite from Facebook, Twitter, and Gmail? | 0.197375 | 0 | 0 | 667 |
4,476,430 | 2010-12-18T03:19:00.000 | 1 | 0 | 0 | 0 | python,django,validation,forms,ip | 4,477,440 | 3 | false | 1 | 0 | You can pass the request object to the form/model code that is being called: this will then provide access to request.META['REMOTE_ADDR']. Alternatively, just pass that in. | 2 | 0 | 0 | I know how to get it in views.py....
request.META['REMOTE_ADDR']
However, how do I get it in models.py when one of my forms is being validateD? | Inside Django's models.py, if I am validating a form, how do I get the user's IP? | 0.066568 | 0 | 0 | 179 |
4,476,430 | 2010-12-18T03:19:00.000 | 0 | 0 | 0 | 0 | python,django,validation,forms,ip | 4,476,456 | 3 | false | 1 | 0 | If you are validating at form level or at model level, both instances know nothing about the HTTP request (where the client IP info is stored).
I can think of two options:
Validate at the view level where you can insert errors into the form error list.
You can put the user IP (may be encrypted) in a hidden field at your form. | 2 | 0 | 0 | I know how to get it in views.py....
request.META['REMOTE_ADDR']
However, how do I get it in models.py when one of my forms is being validateD? | Inside Django's models.py, if I am validating a form, how do I get the user's IP? | 0 | 0 | 0 | 179 |
4,476,663 | 2010-12-18T04:38:00.000 | 6 | 1 | 1 | 0 | c++,python,performance,swig | 4,484,174 | 1 | true | 0 | 1 | The quality and speed of wrappers generated by SWIG is very good, and they will probably perform just as good as handcrafted wrappers.
From my experience, the wrappers themselves are very thin and add very little overhead to the native functions they wrap, making it a perfectly valid choice to use wrapped libraries in python or any other supported language, and is a good way to reuse code.
however, to be if you are interested in performance in addition to code reuse, wrapping native code will probably only pay off if you have some computationally intensive native functions, like multiplying matrices, computing MD5 or CRC, folding proteins etc.
on the other hand, sometimes you can just rewrite everything in an easy language like python or C# and enjoy better code and better tools, with comparable performance. | 1 | 9 | 0 | If I were to write several classes in c++ then use swig to do the conversion so I could later use them in python, would they run faster or slower than if I completely rewrote them in python? Or is there no noticable speed difference? | Speed of swig wrappers | 1.2 | 0 | 0 | 3,456 |
4,476,880 | 2010-12-18T06:02:00.000 | 0 | 0 | 1 | 0 | python | 4,476,895 | 4 | false | 0 | 0 | More to do with the concept of prime factorization than anything to do with python; factorization should raise an exception for all x < 2 or non integer. | 2 | 3 | 0 | I have a prime_factorize function that returns a dictionary mapping from prime divisors to their powers. E.g., 50 = 2^1 * 5^2, so prime_factorize(50) returns {2 : 1, 5 : 2}.
Assuming this is the documented behavior, what would be the least surprising way to signal an error if called 0, 1, or a negative number? Throw ValueError? Return something that looks like correct output (e.g., prime_factorize(-5) -> {-1: 1, 5: 1})? return an empty dict?
And if you have a better format for returning a prime factorization, I'd love to hear that too. | prime_factorize(1) -> ? (Pythonic error signalling) | 0 | 0 | 0 | 109 |
4,476,880 | 2010-12-18T06:02:00.000 | 1 | 0 | 1 | 0 | python | 4,476,958 | 4 | false | 0 | 0 | Not sure why you're using a dictionary here. Wouldn't a list of 2-tuples work as well? I.e., have prime_factor(50) return [(2,1), ((5,2)].
Use of a dictionary presupposes that you know the key and want to look up it's value, which doesn't seem to be the case for the prime factors of an arbitrary number. | 2 | 3 | 0 | I have a prime_factorize function that returns a dictionary mapping from prime divisors to their powers. E.g., 50 = 2^1 * 5^2, so prime_factorize(50) returns {2 : 1, 5 : 2}.
Assuming this is the documented behavior, what would be the least surprising way to signal an error if called 0, 1, or a negative number? Throw ValueError? Return something that looks like correct output (e.g., prime_factorize(-5) -> {-1: 1, 5: 1})? return an empty dict?
And if you have a better format for returning a prime factorization, I'd love to hear that too. | prime_factorize(1) -> ? (Pythonic error signalling) | 0.049958 | 0 | 0 | 109 |
4,478,478 | 2010-12-18T14:36:00.000 | 0 | 0 | 0 | 0 | python,ms-word,reportlab,openoffice-writer | 4,691,989 | 1 | false | 0 | 0 | You can not embed such objects as is within a PDF, adobe specification does not support that. However you could always parse the data from the Office document and reproduce it as a table/graph/etc using reportlab in the output PDF. If you don't care about the data being an actual text you could always save it in the PDF as an image. | 1 | 1 | 0 | The desire is to have the user provide information in an OpenOffice Writer or MS Word file that is inserted into part of a ReportLab generated PDF. I am comfortable with ReportLab; but, I don't have any experience with using Writer or Word data in this way. How would you automate the process of pulling in the Writer/Word data? Is it possible to retain tables and graphs? | Is it possible to include OpenOffice Writer or MS Word data in a ReportLab generated PDF? | 0 | 1 | 0 | 147 |
4,479,069 | 2010-12-18T17:01:00.000 | 0 | 0 | 1 | 0 | python,sage | 4,479,077 | 5 | false | 0 | 0 | Well, the for statement in Python iterates over a sequence which may be a list or a string. You always loop over items as they appear in the sequence. This differs from languages like PHP and C# where you can control this for(x = 0; x < y; x++).
Do you want to know something more? If so, please elaborate. | 1 | 1 | 0 | I am a little confused as to what a for statement does/works in python. Can anyone be able to explain to me on how it works? | Python-for statements understanding | 0 | 0 | 0 | 216 |
4,479,295 | 2010-12-18T17:58:00.000 | 1 | 0 | 1 | 0 | python,installation | 4,479,324 | 1 | false | 0 | 0 | On Windows, this is trivial. You just install both, they get put in different directories.
On Linux, this is less so, but still fairly simple. Install from source, and use make altinstall instead of make install. | 1 | 0 | 0 | I want to install different versions of Python (and related packages and IDEs) on a single PC and keep them independent. I like the pythonxy but runs on Python 2.6, but I also wat to try Eric5 with Python3.1.
How can I keep thess different install separated ? | Different Python versions on single PC | 0.197375 | 0 | 0 | 137 |
4,479,679 | 2010-12-18T19:21:00.000 | 3 | 1 | 1 | 0 | c#,dynamic,interop,ironpython | 4,480,156 | 1 | true | 0 | 1 | You can create a ScriptSource with SourceCodeKind.AutoDetect and it will return the last expression in the file. | 1 | 2 | 0 | I'm trying to create a configuration file for a C# app in IronPython. Is there any way I can have that python file just return a value, or do I have to go through variables/functions to access the results of the script?
i.e., right now I've got Config.py that looks like
x = "test"
and C# code that goes
dynamic pyfile = Python.CreateRuntime().ExecuteFile("Config.py");
Console.WriteLine(pyfile.x);
Is there any way to remove the x? | How to create an IronPython file that simply returns a single value to C#? | 1.2 | 0 | 0 | 618 |
4,479,901 | 2010-12-18T20:06:00.000 | 0 | 0 | 1 | 0 | python,django | 4,480,885 | 4 | false | 1 | 0 | Wherever you want, you can import them if they are in the PYTHON_PATH. | 1 | 13 | 0 | Am new to django and was looking for advice where to place my shared library. Am planning on creating classes that I want to use across all my apps within the project. Where would be the best location to place them?
e.x abstract models
regards, | django shared library/classes | 0 | 0 | 0 | 9,474 |
4,480,020 | 2010-12-18T20:32:00.000 | 1 | 0 | 1 | 0 | c#,java,python,vb.net,math | 4,481,798 | 6 | false | 0 | 0 | I think the real reason, the root of this, is the well known fact: computers store everything in zeroes and ones.
What does it have to do with integers, floats and zero division? It's pretty simple. If you have only zeroes and ones, it is pretty easy to combine them into integer numbers, like you do with decimal digits. So "10" becomes two, "11" becomes three and so on. This kind of integer representation is so natural that no one would think of inventing anything else for integers, it would just make CPUs more complicated and things more confusing. The only "invention" that was required is to figure out how to store negative numbers, but that's also very natural and simple if you start from the point that x+(-x) should always be equal to zero, without using any special kind of addition here. That's why 11111111 is -1 for 8-bit integers, because if you add 1 to it, it becomes 100000000, then 8th bit is truncated due to overflow and you get your zero. But this natural format has no place for infinities and NaNs, and nobody wanted to invent a non-natural representation just for that. Well, I won't be surprised if someone actually did that, but there is no way such format would become well-known and widely used.
Now, for floating-point numbers, there is no natural representation. Even if we translate 0.5 to binary, it would still be something like 0.1 only now we have "binary point" instead of decimal point. But CPUs can't naturally represent a "point", only 1 and 0. So some kind of special format was needed. There was simply no other way to go. And then someone probably suggested, "Hey guys, while we are at it, why not to include special representation for infinity and other numeric nonsense?" and so it was done.
This is the reason why these formats are so different. How to handle divisions by zero, it's up to language designers, but for floating-points they have the choice between inf/NaN and exceptions, while for integers they don't naturally have such kind of thing. | 3 | 1 | 0 | Dividing an int by zero, will throw an exception, but a float won't - at least in Java. Why does a float have additional NaN info, while an int type doesn't? | Division by zero: int vs. float | 0.033321 | 0 | 0 | 2,636 |
4,480,020 | 2010-12-18T20:32:00.000 | 1 | 0 | 1 | 0 | c#,java,python,vb.net,math | 4,480,080 | 6 | false | 0 | 0 | Java reflects the way most CPUs are implemented. Integer divide by zero causes an interrupt on x86/x64 and Floating point divide by zero results in Infinity, Negative infinity or NaN. Note: with floating point you can also divide by negative zero. :P | 3 | 1 | 0 | Dividing an int by zero, will throw an exception, but a float won't - at least in Java. Why does a float have additional NaN info, while an int type doesn't? | Division by zero: int vs. float | 0.033321 | 0 | 0 | 2,636 |
4,480,020 | 2010-12-18T20:32:00.000 | 1 | 0 | 1 | 0 | c#,java,python,vb.net,math | 4,480,056 | 6 | false | 0 | 0 | Ints and floats are represented differently inside the machine. Integers usually use a signed, two's complement representation that is (essentially) the number written out in base two. Floats, on the other hand, use a more complex representation that can hold much larger and much smaller values. However, the machine reserves several special bit patterns for floats to mean things other than numbers. There's values for NaN, and for positive or negative infinity, for example. This means that if you divide a float by zero, there is a series of bits that the computer can use to encode that you divided by zero. For ints, all bit patterns are used to encode numbers, so there's no meaningful series of bits the computer could use to represent the error.
This isn't an essential property of ints, though. One could, in theory, make an integer representation that handles division by zero by returning some NaN variant. It's just not what's done in practice. | 3 | 1 | 0 | Dividing an int by zero, will throw an exception, but a float won't - at least in Java. Why does a float have additional NaN info, while an int type doesn't? | Division by zero: int vs. float | 0.033321 | 0 | 0 | 2,636 |
4,481,944 | 2010-12-19T06:50:00.000 | 0 | 0 | 0 | 0 | javascript,jquery,python,django | 4,483,185 | 2 | false | 1 | 0 | If you use javascript obfuscator chances are high it might be cracked, obfuscation is not encryption.
You should hash the conten on the serverside using md5.
Can you be more clear and specific in the question? | 1 | 1 | 0 | This is my demand:
User content is ultimately stored on the server side, but the preservation of data is encrypted
Server side, that is, site technical staff, can not have any way to decrypt the contents of the user, as the user's password as stored on the server side is a long list of md5 encrypted characters.
For encryption, we can temporarily consider only the text
The same as the password I want to process the data, but these data need to output to the user, so i have to decrypt the data on the client-side ,
what can i do ,
thanks
updated:
if i use javascript obfuscator on my javascript data , How much chance to be cracked by somebody . | How to encrypt my data on the server side using django | 0 | 0 | 0 | 1,120 |
4,483,182 | 2010-12-19T13:44:00.000 | 1 | 1 | 0 | 1 | python,timing | 4,483,416 | 1 | true | 0 | 0 | The quick answer, at least for linux, is to use getrusage along with a kernel that has a higher resolution timer.
The reason my initial tests gave the terrible precision of 10ms was because apparently 64-bit ubuntu is configured to a 100hz timer by default. | 1 | 4 | 0 | I'm designing a distributed system where a master node starts a bunch of worker nodes on remote machines. Since I am using Python and want to take advantage of the fact each physical machine has several cores, I want to run multiple worker nodes per machine (GIL etc). Additionally, each worker node may vary quite a bit in the amount of CPU it requires each "cycle". I can however split the worker nodes into quite a few pieces and my initial strategy will be to spawn many more worker nodes than there are cores per machine. The reasoning being that if a few nodes require more CPU, they can occupy a core for a longer duration. (If each node was already CPU bound, it could not suddenly require more CPU.)
This leads me to a question: How can I accurately gauge the CPU time of a python process?
I cannot measure the time naively, I need the time actually spent specifically for a given process. That is, for each process I want a number X, which, as accurately as possible, represents the amount of CPU resources spent exclusively on that process, regardless of unrelated processes. (I have been looking at Python's getrusage but it appears to give only 2 decimal points of precision on ubuntu, which is insufficient. EDIT: This also happens if I use getrusage() directly in C; at most 0.01 second precision. Close, but no cigar)
My specific use-case would be to measure the CPU time of each node cycle, from Start to End, where End happens about 0-30ms after Start.
The best answer would be a portable way to do this in Python. Methods that requires using C extension is fine. | How can I accurately gauge the CPU time of a python process? | 1.2 | 0 | 0 | 334 |
4,485,404 | 2010-12-19T22:13:00.000 | 1 | 0 | 0 | 0 | python,client-server,rich-internet-application | 4,485,440 | 1 | false | 1 | 0 | If possible, make the application run without any installation procedure, and provide it on a network share (e.g. with a fixed UNC path). You didn't specify the client operating system: if it's Windows, create an MSI that sets up something in the start menu that will still make the application launch from the network share.
With that approach, updates will be as simple as replacing the files on the file server - yet it will always run on the client. | 1 | 1 | 0 | I am developing an application for managers that might be used in a large organisation. The app is improved and extended step by step on a frequent (irregular) basis. The app will have SQL connections to several databases and has a complex GUI.
What would you advise to deploy the app ?
Based on my current (limited) knowledge of apps in lager organisations I prefer a setup where the app runs on a server and the user uses a thin client via the web. I prefer not to use a webbrowser because of (possible)limitations of the user GUI. The user experience should be as if the app was running on his own laptop/pc/tablet(?)
What opensource solution would you advise ?
Thanks ! | Deploy python application | 0.197375 | 1 | 0 | 318 |
4,485,550 | 2010-12-19T22:45:00.000 | 0 | 0 | 1 | 0 | python,binary | 4,485,565 | 8 | false | 0 | 0 | Like in most programming languages, Python follows the C tradition of numbers starting with 0 being octal (base 8) numbers. | 4 | 3 | 0 | I am using the python shell to figure out how the print command works in python.
When I type in
print 01
1
print 010
8
print 0100
64
print 030
24
What's going on here? Is it just base 2? Why does the "one" in the second position print as 8? Shouldn't it be 2 if it's binary? | binary numbers? | 0 | 0 | 0 | 6,112 |
4,485,550 | 2010-12-19T22:45:00.000 | 0 | 0 | 1 | 0 | python,binary | 4,485,571 | 8 | false | 0 | 0 | Definitely not base2. It's Octal - base 8. | 4 | 3 | 0 | I am using the python shell to figure out how the print command works in python.
When I type in
print 01
1
print 010
8
print 0100
64
print 030
24
What's going on here? Is it just base 2? Why does the "one" in the second position print as 8? Shouldn't it be 2 if it's binary? | binary numbers? | 0 | 0 | 0 | 6,112 |
4,485,550 | 2010-12-19T22:45:00.000 | 0 | 0 | 1 | 0 | python,binary | 4,485,567 | 8 | false | 0 | 0 | It's interpreting them as octal (base 8) numbers, not binary. | 4 | 3 | 0 | I am using the python shell to figure out how the print command works in python.
When I type in
print 01
1
print 010
8
print 0100
64
print 030
24
What's going on here? Is it just base 2? Why does the "one" in the second position print as 8? Shouldn't it be 2 if it's binary? | binary numbers? | 0 | 0 | 0 | 6,112 |
4,485,550 | 2010-12-19T22:45:00.000 | 1 | 0 | 1 | 0 | python,binary | 4,485,569 | 8 | false | 0 | 0 | When you append 0 to the left of the number, it is interpreted as an octal number. So 10 in octal equals 8 in decimal, and 100 in octal equals 64 in decimal and so on.
If you want to deal with binary number, you should use bit-wise operators to play with the bits. | 4 | 3 | 0 | I am using the python shell to figure out how the print command works in python.
When I type in
print 01
1
print 010
8
print 0100
64
print 030
24
What's going on here? Is it just base 2? Why does the "one" in the second position print as 8? Shouldn't it be 2 if it's binary? | binary numbers? | 0.024995 | 0 | 0 | 6,112 |
4,485,610 | 2010-12-19T22:58:00.000 | 2 | 0 | 1 | 0 | python,windows,user-interface,windows-7 | 40,915,752 | 6 | false | 0 | 1 | You can also use the messagebox class from tkinter:
from tkinter import messagebox
unless tkinter is that huge GUI you want to avoid.
Usage is simple, ie:
messagebox.FunctionName(title, message [, options])
with FuntionName in (showinfo, showwarning, showerror, askquestion, askokcancel, askyesno, askretrycancel). | 1 | 43 | 0 | Is there a messagebox class where I can just display a simple message box without a huge GUI library or any library upon program success or failure. (My script only does 1 thing).
Also, I only need it to run on Windows. | Python Message Box Without huge library dependency | 0.066568 | 0 | 0 | 53,872 |
4,486,178 | 2010-12-20T01:19:00.000 | 1 | 0 | 0 | 0 | python,security,activemq,mod-security,apache-modules | 4,486,208 | 5 | false | 1 | 0 | Django is a web application framework. I don't see anyone writing a firewall implementation using it. | 4 | 3 | 0 | I have an assignment to develop a web application firewall. I have been researching for some source codes about that.My main source was ModSecurity.
Main question is that:
-Which framework or programming language I can use, to develop a web application firewall? Which one would be the most useful?
-Can I use Django & Python?
It would be a starting point for the project research. | web application firewall development | 0.039979 | 0 | 0 | 3,881 |
4,486,178 | 2010-12-20T01:19:00.000 | 3 | 0 | 0 | 0 | python,security,activemq,mod-security,apache-modules | 4,486,453 | 5 | true | 1 | 0 | OK, so my guess was basically correct, although I thought it was protecting an app with no or bad security, but it's more about protecting against attacks. In that Case, Django is definitely wrong. It's clearly doable in Python, but don't expect to be able to handle 100.000 requests per second. :) But if it's research and development, I think Python can be a great choice, as it's fast to develop in, and with tools like Cython it can be quite fast to run as well. Should you then end up making a finished product that does need extreme performance, you can take the algorithms and translate them to C/C++.
I'd look into Twisted in your case. That may be the correct solution.
"It will be used on the server side to control the user transactions via HTTP."
Most web application frameworks have security settings. These are usually not called "firewalls", and you didn't answer my questions, so I'm going to guess here:
You are writing a web proxy that will act to filter out requests which do not have the correct permission because there is an application which does not have any access control at all. Is this correct?
Yes, you can do that in Python. Django is probably not the correct solution. If you need to implement access control with login pages and user management, then you probably want SQL and templating and a lightweight Python framework could be helpful. Otherwise Twisted or just doing it with the functionality in standard lib might be the correct solution. | 4 | 3 | 0 | I have an assignment to develop a web application firewall. I have been researching for some source codes about that.My main source was ModSecurity.
Main question is that:
-Which framework or programming language I can use, to develop a web application firewall? Which one would be the most useful?
-Can I use Django & Python?
It would be a starting point for the project research. | web application firewall development | 1.2 | 0 | 0 | 3,881 |
4,486,178 | 2010-12-20T01:19:00.000 | 1 | 0 | 0 | 0 | python,security,activemq,mod-security,apache-modules | 4,486,542 | 5 | false | 1 | 0 | Unless this is just some kind of academic exercise and Python helps you get it done fast, I don't think a high level language like Python is the best choice for a firewall (I don't even know if it's possible honestly). If you're planning some sort of proxy/filter application, that might be fine, but Django isn't needed either way. | 4 | 3 | 0 | I have an assignment to develop a web application firewall. I have been researching for some source codes about that.My main source was ModSecurity.
Main question is that:
-Which framework or programming language I can use, to develop a web application firewall? Which one would be the most useful?
-Can I use Django & Python?
It would be a starting point for the project research. | web application firewall development | 0.039979 | 0 | 0 | 3,881 |
4,486,178 | 2010-12-20T01:19:00.000 | 0 | 0 | 0 | 0 | python,security,activemq,mod-security,apache-modules | 51,471,417 | 5 | false | 1 | 0 | C, C++, Golang, Lua are all optional languages to develop a Web Application Firewall or Gateway, but django is not suitable for it.
C, C++ can develop nginx plugin or backend WAF.
Golang can develop gateway with WAF, such as Janusec Application Gateway.
Lua can extend nginx access control and work as a WAF. | 4 | 3 | 0 | I have an assignment to develop a web application firewall. I have been researching for some source codes about that.My main source was ModSecurity.
Main question is that:
-Which framework or programming language I can use, to develop a web application firewall? Which one would be the most useful?
-Can I use Django & Python?
It would be a starting point for the project research. | web application firewall development | 0 | 0 | 0 | 3,881 |
4,486,472 | 2010-12-20T02:37:00.000 | 8 | 1 | 0 | 1 | python,linux,cron,ubuntu-10.04 | 4,486,483 | 1 | true | 0 | 0 | From cron you should be running the script as script_name.py and your script meets the following criteria:
Executable bit is set
The script's hash-bang is set correctly eg. #!/usr/bin/env python
it is accessible from the PATH
e.g. place it in /usr/local/bin/ or /opt/local/bin/ (and they are accessible to your system PATH.)
If these conditions are met, you should be able to run it from anywhere on your local system as script_name.py | 1 | 6 | 0 | I have a python script that I'd like to add to cron.
The script has +x permission on it.
How shall I add it to crontab? (say, I want it to run every minute).
Important: when I navigate (using the shell) to the script's folder, I cannot run it using "./script_name.py"; it doesn't work. Yet, when I run it using "Python script_name.py", everything works. | Running a Python Script using Cron? | 1.2 | 0 | 0 | 4,736 |
4,486,481 | 2010-12-20T02:41:00.000 | 3 | 0 | 1 | 1 | python,command-line | 4,486,505 | 3 | false | 0 | 0 | You have basically two possibilities:
Use the full path to the Python interpreter when starting you program, e.g. c:\Python2.7\python.exe HelloWorld
Add the directory of the Python interpreter to your PATH environment variable. I can't tell you how to do this in Windows 7, though. | 1 | 1 | 0 | I know this is really basic but it is frustrating. I'm using Python 2 to try and create my first program (in Windows 7 64bit). Every guide I look at says to install Python2, then go to the command prompt and type python. But... I get an error, because python.exe is not in that directory. So I change to the "python27" directory, and it runs fine. But then when I want to run a program, I type python HelloWorld, but of course that doesn't work. I need to be in the directory that has both the python.exe, and the directory that has my program file.
Surely everyone does not have all of their programs in the python install directory; what am I missing? | Trying to learn programming; I suck at command prompt | 0.197375 | 0 | 0 | 330 |
4,488,570 | 2010-12-20T10:04:00.000 | 14 | 0 | 1 | 0 | python,tabs | 4,488,586 | 7 | false | 0 | 0 | It's usually \t in command-line interfaces, which will convert the char \t into the whitespace tab character.
For example, hello\talex -> hello--->alex. | 3 | 159 | 0 | Let's say I have a file. How do I write "hello" TAB "alex"? | How do I write a "tab" in Python? | 1 | 0 | 0 | 618,399 |
4,488,570 | 2010-12-20T10:04:00.000 | 26 | 0 | 1 | 0 | python,tabs | 4,488,585 | 7 | false | 0 | 0 | You can use \t in a string literal:
"hello\talex" | 3 | 159 | 0 | Let's say I have a file. How do I write "hello" TAB "alex"? | How do I write a "tab" in Python? | 1 | 0 | 0 | 618,399 |
4,488,570 | 2010-12-20T10:04:00.000 | 0 | 0 | 1 | 0 | python,tabs | 65,945,746 | 7 | false | 0 | 0 | Assume I have a variable named file that contains a file.
Then I could use file.write("hello\talex").
file.write("hello means I'm starting to write to this file.
\t means a tab
alex") is the rest I'm writing | 3 | 159 | 0 | Let's say I have a file. How do I write "hello" TAB "alex"? | How do I write a "tab" in Python? | 0 | 0 | 0 | 618,399 |
4,488,783 | 2010-12-20T10:32:00.000 | 0 | 0 | 0 | 0 | python,algorithm,social-networking,traversal,breadth-first-search | 6,335,027 | 2 | false | 0 | 0 | I have around 300 friends in facebook and some of my friends also have 300 friends on an average. If you gonna build a graph out of it , it's gonna be huge . Correct me , if I am wrong ? . A BFS will be quit lot demanding in this scenario ?
Thanks
J | 1 | 2 | 1 | I've been reading a lot of stackoverflow questions about how to use the breadth-first search, dfs, A*, etc, the question is what is the optimal usage and how to implement it in reality verse simulated graphs. E.g.
Consider you have a social graph of Twitter/Facebook/Some social networking site, to me it seems a search algorithm would work as follows:
If user A had 10 friends, then one of those had 2 friends and another 3. The search would first figure out who user A's friends were, then it would have to look up who the friends where to each of the ten users. To me this seems like bfs?
However, I'm not sure if that's the way to go about implementing the algorithm.
Thanks, | Python usage of breadth-first search on social graph | 0 | 0 | 0 | 1,271 |
4,489,683 | 2010-12-20T12:38:00.000 | 0 | 0 | 1 | 0 | python,windows,collabnet | 4,491,375 | 3 | false | 0 | 0 | Have you considered changing the Subversion Edge services to run as a specific user account, and then move the PYTHONHOME environment variable to a user-level variable for that account only? As opposed to a system-wide variable? It seems like it should work.
BTW, the PYTHONHOME variable is added for mod_python to work properly (which is what serves ViewVC). If you can find another way to get mod_python to work, then you could try that. | 3 | 5 | 0 | I'm using Python 3 for developing and CollabNet Subversion Edge as versioning software. Subversion Edge comes with a little program called ViewVC which is written in Python 2, which is also directly bundled with it. There is a system environment variable called PYTHONHOME.
If it is set to the Python 2 distribution from Subversion Edge, my Python 3 won't start (not even IDLE), instead giving a runtime error messagebox.
If it is set to Python 3, ViewVC doesn't work.
Is there a way to make both work at the same time? | Python home directory in Windows / Problem with multiple versions | 0 | 0 | 0 | 3,161 |
4,489,683 | 2010-12-20T12:38:00.000 | 3 | 0 | 1 | 0 | python,windows,collabnet | 4,490,012 | 3 | true | 0 | 0 | You shouldn't need to set PYTHONHOME at all. Python uses it (if set) to locate its installation. Typically, it should be able to locate it without this variable, as well: by looking at the path name of the python executable, and, failing that, by looking into the registry. | 3 | 5 | 0 | I'm using Python 3 for developing and CollabNet Subversion Edge as versioning software. Subversion Edge comes with a little program called ViewVC which is written in Python 2, which is also directly bundled with it. There is a system environment variable called PYTHONHOME.
If it is set to the Python 2 distribution from Subversion Edge, my Python 3 won't start (not even IDLE), instead giving a runtime error messagebox.
If it is set to Python 3, ViewVC doesn't work.
Is there a way to make both work at the same time? | Python home directory in Windows / Problem with multiple versions | 1.2 | 0 | 0 | 3,161 |
4,489,683 | 2010-12-20T12:38:00.000 | 0 | 0 | 1 | 0 | python,windows,collabnet | 4,489,838 | 3 | false | 0 | 0 | Write a .bat or cmd file that saves the value of the PYTHONHOME env var, invokes ViewVC and wait for it to finish, then restores PYTHONHOME to the saved value. | 3 | 5 | 0 | I'm using Python 3 for developing and CollabNet Subversion Edge as versioning software. Subversion Edge comes with a little program called ViewVC which is written in Python 2, which is also directly bundled with it. There is a system environment variable called PYTHONHOME.
If it is set to the Python 2 distribution from Subversion Edge, my Python 3 won't start (not even IDLE), instead giving a runtime error messagebox.
If it is set to Python 3, ViewVC doesn't work.
Is there a way to make both work at the same time? | Python home directory in Windows / Problem with multiple versions | 0 | 0 | 0 | 3,161 |
4,490,366 | 2010-12-20T14:06:00.000 | 23 | 0 | 0 | 0 | python,django,pypy | 4,490,438 | 3 | true | 1 | 0 | Unlikely. A Django application is almost always I/O-bound, usually because of the database connection. PyPy wouldn't help with that at all, even if it was purely compatible (which I'm not sure it is). | 3 | 17 | 0 | Are there some reasons of using Django with PyPy?
I read PyPy increases perfomance. | Django with PyPy | 1.2 | 0 | 0 | 8,263 |
4,490,366 | 2010-12-20T14:06:00.000 | 10 | 0 | 0 | 0 | python,django,pypy | 4,490,455 | 3 | false | 1 | 0 | Depends.
PyPy does improve performance for all benchmarks that are in the PyPy's benchmark suite. This is only template rendering for now, but noone submitted anything else. It's however safe to assume that performance critical code will be faster (especially after some tuning).
Compatibility-wise databases are a bit of an issue, because only sqlite is working and it's slow (there is a branch to fix it though). People also reported pg8000 working with sqlalchemy for example, but I don't have a first-hand experience.
Cheers,
fijal | 3 | 17 | 0 | Are there some reasons of using Django with PyPy?
I read PyPy increases perfomance. | Django with PyPy | 1 | 0 | 0 | 8,263 |
4,490,366 | 2010-12-20T14:06:00.000 | 6 | 0 | 0 | 0 | python,django,pypy | 14,871,428 | 3 | false | 1 | 0 | I have done some experimentation with PyPy + Django. There are two main issues:
Most database adaptors and other third-party modules cannot be compiled with PyPy (even when the wiki says they can).
One server I thought might benefit from JIT compilation because it did a fancy calculation in some requests had an increasing memory footprint, perhaps because the JIT was storing traces that turned out to be unique to each request so were never reused?
Theoretically PyPy might be a win if your server is doing interesting calculations, uses pure-python modules, and has large numbers of objects in-memory (because PyPy can reduce the memory used per-object in some circumstances). Otherwise the higher memory requirements of the JIT will be an impediment because it reduces opportunities for in-memory caching and may require extra servers to run enough server processes. | 3 | 17 | 0 | Are there some reasons of using Django with PyPy?
I read PyPy increases perfomance. | Django with PyPy | 1 | 0 | 0 | 8,263 |
4,490,991 | 2010-12-20T15:19:00.000 | 2 | 0 | 1 | 0 | python,3d | 4,491,082 | 4 | false | 0 | 1 | If you're solely trying to learn how to do a 3d model go for the language you're the most familiar with. I'd recommend C++ or C# in that case (whichever of the 2 you meant with the second C).
If you also want to learn more about the language Python is the better choice.
But pure language wise I wouldn't say that C++/c#/python beats the other. | 1 | 5 | 0 | I am C/C /Java programmer, but lately I have started learn Python.
Moreover I have 3D Graphics on my studies. I have to create 3D model of my apartment, with dynamic camera. I am wondering if this is a good idea to merge this two issues, by writing this 3D model in python.
However as I said, I am a python beginner, so I don't know possibilities, which python can give me in this area. Which libraries/engine will be the best for a start? | Is python is a good choice as language used to implementing my first 3D model? | 0.099668 | 0 | 0 | 425 |
4,491,434 | 2010-12-20T16:10:00.000 | 1 | 0 | 0 | 0 | python,django,web-services | 4,491,538 | 2 | false | 1 | 0 | This sounds like it should be done in a View, because then you will be returning to a template with all the required context. | 1 | 1 | 0 | Suppose I have a Django app named "blog".
There's a model called Post and I have an external API call that returns the list of the most popular posts in a given time, e.g., the Google Analytics API.
My question is: Where is the expected place that I should place the code that makes the call to the external API, parses the id from each post, query the database and sort the list of models accordingly?
I don't think that it should live in the Manager or in a templatetag. Any tips or suggestions?
Thanks in advance!
EDIT: The desired result might be need in several places across the project, so if I place the code in view, I'll have duplication. | Where to place the call to a external API that has a dependency on a Model? | 0.099668 | 0 | 0 | 625 |
4,493,761 | 2010-12-20T20:42:00.000 | 2 | 0 | 0 | 0 | python,django,datetime,django-templates | 4,499,448 | 2 | false | 1 | 0 | IMO it is cleaner to do that kind of things in a view or in a helper module, and pass it in the context. The templates are better left with no logic or the very least possible (that's the MVC pattern after all). | 1 | 1 | 0 | How do I compare dates in a Django template? I thought of several possible avenues:
Send today's date in the context to be compared at the template
Create my own template tag
Have some logic in the view to only pass the date if it's in the future
Although the last option seems easier, I rather leave the display logic in the template than in the view. I also do not want to pass something that seems so trivial like today's date in the template context.
Perhaps someone has another option or could share their implementation of one of the options I mentioned above and why they decided to go that route. | Django Templates: Display a date only if it's in the future | 0.197375 | 0 | 0 | 3,751 |
4,493,871 | 2010-12-20T20:55:00.000 | 0 | 0 | 1 | 0 | python,windows,setuptools,distribute | 4,498,345 | 2 | false | 0 | 0 | A punk/goth approach to programming probably has the right to be..
To get the C-compliation part to work on windows you either need (1) to have Visual Studio of the same version that was used to compile the python version you are using, or (2) mingw which is a bit trickier to set up. | 1 | 0 | 0 | I need to install in python 2.6 or 2.7 for windows the library PyWeka0.3dev, It says it requires setuptools, which I installed but then they told me it was a deprecated instalation library and I installed distribute, then I downloaded the PyWeka compressed package and each time I try to install it neither with setup.py nor with easy_install (where it says something like no module ez_setup). Can anybody give me a clue about how to do this? | Has anybody been able to install PyWeka? | 0 | 0 | 0 | 1,152 |
4,494,941 | 2010-12-20T23:15:00.000 | 0 | 0 | 0 | 0 | python,command-line-interface | 4,494,975 | 4 | false | 0 | 0 | Pretty much any python script can be a "command line program". What specific question do you have? | 1 | 3 | 0 | There has been a need for python command line utilities at work lately and I have no experience in writing cli's. Regardless, I must still pop them out.
My biggest hurdle is the structure of these programs. Also, the method in getting and verifying input from the user. I have been ending up with very looong while loops and I just dont think that is the most efficient approach.
Could someone provide links to open source cli programs that I may pick to gain a bit of an understanding? Or, books, tutorials, etc that I could get my hands on. I have dug around but have had little success (my google skills must be lacking). | python command line programming examples, recipes | 0 | 0 | 0 | 1,850 |
4,496,109 | 2010-12-21T03:47:00.000 | 17 | 0 | 0 | 0 | python,django,django-template-filters | 4,499,889 | 2 | false | 1 | 0 | The easiest way to test a template filter is to test it as a regular function.
@register.filter decorator doesn't harm the underlying function, you can import the filter and use just it like if it is not decorated. This approach is useful for testing filter logic.
If you want to write more integration-style test then you should create a django Template instance and check if the output is correct (as shown in Gabriel's answer). | 1 | 18 | 0 | I have a custom template filter I created under project/app/templatetags.
I want to add some regression tests for some bugs I just found. How would I go about doing so? | Testing a custom Django template filter | 1 | 0 | 0 | 2,822 |
4,496,914 | 2010-12-21T06:56:00.000 | 0 | 0 | 0 | 1 | python,hosting,shared-hosting | 4,497,237 | 4 | false | 0 | 0 | IMO it's not a standard python, but a version specifically patched for app engine. In other words you can think more or less like an "higher level" VM that however is not emulating x86 instructions but python opcodes (if you don't know what they are try writing a small function named "foo" and the doing "import dis; dis.dis(foo)" you will see the python opcodes that the compiler produced).
By patching python you can impose to it whatever limitations you like. Of course you've however to forbid the use of user supplied C/C++ extension modules as a C/C++ module will have access to everything the process can access.
Using such a virtual environment you're able to run safely python code without the need to use a separate x86 VM for every instance. | 2 | 0 | 0 | Does anybody know, how GAE limit Python interpreter? For example, how they block IO operations, or URL operations.
Shared hosting also do it in some way? | How Google App Engine limit Python? | 0 | 0 | 0 | 269 |
4,496,914 | 2010-12-21T06:56:00.000 | 1 | 0 | 0 | 1 | python,hosting,shared-hosting | 4,496,983 | 4 | true | 0 | 0 | The sandbox "internally works" by them having a special version of the Python interpreter. You aren't running the standard Python executable, but one especially modified to run on Google App engine.
Update:
And no it's not a virtual machine in the ordinary sense. Each application does not have a complete virtual PC. There may be some virtualization going on, but Google isn't saying exactly how much or what.
A process has normally in an operating system already limited access to the rest of the OS and the hardware. Google have limited this even more and you get an environment where you are only allowed to read the very specific parts of the file system, and not write to it at all, you are not allowed to open sockets and not allowed to make system calls etc.
I don't know at which level OS/Filesystem/Interpreter each limitation is implemented, though. | 2 | 0 | 0 | Does anybody know, how GAE limit Python interpreter? For example, how they block IO operations, or URL operations.
Shared hosting also do it in some way? | How Google App Engine limit Python? | 1.2 | 0 | 0 | 269 |
4,498,125 | 2010-12-21T10:10:00.000 | 1 | 0 | 0 | 0 | python,django | 4,498,355 | 3 | false | 1 | 0 | using web browser as your client platform? | 1 | 4 | 0 | I need to develop a web application with the following requirements:
Desktop like UI on the client side
Application deployment
Scalability (i.e. distributing the service on multiple servers)
What I thought of so far (as I love Python but haven't done much web development yet):
Django
Fabric (think I've read somewhere it's suited for this)
What I'm missing is:
How to create rich clients (probably need some javascript libraries for that)?
How to distribute the service? | Developing a RIA with Django - what technology stack? | 0.066568 | 0 | 0 | 3,240 |
4,498,313 | 2010-12-21T10:30:00.000 | 0 | 0 | 1 | 0 | python,twisted,zope | 11,055,554 | 2 | false | 1 | 0 | I had the same error after following the steps scrapy suggested, mainly using pip install Scrapy. In order to install some Scrapy dependencies you will need root permision, and my mistake was creating a virtualenv for my scrapy project. Maybe you will run into the same error after following the scrapy setup steps and using virtualenv. Just dont use virtualenv. | 1 | 5 | 0 | I am new in python.I installed "scrapy" but it giving error "importerror no module named zope.interface twisted".Please help me.
Thanks in advance.......... | python importerror no module named zope.interface twisted | 0 | 0 | 0 | 4,933 |
4,498,330 | 2010-12-21T10:32:00.000 | 0 | 0 | 1 | 1 | python,file | 4,499,110 | 3 | false | 0 | 0 | If the file other process has the file open and you delete it, it will not be removed from the filesystem until all processes close their handles to it.
If the other process merely needs its file handle/object to continue to work you may safely delete the file, it will be removed when the process closes its handle. If you want to be able to call open() on the file until the process has finished with it, both processes need to use locks (see fcntl.flock()). | 1 | 0 | 0 | I'm looking for some code to check if a file in the file system is available (not used by another process). How could I do it in Python? Thanks!
How I'll use it: cylically check if file is available and when it is (processes don't need it anymore) delete it. | Check if a file is available (not used by another process) in Python | 0 | 0 | 0 | 3,773 |
4,498,678 | 2010-12-21T11:20:00.000 | 4 | 0 | 0 | 0 | python,html,django,excel | 4,499,265 | 2 | true | 1 | 0 | Why don't you need xlrd? It sounds like exactly what you need.
Create a Django model with a FileField that holds the spreadsheet. Then your view uses xlrd to loop over the rows and columns and put them into an HTML table. Job done.
Possible complications: multiple sheets in one Excel file; formulas; styles. | 1 | 1 | 0 | Okay, so what I want to do is upload an excel sheet and display it on my website, in html. What are my options here ? I've found this xlrd module that allows you to read the data from spreadsheets, but I don't really need that right now. | Python/Django excel to html | 1.2 | 1 | 0 | 1,961 |
4,499,204 | 2010-12-21T12:25:00.000 | 0 | 0 | 1 | 0 | python,linux,qt4,pyqt | 4,499,868 | 2 | false | 0 | 1 | If it's really an ImportError, that suggests that it's failing to import the library altogether. Check that it's definitely somewhere that's in your sys.path, and that from PyQt4 import QtCore works.
If the library exists, and QT_VERSION_STR doesn't exist, it will give you a NameError rather than an ImportError. | 2 | 0 | 0 | I have built PyQt4 from source and everything went smoothly until I tried to use some of the classes and attributes located in QtCore. For some reason QtCore is missing a lot of functionality and data that should be there. For example from PyQt4.QtCore import QT_VERSION_STR is an import error. There were no errors or warnings given when building the packages and I have also tried with the PyQt packages from yum but I have the same problem.
Has anyone else encountered this problem before?
Thanks. | PyQt4.QtCore doesn't contain many of its classes and attributes | 0 | 0 | 0 | 856 |
4,499,204 | 2010-12-21T12:25:00.000 | 0 | 0 | 1 | 0 | python,linux,qt4,pyqt | 4,592,960 | 2 | true | 0 | 1 | The reason for this problem was a conflict in my python path. I had two modules named sip.py in different locations on my python path, the python path was using the first one but I wanted it to use the second one. I removed the first entry from the python path as it wasn't necessary. | 2 | 0 | 0 | I have built PyQt4 from source and everything went smoothly until I tried to use some of the classes and attributes located in QtCore. For some reason QtCore is missing a lot of functionality and data that should be there. For example from PyQt4.QtCore import QT_VERSION_STR is an import error. There were no errors or warnings given when building the packages and I have also tried with the PyQt packages from yum but I have the same problem.
Has anyone else encountered this problem before?
Thanks. | PyQt4.QtCore doesn't contain many of its classes and attributes | 1.2 | 0 | 0 | 856 |
4,499,483 | 2010-12-21T12:59:00.000 | 2 | 1 | 1 | 0 | python,c,mmap,cpython,memory-mapping | 4,499,674 | 1 | true | 0 | 0 | No, you're fine.
On 32-bit systems, you could run out of virtual memory, or with virtual memory fragmentation not have a single chunk big enough to map as many huge files as you want. But that pitfall isn't particular to CPython. | 1 | 1 | 0 | I'm writing a Python module in C and I intend to mmap largeish blocks of memory (perhaps 500 MB). Is there anything about working in the same process space as the Python interpreter that I should be careful of? | mmapping in Python C modules - any pitfalls to be aware of? | 1.2 | 0 | 0 | 140 |
4,499,917 | 2010-12-21T13:48:00.000 | 2 | 0 | 1 | 0 | python | 5,743,396 | 2 | false | 0 | 0 | in a command prompt go to install zope.interface 3.6.1 folder
write "SETUP.py install"
it will install | 2 | 1 | 0 | I am unable to install zope.interface 3.6.1 in Python for Windows. If any one know about this please help me? | Unable to install zope.interface 3.6.1 in python | 0.197375 | 0 | 0 | 1,920 |
4,499,917 | 2010-12-21T13:48:00.000 | 1 | 0 | 1 | 0 | python | 8,131,237 | 2 | false | 0 | 0 | You don't need to install it. After you download the file zope.interface-3.8.0-py2.7-win32.egg, you unzip it then copy the two directories EGG-INFO and zope into the Python27. It works fine. | 2 | 1 | 0 | I am unable to install zope.interface 3.6.1 in Python for Windows. If any one know about this please help me? | Unable to install zope.interface 3.6.1 in python | 0.099668 | 0 | 0 | 1,920 |
4,500,232 | 2010-12-21T14:20:00.000 | 6 | 1 | 1 | 0 | c#,java,python,performance,jit | 4,500,536 | 7 | false | 0 | 0 | People have already pointed out the technical details, so I'll add another factor: money.
In the last few years, Javascript VMs (Google's V8, Mozilla's Tracemonkey & Jaegermonkey, Apple's Nitro) have delivered a huge speed increase for another dynamic language. That's been driven in large part by Google's desire to make web apps more powerful. Python just doesn't have a big company standing to gain by making it 50x faster.
Oh, and the integration with C extensions like numpy means that speed is rarely critical for Python code, anyway. | 3 | 15 | 0 | I understand why interpretation overhead is expensive, but why are JITted Python implementations (Psyco and PyPy) still so much slower than other JITted languages like C# and Java?
Edit: I also understand that everything is an object, dynamic typing is costly, etc. However, for functions where types can be inferred, I'm not sure why this matters. | Why are JITted Python implementations still slow? | 1 | 0 | 0 | 878 |
4,500,232 | 2010-12-21T14:20:00.000 | 1 | 1 | 1 | 0 | c#,java,python,performance,jit | 4,500,345 | 7 | false | 0 | 0 | A really good question. I can't give you a complete answer, but I think one of the reasons is the "everything is objects and an object could be anything" concept. In Java, if you try "1.getClass()", it won't work unless you box it first, either explicitly or implicitly. In Python, it works out of the box. But objects are definitely more heavyweight than primitive types, which Python just doesn't seem to have.
The "an object can be anything" part is even more important. If you write "someobject.somefield" in Java, it knows at compile time what exactly is "somefield" and generates code that accesses it directly. Well, there are probably some tricks to give better binary compatibility, but that's nothing like Python, where it actually performs some sort of dictionary look-up at run time to figure out what exactly is "somefield" at that particular moment, as fields can be added and deleted dynamically.
To put it short, Python is more powerful, but that power has its cost. | 3 | 15 | 0 | I understand why interpretation overhead is expensive, but why are JITted Python implementations (Psyco and PyPy) still so much slower than other JITted languages like C# and Java?
Edit: I also understand that everything is an object, dynamic typing is costly, etc. However, for functions where types can be inferred, I'm not sure why this matters. | Why are JITted Python implementations still slow? | 0.028564 | 0 | 0 | 878 |
4,500,232 | 2010-12-21T14:20:00.000 | 0 | 1 | 1 | 0 | c#,java,python,performance,jit | 23,262,554 | 7 | false | 0 | 0 | The whole issue is not so clear anymore in 2014. Google's V8 JS engine does some pretty heavy stuff to optimize the hell out of js.
PyPy could be much faster if only enough money would be available. Python's execution speed mostly does not matter so nobody heavily invests in PyPy.
It's really not a technical issue anymore. Look at Java's InvokeDynamic instruction. Sure, those invocations cost more the first time they are called, but the JVM can do magic stuff once those invocations start to start up. That is: The JVM can do assumptions and can learn about the code while running it. If a method always returns an int, it's possible that this method always returns an int. In reality the JVM does much more.
In 2014 it's really not dynamic vs static in terms of performance. Sure C++ will always be the fastest tool around, but jitted dynamic languages are not "magnitudes" slower as they used to be a few years ago.
Wait a few more years, I bet static analysis is much stronger in 2016 or 2017. There are a few very interesting research projects running right now.
In Theory:
You can basically infer every type using static type analysis, you have to understand what the code is doing before it does it. That's not impossible.
When static analysis becomes more powerful, you really do not need a static type system anymore. All static type systems, even haskell's, limit the number of correct programs. So in essence: If you have an analyzer which can proof the correctness of a program by analyzing it is much more powerful as a static type system which only can act within boundaries. And concerning code re-usage: Nothing can beat dynamic typing.
There are a few who would say that dynamic typing is bad for large applications but if static analysis becomes more powerful, you would actually have the same or maybe much more proven correctness as a static type system could ever offer. Of course statically typed languages could also be statically analyzed, but than the static type system would be useless.
So in essence: Here are a lot of if's, i know. But 10 years ago people would have laughed if you would have told them that js becomes the so fast, that you could easily write heavy 3d opengl applications in it.
Never underestimate the future. | 3 | 15 | 0 | I understand why interpretation overhead is expensive, but why are JITted Python implementations (Psyco and PyPy) still so much slower than other JITted languages like C# and Java?
Edit: I also understand that everything is an object, dynamic typing is costly, etc. However, for functions where types can be inferred, I'm not sure why this matters. | Why are JITted Python implementations still slow? | 0 | 0 | 0 | 878 |
4,502,469 | 2010-12-21T18:11:00.000 | 4 | 1 | 0 | 1 | python,linux,subprocess | 4,502,661 | 1 | true | 0 | 0 | I would expect any speed difference between, say, os.system and os.execv and subprocess.Popen, to be swamped by the expense of starting a new process (and the context-switching needed to actually run it). Therefore I recommend using subprocess first and measuring the performance.
One possible performance consideration: os.system and subprocess.Popen(shell=True, ...) cause an extra shell process to be created. In most cases, that shell isn't necessary. It's wasteful to create it; you get twice as many processes as you need for no benefit. | 1 | 3 | 0 | What is the fastest/most efficient method to execute an executable from python? It seems to me that os.system is faster than subprocess.popen. I would like to be able to read the lines that come out of this other process, but far more important than anything else is speed. | fastest way to invoke a process from python? | 1.2 | 0 | 0 | 2,379 |
4,503,301 | 2010-12-21T19:51:00.000 | 0 | 0 | 0 | 0 | python,database-design,relational-database,object-oriented-database | 4,505,053 | 2 | false | 1 | 0 | I'm a huge Oracle booster but I think you should seriously consider NoSQL. Cassandra and other NoSQL Databases have already considered your conundrum and have smashed it down to the ground. CouchDB is another who, I believe their example code is how to store a blog. | 2 | 0 | 0 | I'm designing some custom blog software, and have run into a conundrum regarding database design. The software requires that there be multiple content types, each of which will require different entry forms and presentation templates.
My initial instinct is to create these content types as objects, then serialize them and store them in the database as JSON or YAML, with the entry forms and templates as simple strings attached to the "contentTypes" table. This seems cumbersome, however. Are there established best practices for dealing with this design? Is this a use case where I should consider an object database?
If I should be using an object database, which should I consider? I am currently working in Python and would prefer a capable Python library, but can move to Java if need be. | Storing Templates and Object-Oriented vs Relational Databases | 0 | 0 | 0 | 233 |
4,503,301 | 2010-12-21T19:51:00.000 | 2 | 0 | 0 | 0 | python,database-design,relational-database,object-oriented-database | 4,517,964 | 2 | true | 1 | 0 | Please do Not Store templates (that might be altered by a user) in a database. There's no sane way to migrate from a staging environment to production if you have to deal with doffs of database dumps. We are dumping some software right one for this very reason.
Apart from that I'd simply store the source (user editable part) in the database plus a "precompiled version" either directly in the database (for faster retrieval) or in some cache system.
I'd personally go with a set theory approach.
Store each set of content type precompiled and recompile it when edited for fast serving in a separate place (table, collection, directory, whatever)
Store the sources in a common place to make it easy to rebuild different content types (the source format really just is a special case content type)
keep the templates in a place where migration between systems (dev, staging, prod) makes migration easy | 2 | 0 | 0 | I'm designing some custom blog software, and have run into a conundrum regarding database design. The software requires that there be multiple content types, each of which will require different entry forms and presentation templates.
My initial instinct is to create these content types as objects, then serialize them and store them in the database as JSON or YAML, with the entry forms and templates as simple strings attached to the "contentTypes" table. This seems cumbersome, however. Are there established best practices for dealing with this design? Is this a use case where I should consider an object database?
If I should be using an object database, which should I consider? I am currently working in Python and would prefer a capable Python library, but can move to Java if need be. | Storing Templates and Object-Oriented vs Relational Databases | 1.2 | 0 | 0 | 233 |
4,504,470 | 2010-12-21T22:16:00.000 | 0 | 1 | 1 | 0 | c++,python,c,configuration-files | 4,504,547 | 4 | false | 0 | 0 | Use a plain human readable format such as XML, and then obfuscate that to make it uneditable (i.e. encrypt the whole thing and store a hash somewhere and fail to load if its' been messed with).
Otherwise you just have to bite the bullet and write a spec for the binary format that'll be exchanged between the two programs. | 3 | 2 | 0 | I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.
The only prerequisite of this configuration file is that it can't be human readable.
Anyone have any suggestions on what file format I should use for this project?
Edit: The file can't be human readable because we don't want the user to be able to modify the configuration, also, in some cases, we don't want the user to know about certain configurations. | Shared configuration file format between python and C? | 0 | 0 | 0 | 754 |
4,504,470 | 2010-12-21T22:16:00.000 | 1 | 1 | 1 | 0 | c++,python,c,configuration-files | 4,504,538 | 4 | false | 0 | 0 | Probably easiest to use XML, then obfuscate it with a simple cypher or encryption with a fixed key. | 3 | 2 | 0 | I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.
The only prerequisite of this configuration file is that it can't be human readable.
Anyone have any suggestions on what file format I should use for this project?
Edit: The file can't be human readable because we don't want the user to be able to modify the configuration, also, in some cases, we don't want the user to know about certain configurations. | Shared configuration file format between python and C? | 0.049958 | 0 | 0 | 754 |
4,504,470 | 2010-12-21T22:16:00.000 | 2 | 1 | 1 | 0 | c++,python,c,configuration-files | 4,505,256 | 4 | false | 0 | 0 | How secure do you need this config file to be?
There is no absolute security, you'll quickly run into DRM like issues (allow users to open a file but not allow them to open it ... I know it's insane).
Often simple obfuscation is quite effective. Dump the config to a JSON file (please don't use xml). XOR the contents and change the extension. That will stop all casual inspection of the file. Obviously don't document that this is your obfuscation procedure.
If you're worried about user modification of config files (you don't care if the configs are readable you just want prevent loading custom configs) use a cryptographic signature. Store the private key at your company and use it and the python app to generate a signed configuration. Store the public key in the c++ application and use it to verify the config is properly signed before applying the settings. | 3 | 2 | 0 | I'm looking to implement a shared configuration file that will be written (output) in python, but be read (input) in C.
The only prerequisite of this configuration file is that it can't be human readable.
Anyone have any suggestions on what file format I should use for this project?
Edit: The file can't be human readable because we don't want the user to be able to modify the configuration, also, in some cases, we don't want the user to know about certain configurations. | Shared configuration file format between python and C? | 0.099668 | 0 | 0 | 754 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.