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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7,890,810 | 2011-10-25T14:25:00.000 | 3 | 0 | 0 | 0 | python,django,django-models | 7,891,949 | 3 | true | 1 | 0 | TBH for a shoe size field I'd probably use a CharField with choices attribute - there are a relatively small number of valid shoe sizes and that way you can format them how you want to.
If it's part of a Product model that may contain things other than shoes, a CharField for 'size' is useful because you can also store ... | 1 | 1 | 0 | I am creating an app that basically stores shoe sizes, along with other information. I have been using the Django Decimal field to store the sizes, however the decimal field stores sizes like 10 as 10.0, so my question is, is there a way to make or if already exists a field that when provided an int ( 10 ) it stores th... | django smart decimal field | 1.2 | 0 | 0 | 1,215 |
7,891,586 | 2011-10-25T15:19:00.000 | 3 | 0 | 0 | 0 | java,python,numpy,jython | 7,892,106 | 3 | true | 1 | 0 | If you're using Numpy you probably have to just use C Python, as it's a compiled extension. I'd recommend saving the image to disk, perhaps as a temporary file, and then calling the Python as a subprocess. If you're dealing with binary data you could even try memory mapping the data in Java and passing in in the path t... | 1 | 1 | 1 | In a java application I need to use a specific image processing algorithm that is currently implemented in python.
What would be the best approach, knowing that this script uses the Numpy library ?
I alreayd tried to compile the script to java using the jythonc compiler but it seems that it doesn't support dependencies... | Run python script (with numpy dependency) from java | 1.2 | 0 | 0 | 2,255 |
7,894,472 | 2011-10-25T19:05:00.000 | 7 | 0 | 1 | 0 | python,filesystems,directory-traversal | 7,894,533 | 2 | false | 0 | 0 | os.walk to go over files in the directory and its sub-directories, recursively
os.rename to rename them
The encoding of the files pays no role here, I think. You can, of course, detect their extension (use os.path.splitext for that) and do something based on it, but as long as you just need to rename files (i.e. manip... | 1 | 5 | 0 | I have a directory of music that has album folders as well as individual songs on each level. How can I traverse all of these files that also are encoded in different formats(mp3, wav etc)? In addition is there a way I can rename them to a format that is more consistent to my liking using regular expressions?
Thanks | How to loop through files and rename them in Python | 1 | 0 | 0 | 3,359 |
7,898,489 | 2011-10-26T03:37:00.000 | 1 | 0 | 0 | 0 | python,user-interface,wxpython,tkinter | 7,900,401 | 5 | false | 0 | 1 | If your software is mostly about the complicated processing, with a fairly simple UI, tkinter is probably fine | 3 | 1 | 0 | I am making programs that solve and show work for math problems. I would like to add a GUI, and I think wxPython will be best. If I use wxPython for the GUI, will the end user need wxPython on their computer in order to use the program with the GUI? If not, what would should I use?
These apps will be used on mostly Wi... | Is wxPython Needed on the End User's Computer | 0.039979 | 0 | 0 | 469 |
7,898,489 | 2011-10-26T03:37:00.000 | 0 | 0 | 0 | 0 | python,user-interface,wxpython,tkinter | 7,903,064 | 5 | false | 0 | 1 | Tkinter comes with Python, so it can be handier in some respects just because of that. On the other hand, wxPython uses the native widgets of the OS (which has it's own set of pros and cons). I personally prefer wxPython. But no, Tkinter is not dead to my knowledge.
You can use py2exe to bundle up your app on Windows o... | 3 | 1 | 0 | I am making programs that solve and show work for math problems. I would like to add a GUI, and I think wxPython will be best. If I use wxPython for the GUI, will the end user need wxPython on their computer in order to use the program with the GUI? If not, what would should I use?
These apps will be used on mostly Wi... | Is wxPython Needed on the End User's Computer | 0 | 0 | 0 | 469 |
7,898,489 | 2011-10-26T03:37:00.000 | 0 | 0 | 0 | 0 | python,user-interface,wxpython,tkinter | 13,719,743 | 5 | false | 0 | 1 | PyInstaller.
install and run.
cmd -> python pyinstaller.py NAMEOFSCRIPT.py --onefile --noconsole.
easy as 123. | 3 | 1 | 0 | I am making programs that solve and show work for math problems. I would like to add a GUI, and I think wxPython will be best. If I use wxPython for the GUI, will the end user need wxPython on their computer in order to use the program with the GUI? If not, what would should I use?
These apps will be used on mostly Wi... | Is wxPython Needed on the End User's Computer | 0 | 0 | 0 | 469 |
7,899,732 | 2011-10-26T07:18:00.000 | 4 | 0 | 1 | 1 | python,ide | 7,899,770 | 4 | false | 0 | 0 | U can use eclipse. but u need to download pydev addon for that. | 1 | 43 | 0 | I am new to python and I am using simple gedit application on linux machine to write python code, however its very difficult to manage the indentations of my code. I am looking for any Python IDEs that provides some functionality and should not slow down my P4 machine. | Which is the best IDE for Python For Windows | 0.197375 | 0 | 0 | 401,989 |
7,901,853 | 2011-10-26T11:15:00.000 | 1 | 0 | 0 | 0 | python,arrays,sqlite,numpy,scipy | 12,100,118 | 4 | false | 0 | 0 | This looks a bit older but is there any reason you cannot just do a fetchall() instead of iterating and then just initializing numpy on declaration? | 1 | 6 | 1 | The most common SQLite interface I've seen in Python is sqlite3, but is there anything that works well with NumPy arrays or recarrays? By that I mean one that recognizes data types and does not require inserting row by row, and extracts into a NumPy (rec)array...? Kind of like R's SQL functions in the RDB or sqldf lib... | NumPy arrays with SQLite | 0.049958 | 1 | 0 | 7,905 |
7,904,055 | 2011-10-26T14:21:00.000 | 1 | 0 | 0 | 0 | python,opencv,computer-vision,motion-detection | 9,572,786 | 1 | false | 0 | 0 | You can try the very basic but so effective and fast solution:
on the upper half of the image:
canny edge detection
morphologyEx with adequate Structuring element(also simple combination of erode/dilate may be enough)
convert to BW using adaptive threshold
Xor the result with a mask representing the expected covered a... | 1 | 1 | 1 | I want to use openCV to detect when a person raises or lowers a hand or both hands. I have looked through the tutorials provided by python opencv and none of them seem to do the job. There is a camera that sits in front of the 2 persons, about 50cm away from them(so you see them from the waist up). The person is able t... | Detect Hand using OpenCV | 0.197375 | 0 | 0 | 3,058 |
7,904,445 | 2011-10-26T14:49:00.000 | 0 | 0 | 1 | 0 | python,math,integer,python-2.x,integer-division | 31,426,085 | 5 | false | 0 | 0 | / is used for floating point division
// is used for integer division(returns a whole number)
And python rounds the result down | 3 | 6 | 0 | I'm confused about the following integer math in python:
-7/3 = -3 since (-3)*3 = -9 < -7. I understand.
7/-3 = -3 I don't get how this is defined. (-3)*(-3) = 9 > 7. In my opinion, it should be -2, because (-3)*(-2) = 6 < 7.
How does this work? | Integer division in Python | 0 | 0 | 0 | 1,130 |
7,904,445 | 2011-10-26T14:49:00.000 | 0 | 0 | 1 | 0 | python,math,integer,python-2.x,integer-division | 7,904,499 | 5 | false | 0 | 0 | Python rounds down.
7/3 = 2 (2+1/3)
-7/3 = -3 (-2+1/3) | 3 | 6 | 0 | I'm confused about the following integer math in python:
-7/3 = -3 since (-3)*3 = -9 < -7. I understand.
7/-3 = -3 I don't get how this is defined. (-3)*(-3) = 9 > 7. In my opinion, it should be -2, because (-3)*(-2) = 6 < 7.
How does this work? | Integer division in Python | 0 | 0 | 0 | 1,130 |
7,904,445 | 2011-10-26T14:49:00.000 | 1 | 0 | 1 | 0 | python,math,integer,python-2.x,integer-division | 7,904,604 | 5 | false | 0 | 0 | Expanding on the answers from aix and robert.
The best way to think of this is in terms of rounding down (towards minus infinity) the floating point result:
-7/3 = floor(-2.33) = -3
7/-3 = floor(-2.33) = -3 | 3 | 6 | 0 | I'm confused about the following integer math in python:
-7/3 = -3 since (-3)*3 = -9 < -7. I understand.
7/-3 = -3 I don't get how this is defined. (-3)*(-3) = 9 > 7. In my opinion, it should be -2, because (-3)*(-2) = 6 < 7.
How does this work? | Integer division in Python | 0.039979 | 0 | 0 | 1,130 |
7,905,904 | 2011-10-26T16:39:00.000 | 7 | 0 | 1 | 0 | python,debugging,pdb | 7,905,927 | 4 | false | 0 | 0 | If a is your object, use dir(a) to get a list of its symbols. See the documentation about the dir function for more information. | 3 | 43 | 0 | I try to list all the attributes of an object in Python pdb.
Let's say I want to list all the attributes and all methods of sys.stderr.
How can I do that? | How do I list all the attributes of an object in python pdb? | 1 | 0 | 0 | 47,695 |
7,905,904 | 2011-10-26T16:39:00.000 | 61 | 0 | 1 | 0 | python,debugging,pdb | 7,905,945 | 4 | true | 0 | 0 | For pdb, you should be able to do p dir(a). | 3 | 43 | 0 | I try to list all the attributes of an object in Python pdb.
Let's say I want to list all the attributes and all methods of sys.stderr.
How can I do that? | How do I list all the attributes of an object in python pdb? | 1.2 | 0 | 0 | 47,695 |
7,905,904 | 2011-10-26T16:39:00.000 | 6 | 0 | 1 | 0 | python,debugging,pdb | 44,451,545 | 4 | false | 0 | 0 | print dir(object_name) will list all the attributes of object for you. | 3 | 43 | 0 | I try to list all the attributes of an object in Python pdb.
Let's say I want to list all the attributes and all methods of sys.stderr.
How can I do that? | How do I list all the attributes of an object in python pdb? | 1 | 0 | 0 | 47,695 |
7,908,800 | 2011-10-26T20:52:00.000 | 1 | 0 | 0 | 0 | python,algorithm,random | 7,917,373 | 6 | false | 0 | 0 | Blocked Gibbs sampling is pretty simple and converges to the right distribution (this is along the lines of what Alexandre is proposing).
For all i, initialize ai = A / n and bi = B / n.
Select i ≠ j uniformly at random. With probability 1/2, update ai and aj with uniform random values satisfying the constraints. The ... | 3 | 12 | 1 | I am faced with the following programming problem. I need to generate n (a, b) tuples for which the sum of all a's is a given A and sum of all b's is a given B and for each tuple the ratio of a / b is in the range (c_min, c_max). A / B is within the same range, too. I am also trying to make sure there is no bias in the... | Generating random numbers under very specific constraints | 0.033321 | 0 | 0 | 2,895 |
7,908,800 | 2011-10-26T20:52:00.000 | 2 | 0 | 0 | 0 | python,algorithm,random | 7,908,987 | 6 | true | 0 | 0 | Start by generating as many identical tuples, n, as you need:
(A/n, B/n)
Now pick two tuples at random. Make a random change to the a value of one, and a compensating change to the a value of the other, keeping everything within the given constraints. Put the two tuples back.
Now pick another random pair. This times... | 3 | 12 | 1 | I am faced with the following programming problem. I need to generate n (a, b) tuples for which the sum of all a's is a given A and sum of all b's is a given B and for each tuple the ratio of a / b is in the range (c_min, c_max). A / B is within the same range, too. I am also trying to make sure there is no bias in the... | Generating random numbers under very specific constraints | 1.2 | 0 | 0 | 2,895 |
7,908,800 | 2011-10-26T20:52:00.000 | 2 | 0 | 0 | 0 | python,algorithm,random | 7,908,989 | 6 | false | 0 | 0 | I think the simplest thing is to
Use your favorite method to throw n-1 values such that \sum_i=0,n-1 a_i < A, and set a_n to get the right total. There are several SO question about doing that, though I've never seen a answer I'm really happy with yet. Maybe I'll write a paper or something.
Get the n-1 b's by throwing... | 3 | 12 | 1 | I am faced with the following programming problem. I need to generate n (a, b) tuples for which the sum of all a's is a given A and sum of all b's is a given B and for each tuple the ratio of a / b is in the range (c_min, c_max). A / B is within the same range, too. I am also trying to make sure there is no bias in the... | Generating random numbers under very specific constraints | 0.066568 | 0 | 0 | 2,895 |
7,909,527 | 2011-10-26T22:08:00.000 | 0 | 0 | 0 | 0 | python,django,dos,recover | 7,909,570 | 2 | false | 1 | 0 | You should stop your screen-scraping software if you have not already.
Depending on what part of the system is down (Either the database, the server, the network or all), there is a chance it will recover by itself when the loads come back down.
If your application cannot sustain 250 simultaneous connections, you will ... | 2 | 2 | 0 | I'm in a rather peculiar situation right now. To make a long story short, I'm part of a (real life) volunteer organization of about 2000 members. Our current website was built and maintained by a member who is no longer part of the organization (he quit). Unfortunately, he was the only one that actually had access t... | Will a website recover from a Denial of Service attack on its own? | 0 | 0 | 0 | 702 |
7,909,527 | 2011-10-26T22:08:00.000 | 1 | 0 | 0 | 0 | python,django,dos,recover | 7,909,619 | 2 | true | 1 | 0 | More than likely the system is not truly down for good, unless the guy might have gotten pissed or the hosting provider, etc disabled it due to the traffic load. But there are a number of things to think of. But 250 connections isn't that much load, even for a shared hosting account, unless you were just flooding the... | 2 | 2 | 0 | I'm in a rather peculiar situation right now. To make a long story short, I'm part of a (real life) volunteer organization of about 2000 members. Our current website was built and maintained by a member who is no longer part of the organization (he quit). Unfortunately, he was the only one that actually had access t... | Will a website recover from a Denial of Service attack on its own? | 1.2 | 0 | 0 | 702 |
7,909,666 | 2011-10-26T22:23:00.000 | 3 | 1 | 1 | 0 | c++,python,c | 7,909,723 | 2 | false | 0 | 1 | You're looking at this wrong. What's your goal? If your goal is to "learn a language" then you are wasting your time. That is like investing your time into learning to use photoshop with no ambition to ever create any neato graphics.
Instead of focusing on the tool, focus on what you want to do with it. If I learn ... | 1 | 2 | 0 | I will admit that starting programming on your own as a newbie can seem a bit daunting. However after toying around very basically in both Python and currently C++ I'm wondering if C may be more suitable for a hobbyist. By hobbyist I mean someone who foresees no real future in actually programming for a living but rath... | Learning programming as a hobbyist... the merits of C vs C++ | 0.291313 | 0 | 0 | 784 |
7,909,761 | 2011-10-26T22:36:00.000 | 4 | 0 | 1 | 0 | python,numpy | 7,909,874 | 3 | true | 0 | 0 | find where numpy is installed on your system. For me, it's here:
/usr/lib/pymodules/python2.7
import it explicitly before importing numpy
import sys
sys.path.append('/usr/lib/pymodules/python2.7')
... if you need help finding the correct path, check the contents of sys.path while using your python interpreter
import s... | 3 | 3 | 1 | I have an .x3d code which references a python script. I am trying to implement certain functions which make use of the numpy module. However, I am only able to import the builtin modules from Python.
I am looking for a way to import the numpy module into the script without having to call the interpreter (i.e. "test.py"... | Python - Run numpy without the python interpreter | 1.2 | 0 | 0 | 1,209 |
7,909,761 | 2011-10-26T22:36:00.000 | 3 | 0 | 1 | 0 | python,numpy | 7,909,895 | 3 | false | 0 | 0 | I'm going to guess that your #! line is pointing to a different python interpreter then the one you use normally. Make sure they point to the same one. | 3 | 3 | 1 | I have an .x3d code which references a python script. I am trying to implement certain functions which make use of the numpy module. However, I am only able to import the builtin modules from Python.
I am looking for a way to import the numpy module into the script without having to call the interpreter (i.e. "test.py"... | Python - Run numpy without the python interpreter | 0.197375 | 0 | 0 | 1,209 |
7,909,761 | 2011-10-26T22:36:00.000 | 1 | 0 | 1 | 0 | python,numpy | 7,909,774 | 3 | false | 0 | 0 | Add the num.py libraries to sys.path before you call import | 3 | 3 | 1 | I have an .x3d code which references a python script. I am trying to implement certain functions which make use of the numpy module. However, I am only able to import the builtin modules from Python.
I am looking for a way to import the numpy module into the script without having to call the interpreter (i.e. "test.py"... | Python - Run numpy without the python interpreter | 0.066568 | 0 | 0 | 1,209 |
7,910,445 | 2011-10-27T00:19:00.000 | 3 | 0 | 1 | 0 | python | 7,910,491 | 1 | true | 0 | 0 | All you've said you want to do with these strings is collect them in order, and then print them out in order. Based on that, a list sounds totally reasonable. | 1 | 1 | 0 | I am planning to break a long document in various strings, and save them as they are (so each string can have different length, i will not break them to strings with specific length).
I was planning to use an array, so as i scroll trough the document, i can just add each string to a position of the array and increment ... | python: best data structure to use to store strings? | 1.2 | 0 | 0 | 1,912 |
7,911,467 | 2011-10-27T03:36:00.000 | 2 | 0 | 1 | 0 | python,logging | 7,911,506 | 2 | true | 0 | 0 | The usual technique is to use a try/except Exception at the highest level call (the main function). This pretty much assures that you will not have "missed some". Exception matches non-exiting exceptions, so it is casting a broad net. | 1 | 0 | 0 | I have a python script running in background, and I want to log all the exception and output to a log file.
I know to use logging module and try.. catch.. to log exception, but what if I missed some, is there any way to log these exceptions too? | how to log background python script's output if some exception is not catched | 1.2 | 0 | 0 | 1,417 |
7,912,140 | 2011-10-27T05:50:00.000 | 1 | 0 | 0 | 0 | python,django,web-applications,ubuntu | 7,912,158 | 4 | false | 1 | 0 | How about using some free statistics provider like Statcounter or Google Analytics? | 2 | 0 | 0 | I have a django application hosted on a server running on Apache + Ubuntu. I deployed the application using mod_wsgi. Is there any way to find out the number of visitors to my web site.
I realize that this query might have little to do with django and more do with the server. Any help would be appreciated. | How do I find the number of visitors to my web hosted django application? | 0.049958 | 0 | 0 | 307 |
7,912,140 | 2011-10-27T05:50:00.000 | 1 | 0 | 0 | 0 | python,django,web-applications,ubuntu | 7,912,159 | 4 | true | 1 | 0 | Why not just use Google Analytics? You can easily monitor user behavior, traffic source, time spend on each page, etc.
If you really want to do this with Django you could write a context processor to record each request, but then you would have to write the user's IP and check if the user has not visited before and thi... | 2 | 0 | 0 | I have a django application hosted on a server running on Apache + Ubuntu. I deployed the application using mod_wsgi. Is there any way to find out the number of visitors to my web site.
I realize that this query might have little to do with django and more do with the server. Any help would be appreciated. | How do I find the number of visitors to my web hosted django application? | 1.2 | 0 | 0 | 307 |
7,913,999 | 2011-10-27T09:25:00.000 | 4 | 0 | 0 | 0 | python,django,turbogears,genshi | 9,769,018 | 2 | true | 1 | 0 | You have three possible solutions to achieve this.
First you can use tg.tmpl_context which is available inside every template as tmpl_context.
You can fill the variables inside the BaseController.__call__ so that they are available everywhere.
Another approach is to register base_config.variable_provider inside app_cf... | 1 | 0 | 0 | Is there any analog of django context processors in turbogears2?
In tg1 was stdvars, but not in tg2 anymore.
Explaining:
I need to have some template tags, avaible on each page, without obvious declaring in each controller. | Turbogears2: analog of django context processors | 1.2 | 0 | 0 | 198 |
7,914,505 | 2011-10-27T10:14:00.000 | 0 | 0 | 1 | 1 | python,cross-platform,environment-variables,distutils | 7,930,947 | 2 | false | 0 | 0 | Distutils doesn’t set environment variables. On Windows, this would imply mucking with the registry; on UNIX, it would require to find out the right shell configuration file (which is not trivial) and edit it, which is just not done in this culture: people are told to edit their $PATH or to use full paths to the progr... | 1 | 0 | 0 | Is that possible to modify PATH environment variable, globally and permanently, in a platform-independent way using Python (distutils)?
Background
I have some application (a plugin for Serna XML Editor), and now I'm going to make an installer for it, probably using python distutils (setup.py). After the installation se... | Modify `PATH` environment variable globally and permanently using Python | 0 | 0 | 0 | 2,054 |
7,917,107 | 2011-10-27T14:07:00.000 | 17 | 0 | 1 | 0 | python,matplotlib | 7,918,549 | 2 | true | 0 | 0 | One way would be just use plt.text(x,y,'text') | 1 | 26 | 1 | I couldn't find the right function to add a footnote in my plot.
The footnote I want to have is something like an explanation of one item in the legend, but it is too long to put in the legend box. So, I'd like to add a ref number, e.g. [1], to the legend item, and add the footnote in the bottom of the plot, under the ... | Add footnote under the x-axis using matplotlib | 1.2 | 0 | 0 | 42,816 |
7,918,395 | 2011-10-27T15:32:00.000 | 1 | 0 | 1 | 1 | python,subprocess,parallel-processing | 7,918,418 | 1 | false | 0 | 0 | If the subprocess is really capable of multicore operation, it shouldn't matter how you spawn it. You don't (and generally, can't) "request" more cores for it -- the OS will automatically give it whatever resources are available.
I suspect the answer lies with the commercial program in question rather than with the par... | 1 | 0 | 0 | I have code that calls a commercial program to run as a subprocess using the subprocess module.
The commercial program is capable of running in parallel, but I have noticed that only 1 processor is being used when the subprocess is running.
Is there a simple way to run a serial python program that requests more resou... | python calling a subprocess that runs in parallel | 0.197375 | 0 | 0 | 245 |
7,918,718 | 2011-10-27T15:54:00.000 | 11 | 0 | 0 | 0 | python,r,pdf,screen-scraping | 7,918,885 | 4 | true | 1 | 0 | Extracting text from PDFs is hard, and nearly always requires lots of care.
I'd start with the command line tools such as pdftotext and see what they spit out. The problem is that PDFs can store the text in any order, can use awkward font encodings, and can do things like use ligature characters (the joined up 'ff' and... | 1 | 10 | 0 | I have been using the XML package successfully for extracting HTML tables but want to extend to PDF's. From previous questions it does not appear that there is a simple R solution but wondered if there had been any recent developments
Failing that, is there some way in Python (in which I am a complete Novice) to obtai... | PDF scraping using R | 1.2 | 0 | 1 | 4,014 |
7,919,133 | 2011-10-27T16:23:00.000 | 4 | 0 | 0 | 0 | algorithm,python,duck-typing,typechecking | 7,919,388 | 3 | true | 0 | 0 | The duck-typing solution is by far more Pythonic. However, rather than testing the argument to see whether it's an ID or an edge, just treat it as if it were the more common case first, and if that doesn't work, try it the other way.
If you do use explicit type-checking, which is sometimes the only way, use isintance()... | 1 | 4 | 0 | So, another question on what is Pythonic! The application domain in this case is network algorithms (as in, nodes, edges, Dijkstra, that kind of thing...), something I have only previously coded in strongly typed languages where we can be very certain what everything is.
Meanwhile in Python, I've got a class Net; a si... | Pythonic way to handle a method on network data structure | 1.2 | 0 | 0 | 105 |
7,919,968 | 2011-10-27T17:34:00.000 | 0 | 0 | 0 | 0 | python,django,wsgi,django-wsgi | 7,925,410 | 3 | false | 1 | 0 | I've worked a bit with some django "apps" ,its really easy, but setting up the "apps" can be a bit of a long process. Django has a lot of nice features that you won't be using and I agree that you might be on one "extreme" here. | 1 | 4 | 0 | I'm in the process of setting up a new web app and deciding whether to just do it with WSGI or go the full framework route with Django.
The app's foremost requirements:
1) The app has no UI what so ever and all of the data is exposed to clients via a REST api with JSON.
2) It will have data to persist so MongoDB & pr... | Deciding to WSGI or Django for new web app | 0 | 0 | 0 | 213 |
7,922,487 | 2011-10-27T21:14:00.000 | 0 | 0 | 0 | 0 | python,numpy,scipy,sparse-matrix | 33,510,117 | 4 | false | 0 | 0 | As for the inverse, the function is inv(A), but I won't recommend using it, since for huge matrices it is very computationally costly and unstable. Instead, you should use an approximation to the inverse, or if you want to solve Ax = b you don't really need A-1. | 1 | 102 | 1 | For SciPy sparse matrix, one can use todense() or toarray() to transform to NumPy matrix or array. What are the functions to do the inverse?
I searched, but got no idea what keywords should be the right hit. | How to transform numpy.matrix or array to scipy sparse matrix | 0 | 0 | 0 | 141,998 |
7,924,499 | 2011-10-28T02:24:00.000 | 0 | 0 | 0 | 0 | python,api,twitter,streaming,pycurl | 7,928,557 | 1 | false | 0 | 0 | Do you get an exception or something and could you please add some code? :)
Maybe you should think about using another module like httplib (if you want to
use SSL/TLS you could create a new socket and overwrite the connect function of httplib with
your secure wrapped socket :) ) | 1 | 0 | 0 | I'm using pycurl to crawl data from the Twitter Streaming API. However, after several hours, the connection just hangs there.
Is there anyway to detect this and exit the program? I know pycurl has TIMEOUT and CONNECTTIMEOUT, but these two params do not apply. | Python pycurl with Twitter Streaming API | 0 | 0 | 1 | 478 |
7,929,014 | 2011-10-28T12:06:00.000 | 1 | 0 | 0 | 0 | javascript,python,django | 7,929,052 | 2 | false | 1 | 0 | Most sites that do something like this implement it with a second form where you attach the file. Doing the upload via ajax means you do need to store the file on your server for some amount of time, and then your original form just needs a reference to that file so you know when you're done with it.
Then you just need... | 2 | 0 | 0 | I have a form with "subject", "body" and "file" fields on some page on my Django site.
If "subject" and/or "body" parameters exist in GET, I pre-fill them in the form from server side.
I want to do the same with "file" field - more exactly, I want if there is an "URL" parameter in request.GET, take the file from this U... | Pre-fill a form with attached file taken from some URL in Django | 0.099668 | 0 | 0 | 851 |
7,929,014 | 2011-10-28T12:06:00.000 | 1 | 0 | 0 | 0 | javascript,python,django | 7,929,043 | 2 | true | 1 | 0 | You can't pre-fill a file field. But I don't think you need to use one at all, since you're getting the file from a URL, not from the user's local machine. Just use a normal text field for the URL, and get the file server-side (eg using urllib) after the form is submitted. | 2 | 0 | 0 | I have a form with "subject", "body" and "file" fields on some page on my Django site.
If "subject" and/or "body" parameters exist in GET, I pre-fill them in the form from server side.
I want to do the same with "file" field - more exactly, I want if there is an "URL" parameter in request.GET, take the file from this U... | Pre-fill a form with attached file taken from some URL in Django | 1.2 | 0 | 0 | 851 |
7,930,526 | 2011-10-28T14:23:00.000 | -4 | 0 | 0 | 0 | python,django,django-authentication,django-registration | 7,937,107 | 2 | false | 1 | 0 | You should use the same decorator @login_required, django-registration uses that too. | 1 | 9 | 0 | django.contrib.auth has an awesome feature: When you try to access a page that's decorated by login_required, you get redirected to the login page with a next argument, so after you login you get redirected back to the page you were originally trying to access. That's good for the user flow.
But, apparently django-regi... | Getting `django-registration` to send you to the page you were originally trying to visit | -1 | 0 | 0 | 2,566 |
7,931,936 | 2011-10-28T16:15:00.000 | 0 | 0 | 0 | 1 | python,google-app-engine | 7,934,948 | 1 | true | 1 | 0 | Unfortunately this is not possible, there is no API that you can use for this.
Looking at the App Engine roadmap there is no such feature coming along any time soon.
The only thing i can recommend is you sign up for billing and recieve the 50$ free quota, it's here till 31 october. You can enable billing and disable it... | 1 | 0 | 0 | I am thinking about implementing resource throttling in my application in google app engine.
My idea is checking whether I am running out of resources (for example, bandwidth) and disabling part of the website, using the final part of the available daily traffic to inform the user that the site is running in a "resourc... | get amount of used resources in app engine | 1.2 | 0 | 0 | 34 |
7,932,623 | 2011-10-28T17:22:00.000 | 0 | 0 | 1 | 0 | python,fortran,fortran90,gfortran,f2py | 7,935,295 | 1 | true | 0 | 0 | It seems that the intel svml lib has been changed quite a bit, I tried various ways and option/flags but ended up not solving the problem at all, but after I upgraded intel fortran compiler from 9.1 to 12.0, it disappeared and now everything works like a charm. | 1 | 0 | 0 | I am using f2py and Intel fortran compiler to wrap some fortran code which calls some math library like dexp and dpow.
The compilation went smoothly without reporting any err, but when I attempted to run the wrapped python modules, the error prompts up:
ImportError: /usr/lib/python2.7/site-packages/foo/foo.so: undefi... | undefined symbol: vmldExp2 | 1.2 | 0 | 0 | 213 |
7,937,928 | 2011-10-29T09:04:00.000 | 3 | 0 | 0 | 0 | python,sockets,streaming,ipv6,multicast | 7,939,658 | 1 | false | 0 | 0 | You DO want to use datagrams, as with multicast there are multiple receivers and a stream socket will not work.
You need to send your data in small chunks (datagrams) and state in each which part of the stream it is so receivers can detect lost (and reordered) datagrams.
Instead of inventing a new mechanism for identif... | 1 | 0 | 0 | I need some help in implementing Multicast Streaming server over IPv6 preferably in Python. I am able to do so with Datagram servers but since I need to send large amounts of data (images and videos) over the connection, I get an error stating , data too large to send.
Can any one tell me how do I implement a Streamin... | How do I create a multicast stream socket over IPv6 in Python? | 0.53705 | 0 | 1 | 570 |
7,938,297 | 2011-10-29T10:29:00.000 | 11 | 0 | 1 | 0 | python | 7,938,303 | 1 | true | 0 | 0 | You can use foo or '', but in case foo is any other falsy value (0, an empty list, etc.) it will result in an empty string, too.
Another way would be '' if foo is None else foo | 1 | 1 | 0 | Something my string var is equal to None.
I don't want to have if statements to verify the value. Is there any simple way (like str(my_var)) which will return string value if this is not None and '' if None? | Is there any function to convert None to empty string? | 1.2 | 0 | 0 | 2,014 |
7,938,889 | 2011-10-29T12:27:00.000 | 2 | 0 | 1 | 0 | python,python-3.x | 7,938,963 | 1 | true | 0 | 0 | You could have "config" module, which parses the options into a global variable (in that same module) which you then include in all places where you need it.
Admittedly though, I do agree with delnan's comment, avoid globals if it's possible as in general it will push you to design better code. Personally I don't find ... | 1 | 0 | 0 | I like to parse parameters, vars by using configparser. However, I have to
pass the instance to every .py, in order to get the parameters.
What is the most elegant way to make the parameters visible to every .py ?
Thanks! | How do I make the parameters parsed by configparser visible to every .py | 1.2 | 0 | 0 | 76 |
7,939,069 | 2011-10-29T13:02:00.000 | 0 | 0 | 0 | 0 | java,python,webkit,rendering,server-side | 51,939,389 | 1 | false | 1 | 0 | If you want to process (execute) the javascript on headless server to generate the HTML snapshot, try using a tool like Selenium.
Selenium will allow you to fully render the HTML webpage on server side and then you can use the generated HTML to make a snapshot. | 1 | 1 | 0 | I am looking for a library in Python OR Java that can use webkit or similar rendering engine on the server side (without GUI) and return the DOM object for further processing like selecting the elements etc. | Python or Java module to render HTML page on server side and obtain DOM object | 0 | 0 | 1 | 412 |
7,940,745 | 2011-10-29T18:13:00.000 | 1 | 0 | 0 | 0 | python,apache,wsgi,flask | 7,942,317 | 1 | false | 1 | 0 | Are you sure the error is actually coming from Flask if you are getting a generic Apache 500 error page? You should look in the Apache error log to see what error messages are in there first. The problem could be configuration or your WSGI script file being wrong or failing due to wrong sys.path etc. | 1 | 2 | 0 | I am running Ubuntu, Flask 0.8, mod_wsgi 3 and apache2. When an error occurs, I am unable to get Flask's custom 500 error page to trigger (and not the debug mode output either). It works fine when I run it without WSGI via app.run(debug=True).
I've tried setting WSGIErrorOverride to both On and Off in apache settings... | Using Python Flask, mod_wsgi, apache2 - unable to get custom 500 error page | 0.197375 | 1 | 0 | 873 |
7,940,848 | 2011-10-29T18:33:00.000 | 0 | 0 | 0 | 0 | python,qt,opencv,import | 7,940,923 | 1 | false | 0 | 1 | Probably need the qt dll's in the same place as the opencv dlls - and they have to be the version built with the same compiler as opencv (and possibly python) | 1 | 2 | 1 | I recently downloaded OpenCV 2.3.1, compiled with the CMake flags withQt and withQtOpenGL turned on. My Qt version is 4.7.4 and is configured with OpenGL enabled. Supposedly I only need to copy cv2.pyd to Python's site-package path:
C:\Python27\Lib\site-packages
And in the mean time make sure the OpenCV dlls are some... | Error when importing OpenCV python module (when built with Qt and QtOpenGL) | 0 | 0 | 0 | 488 |
7,941,623 | 2011-10-29T20:52:00.000 | 0 | 0 | 0 | 0 | python,database,django,psycopg2 | 7,942,855 | 2 | false | 1 | 0 | Generally, you would create the database externally before trying to hook it up with Django.
Is this your private server? If so, there are command-line tools you can use to set up a PostgreSQL user and create a database.
If it is a shared hosting situation, you would use CPanel or whatever utility your host provides t... | 2 | 0 | 0 | I'm create a blog using django.
I'm getting an 'operational error: FATAL: role "[database user]" does not exist.
But i have not created any database yet, all i have done is filled in the database details in setting.py.
Do i have to create a database using psycopg2? If so, how do i do it?
Is it:
python
import psycop... | how do i create a database in psycopg2 and do i need to? | 0 | 1 | 0 | 1,391 |
7,941,623 | 2011-10-29T20:52:00.000 | 0 | 0 | 0 | 0 | python,database,django,psycopg2 | 7,941,712 | 2 | false | 1 | 0 | before connecting to database, you need to create database, add user, setup access for user you selected.
Reffer to installation/configuration guides for Postgres. | 2 | 0 | 0 | I'm create a blog using django.
I'm getting an 'operational error: FATAL: role "[database user]" does not exist.
But i have not created any database yet, all i have done is filled in the database details in setting.py.
Do i have to create a database using psycopg2? If so, how do i do it?
Is it:
python
import psycop... | how do i create a database in psycopg2 and do i need to? | 0 | 1 | 0 | 1,391 |
7,941,660 | 2011-10-29T20:57:00.000 | 0 | 1 | 1 | 0 | c++,python,class,metaprogramming,introspection | 7,944,715 | 5 | false | 0 | 0 | Python is interpreted, so when a Python module is imported any class code at the module level is run, along with those classes' meta-classes -- this is so the classes will exist.
C++ is compiled: the classes already exist when they are imported; there is no way to control how they are created as they are already creat... | 1 | 4 | 0 | When I import a module that has a class, what code is executed when that class is first read and the class object created? Is there any way I can influence what happens?
Edit: I realize my question might be a bit too general...
I'm looking for something more low-level which will allow me to do introspection from C++. ... | What code is executed when a class is being defined? | 0 | 0 | 0 | 144 |
7,943,751 | 2011-10-30T07:22:00.000 | 7 | 1 | 0 | 0 | python,python-3.x,httpserver,simplehttpserver | 71,111,456 | 7 | false | 0 | 0 | Just wanted to add what worked for me:
python3 -m http.server 8000 (you can use any port number here except the ones which are currently in use) | 1 | 1,528 | 0 | What is the Python 3 equivalent of python -m SimpleHTTPServer? | What is the Python 3 equivalent of "python -m SimpleHTTPServer" | 1 | 0 | 1 | 725,970 |
7,944,992 | 2011-10-30T12:49:00.000 | 3 | 0 | 1 | 0 | python,django,utf-8,file-encodings | 7,945,023 | 1 | true | 1 | 0 | The # coding: utf-8 line is only necessary for files which contain special characters directly. Depending on how you want to achieve l10n, you have to take care how you process the strings.
In Python2, you should use unicode() objects, while in Python3, normal str()ings are the thing to use. | 1 | 4 | 0 | I have a Django site that contains only English language strings. I'll be localising this to other languages. I haven't set any sort of file encoding options. Do need to convert all my Python code to UTF-8? is this a good practice? If so, do I need to actually convert the file to be UTF-8 or do I simply need to add thi... | Should I ensure that all my web application code is UTF-8? | 1.2 | 0 | 0 | 101 |
7,945,669 | 2011-10-30T15:06:00.000 | 2 | 0 | 0 | 0 | python,xml,rss,atom-feed,feedparser | 8,021,162 | 1 | true | 0 | 0 | I'm the current developer of feedparser. Currently, one of the ways you can get that information is to monkeypatch feedparser._FeedParserMixin (or edit a local copy of feedparser.py). The methods you'll want to modify are:
feedparser._FeedParserMixin.unknown_starttag
feedparser._FeedParserMixin.unknown_endtag
At the ... | 1 | 2 | 0 | I'm trying to use feedparser to retrieve some specific information from feeds, but also retrieve the raw XML of each entry (ie. elements for RSS and for Atom), and I can't see how to do that. Obviously I could parse the XML by hand, but that's not very elegant, would require separate support for RSS and Atom, and I i... | Retrieving raw XML for items with feedparser | 1.2 | 0 | 1 | 1,115 |
7,948,443 | 2011-10-30T22:43:00.000 | 1 | 0 | 0 | 0 | javascript,python,fonts | 7,948,472 | 2 | false | 0 | 0 | You should remember the law of large numbers. Not many essays are composed of just letter i or M. Try some real comment text first, the character counting could work better than you expected. Also it is much faster than using PIL to render your text serverside. | 1 | 2 | 0 | I have a web site with comments; each comment could be a variable length. Longer comments naturally take up more space. However, I only have a finite amount of space on the page to put these comments.
Naturally, picking a fixed number of comments out of the stack doesn't work, because they could be short 1 liners or 5... | Estimating client-side font-rendering-size on the server? | 0.099668 | 0 | 0 | 174 |
7,950,124 | 2011-10-31T04:56:00.000 | 1 | 0 | 1 | 0 | python,list,formatting,strip | 7,950,136 | 4 | false | 0 | 0 | iterate over the elements of your list and print them out with your preferred formatting rather than relying on the default formatting when printing the whole list at once. | 1 | 0 | 0 | Ok, so I converted each line in a text file into a member of a list by doing the following: chkseq=[line.strip() for line in open("sequence.txt")] So when I print chkseq I get this: ['3','3'] What I would like is for it to instead look like this: [3,3] I know this is possible, I'm just unsure of how! I need them t... | strip ' from all members in a list | 0.049958 | 0 | 0 | 167 |
7,952,526 | 2011-10-31T10:36:00.000 | 0 | 0 | 1 | 0 | python,naming-conventions | 7,952,602 | 4 | false | 0 | 0 | this depends on how you import the module. If you just import the file and not the class , then I guess it would be something like
myModule.myModule.function()
which doesn't seem so desirable. if you use
from myModule import *
then you would use like
myModule.function() | 2 | 1 | 0 | I would like to know if there any risks to use the exact same name for module and a class from inside the module. | Are there any risks in Python if the module name and class name from inside had identical names? | 0 | 0 | 0 | 127 |
7,952,526 | 2011-10-31T10:36:00.000 | 1 | 0 | 1 | 0 | python,naming-conventions | 7,952,593 | 4 | false | 0 | 0 | Apart from potentially confusing yourself (or other devs), I don't see anything wrong with it. In fact, there are several examples of this in the standard Python modules e.g. random.random and pprint.pprint.
p.s. to be pedantic random and pprint are functions rather than classes, but the risks would be equivalent shou... | 2 | 1 | 0 | I would like to know if there any risks to use the exact same name for module and a class from inside the module. | Are there any risks in Python if the module name and class name from inside had identical names? | 0.049958 | 0 | 0 | 127 |
7,953,708 | 2011-10-31T12:28:00.000 | 2 | 0 | 0 | 0 | python,xml,performance,expat-parser | 7,960,421 | 1 | true | 0 | 0 | You're talking about the xmlparse.ParseFile method, right?
Unfortunately, no, that value is hardcoded as BUF_SIZE = 2048 in pyexpat.c. | 1 | 0 | 0 | I'm parsing some XML using Python's Expat (by calling parser = xml.parsers.expat.ParserCreate() and then setting the relevant callbacks to my methods).
It seems that when Expat calls read(nbytes) to return new data, nbytes is always 2,048. I have quite a lot of XML to process, and suspect that these small read()s are m... | Controlling number of bytes read() at a time with Expat | 1.2 | 0 | 1 | 192 |
7,953,996 | 2011-10-31T12:54:00.000 | 0 | 1 | 0 | 1 | python,shell,interactive | 7,954,357 | 2 | false | 0 | 0 | It will not be easy at all.
You will have to know if meterpreter has any means for other programs to communicate with it.
If it doesn't, you might want to go through hacking through it, e.g using OS pipes, etc to be able to get it to work.
In any case, the code needed for such communication might be beyond Python's pow... | 1 | 1 | 0 | Is there a way to send command to another interactive shell ? Let's take the example of the meterpreter shell used in metasploit. Could it be a way to say command to this shell from python code, as soon as I get control of a computer and have a meterpreter shell to play with ?
I mean All this from python code. | Send commands to an interactive shell from Python | 0 | 0 | 0 | 3,763 |
7,955,410 | 2011-10-31T14:52:00.000 | 0 | 0 | 0 | 0 | python,django,cryptography,certificate,digital-signature | 7,959,329 | 3 | false | 1 | 0 | This sounds like something from EU. Unfortunately there are countless of different existing online signature plugins. Keep in mind that many depend on the client side software as well (if the certificates come from a smart card, smart card middleware usually needs to be present as well). So you better study your target... | 2 | 3 | 0 | Immagine a web application written in python/django in which users authenticate with digital certificates via apache+mod_ssl (and a custom django authentication backend), how can they sign files then? The certificates are released by government approved CAs.
If I'm not wrong, a file needs to be signed with the private ... | Web application to sign PDF documents with digital certificates released by CAs | 0 | 0 | 0 | 4,082 |
7,955,410 | 2011-10-31T14:52:00.000 | 0 | 0 | 0 | 0 | python,django,cryptography,certificate,digital-signature | 7,955,645 | 3 | false | 1 | 0 | As tawman described in his answer, the right approach is to have a client-side module in the browser, and have this module do actual signing. You can have signed Java applet or signed ActiveX control to do the job.
We offer such solution for distributed signing with ready to use client modules, but server-side part req... | 2 | 3 | 0 | Immagine a web application written in python/django in which users authenticate with digital certificates via apache+mod_ssl (and a custom django authentication backend), how can they sign files then? The certificates are released by government approved CAs.
If I'm not wrong, a file needs to be signed with the private ... | Web application to sign PDF documents with digital certificates released by CAs | 0 | 0 | 0 | 4,082 |
7,955,695 | 2011-10-31T15:18:00.000 | 1 | 1 | 0 | 0 | python,unit-testing,mocking | 7,956,472 | 1 | true | 0 | 0 | Your cutting point is the HTTP requests.
Write a mock library which intercepts the sending of the HTTP requests. Instead of sending them, convert them into a String and analyze them to test sending code.
For receiving code, mock the response handler. Save a good response from the REST server in a String and create the ... | 1 | 1 | 0 | I'm writing a Python library to access Ubuntu One's REST API. (Yes, I know one already exists; this is a scratch-my-itch-and-learn-while-doing-it project.)
The library will be a relatively thin wrapper around the REST calls. I would like to be able to unit-test my library, without hitting U1 at all. What's the best pra... | How to test python library wrapping an external REST service (without hitting the service) | 1.2 | 0 | 1 | 604 |
7,956,696 | 2011-10-31T16:37:00.000 | 1 | 1 | 0 | 0 | python,linux,cgi | 7,957,775 | 4 | false | 0 | 0 | You could capture (or form by hand) the data and env variables which the CGI script receives, then plainly run the script under your favorite debugger and feed the data to it.
In order to capture the incoming data you can just dump it from the script in CGI mode to some log file, then re-use under debugger in standalo... | 1 | 5 | 0 | Is there any easy way to debug cgi python programs apart from looking at the log file each time the browser generates an error? | Debugging CGI python | 0.049958 | 0 | 0 | 3,944 |
7,958,276 | 2011-10-31T18:54:00.000 | 1 | 0 | 0 | 0 | python,gimp | 7,965,336 | 2 | false | 0 | 0 | You can script GIMP in Python, and pretty much everything you can do o n the prgoram can be done via the API -- you can check for the available API functions in help->procedure browser.
To enable Python scripting in gimp 2.6 under Windows, you have to google for it -- Python, python gtk and one other package have to be... | 1 | 0 | 0 | My wife recently started a business making soap bars and the soap labels have quickly spiraled out of control into tons of diverging Gimp .xcf files. The only difference between the files are the names of the product, description, and ingredients. I'd like to make a template and produce the labels from a .xcf file an... | Templatizing images using gimp | 0.099668 | 0 | 0 | 366 |
7,958,327 | 2011-10-31T18:58:00.000 | 0 | 0 | 1 | 0 | python,dictionary | 7,958,425 | 3 | false | 0 | 0 | Store the item in the dictionary without the ev prefix in the first place.
If you also need to access it with the prefix, store it both ways.
If there can be multiple prefixes for a given number, use a second dictionary that stores the actual keys associated with each number as a list or sub-dictionary, and use that t... | 1 | 1 | 0 | I have a dictionary with a key called ev#### where #### is some number that I do not know ahead of time. There is only one of this type of key in the dictionary and no other key starts with ev.
What's the cleanest way to access that key without knowing what the #### is? | Finding a key in a dictionary without knowing its full name | 0 | 0 | 0 | 347 |
7,958,537 | 2011-10-31T19:17:00.000 | 0 | 0 | 1 | 0 | python,import,external | 7,958,708 | 3 | false | 0 | 0 | Yes, exec and eval are not safe for user-supplied data, like handling expressions or Web input. But if you specifically want to give users the full power of Python, and you understand the risks (users can do anything – erase/read files on the computer, crash Python, enter an infinite loop, etc.), using exec is perfectl... | 1 | 1 | 0 | I am writing a game engine in Python and the thing is I am not sure how to handle external scripts (think source engine mods, LUA). Every scene, entity in a game can have custom script attached to it, but game engine is not aware of those scripts until the scene is being loaded. For example there could be a script, whi... | How to import external Python script? | 0 | 0 | 0 | 1,013 |
7,960,578 | 2011-10-31T22:33:00.000 | 3 | 0 | 0 | 0 | python,boto,amazon-emr | 9,055,033 | 3 | true | 1 | 0 | If it finishes correctly, it should not terminate with keep_alive=True. That said, it would normally exit on failure, so you want to add terminate_on_failure="CONTINUE" to your add_job_steps arguments. | 1 | 2 | 0 | How can I add steps to a waiting Amazon EMR job flow using boto without the job flow terminating once complete?
I've created an interactive job flow on Amazon's Elastic Map Reduce and loaded some tables. When I pass in new steps to the job flow using Boto's emr_conn.add_jobflow_steps(...), the job flow terminates after... | Boto: how to keep EMR job flow running after completion/failure? | 1.2 | 0 | 0 | 2,242 |
7,961,431 | 2011-11-01T00:54:00.000 | 1 | 0 | 1 | 1 | python,py2exe,veusz | 7,996,527 | 1 | false | 0 | 0 | Veusz runs its user interface in a separate python process so that it does not block python. If you look at veusz/embed.py, it tries to start up python or a veusz executable. You'd need to modify embed.py to start your .exe (sys.executable) if frozen instead of veusz and pass some special parameter which your program w... | 1 | 0 | 0 | I would like to distribute an application written in python as a .exe file. I have already been able to do this using py2exe, but now I have incorporated the veusz library into my code. Ideally my program should open up a veusz plot (as it does on my computer, which has python, numpy, etc. all installed). However, I wa... | Distributing python-written executable with veusz | 0.197375 | 0 | 0 | 272 |
7,962,157 | 2011-11-01T03:28:00.000 | 7 | 0 | 1 | 0 | python,windows | 39,889,705 | 4 | true | 0 | 0 | My approach is to use a redirect .bat file containing python someprogram.py %1. The %1 passes the file path into the python script which can be accessed with
from sys import argv
argv[1] | 1 | 14 | 0 | I am trying to figure out how to make a python program open a file when a user right clicks on the file and selects "Open With". For example, I want a user to be able right click on a text file and to select my program so that my program can process the text file. Is the name of the text file passed into my program som... | "Open with..." a file on Windows, with a python application | 1.2 | 0 | 0 | 5,750 |
7,964,869 | 2011-11-01T09:59:00.000 | 7 | 0 | 0 | 0 | python,qt4,qt-designer | 34,307,822 | 2 | false | 0 | 1 | Right-click on your widget
Select "Go to slot..."
Select a signal and click OK
Your custom slot declaration and definition for that signal will be added to *.cpp and *.h files. Its name will be generated automatically.
upd:
Sorry, I didn't notice that the question is about Python & QtDesigner itself, I was thinking of... | 2 | 22 | 0 | I use Qt4 Designer and I want that when I click on the "yes" button, some code will execute. And when I click on the "no", some other code will be execute. How can I do it? | Qt Designer: how to add custom slot and code to a button | 1 | 0 | 0 | 38,462 |
7,964,869 | 2011-11-01T09:59:00.000 | 45 | 0 | 0 | 0 | python,qt4,qt-designer | 7,965,081 | 2 | false | 0 | 1 | Click on the Edit Signal/Slots tool.
Create a connection for your button. For this, select your button in the designer by pressing on it with the left button of the mouse. Move the mouse to some place in the main window to create a connection with the main window (it is like a red line with a earth connection).
When yo... | 2 | 22 | 0 | I use Qt4 Designer and I want that when I click on the "yes" button, some code will execute. And when I click on the "no", some other code will be execute. How can I do it? | Qt Designer: how to add custom slot and code to a button | 1 | 0 | 0 | 38,462 |
7,965,611 | 2011-11-01T11:14:00.000 | 1 | 0 | 0 | 0 | python,django | 51,285,099 | 9 | false | 1 | 0 | Here is the simple approach worked for me. Add our custom template path in such a way worked for me.
path('users/password/reset/', password_reset, {'html_email_template_name': 'registration/password_reset_email.html'},name='password_reset'), | 2 | 10 | 0 | It seems to me django only supports plain text messages for password reset emails out of the box. How can I use html templates for this purpose? | Does Django password_reset support html email templates? | 0.022219 | 0 | 0 | 6,136 |
7,965,611 | 2011-11-01T11:14:00.000 | 5 | 0 | 0 | 0 | python,django | 7,965,953 | 9 | false | 1 | 0 | You can override save method of django.contrib.auth.forms.PasswordResetForm and pass new form as an argument to password_reset view. | 2 | 10 | 0 | It seems to me django only supports plain text messages for password reset emails out of the box. How can I use html templates for this purpose? | Does Django password_reset support html email templates? | 0.110656 | 0 | 0 | 6,136 |
7,967,575 | 2011-11-01T13:59:00.000 | 0 | 0 | 0 | 0 | python,html,css,user-interface | 7,967,656 | 3 | false | 1 | 1 | you could always use django, django templates support html, js, css, php etc. | 2 | 5 | 0 | I wonder if there's a python GUI like pyqt etc. which works purely with html and javascript for layouting desktop applications...
Do you know if there are projects like this? Does this make sense at all ;-) Or it it just me finding that a nice tool... | HTML/Javascript/CSS GUI for the development of desktop applications with python? | 0 | 0 | 0 | 3,024 |
7,967,575 | 2011-11-01T13:59:00.000 | 2 | 0 | 0 | 0 | python,html,css,user-interface | 7,967,652 | 3 | false | 1 | 1 | Since you mention PyQt yourself, you could perhaps just create a simple GUI using these tools, with your entire application made up of a QtWebKit module. Then just point to some files you created locally, and browse them using your appliction? But, this would not be any different compared to using a normal browser, so ... | 2 | 5 | 0 | I wonder if there's a python GUI like pyqt etc. which works purely with html and javascript for layouting desktop applications...
Do you know if there are projects like this? Does this make sense at all ;-) Or it it just me finding that a nice tool... | HTML/Javascript/CSS GUI for the development of desktop applications with python? | 0.132549 | 0 | 0 | 3,024 |
7,970,055 | 2011-11-01T17:06:00.000 | 0 | 0 | 0 | 0 | windows,wxpython | 7,970,931 | 2 | false | 0 | 1 | You can rename your .py file to .pyw it will then run without displaying the console. | 1 | 0 | 0 | I developed an application with wxPython and used cx_freeze to covert it to a .exe. I installed the app on WinXP and it works fine. My only misgiving is that the gui app is running with a command prompt behind it. How can I get rid of this command prompt? I imagine that it is there to display errors etc.... There must ... | Running a wxPython application in a Windows environment w/o the command prompt displaying | 0 | 0 | 0 | 370 |
7,971,603 | 2011-11-01T19:13:00.000 | 1 | 0 | 1 | 0 | python,intellij-idea,pycharm | 7,979,092 | 1 | true | 0 | 0 | The installation path is stored in the registry:
HKEY_CURRENT_USER\JetBrains\IntelliJ IDEA\<build number>\(Default)
(replace IntelliJ IDEA with PyCharm if you need the PyCharm installation path)
You can use the _winreg module to read the registry and retrieve the path. | 1 | 1 | 0 | I am looking for a piece of code Python code that would give me the path to IntelliJ IDEA or PyCharm exe if they are installed.
Usually, I would want to detect the same for Eclipse but it seems that Eclipse doesn't have an installer :( | How can I detect if IntelliJ IDEA or PyCharm is installed and get the path to the exe on Windows by using Python? | 1.2 | 0 | 0 | 1,187 |
7,976,269 | 2011-11-02T05:40:00.000 | 9 | 0 | 1 | 0 | python,iterator,boolean,generator | 7,976,309 | 3 | false | 0 | 0 | Guido doesn't want generators and iterators to behave that way.
Objects are true by default. They can be false only if they define __len__ that returns zero or __nonzero__ that returns False (the latter is called __bool__ in Py3.x).
You can add one of those methods to a custom iterator, but it doesn't match Guido's in... | 1 | 16 | 0 | Other empty objects in Python evaluate as False -- how can I get iterators/generators to do so as well? | How can I get generators/iterators to evaluate as False when exhausted? | 1 | 0 | 0 | 5,257 |
7,976,495 | 2011-11-02T06:18:00.000 | 0 | 0 | 0 | 0 | python,django,localization,internationalization | 7,977,014 | 1 | true | 1 | 0 | UI text: gettext is the way to go.
User Data (Dynamic): Very simple: you don't translate it at all. The only things you could do is asking the users to provide more than one language (only few will do) or using machine translations (will piss of people - usually they prefer english over a crappy translation). Especiall... | 1 | 1 | 0 | I am confused with how to proceed on Internationalization & Localizations, so I categorized a website's data as follows :
Site Content : Content that is hosted by the website i.e. the data about the subject. Eg: Mobile Phone Site (Data about mobile models, specs, prices, etc.)
User Data : Data that is added by the use... | Django Translation : User data --vs-- Site Content --vs-- UI static text? | 1.2 | 0 | 0 | 493 |
7,976,926 | 2011-11-02T07:20:00.000 | 9 | 0 | 1 | 1 | python,linux | 7,977,112 | 2 | true | 0 | 0 | Add a shebang to the Python file in question, make the Python file executable (e.g. by chmod a+x ./logserver.py) and start it directly by ./logserver.py.
A shebang is a line telling the kernel which interpreter to use. It's simply a line like #!/usr/bin/env python at the very beginning of the file. | 1 | 4 | 0 | I have a few long term processes and temporary processes in Python. While shell and C programs run under their own names, all Python processes run as 'python filename.py', which makes it tough to identify processes.
How can I make python processes show up as 'logserver.py' or such in Linux? I use Python 2.7 in Ubuntu ... | How do I make python processes run with correct process name? | 1.2 | 0 | 0 | 654 |
7,979,714 | 2011-11-02T11:40:00.000 | 7 | 0 | 1 | 0 | python,private | 7,979,954 | 4 | false | 0 | 0 | Python has the philosophy of "consenting adults": Prefix methods with an underscore to mark them as private. Don't call any methods with a leading underscore from the outside. If you do, you're on your own. You are free to do so, but you have been warned.
To adopt this convetion in an existing code base, rename the ... | 1 | 0 | 0 | I know that there is no such thing as true private in Python for sometimes you need to following:
prevent people from calling some methods or warn them when they do, but allow them to be called from other modules
detect where these methods are used and raise an warning on the console or even an exception, this would a... | How to refactor methods in Python in order to make them private? | 1 | 0 | 0 | 249 |
7,983,724 | 2011-11-02T16:20:00.000 | 3 | 0 | 0 | 0 | python,routing,path-finding,networkx | 33,684,974 | 2 | false | 0 | 0 | You could set your node data {color=['blue']} for node 1, node 2 has {color=['red','blue']} and node3 has {color=['red']}. Then use an networkx.algorithms. astar_path() approach setting the
heuristic is set to a function which returns a might_as_well_be_infinity when it encountered an node without the same color you... | 1 | 11 | 0 | I am trying to calculate shortest path between 2 points using Dijkstra and A Star algorithms (in a directed NetworkX graph).
At the moment it works fine and I can see the calculated path but I would like to find a way of restricting certain paths.
For example if we have following nodes:
nodes = [1,2,3,4]
With these ed... | How to restrict certain paths in NetworkX graphs? | 0.291313 | 0 | 1 | 2,143 |
7,984,146 | 2011-11-02T16:49:00.000 | 12 | 0 | 1 | 0 | python,json,unicode | 7,984,562 | 2 | true | 0 | 0 | You don't ask simplejson to ignore them. When I got similar problem like yours I just ran .decode('utf-8', 'ignore').encode('utf-8') and proceed. | 1 | 15 | 0 | My code makes gets some content from an UserVoice site. As you might know, UserVoice is a shitty piece of software that can't handle data correctly; indeed, to reduce the amount of text on the search page, they cut the text at, let's say, 300 characters and then add a "..." to the end. Thing is, they don't care cutting... | Python: handle broken unicode bytes when parsing JSON string | 1.2 | 0 | 0 | 7,937 |
7,984,714 | 2011-11-02T17:29:00.000 | 1 | 1 | 0 | 0 | python,crontab,scrapy | 7,984,842 | 1 | false | 1 | 0 | Scrapy executes correctly, but doesn't output all its messages to STDOUT, so the simple pipe (>) doesn't redirect everything into your file, only that stuff that goes to STDOUT (which as you say, seems to be the constructor only).
With &> it fetches all messages from scrapy and puts them into your log. | 1 | 0 | 0 | scrapy crawler is called through a shell script, which is used as the command line in a crontab entry. The shell script looks like:
scrapy crawl targethost.com
when time is due and it did execute, but seems only the constructor is called (I verified with debug output). The problem is solved by re-write the shell script... | scrapy script called from cron only constructor called | 0.197375 | 0 | 0 | 359 |
7,985,696 | 2011-11-02T18:45:00.000 | 0 | 0 | 1 | 0 | python | 7,985,748 | 4 | false | 0 | 0 | Arbitrary implementation choice. It's a TypeError in Python 3. | 1 | 1 | 0 | For some reason in Python 2.7 expressions of the form tuple > list return True, but tuple < list and tuple == list return False. Why is that?
This observation is not original to me by any means. | A curious occurrence in Python | 0 | 0 | 0 | 146 |
7,986,900 | 2011-11-02T20:27:00.000 | 6 | 0 | 0 | 0 | python,nlp,machine-learning,nltk | 7,987,856 | 2 | true | 0 | 0 | You need a huge training set of documents. Small subset of this collection (but still large set of documents) should represent given domain. Using nltk calculate words statistics taking into account morphology, filter out stopwords. The good statistics is TF*IDF which is roughly a number of occurenses of a word in the ... | 1 | 5 | 0 | I am trying to determine the most popular keywords for certain class of documents in my collection. Assuming that the domain is "computer science" (which of course, includes networking, computer architecture, etc.) what is the best way to preserve these domain-specific keywords from text? I tried using Wordnet but I am... | Preserving only domain-specific keywords? | 1.2 | 0 | 0 | 1,008 |
7,987,845 | 2011-11-02T21:59:00.000 | -1 | 0 | 0 | 0 | python,django,django-models | 7,987,920 | 2 | false | 1 | 0 | Why not replicate the models from the crawler into your new project (so they are created in the same project space), then simply use django's manage.py to dump the data from the old crawler project into json files and migrate them over to your new project?
Provided your crawler project is settings/db type independent, ... | 1 | 5 | 0 | I'm looking for a way to interact with the models of a django project from within a separate django project. I don't mean different apps, I mean 2 separate projects with 2 separate settings files.
I'm in the process of migrating an old web store (really old, it's all static html) to our django based backend. To do this... | interacting with an external django project from within another django project | -0.099668 | 0 | 0 | 1,952 |
7,988,494 | 2011-11-02T23:14:00.000 | 2 | 1 | 1 | 0 | python,random | 36,474,703 | 5 | false | 0 | 0 | Code to generate 10M random numbers efficiently and faster:
import random
l=10000000
listrandom=[]
for i in range (l):
value=random.randint(0,l)
listrandom.append(value)
print listrandom
Time taken included the I/O time lagged in printing on screen:
real 0m27.116s
user 0m24.391s
sys 0m0.819s | 1 | 14 | 1 | I'm in the process of working on programming project that involves some pretty extensive Monte Carlo simulation in Python, and as such the generation of a tremendous number of random numbers. Very nearly all of them, if not all of them, will be able to be generated by Python's built in random module.
I'm something of a... | Efficient way to generate and use millions of random numbers in Python | 0.07983 | 0 | 0 | 12,900 |
7,988,772 | 2011-11-02T23:50:00.000 | 8 | 0 | 1 | 1 | python | 7,988,865 | 3 | true | 0 | 0 | To produce 32 bit executables you need to install 32-bit versions of Python and cx_freeze. | 3 | 12 | 0 | I have already created a 64-bit program for windows using cx freeze on a 64-bit machine. I am using Windows 7 64-bit Home premium. py2exe is not working because as i understand it does not work with python 3.2.2 yet. Is there an option i have to specify in cx freeze to compile in 32-bit instead of 64-bit.
Thanks! | Create 32-bit exe's from python code on 64-bit machine | 1.2 | 0 | 0 | 15,094 |
7,988,772 | 2011-11-02T23:50:00.000 | 0 | 0 | 1 | 1 | python | 7,989,276 | 3 | false | 0 | 0 | All the "produce an executable from Python code" methods I know of basically create a file that bundles up the Python interpreter with the Python code you want to execute inside a single file. It is nothing at all like compiling C code to an executable; Python is just about impossible to compile to machine code in any ... | 3 | 12 | 0 | I have already created a 64-bit program for windows using cx freeze on a 64-bit machine. I am using Windows 7 64-bit Home premium. py2exe is not working because as i understand it does not work with python 3.2.2 yet. Is there an option i have to specify in cx freeze to compile in 32-bit instead of 64-bit.
Thanks! | Create 32-bit exe's from python code on 64-bit machine | 0 | 0 | 0 | 15,094 |
7,988,772 | 2011-11-02T23:50:00.000 | 4 | 0 | 1 | 1 | python | 18,043,350 | 3 | false | 0 | 0 | In addition to the answers already given:
To compile/freeze python code for different architectures (x86/x64), install both, x86 and x64 versions of python, to your system and corresponding variations of all required modules and libraries to your python installations so both installations have the same (required) set ... | 3 | 12 | 0 | I have already created a 64-bit program for windows using cx freeze on a 64-bit machine. I am using Windows 7 64-bit Home premium. py2exe is not working because as i understand it does not work with python 3.2.2 yet. Is there an option i have to specify in cx freeze to compile in 32-bit instead of 64-bit.
Thanks! | Create 32-bit exe's from python code on 64-bit machine | 0.26052 | 0 | 0 | 15,094 |
7,988,856 | 2011-11-03T00:02:00.000 | 0 | 0 | 0 | 1 | python,eclipse,pydev | 7,993,203 | 1 | false | 1 | 0 | This was a bug -- and it was fixed in the latest version (PyDev 2.2.4), so, please upgrade to the latest version and that should be working already. | 1 | 1 | 0 | I am using the pydev remote debugger feature for my application.
When I try to stop the debugger server via the stop button it shows on the console that the server is successfully terminated but it isn't because it is still accepting new connections on its default port (5678).
Do you know how can I stop the server in a... | How can I stop the debugger server from pydev? | 0 | 0 | 0 | 525 |
7,989,036 | 2011-11-03T00:36:00.000 | 0 | 1 | 1 | 0 | c++,python,c | 7,989,058 | 4 | false | 0 | 0 | Both are compiled to native code and usually with the same compiler and thus the same compiler optimizations available. The performance difference you pay for supporting C++ language constructs should be negligible. Choose the one you prefer / the one that integrates better with Python / the one that integrates better ... | 2 | 0 | 0 | Would it be better to use c or c++ for handling computationally intensive tasks in a python program, where speed matters above all. Is there much of a difference between the two ? Which is more cleaner? | Which is a better extension language for speed optimization for python c or c++ | 0 | 0 | 0 | 146 |
7,989,036 | 2011-11-03T00:36:00.000 | 0 | 1 | 1 | 0 | c++,python,c | 7,989,440 | 4 | false | 0 | 0 | The runtime performance you gain from using C++ versus C is negligible. In terms of integrating the code with your Python program (and most other languages) it is almost always easier to do with C. In fact if you're using ctypes to load and run the code (which I'd recommend), you still need to write a C interface aroun... | 2 | 0 | 0 | Would it be better to use c or c++ for handling computationally intensive tasks in a python program, where speed matters above all. Is there much of a difference between the two ? Which is more cleaner? | Which is a better extension language for speed optimization for python c or c++ | 0 | 0 | 0 | 146 |
7,990,060 | 2011-11-03T03:48:00.000 | -1 | 0 | 0 | 0 | javascript,python,html,mongodb | 8,487,539 | 2 | false | 1 | 0 | It's nothing about MongoDB, it's the AJAX call.
The string in response of an AJAX call will be converted to character entities, or they will break ur DOM with characters like '<'. All u need to do is converted them back. | 1 | 1 | 0 | I'm having a peculiar issue. I'm reading the HTML from a div contenteditable, and then sending an AJAX request to my backend that saves that HTML to a mongodb document, and I also save that exact same HTML to localStorage.
And, guess what happens? When the text is loaded back later, the localStorage renders fine, but,... | Funny issue; localStorage and MongoDB | -0.099668 | 0 | 0 | 1,051 |
7,990,321 | 2011-11-03T04:36:00.000 | 3 | 1 | 0 | 0 | python,browser,mechanize,web-scraping | 7,990,338 | 1 | true | 0 | 0 | You don't need one -- if you don't specify one, Mechanize will just handle it. You might want to use cookies you have already stored in a jar, or save cookies in a jar for use with other scripts, so Mechanize lets you specify one. | 1 | 2 | 0 | In mechanize, we have :
method : set_cookiejar()
But, why do we need a cookie jar anyway, when we say that mechanize has automatic cookie handling ?
Please help ! | Python - Mechanize : Why does it need CookieJar? | 1.2 | 0 | 0 | 486 |
7,991,529 | 2011-11-03T07:36:00.000 | 3 | 1 | 0 | 1 | python,putty | 7,991,590 | 4 | false | 0 | 0 | you can use code similar to:
command = "plink.exe -ssh username@" + hostname + " -pw password -batch \"export DISPLAY='" + hostname + "/unix:0.0' ; "
which will open an ssh to the desired hostname using username and password
shutdown:
command += "sudo /sbin/halt\""
reboot:
command += "sudo /sbin/reboot\""
add your othe... | 1 | 6 | 0 | I want to connect to putty and want to do few step:
login to Putty
type few command to bring down the server
Traverse to the particular path
Remove the file from the directory
Again start the server
I need to write the code in windows. But my server is in linux.
How shall I proceed?
Thanks in advance | Connect to putty and type few command | 0.148885 | 0 | 0 | 59,795 |
7,993,348 | 2011-11-03T10:28:00.000 | 3 | 0 | 0 | 0 | python,django,django-templates | 7,993,570 | 2 | true | 1 | 0 | Django expects you to arrange your apps in certain ways. Requiring a templatetags directory in the app is not the exception. Some other requirements are:
ModelAdmin in admin.py (for autodiscovery)
Models in models.py
Management commands in management/commands directory
Fixtures in the fixtures directory
Unlike templa... | 1 | 0 | 0 | I'm now working with template tags and one thing I haven't understood is why do template-tags have to be stored inside a templatetags directory in the app. Is there an underlying reason for this? Is it possible to store them in a templatetags.py file somehow so that I can reduce the extra bloat around having extra dire... | Why are templatetags stored in directories? | 1.2 | 0 | 0 | 107 |
7,993,624 | 2011-11-03T10:51:00.000 | 2 | 0 | 1 | 0 | python,video,streaming,live,ipv6 | 7,994,014 | 3 | true | 1 | 0 | You can use gstreamer's python module. I mean gst-python mentioned above. Use rtmp protocol to synchronize client/server videos. Last time I use gst-python, there was no support for rtmp. At the time, my solution was to limit buffer size. When buffer gets full oldest frames will be dropped. | 1 | 10 | 0 | I need to make an application which streams live multimedia. At present my application is taking image frames from a webcam (using OpenCV) and sending it to the client. It is also sending audio using pymedia module. The problem is that both the image and audio packets that arrive at the client are out of sync.
So I hav... | Streaming audio and video with Python | 1.2 | 0 | 1 | 18,589 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.