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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5,958,929 | 2011-05-11T03:33:00.000 | 1 | 0 | 1 | 0 | python,list,methods,naming | 5,958,955 | 5 | false | 0 | 0 | Do you know which is which?
Extend: adds a list
Append: adds only element
Did you know without having to look it
up? If so, could you please share your
secret for remembering which is which?
Experience for the most part. To add a single Element, you don't use Extend. Basically, don't use E with E. | 4 | 1 | 0 | In Python, lists have two methods for adding elements to the end: "append" and "extend". One of them adds a single element to the list, and the other adds every element from an iterable to the end of the list. Do you know which is which? Did you know without having to look it up? If so, could you please share your secr... | How can I remember which of list.append and list.extend is which in Python? | 0.039979 | 0 | 0 | 121 |
5,959,130 | 2011-05-11T04:08:00.000 | 1 | 0 | 1 | 0 | python,time,standards | 5,959,400 | 3 | false | 0 | 0 | It's not a true answer like the other two, but the philosophy I use when dealing with dates and times in python: convert to a datetime object as soon as possible after getting from the user, and only convert back into a string when you are presenting the value back to the user.
Most of the date/time math you will need ... | 1 | 2 | 0 | I am having problems with logic on how to convert military time from a text file to standard time and discard all the wrong values. I have only got to a point where the user is asked for the input file and the contents are displayed from the text file entered. Please help me | Convert Military Time from text file to Standard time Python | 0.066568 | 0 | 0 | 2,701 |
5,959,553 | 2011-05-11T05:12:00.000 | 3 | 0 | 0 | 0 | python,django | 5,959,856 | 1 | true | 1 | 0 | Use the safe filter only if you html-escape the data first. Otherwise you should use escape. If you want your users to be able to input data with html tags you could try to sanitize the input to prevent users from using <iframe>, <script>, etc, but allow other tags to be white-listed, and then mark it as safe. | 1 | 0 | 0 | I have a form with a jwysiwyg editor. Looking at it, it can use basic-formatting html tags using the formatting buttons like SO's. Upon submitting the form, I notice its saved into the database as-is, whereas if I enter stuff like <iframe> ... </iframe> into the editor I notice that it is html-encoded inside the table.... | Django: saving data from user input and display | 1.2 | 0 | 0 | 579 |
5,959,647 | 2011-05-11T05:25:00.000 | 10 | 0 | 1 | 0 | python,django,uninstallation | 5,959,706 | 2 | true | 1 | 0 | go to the python shell
>> import django
django.__path__
copy the path
on the shell
sudo rm -r path | 1 | 5 | 0 | I have to delete a python module named "django" (a popular one), because I installed the wrong version (1.3 - beta in py-2.6).
How to uninstall this module?
Please explain, because I've used python only in Windows and never in Ubuntu. | Uninstalling a python module in ubuntu | 1.2 | 0 | 0 | 6,576 |
5,960,483 | 2011-05-11T07:05:00.000 | 4 | 0 | 0 | 1 | python,linux,window-managers | 5,961,317 | 3 | false | 0 | 0 | I think the correct answer may be "with some difficulty". Essentially, the contents of a window is a bitmap. This bitmap is drawn on by a whole slew of primitives (including "display this octet-string, using that encoding and a specific font"), but the window contents is still "just pixels".
Getting the "just pixels" i... | 1 | 1 | 0 | I want to collect data and parse it eventually from an open window in linux.
An example- Suppose a terminal window is open. I need to retrieve all the data that appears on that window. After retrieval, I would parse it to get specific commands entered.
So is it possible to do that? If so, how? I would prefer to use pyt... | Get content from open window in Linux | 0.26052 | 0 | 0 | 1,235 |
5,960,791 | 2011-05-11T07:37:00.000 | 6 | 0 | 1 | 0 | c++,python,c,bash | 5,960,952 | 6 | true | 0 | 0 | Interfacing between C/C++ and Python is heavily documented and there are several different approaches. However, if you're just setting values then it may be overkill to use Python, which is more geared toward customising large operations within your process by farming it off to the interpreter.
I would personally recom... | 1 | 5 | 0 | I have c++ code that has grown exponential. I have a number of variables (mostly Boolean) that need to be changed for each time I run my code (different running conditions). I have done this using the argument command line inputs for the main( int argc, char* argv[]) function in the past.
Since this method has become c... | C, C++ Interface with Python | 1.2 | 0 | 0 | 6,031 |
5,961,379 | 2011-05-11T08:31:00.000 | 0 | 0 | 0 | 0 | python,windows,path,drag | 6,085,729 | 1 | false | 0 | 0 | I think the filename path, the function that handles a 'drop' normally has a struct with the data you need, but python itself does not provides a gui to drop files, what widget framework are you using? | 1 | 0 | 0 | How can I know what is the address of dragged file or folder in windows explorer with Python? | Address of Dragged File in Windows | 0 | 0 | 0 | 100 |
5,962,152 | 2011-05-11T09:38:00.000 | 3 | 0 | 1 | 0 | python,shutil | 5,962,307 | 2 | false | 0 | 0 | Unless you do something very funky, os.error and OSError | 1 | 11 | 0 | I am using the rmtree method from shutil in Python (2.7).
What are all possible exceptions that can occur while calling this method? | What is a complete list of Exceptions that can be thrown by shutil.rmtree | 0.291313 | 0 | 0 | 8,236 |
5,963,366 | 2011-05-11T11:21:00.000 | 3 | 0 | 1 | 0 | python,stdout,python-embedding | 5,963,680 | 1 | true | 0 | 0 | In python, the print statement writes into sys.stdout (which is the standard output) even in an embedded app, you should see your prints in the console that started the application. | 1 | 1 | 0 | Where does Python print to, if the print statement is in a python function, called from C\C++ in an embedded Python configuration? | Python print output while embedding Python in C\C++ | 1.2 | 0 | 0 | 498 |
5,965,655 | 2011-05-11T14:12:00.000 | 2 | 1 | 0 | 0 | php,python,ajax,ipc | 5,965,679 | 4 | false | 0 | 0 | I think you would have to use a meta refresh and maybe have the python write the status to a file and then have the php read from it.
You could use AJAX as well to make it more dynamic.
Also, probably shouldn't use exec()...that opens up a world of vulnerabilities. | 1 | 10 | 0 | I'm trying to build a web interface for some python scripts. The thing is I have to use PHP (and not CGI) and some of the scripts I execute take quite some time to finish: 5-10 minutes. Is it possible for PHP to communicate with the scripts and display some sort of progress status? This should allow the user to use the... | Communication between PHP and Python | 0.099668 | 0 | 0 | 16,013 |
5,967,521 | 2011-05-11T16:23:00.000 | 1 | 1 | 0 | 1 | python,macos,file-io | 5,967,726 | 6 | false | 0 | 0 | It seems like you have control of the (python?) program doing the copying. What commands are you using to copy? I would think writing your code such that it blocks until the copy operation is complete would be sufficient.
Is this program multi-threaded or processed? If so you could add file paths to a queue when they a... | 2 | 3 | 0 | is it possible to check if a file is done copying of if its complete using python?
or even on the command line.
i manipulate files programmatically in a specific folder on mac osx but i need to check if the file is complete before running the code which makes the manipulation. | check if a file is 'complete' (with python) | 0.033321 | 0 | 0 | 6,644 |
5,967,521 | 2011-05-11T16:23:00.000 | 2 | 1 | 0 | 1 | python,macos,file-io | 5,967,724 | 6 | true | 0 | 0 | If you know where the files are being copied from, you can check to see whether the size of the copy has reached the size of the original.
Alternatively, if a file's size doesn't change for a couple of seconds, it is probably done being copied, which may be good enough. (May not work well for slow network connections,... | 2 | 3 | 0 | is it possible to check if a file is done copying of if its complete using python?
or even on the command line.
i manipulate files programmatically in a specific folder on mac osx but i need to check if the file is complete before running the code which makes the manipulation. | check if a file is 'complete' (with python) | 1.2 | 0 | 0 | 6,644 |
5,967,858 | 2011-05-11T16:53:00.000 | 1 | 0 | 1 | 0 | python | 5,967,917 | 2 | false | 0 | 0 | You can always rename a module when you import it, such as:
import sys as realsys
realsys.exit(1)
It seems like you'll have to do this either for the system module whose name you have overloaded or for your module, depending on which causes the least pain.
Bottom line, when you create modules, it's good to more fully... | 1 | 1 | 0 | I have a legacy python program which defined a module whose name conflict with a system module in the current python, what's the easiest method to fix this? This module has been imported in many place, so it would be great if no need to change the the old python source. | How to import a user module which has the same name with a system module? | 0.099668 | 0 | 0 | 219 |
5,969,337 | 2011-05-11T19:08:00.000 | 1 | 1 | 0 | 1 | python,strace | 5,969,373 | 3 | false | 0 | 0 | I would generally start by adding logging to it. At a minimum, have whatever is launching it capture stdout/stderr so that any stack traces are saved. Examine your except blocks to make sure you're not capturing exceptions silently. | 1 | 4 | 0 | What's the best way to monitor a python daemon to determine the cause of it quitting unexpectedly? Is strace my best option or is there something Python specific that does the job? | Troubleshoot python daemon that quits unexpectedly? | 0.066568 | 0 | 0 | 2,169 |
5,972,807 | 2011-05-12T02:48:00.000 | 2 | 0 | 1 | 0 | python,exec | 5,972,839 | 2 | false | 0 | 0 | You're using e as the variable for your loop. Naturally, it contains a string since that's what the list contains. Use another name instead. | 2 | 0 | 0 | I tested these under python 2.6 and 2.7.
See this is OK:
>>> exec 'e=1'
>>> exec 'f=2'
>>> exec 'g=e+f'
>>> print g
3
But this returns error:
>>> cont=['e=1','f=2','g=e+f']
>>> for e in cont:
... try:
... exec e
... except Exception,em:
... print em
...
cannot concatenate 'str' and 'int'... | python exec problem: why cannot concatenate 'str' and 'int' objects | 0.197375 | 0 | 0 | 869 |
5,972,807 | 2011-05-12T02:48:00.000 | 5 | 0 | 1 | 0 | python,exec | 5,972,829 | 2 | true | 0 | 0 | You've chosen your variable names poorly. You're using e as both the for loop variable and the int variable in cont[0]. What happens is that the first time through the loop, e == 'e=1'; then exec e is called and e == 1; then the next time through the loop, e == 'f=2', and so on. By the time the last expression 'g=e+f' ... | 2 | 0 | 0 | I tested these under python 2.6 and 2.7.
See this is OK:
>>> exec 'e=1'
>>> exec 'f=2'
>>> exec 'g=e+f'
>>> print g
3
But this returns error:
>>> cont=['e=1','f=2','g=e+f']
>>> for e in cont:
... try:
... exec e
... except Exception,em:
... print em
...
cannot concatenate 'str' and 'int'... | python exec problem: why cannot concatenate 'str' and 'int' objects | 1.2 | 0 | 0 | 869 |
5,973,120 | 2011-05-12T03:51:00.000 | 85 | 0 | 1 | 0 | python-3.x,python-dateutil | 5,973,932 | 4 | true | 0 | 0 | dateutil is a third party module. It has recently been ported to Python 3 with dateutil 2.0, and the parser functions was ported as well.
So the replacement is dateutil.parser. You just forgot to install it. | 1 | 51 | 0 | Python 2.x has a great function called dateutil.parser which turns an ISO8601 formatted date into a python datetime value. It's not present in Python 3. What is the replacement? | What is the replacement for dateutil.parser in python3? | 1.2 | 0 | 0 | 79,257 |
5,973,245 | 2011-05-12T04:17:00.000 | 1 | 1 | 0 | 0 | asp.net,python,asp.net-ajax,screen-scraping,urllib2 | 5,974,002 | 2 | false | 1 | 0 | When scraping a web application, I use either:
1) WireShark ... or...
2) A logging proxy server (that logs headers as well as payload)
I then compare what the real application does (in this case, how your browser interacts with the site) with the scraper's logs. Working through the differences will bring you to a work... | 2 | 2 | 0 | I've been trying (unsuccessfully, I might add) to scrape a website created with the Microsoft stack (ASP.NET, C#, IIS) using Python and urllib/urllib2. I'm also using cookielib to manage cookies. After spending a long time profiling the website in Chrome and examining the headers, I've been unable to come up with a w... | Scraping ASP.NET with Python and urllib2 | 0.099668 | 0 | 1 | 1,706 |
5,973,245 | 2011-05-12T04:17:00.000 | 2 | 1 | 0 | 0 | asp.net,python,asp.net-ajax,screen-scraping,urllib2 | 6,035,498 | 2 | true | 1 | 0 | For anyone else that might be in a similar predicament in the future:
I'd just like to note that I've had a lot of success with a Greasemonkey user script in Chrome to do all of my scraping and automation. I found it to be a lot easier than Python + urllib2 (at least for this particular case). The user scripts are w... | 2 | 2 | 0 | I've been trying (unsuccessfully, I might add) to scrape a website created with the Microsoft stack (ASP.NET, C#, IIS) using Python and urllib/urllib2. I'm also using cookielib to manage cookies. After spending a long time profiling the website in Chrome and examining the headers, I've been unable to come up with a w... | Scraping ASP.NET with Python and urllib2 | 1.2 | 0 | 1 | 1,706 |
5,977,648 | 2011-05-12T12:02:00.000 | 7 | 0 | 1 | 0 | python,file,sys | 5,977,686 | 3 | false | 0 | 0 | sys.getsizeof returns a size of an object (i.e. how many bytes a file class instance takes up in the memory), and has nothing to do with the size of the file contents. | 2 | 1 | 0 | I created a file with the following entry, returned by file.read()
'abcd\nefgh\n1234\nijkl\n5678\n\nend'
I open the file to read now, with 'f' as handler.
f.read() returns the above.
f.tell() returns 35L
sys.getsizeof(f) returns 76.
Trying to call f.seek(offset) with offset any higher than 35 returns nothing.
Python do... | size of a python file object and seek() | 1 | 0 | 0 | 2,397 |
5,977,648 | 2011-05-12T12:02:00.000 | 3 | 0 | 1 | 0 | python,file,sys | 5,977,714 | 3 | true | 0 | 0 | sys.getsizeof() does not return the size of the file on disk. Instead, it returns the size that the file object (the interface to the real file on disk) takes up in memory.
You could even use sys.getsizeof() with objects that don't have any disk presence. For instacen, if s = 'abcd', then calling sys.getsizeof(s) might... | 2 | 1 | 0 | I created a file with the following entry, returned by file.read()
'abcd\nefgh\n1234\nijkl\n5678\n\nend'
I open the file to read now, with 'f' as handler.
f.read() returns the above.
f.tell() returns 35L
sys.getsizeof(f) returns 76.
Trying to call f.seek(offset) with offset any higher than 35 returns nothing.
Python do... | size of a python file object and seek() | 1.2 | 0 | 0 | 2,397 |
5,980,101 | 2011-05-12T15:05:00.000 | 2 | 1 | 0 | 0 | python,configuration | 5,980,640 | 4 | false | 0 | 0 | I doesn't matter technically proficient your users are; you can count on them to screw up editing a text file. (They'll save it in the wrong place. They'll use MS Word to edit a text file. They'll make typos.) I suggest making a gui that validates the input and creates the configuration file in the correct format an... | 1 | 2 | 0 | I want to write a program that sends an e-mail to one or more specified recipients when a certain event occurs. For this I need the user to write the parameters for the mail server into a config. Possible values are for example: serveradress, ports, ssl(true/false) and a list of desired recipients.
Whats the user-frien... | Userfriendly way of handling config files in python? | 0.099668 | 0 | 1 | 1,174 |
5,981,117 | 2011-05-12T16:17:00.000 | 0 | 1 | 0 | 0 | python,firefox-addon,xpcom,pycrypto | 5,989,716 | 1 | false | 0 | 0 | AES.so has not been linked against the Python dynamic library. It's finding other symbols it needs in the process's symbol table, but it can't find that one and doesn't know where it is. | 1 | 0 | 0 | I'm developing a firefox addon which is depended on Python (which means that the user must install PyXpcomExt on his firefox). On the other hand I used PyCrypto lib (based on python) for encryption purposes.
So when firefox is loaded I have registered path to this library. However when the extension is run I get the fo... | PyExc_ValueError and Firefox extension | 0 | 0 | 0 | 434 |
5,981,933 | 2011-05-12T17:26:00.000 | 4 | 0 | 1 | 1 | python,linux,libraries | 5,982,042 | 2 | true | 0 | 0 | You should be able to install the files to an external location and define the environment variable PYTHONPATH to point to the directory that contains the modules. | 2 | 2 | 0 | I currently have both Python 2.6 and 2.7 running on my Linux machine.
Now, from Python 2.7, I can't access the libraries that I installed through package manager for Python 2.6.
I tried uninstalling the library and installing it back with Python 2.7 installed as my default runtime. No luck.
How can I share libraries be... | Two Python instances, same libraries | 1.2 | 0 | 0 | 113 |
5,981,933 | 2011-05-12T17:26:00.000 | 0 | 0 | 1 | 1 | python,linux,libraries | 5,982,011 | 2 | false | 0 | 0 | You should have now both a /usr/lib/python2.6 folder and a /usr/lib/python2.7. Try creating links inside the 2.7 folders to the required files or folders inside the 2.6 folder. | 2 | 2 | 0 | I currently have both Python 2.6 and 2.7 running on my Linux machine.
Now, from Python 2.7, I can't access the libraries that I installed through package manager for Python 2.6.
I tried uninstalling the library and installing it back with Python 2.7 installed as my default runtime. No luck.
How can I share libraries be... | Two Python instances, same libraries | 0 | 0 | 0 | 113 |
5,983,032 | 2011-05-12T19:00:00.000 | 2 | 0 | 0 | 1 | python,file-upload,tornado,ajax-upload | 5,989,216 | 1 | true | 1 | 0 | I got the answer.
I need to use self.request.body to get the raw post data.
I also need to pass in the correct _xsrf token, otherwise tornado will fire a 403 exception.
So that's about it. | 1 | 3 | 0 | I'm using this javascript library (http://valums.com/ajax-upload/) to upload file to a tornado web server, but I don't know how to get the file content. The javascript library is uploading using XHR, so I assume I have to read the raw post data to get the file content. But I don't know how to do it with Tornado. Their ... | asynchronous file upload with ajaxupload to a tornado web server | 1.2 | 1 | 0 | 1,836 |
5,983,100 | 2011-05-12T19:06:00.000 | 3 | 0 | 0 | 0 | python,django,unit-testing,importerror | 5,986,697 | 3 | false | 1 | 0 | I had the same problem just a minute ago. Investigating I realized the problem was with my settings.py* file.
Check if you are having problems with Django finding your settings file correctly.
This error message is totally non-sense.
* IIRC Django looks for settings.py file, if not found, it looks for environment varia... | 3 | 7 | 0 | I'm using Django 1.3.0 with Python 2.7.1.
In every test I write the following imports I get the importError above:
from django.utils import unittest
from django.test.client import Client
The full stack trace:
File "C:\Program Files (x86)\j2ee\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line... | ImportError: cannot import name signals | 0.197375 | 0 | 0 | 16,619 |
5,983,100 | 2011-05-12T19:06:00.000 | 5 | 0 | 0 | 0 | python,django,unit-testing,importerror | 6,003,401 | 3 | true | 1 | 0 | @Hugo was right in that it was a settings.py problem. But I didn't had that problem when running through the Django environment. But when I wanted to run unit tests one by one (By using Pydev's run as unittest) it failed to run.
What I needed to do was to add the Django settings module information, so for now what I'm ... | 3 | 7 | 0 | I'm using Django 1.3.0 with Python 2.7.1.
In every test I write the following imports I get the importError above:
from django.utils import unittest
from django.test.client import Client
The full stack trace:
File "C:\Program Files (x86)\j2ee\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line... | ImportError: cannot import name signals | 1.2 | 0 | 0 | 16,619 |
5,983,100 | 2011-05-12T19:06:00.000 | -1 | 0 | 0 | 0 | python,django,unit-testing,importerror | 24,360,080 | 3 | false | 1 | 0 | This is easy to solve.
If you have already written the settings.py (most probable) just navigate into the directory which contains the "settings.py" file and execute it.
1] python
2] import settings
These commands should do the trick. Then go to any folder and continue with execution. | 3 | 7 | 0 | I'm using Django 1.3.0 with Python 2.7.1.
In every test I write the following imports I get the importError above:
from django.utils import unittest
from django.test.client import Client
The full stack trace:
File "C:\Program Files (x86)\j2ee\plugins\org.python.pydev.debug_1.6.3.2010100513\pysrc\runfiles.py", line... | ImportError: cannot import name signals | -0.066568 | 0 | 0 | 16,619 |
5,986,382 | 2011-05-13T01:36:00.000 | 0 | 0 | 1 | 0 | functional-programming,python,abstraction,pexpect | 5,986,974 | 2 | false | 0 | 0 | Could you pass a data processing function to the function you described as an argument?
That may be more or less elegant, depending on your taste.
(Forgive me: I know nothing about pexpect, and I may even have misunderstood your question!) | 1 | 0 | 0 | I have a function that logs into a sensor via telnet/pexpect and acts as a data collector.
I don't want to rewrite the part that logs in, grabs the data, and parses out relevant output from it (pexpect). However, I need to do different things with this code and the data it gathers
For example, I may need to:
Time unti... | What is an elegant way to abstract functions - not objects? | 0 | 0 | 0 | 149 |
5,986,388 | 2011-05-13T01:36:00.000 | 0 | 0 | 0 | 0 | python,django,release-management | 5,987,736 | 3 | false | 1 | 0 | Migrating to a new version of Django (especially from a directly previous release) is really easy and takes less than ten minutes for one project (if its not super complex).
It it's running for 18 to 24 months I would better upgrade. After one or two more releases of Django (one major release each year) they will simpl... | 2 | 7 | 0 | Short Question
Are there any compelling reasons to update Django 1.2.5 to 1.3? If the noted changes in the release notes do not impact my application directly.
EDIT:
To better clarify my question (thanks S.Lott!): Are there any issues not mentioned in the Django 1.3's release notes that I should be aware of if upgradi... | Should I migrate from Django 1.2.5 to 1.3.x ? Are there any undocumented issues? | 0 | 0 | 0 | 929 |
5,986,388 | 2011-05-13T01:36:00.000 | 0 | 0 | 0 | 0 | python,django,release-management | 5,990,072 | 3 | false | 1 | 0 | As I once read somewhere, Django has releases mostly because people ask about releases. Other than that, it's perfectly ok to stick to the trunk revision. | 2 | 7 | 0 | Short Question
Are there any compelling reasons to update Django 1.2.5 to 1.3? If the noted changes in the release notes do not impact my application directly.
EDIT:
To better clarify my question (thanks S.Lott!): Are there any issues not mentioned in the Django 1.3's release notes that I should be aware of if upgradi... | Should I migrate from Django 1.2.5 to 1.3.x ? Are there any undocumented issues? | 0 | 0 | 0 | 929 |
5,986,472 | 2011-05-13T01:51:00.000 | 2 | 0 | 0 | 1 | python,django,linux,nginx,uwsgi | 5,986,912 | 1 | true | 1 | 0 | I like having regular users on a system:
multiple admins show up in sudo logs -- there's nothing quite like asking a specific person why they made a specific change.
not all tasks require admin privileges, but admin-level mistakes can be more costly to repair
it is easier to manage the ~/.ssh/authorized_keys if each f... | 1 | 6 | 0 | I'm currently trying to set up nginx + uWSGI server for my Django homepage. Some tutorials advice me to create specific UNIX users for certain daemons. Like nginx user for nginx daemon and so on. As I'm new to Linux administration, I thought just to create second user for running all the processes (nginx, uWSGI etc.), ... | Linux user scheme for a Django production server | 1.2 | 0 | 0 | 925 |
5,987,185 | 2011-05-13T04:19:00.000 | 4 | 0 | 0 | 1 | python,c | 5,987,204 | 3 | true | 0 | 0 | An emphatic NO on that one, I'm afraid. C has basic file I/O. Any structuring of data is up to you. Make up a format, dump it out, read it in.
There may be libraries which can do this, but by itself no C doesn't do this. | 2 | 2 | 1 | I'm wondering if C has anything similar to the python pickle module that can dump some structured data on disk and then load it back later.
I know that I can write my structure byte by byte to a file on disk and then read it back later, but with this approach there's still quite some work to do. For example, if I have... | does C has anything like python pickle for object serialisation? | 1.2 | 0 | 0 | 207 |
5,987,185 | 2011-05-13T04:19:00.000 | 2 | 0 | 0 | 1 | python,c | 5,987,230 | 3 | false | 0 | 0 | The C library functions fread(3) and fwrite(3) will read and write 'elements of data', but that's pretty fanciful way of saying "the C library will do some multiplication and pread(2) or pwrite(2) calls behind the scenes to fill your array".
You can use them on structs, but it is probably not a good idea:
holes in the... | 2 | 2 | 1 | I'm wondering if C has anything similar to the python pickle module that can dump some structured data on disk and then load it back later.
I know that I can write my structure byte by byte to a file on disk and then read it back later, but with this approach there's still quite some work to do. For example, if I have... | does C has anything like python pickle for object serialisation? | 0.132549 | 0 | 0 | 207 |
5,987,371 | 2011-05-13T04:54:00.000 | -2 | 0 | 1 | 0 | python | 16,633,853 | 8 | false | 0 | 0 | Since this question is now over 2 years old I guess this is more for future references :)
What I like to do is max('', mightBeNoneVar) or max(0, mightBeNoneVar) (depending on the context).
More elaborate example:
print max('', col1).ljust(width1) + ' ==> '+ max('', col2).ljust(width2) | 2 | 15 | 0 | Is there a function in Python that checks if the returned value is None and if it is, allows you to set it to another value like the IFNULL function in MySQL? | Python equivalent for MySQL's IFNULL | -0.049958 | 1 | 0 | 35,088 |
5,987,371 | 2011-05-13T04:54:00.000 | 1 | 0 | 1 | 0 | python | 50,119,942 | 8 | false | 0 | 0 | nvl(v1,v2) will return v1 if not null otherwise it returns v2.
nvl = lambda a,b: a or b | 2 | 15 | 0 | Is there a function in Python that checks if the returned value is None and if it is, allows you to set it to another value like the IFNULL function in MySQL? | Python equivalent for MySQL's IFNULL | 0.024995 | 1 | 0 | 35,088 |
5,988,099 | 2011-05-13T06:32:00.000 | 1 | 1 | 0 | 0 | python,eclipse,package,definition,pydev | 6,316,500 | 2 | false | 0 | 0 | add your code dir into the project->properties->PyDev - PYTHONPATH->sourceFolders, you can find the C mark in the package Explorer | 1 | 1 | 0 | I'm using Pydev on Eclipse. I have created a new project, added __init__.py and a module in a package in the src folder. The problem is, I can't see classes and functions outlines when I try to expand the module by clicking the arrow left to it. Nothing expands. I expect to see a list of classes with a capital "C" lett... | Pydev problems with "Go to definition" and "package Explorer" | 0.099668 | 0 | 0 | 1,261 |
5,988,172 | 2011-05-13T06:41:00.000 | 0 | 0 | 0 | 0 | java,php,python,flash | 6,071,331 | 6 | false | 1 | 0 | The swf files are handled by plugins running inside or outside the browser. There is no way to tell if a certain flash has or hasn't transparent background... i guess you can assume that all of them are transparent.. | 4 | 9 | 0 | Is there a way to do this programmatically in PHP, Python or Java?
Use case:
User uploads .swf through an upload form.
Detect if it has a transparent background.
If it does, change it to something else, e.g. white. | Detect if .swf has transparent background | 0 | 0 | 0 | 625 |
5,988,172 | 2011-05-13T06:41:00.000 | 1 | 0 | 0 | 0 | java,php,python,flash | 6,078,955 | 6 | false | 1 | 0 | Flash is a bunch of compiled binary data. You Might be able to hunt down a third party library which can un-compile the flash file and get some of the data from the root movie scene, but it's a large stretch. As others have recommended, a checkbox during upload would be the best route to take. | 4 | 9 | 0 | Is there a way to do this programmatically in PHP, Python or Java?
Use case:
User uploads .swf through an upload form.
Detect if it has a transparent background.
If it does, change it to something else, e.g. white. | Detect if .swf has transparent background | 0.033321 | 0 | 0 | 625 |
5,988,172 | 2011-05-13T06:41:00.000 | 0 | 0 | 0 | 0 | java,php,python,flash | 6,060,270 | 6 | false | 1 | 0 | I think you can read the .html where the .swf is placed and see if there is a parameter called "wmode" and is set to "transparent"
If that's the case you can get the html file and read it with Python, Java or PHP.
It's an ugly solution, but it's a solution.
PS: Sorry for my poor English. | 4 | 9 | 0 | Is there a way to do this programmatically in PHP, Python or Java?
Use case:
User uploads .swf through an upload form.
Detect if it has a transparent background.
If it does, change it to something else, e.g. white. | Detect if .swf has transparent background | 0 | 0 | 0 | 625 |
5,988,172 | 2011-05-13T06:41:00.000 | 4 | 0 | 0 | 0 | java,php,python,flash | 6,079,767 | 6 | true | 1 | 0 | This is very difficult to determine, because all SWFs are actually transparent (or they all can be) - it's just that they can contain shapes which cover the entire stage, which make them appear non-transparent.
To determine this programmatically, you'd need to loop over every shape in the SWF and look at it's bounds. H... | 4 | 9 | 0 | Is there a way to do this programmatically in PHP, Python or Java?
Use case:
User uploads .swf through an upload form.
Detect if it has a transparent background.
If it does, change it to something else, e.g. white. | Detect if .swf has transparent background | 1.2 | 0 | 0 | 625 |
5,988,177 | 2011-05-13T06:41:00.000 | 1 | 0 | 0 | 1 | python,deployment,web-deployment | 5,988,654 | 2 | false | 1 | 0 | pip freeze gives you a listing of all installed packages. Bonus: if you redirect the output to a file, you can use it as part of your deployment process to install all those packages (pip can programmatically install all packages from the file).
I see you're already using virtualenv. Good. You can run pip freeze -E myv... | 1 | 5 | 0 | I'm looking for a tool to keep track of "what's running where". We have a bunch of servers, and on each of those a bunch of projects. These projects may be running on a specific version (hg tag/commit nr) and have their requirements at specific versions as well.
Fabric looks like a great start to do the actual deployme... | Python: tool to keep track of deployments | 0.099668 | 0 | 0 | 332 |
5,988,597 | 2011-05-13T07:23:00.000 | 2 | 0 | 1 | 0 | python,django,environment-variables,pycharm | 65,421,376 | 6 | false | 1 | 0 | I faced the same problem and proposed solutions did not work.
I solved it by going in "File > Settings..."
Then search for "Django console" and add the following Environment variable: DJANGO_SETTINGS_MODULE=mysite.settings | 3 | 21 | 0 | I am using PyCharm IDE and when I run any file.py I get this error:
..raise ImportError("Settings cannot be imported, because environment
variable %s is undefined." % ENVIRONMENT_VARIABLE) ImportError:
Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
How to configur... | PyCharm: DJANGO_SETTINGS_MODULE is undefined | 0.066568 | 0 | 0 | 18,748 |
5,988,597 | 2011-05-13T07:23:00.000 | 9 | 0 | 1 | 0 | python,django,environment-variables,pycharm | 7,150,995 | 6 | false | 1 | 0 | You can go to the tool bar which shows a dropdown and select your project ->edit configuration. There in the Environment variable area enter DJANGO_SETTINGS_MODULE mysite.settings and save . | 3 | 21 | 0 | I am using PyCharm IDE and when I run any file.py I get this error:
..raise ImportError("Settings cannot be imported, because environment
variable %s is undefined." % ENVIRONMENT_VARIABLE) ImportError:
Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
How to configur... | PyCharm: DJANGO_SETTINGS_MODULE is undefined | 1 | 0 | 0 | 18,748 |
5,988,597 | 2011-05-13T07:23:00.000 | 0 | 0 | 1 | 0 | python,django,environment-variables,pycharm | 55,761,299 | 6 | false | 1 | 0 | for new commers, below is the additional info'.
where you can find the place to set DJANGO_SETTINGS_MODULE in pycharm 2019.1 is:
config -> language and frameworks -> Django's right pain.
the column just below the django project root you can cite your config file path.
and the environment variables column you can set DJ... | 3 | 21 | 0 | I am using PyCharm IDE and when I run any file.py I get this error:
..raise ImportError("Settings cannot be imported, because environment
variable %s is undefined." % ENVIRONMENT_VARIABLE) ImportError:
Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
How to configur... | PyCharm: DJANGO_SETTINGS_MODULE is undefined | 0 | 0 | 0 | 18,748 |
5,991,193 | 2011-05-13T11:27:00.000 | 3 | 0 | 1 | 1 | python,python-module,multiple-versions | 5,991,416 | 2 | true | 0 | 0 | You can use easy_install. To use it for particular version, you just execute it like for example sudo python2.5 easy_install package_name. | 1 | 4 | 0 | I have installed python 2.6.6 and python 2.5.5 on the same machines (Ubuntu 10.0.4), since 2.6 is my default version and 2.5 I need for maintaining old stuff.
But I have a problem to install modules(MySQLdb and net-snmp) to non-default 2.5v. It seems that only 2.6 is updated when 'sudo apt-get install _module_name_' is... | Installing modules for multiple python versions | 1.2 | 0 | 0 | 4,579 |
5,991,605 | 2011-05-13T12:10:00.000 | 0 | 0 | 1 | 0 | python,thread-safety,stringio | 5,991,674 | 4 | false | 0 | 0 | No it is not currently thread safe. | 2 | 4 | 0 | As title say, does Python cStringIO protect their internal structures for multithreading use?
Thank you. | Is Python cStringIO thread-safe? | 0 | 0 | 0 | 2,523 |
5,991,605 | 2011-05-13T12:10:00.000 | 4 | 0 | 1 | 0 | python,thread-safety,stringio | 5,991,735 | 4 | false | 0 | 0 | I assume you are talking about the CPython implementation of Python.
In CPython there is a global interpreter lock which means that only a single thread of Python code can execute at a time. Code written in C will therefore also be effectively single threaded unless it explicitly releases the global lock.
What that mea... | 2 | 4 | 0 | As title say, does Python cStringIO protect their internal structures for multithreading use?
Thank you. | Is Python cStringIO thread-safe? | 0.197375 | 0 | 0 | 2,523 |
5,993,621 | 2011-05-13T14:45:00.000 | 3 | 1 | 1 | 0 | python,list,search,find,set | 5,993,682 | 4 | false | 0 | 0 | I think it would be better to go with the set implementation. I know for a fact that sets have O(1) lookup time. I think lists take O(n) lookup time. But even if lists are also O(1) lookup, you lose nothing with switching to sets.
Further, sets don't allow duplicate values. This will make your program slightly more mem... | 2 | 34 | 0 | When you do something like "test" in a where a is a list does python do a sequential search on the list or does it create a hash table representation to optimize the lookup? In the application I need this for I'll be doing a lot of lookups on the list so would it be best to do something like b = set(a) and then "test" ... | Fastest way to search a list in python | 0.148885 | 0 | 0 | 59,073 |
5,993,621 | 2011-05-13T14:45:00.000 | 12 | 1 | 1 | 0 | python,list,search,find,set | 5,993,671 | 4 | false | 0 | 0 | "test" in a with a list a will do a linear search. Setting up a hash table on the fly would be much more expensive than a linear search. "test" in b on the other hand will do an amoirtised O(1) hash look-up.
In the case you describe, there doesn't seem to be a reason to use a list over a set. | 2 | 34 | 0 | When you do something like "test" in a where a is a list does python do a sequential search on the list or does it create a hash table representation to optimize the lookup? In the application I need this for I'll be doing a lot of lookups on the list so would it be best to do something like b = set(a) and then "test" ... | Fastest way to search a list in python | 1 | 0 | 0 | 59,073 |
5,994,297 | 2011-05-13T15:38:00.000 | 8 | 0 | 0 | 0 | python,postgresql,centos,trac | 5,998,204 | 1 | true | 0 | 0 | I have had this problem before, although with 8.4 instead of 8.1, but the issue is the same, I believe.
A recent minor upgrade of all supported maintenance branches of PostgreSQL introduced the function PinPortal in the server, and made PL/pgSQL use it. So if you use a plpgsql.so from the newer version with a server f... | 1 | 6 | 0 | I have been running Davical on a CentOS 5 box for a while now with no problems.
Yesterday however, I installed Trac bug-tracker which eventually forced me to run a full update via Yum which updated a whole heap of packages.
I cant seem to work out exactly what the issue is and time spent googling didn't seem to bring a... | Could not load library "/usr/lib/pgsql/plpgsql.so" & undefined symbol: PinPortal | 1.2 | 1 | 0 | 5,259 |
5,994,922 | 2011-05-13T16:24:00.000 | 0 | 0 | 0 | 0 | python,django | 5,995,348 | 2 | true | 1 | 0 | Sounds like an important task ;) Your python scripts (.py) are compiled to bytecode files (.pyc) automatically. If the .py file has changed or there is no .pyc file, your python interpreter will automatically compile.
AFAIK, template files (.html) are not cached in memory. But .pyc files are, and often it is necessary ... | 1 | 0 | 0 | I've been given the keys to a website written in Python on the Django framework. I have a php background, so I'm not used to having to worry about compliation, etc.
I'm just trying to change the copyright at the footer. I found the template that holds the html... it's called base.html, in the 'templates' folder. I c... | How to push changes through django? | 1.2 | 0 | 0 | 2,657 |
5,995,674 | 2011-05-13T17:36:00.000 | 2 | 1 | 0 | 0 | python,django,session,timer | 5,995,769 | 4 | false | 1 | 0 | Either you do the clock on the client side, in which case they can always cheat somehow, or you do it on the server side, and then you aren't taking into account these interruptions.
To reduce cheating somewhat and still allow for interruptions, you could do a 'keep alive'.
Here the client side code announces to the se... | 4 | 4 | 0 | I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet ... | Timed Quiz: How to consider internet interruptions? | 0.099668 | 0 | 0 | 466 |
5,995,674 | 2011-05-13T17:36:00.000 | 2 | 1 | 0 | 0 | python,django,session,timer | 5,995,763 | 4 | false | 1 | 0 | The simplest way would be to add a timestamp when the person starts the quiz and then compare that to when they submit. Of course, this doesn't take into account connection drops, crashes, etc... like you mentioned.
To account for these issues I'd probably use something like node.js. Each client has "check-in" when the... | 4 | 4 | 0 | I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet ... | Timed Quiz: How to consider internet interruptions? | 0.099668 | 0 | 0 | 466 |
5,995,674 | 2011-05-13T17:36:00.000 | 2 | 1 | 0 | 0 | python,django,session,timer | 6,015,282 | 4 | true | 1 | 0 | Your strategy should depend on importance of the test and ability to retake whole test.
Is test/quiz for fun or competence/knowledge checking?
Are you dealing with logged users?
Are tests generated randomly from large poll of available questions?
these are the questions you need to answer yourself first.
Remember tha... | 4 | 4 | 0 | I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet ... | Timed Quiz: How to consider internet interruptions? | 1.2 | 0 | 0 | 466 |
5,995,674 | 2011-05-13T17:36:00.000 | 0 | 1 | 0 | 0 | python,django,session,timer | 5,996,776 | 4 | false | 1 | 0 | The problem with pausing the clock when the connection to the user drops, is that the user could just disconnect their computer from the internet each time they received a new question, and then reconnect once they had worked out the answer.
One thing you could do, is give the user a certain amount of time for each que... | 4 | 4 | 0 | I am preparing a Test or Quiz in Django. The quiz needs to be completed in certain time frame. Say 30 minutes for 40 questions.I can always initiate a clock at start of the test, and then calculate time by the time the Quiz is completed. However it's likely that during the attempt, there may be issues such as internet ... | Timed Quiz: How to consider internet interruptions? | 0 | 0 | 0 | 466 |
5,996,616 | 2011-05-13T19:08:00.000 | 1 | 0 | 1 | 0 | python,file | 5,996,724 | 3 | false | 0 | 0 | As others have said, the traditional way to solve this problem is to keep 5 different files instead of 1 large one. When you need to delete 20%, just delete the oldest file and rename the others.
As handy as text files are, you might also consider a database. It is designed to be able to delete any part of the data at ... | 1 | 4 | 0 | My program is keeping a log for the user. If the log ever gets bigger than a set amount, I want to delete the first 20% of lines.
From similar questions, I've seen suggestions to do read in the old file, and write out all the lines I want to keep into a new file. However, my files might be too large to be constantly ... | Efficient way to delete lines from a file in python (and keep the same file name)? | 0.066568 | 0 | 0 | 297 |
5,997,987 | 2011-05-13T21:30:00.000 | 42 | 0 | 1 | 0 | python,python-3.x | 5,998,002 | 7 | true | 0 | 0 | There is no such operator in Python, but it is trivial to implement on your own. In practice in computing, percentages are not nearly as useful as a modulo, so no language that I can think of implements one. | 1 | 66 | 0 | I've recently learned that the " % " sign is used to calculate the remainder of an integer in Python. However I was unable to determine if there's another operator or method to calculate percent in Python.
Like with " / " which will give you the quotient, if you just use a float for one of the integers, it will actuall... | Is there an operator to calculate percentage in Python? | 1.2 | 0 | 0 | 303,018 |
5,998,245 | 2011-05-13T22:02:00.000 | -2 | 0 | 1 | 0 | python,datetime,time | 60,960,816 | 16 | false | 0 | 0 | Just another solution using the datetime module for Python 3+.
round(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) | 2 | 710 | 0 | How can I get the current time in milliseconds in Python? | Get current time in milliseconds in Python? | -0.024995 | 0 | 0 | 1,092,192 |
5,998,245 | 2011-05-13T22:02:00.000 | 1 | 0 | 1 | 0 | python,datetime,time | 56,624,270 | 16 | false | 0 | 0 | These multiplications to 1000 for milliseconds may be decent for solving or making some prerequisite acceptable. It could be used to fill a gap in your database which doesn't really ever use it. Although, for real situations which require precise timing it would ultimately fail. I wouldn't suggest anyone use this meth... | 2 | 710 | 0 | How can I get the current time in milliseconds in Python? | Get current time in milliseconds in Python? | 0.012499 | 0 | 0 | 1,092,192 |
5,998,693 | 2011-05-13T23:18:00.000 | 0 | 0 | 0 | 1 | python,amqp,kombu | 7,130,213 | 1 | true | 0 | 0 | For most people it is best to just use a topic exchange for everything until you fully understand how AMQP works. You can get fanout and direct behavior just by choosing the right binding key for a queue. For instance if you use "#" for a binding key, then that queue behaves as if it was connected to a direct exchange.... | 1 | 0 | 0 | I'm getting into the whole amqp thing and i have a question regarding which type of exchange type to use under the following scenario's:
1) i have the need to create a worker pool where each worker does something when they receive a message. now i want different workers attached to different types of tasks; which i can... | amqp exchange types | 1.2 | 0 | 0 | 356 |
6,000,205 | 2011-05-14T06:32:00.000 | 0 | 0 | 0 | 0 | python,django,django-views | 68,934,242 | 9 | false | 1 | 0 | I believe the updated solution is view.__module__. This returns your app_name both from Django and Django Rest Framework.
My scenario was working with dynamically module or app_name from view call so that I can work with access permission check for that particular module. | 1 | 26 | 0 | If you are in the view and want to retrieve the app name using Python ( the app name will be used for further logic ), how would you do it ? | How to get an app name using python in django | 0 | 0 | 0 | 31,008 |
6,002,147 | 2011-05-14T13:32:00.000 | 0 | 0 | 0 | 0 | python,mysql,interaction | 40,519,201 | 2 | false | 0 | 0 | I personally use pymysql, but have heard a lot of people use MySQLdb. Both are very similar in the way they behave, and could easily be interchangeable. Personally, (working as a python/MySQL QA) I've yet to hear of / let alone work with OurSQL.
With that said, it honestly depends what you want to accomplish. Python h... | 1 | 3 | 0 | What is the recommonded way to interact between python and MySQL? Currently I am using MySQLdb and I heared from Oursql. But I asked myself, if there is a more appropriate way to manage this. | Is there a recommended way for interaction between python and MySQL? | 0 | 1 | 0 | 234 |
6,005,960 | 2011-05-15T01:41:00.000 | -1 | 0 | 0 | 0 | python,resize,wxpython | 6,006,073 | 2 | false | 0 | 1 | I'm not too familiar with wxPython, but can't you just reset the window size to your max/min size that you want once the user pass that? Preferably in the event that detects resizing? | 1 | 5 | 0 | Is it possible to make a wxPython window only re-sizable to a certain ratio? I know you can disable resizing; however, I'd like it so when the window was resized it stuck to a certain width to height ratio. | Resizing a wxPython Window | -0.099668 | 0 | 0 | 7,440 |
6,006,322 | 2011-05-15T03:35:00.000 | 8 | 0 | 1 | 0 | python,arguments | 6,006,331 | 2 | true | 0 | 0 | python -c 'print("hello world")' | 1 | 3 | 0 | How to pass a piece of code as arguments to python?
I tried like this, but it didn't work.
$ python3 'print("hello world")'
can't open file 'print(hello': [Errno 2] No such file or directory | Python code as arguments | 1.2 | 0 | 0 | 2,259 |
6,006,666 | 2011-05-15T05:26:00.000 | 3 | 0 | 0 | 0 | python,django,apache2,mod-wsgi,hotdeploy | 6,007,285 | 2 | false | 1 | 0 | Just touching the wsgi file allways worked for me. | 1 | 4 | 0 | I have setup an Apache server with mod_wsgi, python_sql, mysql and django.
Everything works fine, except the fact that if I make some code changes, they do not reflect immidiately, though I thing that everything is compiled on the fly when it comes to python/mod_wsgi.
I have to shut down the server and come back again ... | Hot deployment using mod_wsgi,python and django on Apache | 0.291313 | 1 | 0 | 768 |
6,006,773 | 2011-05-15T02:34:00.000 | 0 | 0 | 0 | 0 | python,web-applications,sprox | 6,636,134 | 1 | true | 1 | 1 | You should be able to pass the form to the template, render it there while adding any custom css rule inside the template itself. For example using <style> tag inside the template head.
If you really want to add a custom CSS on python side you can try to add CSSLink/CSSSource to css key inside form __base_widget_args__... | 1 | 1 | 0 | I am looking into using sprox but I can't seem to find any information about styling the generated form. I am sure its got to be something obvious but i didn't see it in the docs or find anything using a google/google groups search.
Ideally i would use sprox to generate the form but be able to pass in some css for lay... | Python / TG2 - Sprox | 1.2 | 0 | 0 | 160 |
6,006,839 | 2011-05-15T06:19:00.000 | 5 | 0 | 0 | 0 | python,django,google-app-engine,internationalization,nlp | 6,007,173 | 1 | true | 1 | 0 | If you have a saved preference somewhere, then that would be the first choice.
The cookie value is, presumably, what they chose last time they were around so that would be the first thing to check.
The hl parameter is something that Google has figured out and they probably know what they're doing so that seems like a s... | 1 | 3 | 0 | given that these all have different values:
HTTP browser accept language header
parameter
HTTP GET human language parameter eg. hl=en or hl=fr
Cookie value for language choice
How should we decide which language to display pages in if deciding based on these values? It's also thinkable saving user's preferred langu... | How to prioritize internationalization parameters | 1.2 | 0 | 1 | 140 |
6,006,882 | 2011-05-15T06:32:00.000 | 1 | 0 | 0 | 0 | python,django,django-models,django-views,django-sessions | 6,006,961 | 3 | false | 1 | 0 | If you don't have any way of identifying your users then your best bet is to store this info in a browser cookie or HTML5 local storage. (I don't advise using flash cookies since there is a long debate about them and they are harder to implement) | 2 | 3 | 0 | I am using Django and my website has no user profiles so all are anonymous. I want to implement a 'like' system. How do I restrict a user to like only once. Thanks. | How to create Django like button for anonymous users? | 0.066568 | 0 | 0 | 1,150 |
6,006,882 | 2011-05-15T06:32:00.000 | 0 | 0 | 0 | 0 | python,django,django-models,django-views,django-sessions | 6,006,968 | 3 | false | 1 | 0 | You can't 100% restrict multiple votes, but you can make it very difficult for a regular user, by using:
a cookie
a DB entry with the voter's IP | 2 | 3 | 0 | I am using Django and my website has no user profiles so all are anonymous. I want to implement a 'like' system. How do I restrict a user to like only once. Thanks. | How to create Django like button for anonymous users? | 0 | 0 | 0 | 1,150 |
6,008,107 | 2011-05-15T11:30:00.000 | 2 | 0 | 0 | 1 | python,scala,twisted,akka,scalaz | 9,134,732 | 1 | true | 0 | 0 | Finagle seems to be modeled closely after, or at least accidentally similar, to twisted. twitter.util.Future looks a lot like twisted's Deferred. So I'm using it for the moment. | 1 | 7 | 0 | I am trying to port a significant amount of code written in python with twisted to scala, and I'm looking for opinions on what framework combination to choose.
The thing is essentially an RPC (custom protobuf-based + xmlrpc)/HTTP server and client, that does some database-keeping and transformations but later sends dow... | Porting python-twisted based code to scala: framework advice needed | 1.2 | 0 | 0 | 975 |
6,009,365 | 2011-05-15T15:35:00.000 | 2 | 0 | 0 | 1 | python,sockets,networking,gevent | 6,010,876 | 2 | false | 0 | 0 | it's not detecting the disconnection because there wasn't any disconnection, the TCP "connection" is still alive and suppose to be reliable. if for example you unplug your LAN cable, and the re-plug it, the connection will still work.
if you really want to detect the disconnection ASAP, then i guess you should just par... | 1 | 4 | 0 | I'm using gevent patched socket to connect to a streaming server and I'm using an adsl connection.
I don't control the server but in my tests, if I stop the server I can detect the disconnection by just checking if the result from recv is an empty string, but if I turn off my adsl modem recv never exits. If I just dis... | How do I detect a socket disconnection? / How do I call socket.recv with a timeout? | 0.197375 | 0 | 1 | 5,998 |
6,011,596 | 2011-05-15T22:08:00.000 | 2 | 0 | 1 | 0 | python,django,json,simplejson | 6,011,614 | 2 | false | 1 | 0 | Find the first non-whitespace character. If it's "<" then you have HTML.
Also, check the content type header and HTTP status code. | 1 | 1 | 0 | Occasionally I'm querying a server for JSON and receiving a 404 HTML page when the requested data is not available.
Thus, I must have a check to ensure that the JSON I'm expecting, is actually json rather than HTML. I'm accomplishing this now by checking for a string that I can expect to be in the HTML is contained ... | How to validate JSON with simplejson | 0.197375 | 0 | 1 | 817 |
6,012,022 | 2011-05-15T23:43:00.000 | 3 | 0 | 1 | 0 | python | 6,012,046 | 3 | false | 0 | 0 | CPython has no limit on the number of imports. However, each .so file will be opened using dlopen(), which is outside of Python's control -- as is the symbol table that would need to keep growing to collect information about your extension modules. Whether those have a practical limit is also outside of Python's purvie... | 3 | 10 | 0 | I have 1000s of custom (compiled to '.so') modules that I'd like to use in python at the same time. Each such module is of size (100 [KB]) on average.
My question is, is there any limit on the number of imports in python? what are the consequences of many imports? (for example, will this require a lot of memory)?
Can I... | Python -- Limits On Number of Imports? | 0.197375 | 0 | 0 | 1,874 |
6,012,022 | 2011-05-15T23:43:00.000 | 9 | 0 | 1 | 0 | python | 6,012,129 | 3 | false | 0 | 0 | The amount of memory consumed by a single imported module is going to be at least as big as the size of the module on disk. The overhead is determined by both the OS itself (for loading a dynamic module) and Python's overhead in importing a module.
So if your module are on average 100kB in size, then importing 10000 of... | 3 | 10 | 0 | I have 1000s of custom (compiled to '.so') modules that I'd like to use in python at the same time. Each such module is of size (100 [KB]) on average.
My question is, is there any limit on the number of imports in python? what are the consequences of many imports? (for example, will this require a lot of memory)?
Can I... | Python -- Limits On Number of Imports? | 1 | 0 | 0 | 1,874 |
6,012,022 | 2011-05-15T23:43:00.000 | 10 | 0 | 1 | 0 | python | 6,012,053 | 3 | false | 0 | 0 | There's no Python limit on number of imports in a module. If there's a limit in any particular implementation, it's probably because of resource limits outside the Python interpreter. | 3 | 10 | 0 | I have 1000s of custom (compiled to '.so') modules that I'd like to use in python at the same time. Each such module is of size (100 [KB]) on average.
My question is, is there any limit on the number of imports in python? what are the consequences of many imports? (for example, will this require a lot of memory)?
Can I... | Python -- Limits On Number of Imports? | 1 | 0 | 0 | 1,874 |
6,012,043 | 2011-05-15T23:48:00.000 | 0 | 0 | 1 | 0 | python,api,file,interface,standard-library | 6,012,172 | 3 | false | 0 | 0 | For example, f.fileno() doesn't necessarily return a true OS-level file descriptor that you could use with os.read(). | 2 | 5 | 0 | From the python docs on urllib.urlopen(), talking about the file-like object the function returns on success:
(It is not a built-in file object, however, so it can’t be used at those few places where a true built-in file object is required.)
What are those few places where a true built-in file object is required?
NB:... | python: where is a true built-in file object required? | 0 | 0 | 1 | 177 |
6,012,043 | 2011-05-15T23:48:00.000 | 3 | 0 | 1 | 0 | python,api,file,interface,standard-library | 6,016,974 | 3 | true | 0 | 0 | As the other answers have noted, there isn't really anywhere that specifically needs a file object, but there are interfaces that need real OS level file descriptors, which file-like objects like StringIO can't provide.
The os module has several methods that operate directly on file descriptors, as do the select and mm... | 2 | 5 | 0 | From the python docs on urllib.urlopen(), talking about the file-like object the function returns on success:
(It is not a built-in file object, however, so it can’t be used at those few places where a true built-in file object is required.)
What are those few places where a true built-in file object is required?
NB:... | python: where is a true built-in file object required? | 1.2 | 0 | 1 | 177 |
6,012,105 | 2011-05-16T00:00:00.000 | 3 | 1 | 1 | 0 | python | 6,012,123 | 1 | false | 0 | 0 | There would be a large time overhead of importing that many shared libraries - the dynamic linker would spend a significant amount of time during the loading phase. The dynamic linker is really optimized for tens to hundreds of shared objects, not thousands to tens of thousands.
If at all possible, combine your shared ... | 1 | 3 | 0 | I have 1000s of custom (compiled to '.so') modules that I'd like to use in python at the same time. Each such module is of size (100 [KB]) on average.
Does anyone know what is the overhead (on the OS -- assuming python is not handling this) of every .so import? meaning, is the overhead equal to the size of the .so file... | Python -- Overhead of `.so` Imports? | 0.53705 | 0 | 0 | 210 |
6,013,930 | 2011-05-16T06:37:00.000 | 1 | 0 | 1 | 0 | python,pdf,pypdf | 6,013,951 | 1 | true | 0 | 0 | Short answer: not possible with pypdf and not with any PDF tool for Python I know. | 1 | 0 | 0 | how to use python pypdf to read pdf and get highlighted words? I highlighted the unknown words in a pdf and I want to extract them for referencing later. | python pypdf to read pdf and get highlighted words | 1.2 | 0 | 0 | 864 |
6,013,996 | 2011-05-16T06:46:00.000 | 1 | 1 | 0 | 0 | python,image,url,dimension | 6,014,083 | 2 | false | 0 | 0 | PHP can open a URL as it does a file. This could be a boon (as in your case), or a bane (as in remote file inclusion vulnerability).
Python opts to be explicit in that a file is a file, and a remote resource (URL, for example), is a remote one.
If you need some utility function to get image size from a remote resource,... | 1 | 6 | 0 | I have search for a while, and there is a function call get_image_dimensions(), however, as to my understanding, it works for the images which are downloaded or say local. So, any functions or solution like getimagesize in PHP, that we can just get the dimension of an image via URL, instead of path to local? | Is there a function for Python which like getimagesize in PHP? | 0.099668 | 0 | 0 | 2,428 |
6,014,836 | 2011-05-16T08:35:00.000 | 2 | 0 | 0 | 1 | python,pyinotify | 6,039,032 | 2 | false | 0 | 0 | And I find that there is an parameter auto_add in function add_watch,
which can auto add the directory in the watch when it is created.
But it need the event IN_CREATE. | 2 | 2 | 0 | I have watch a folder that will create a new sub-folder use date as name(e.g 201105124) everyday. I have start a daemon to watch it but if a new sub-folder added, the event in the new sub-folder cannot be trigger. IS that I need to update the watch for the new folder?
Thx for your answer.
Regards
Roy | Do I need to update the watch when new sub-folder add in the monitor folder | 0.197375 | 0 | 0 | 181 |
6,014,836 | 2011-05-16T08:35:00.000 | 0 | 0 | 0 | 1 | python,pyinotify | 6,015,129 | 2 | true | 0 | 0 | Yes, you need to use update_watch after directory creation. | 2 | 2 | 0 | I have watch a folder that will create a new sub-folder use date as name(e.g 201105124) everyday. I have start a daemon to watch it but if a new sub-folder added, the event in the new sub-folder cannot be trigger. IS that I need to update the watch for the new folder?
Thx for your answer.
Regards
Roy | Do I need to update the watch when new sub-folder add in the monitor folder | 1.2 | 0 | 0 | 181 |
6,015,632 | 2011-05-16T09:51:00.000 | 0 | 0 | 1 | 0 | python,multithreading,python-multithreading | 6,015,707 | 3 | false | 0 | 0 | You shouldn't need to use
threading. 95% of code does not need
threads.
Yes, Python threading is
perfectly valid, it's implemented
through the operating system's native
threads.
Use the standard library
threading module, it's excellent. | 2 | 4 | 0 | I have been trying to write a simple python application to implement a worker queue
every webpage I found about threading has some random guy commenting on it, you shouldn't use python threading because this or that, can someone help me out? what is up with Python threading, can I use it or not? if yes which lib? the ... | Python multi threading Yay or nay? | 0 | 0 | 0 | 579 |
6,015,632 | 2011-05-16T09:51:00.000 | 5 | 0 | 1 | 0 | python,multithreading,python-multithreading | 6,015,853 | 3 | true | 0 | 0 | Python's threads are perfectly viable and useful for many tasks. Since they're implemented with native OS threads, they allow executing blocking system calls and keep "running" simultaneously - by calling the blocking syscall in a separate thread. This is very useful for programs that have to do multiple things at the ... | 2 | 4 | 0 | I have been trying to write a simple python application to implement a worker queue
every webpage I found about threading has some random guy commenting on it, you shouldn't use python threading because this or that, can someone help me out? what is up with Python threading, can I use it or not? if yes which lib? the ... | Python multi threading Yay or nay? | 1.2 | 0 | 0 | 579 |
6,016,663 | 2011-05-16T11:25:00.000 | 3 | 0 | 1 | 0 | python,multithreading | 6,016,696 | 2 | true | 0 | 0 | Deep deep (deep deep deep...) down in the OS's system calls, yes. Modern OSes have thread-safe terminal printing routines which usually just lock around the critical sections that do the actual device access (or buffer, depending on what you're writing into and what its settings are). These waits are very short, howeve... | 2 | 3 | 0 | if you run couple of threads but they all have to print to the same stdout, does this mean they have to wait on each other? so say if all 4 threads have something to write, they have to pause and wait for the stdout to be free so they can get on with their work? | Do python thread wait for standard output? | 1.2 | 0 | 0 | 658 |
6,016,663 | 2011-05-16T11:25:00.000 | 0 | 0 | 1 | 0 | python,multithreading | 6,016,975 | 2 | false | 0 | 0 | It depends. If stdout is a pipe, each pipe gets a 4KB buffer which you can override when the pipe is created. Buffers are flushed when the buffer is full or with a call to flush().
If stdout is a terminal, output is usually line buffered. So until you print a newline, all threads can write to their buffers. When the ne... | 2 | 3 | 0 | if you run couple of threads but they all have to print to the same stdout, does this mean they have to wait on each other? so say if all 4 threads have something to write, they have to pause and wait for the stdout to be free so they can get on with their work? | Do python thread wait for standard output? | 0 | 0 | 0 | 658 |
6,018,214 | 2011-05-16T13:34:00.000 | -4 | 0 | 1 | 0 | python,postgresql,datetime | 18,624,640 | 7 | false | 0 | 0 | Just use
now()
or
CURRENT_TIMESTAMP
I prefer the latter as I like not having additional parenthesis but thats just personal preference. | 1 | 64 | 0 | I need to insert rows into PG one of the fields is date and time with time stamp, this is the time of incident, so I can not use --> current_timestamp function of Postgres at the time of insertion, so how can I then insert the time and date which I collected before into pg row in the same format as it would have been c... | How to insert current_timestamp into Postgres via python | -1 | 1 | 0 | 190,399 |
6,019,192 | 2011-05-16T14:52:00.000 | 0 | 0 | 0 | 1 | python,command-line,keyboard-shortcuts | 6,019,234 | 3 | false | 0 | 0 | If using X, the text is normally copied to the clipboard once it's selected. Just paste it using middle mouse button or Shift+insert. | 1 | 4 | 0 | I have written a piece of code in python, in which I am asking questions and users should give their input. Sometimes, these questions are difficult for the user to understand(they are non-english). So most of the time they want to copy paste the sentence into google translate. However, since this code is running in th... | How to prevent termination of a running program using "ctrl+c" in Linux using python? | 0 | 0 | 0 | 838 |
6,019,627 | 2011-05-16T15:25:00.000 | 55 | 0 | 1 | 0 | python | 6,019,984 | 3 | false | 0 | 0 | I'll supplement Sven's (accurate) response with an answer to the natural follow-up question (i.e. Why is self explicit rather than implicit?).
Python works this way as it operates on the idea of lexical scoping: bare name references will always refer to a local variable within the current function definition, a local v... | 2 | 59 | 0 | I am new to Python (usually work on C#), started using it over the last couple of days.
Within a class, do you need to prefix any call to that classes data members and methods? So, if I am calling a method or obtaining a value from that class, from within that class, I need to use self.method() or self.intvalue, for e... | Python 'self' keyword | 1 | 0 | 0 | 62,596 |
6,019,627 | 2011-05-16T15:25:00.000 | 124 | 0 | 1 | 0 | python | 6,019,656 | 3 | true | 0 | 0 | There is no less verbose way. Always use self.x to access the instance attribute x. Note that unlike this in C++, self is not a keyword, though. You could give the first parameter of your method any name you want, but you are strongly advised to stick to the convention of calling it self. | 2 | 59 | 0 | I am new to Python (usually work on C#), started using it over the last couple of days.
Within a class, do you need to prefix any call to that classes data members and methods? So, if I am calling a method or obtaining a value from that class, from within that class, I need to use self.method() or self.intvalue, for e... | Python 'self' keyword | 1.2 | 0 | 0 | 62,596 |
6,020,070 | 2011-05-16T16:01:00.000 | 1 | 0 | 0 | 0 | wxpython,wxwidgets | 6,641,179 | 1 | false | 0 | 1 | Maybe you could use the editor to set the numeric value of the cell, then on the renderer draw a vertical bar by dividing the value by the maximum possible value and multiplying it by the width of the cell (in px, to get the proportion of the cell that the slider needs to appear at) and drawing a narrow vertical rectan... | 1 | 1 | 0 | I need to show a slider in one column of a grid. I was able to create a custom CellEditor which displays the slider when I double click into a cell of the appropriate column so it enters the edit mode. But I don't know how to create a custom CellRenderer that displays the slider in all cell that are not in edit mode.
U... | wx/wxPython: How to add a slider to a grid cell? | 0.197375 | 0 | 0 | 337 |
6,021,174 | 2011-05-16T17:40:00.000 | 0 | 0 | 0 | 0 | python,selection,clipboard | 6,022,364 | 2 | false | 0 | 0 | Doing what you want would be hard to do properly, assuming it's possible at all.
For example, without requiring the user to press a key (eg: Cmd+C, Ctrl+C, etc) how do you expect your application to know when they are done selecting? If I do a click, then shift-click to select a range, am I done? What if I shift-click... | 2 | 2 | 0 | I want to have a python script, which will "idle" until some text is selected in an other desktop app, and then store it in a var. Eg:
User goes into Safari
User selects a block of text
In the background, the python script will store that block of text in a var
Now that the python script has it's var, it can stop "idl... | get selected text in an other application | 0 | 0 | 0 | 1,973 |
6,021,174 | 2011-05-16T17:40:00.000 | 1 | 0 | 0 | 0 | python,selection,clipboard | 6,021,275 | 2 | false | 0 | 0 | You might want to consider using AppleScript rather than python and have the AppleScript pass the information along to the python if needed. | 2 | 2 | 0 | I want to have a python script, which will "idle" until some text is selected in an other desktop app, and then store it in a var. Eg:
User goes into Safari
User selects a block of text
In the background, the python script will store that block of text in a var
Now that the python script has it's var, it can stop "idl... | get selected text in an other application | 0.099668 | 0 | 0 | 1,973 |
6,021,550 | 2011-05-16T18:13:00.000 | 2 | 0 | 0 | 0 | python,numpy,mmap,memory-mapped-files,large-data | 6,022,144 | 1 | true | 0 | 0 | If you run "pmap SCRIPT-PID", the "real" memory shows as "[ anon ]" blocks, and all memory-mapped files show up with the file name in the last column.
Purging the pages is possible at C level, if you manage to get ahold of the pointer to the beginning of the mapping and call madvise(ptr, length, MADV_DONTNEED) on it, b... | 1 | 0 | 1 | Given a numpy.memmap object created with mode='r' (i.e. read-only), is there a way to force it to purge all loaded pages out of physical RAM, without deleting the object itself?
In other words, I'd like the reference to the memmap instance to remain valid, but all physical memory that's being used to cache the on-disk ... | Purging numpy.memmap | 1.2 | 0 | 0 | 487 |
6,021,771 | 2011-05-16T18:35:00.000 | 4 | 1 | 0 | 1 | python,linux,process,controls,pid | 6,021,798 | 3 | false | 0 | 0 | call ps and check the STAT value.
D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should neve... | 1 | 7 | 0 | I have a python script that is using the SIGSTOP and .SIGCONT commands with os.kill to pause or resume a process. Is there a way to determine whether the related PID is in the paused or resumed state? | Is there a way to determine if a Linux PID is paused or not? | 0.26052 | 0 | 0 | 2,298 |
6,022,119 | 2011-05-16T19:07:00.000 | 4 | 0 | 0 | 0 | javascript,python,html,dhtml | 6,022,254 | 1 | true | 1 | 0 | If your API can output a JSON document with your data, you gain significant flexibility and future-proofing. This might even be something your users will want to access directly for their own external consumption. And of course your JS code can easily generate a table from this data.
However nobody here can tell you ... | 1 | 0 | 0 | SHORT: my python code generates a webpage with a table. i'm considering rewriting it to generate a js file instead, that holds the table contents in an array ... and then let the table be generated client-side. I am not sure of the pros and cons. Anyone care to offer their experience/insight? Are there other solutio... | Advice: where to situate html table content: in JS or HTML | 1.2 | 0 | 1 | 77 |
6,023,377 | 2011-05-16T21:00:00.000 | 3 | 1 | 0 | 1 | python,ide | 6,024,347 | 1 | true | 0 | 0 | In absence of some other file based config, you could just keep the variable definitions in a a file that you import in the main script (e.g, config.py), then have two different versions of that file for 'on' and 'off' network, (or ' development' and 'production', whatever) with the appropriate settings. No IDE needed... | 1 | 0 | 0 | Is there any IDE that allows to run a script in testing mode, allowing to replace at runtime, some values, like a folder or else?
I have a program that will have to run on a network i have no access to where I develop. Since it will use some specific folders to pick up files, I was wondering if i.e. I could use an IDE ... | IDE for Python: test a script | 1.2 | 0 | 0 | 110 |
6,023,488 | 2011-05-16T21:10:00.000 | 6 | 0 | 1 | 0 | python,math,aspect-ratio | 6,023,516 | 3 | false | 0 | 0 | new_y = (float(new_x) / x) * y
or
new_x = (float(new_y) / y) * x | 1 | 3 | 0 | I'm trying to simply take a given box of x by y and scale it up, either by setting x and finding y, or vice versa. How would this formula be expressed in Python (for readability's sake). I'm trying to fit this box inside of a larger box so that the inner box always fits within the larger box. | How to proportionally (respecting aspect ratio) scale a rectangle? | 1 | 0 | 0 | 4,438 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.