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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6,227,618 | 2011-06-03T13:21:00.000 | 1 | 0 | 1 | 0 | python,hash,bittorrent | 6,227,884 | 2 | false | 0 | 0 | Luckily 32 is smaller than 40, so you can just pad with 8 zeroes without losing information. | 1 | 0 | 0 | Some websites such as Sumotorrent.com use the magnet link with the 32 digit long hash, but my code is designed to store and work with 40 digit long hash? | How to convert 32digit long info hash to 40 digit long info hash in python? | 0.099668 | 0 | 0 | 515 |
6,229,610 | 2011-06-03T16:00:00.000 | 3 | 0 | 1 | 0 | python,memory-management,ctypes | 6,229,664 | 2 | false | 0 | 1 | A common way to do this is adding an additional buffer parameter and a length parameter to the C function. If the function is called with a buffer size that is smaller than the required size, the function simply returns the required buffer size and performs no other action, otherwise, the data is copied into the buffer... | 1 | 1 | 0 | My python code is calling a C function in a native library (also written by me). The function takes two strings as arguments and returns its response as a string. The two argument strings that python passes to C library are only read by the C library, so I am not worried about their memory management. AFAIK, their memo... | How to manage string memory with python ctypes | 0.291313 | 0 | 0 | 2,432 |
6,229,910 | 2011-06-03T16:27:00.000 | 0 | 0 | 1 | 0 | python,windows,json,io | 6,230,008 | 4 | false | 0 | 0 | You need the strip() because "for line in file:" keeps the line terminators on the lines. It's not explicitly stated in the docs (at least in the 2.71 doc I'm looking at). But it functions in a fashion similar to file.readline(), which does explicitly state that it retains the newline. | 1 | 4 | 0 | I am working on a simple import routine that translates a text file to a json file format for our system in python.
import json
# Open text file for reading
txtFile = open('Boating.Make.txt', 'r')
# Create picklist obj
picklistObj = dict()
picklistObj['name'] = 'Boating.Make'
picklistObj['items'] = list()
i = 0
# I... | Reading lines from text file in python (windows) | 0 | 0 | 0 | 14,618 |
6,230,525 | 2011-06-03T17:28:00.000 | 0 | 0 | 0 | 0 | python,mobile-phones | 6,231,462 | 1 | true | 0 | 1 | Which phone model and OS are we talking about? Is it running Android?
I believe pre-Android Nokia phones used Qt GUI framework
Python has Qt wrappers, look into PyQt4 for all your UI needs. | 1 | 0 | 0 | I am writing one of the Mobile monitoring program in my phone which I almost finished it. My program has a pedometer which counts human's steps in a real time manner. My question is that I am now writing GUI for phone which will show let's say some picture after they accomplish 1000 steps(like an award) and so on. I am... | Python: Making a GUI in nokia phone | 1.2 | 0 | 0 | 285 |
6,230,793 | 2011-06-03T17:53:00.000 | 2 | 0 | 0 | 0 | python,nosql | 6,231,573 | 3 | false | 0 | 0 | It depends on your use-case. Are you planning on caching the records temporarily or do you want the records to persist? If the former, Redis would be the best choice because of its speed. If the latter, it would be better to choose either CouchDB or MongoDB because they can handle large datasets. | 1 | 2 | 0 | I'm writing a small Python CGI script that captures the User-Agent, parses the OS, browser name and version, maps it to a database, and returns a device grade (integer). Since this is only one table, it's a pretty simple operation, but I will likely have substantial traffic (10,000+ hits a day, potentially scaling muc... | Recommendations for a noSQL database for use with Python | 0.132549 | 1 | 0 | 776 |
6,232,564 | 2011-06-03T20:53:00.000 | 40 | 1 | 0 | 1 | python,amazon-ec2 | 6,232,612 | 3 | true | 0 | 0 | You have a few options.
You can add your script to cron to be run regularly.
You can run your script manually, and detach+background it using nohup.
You can run a tool such as GNU Screen, and detach your terminal and log out, only to continue where you left off later. I use this a lot.
For example:
Log in to your ma... | 1 | 23 | 0 | I've setup an Amazon EC2 server. I have a Python script that is supposed to download large amounts of data from the web onto the server. I can run the script from the terminal through ssh, however very often I loose the ssh connection. When I loose the connection, the script stops.
Is there a method where I tell the sc... | How to continuously run a Python script on an EC2 server? | 1.2 | 0 | 1 | 15,157 |
6,232,629 | 2011-06-03T20:58:00.000 | 11 | 0 | 0 | 1 | macos,wxpython,32bit-64bit | 6,232,781 | 1 | true | 0 | 1 | I don't have a Mac, but I read almost all the messages on the wxPython mailing list. As I understand it, you don't want to use the Python that came with your Mac. It has been modified for the Mac specifically somehow, so you should download a normal version of Python and install it.
As for the 32-bit question, with wxP... | 1 | 5 | 0 | I've spent a very frustrating evening trying to get wxpython to work on my MacBook Pro (running Snow Leopard 10.6.6). From reading the various threads on this topic both here and on other websites this is my understanding so far:
If you are running python 2.6 or greater you can only work with wxpython if you access th... | Battling with wxpython | 1.2 | 0 | 0 | 662 |
6,232,780 | 2011-06-03T21:17:00.000 | 4 | 1 | 0 | 0 | python | 6,232,816 | 1 | true | 1 | 0 | The only way to save the image would be to make a single call to the CATPCHA URL programatically, save the result, and then present that saved result to the user. The whole point of CAPTCHA is that each request generates a unique/different reponse/image. | 1 | 0 | 0 | I tried using mechanize to see the URL of the image, but its a dynamic page generating a different image each time. I was wondering if there was any way to "capture" this image for viewing/saving.
Thanks! | Capturing CAPTCHA image with Python | 1.2 | 0 | 1 | 540 |
6,233,230 | 2011-06-03T22:22:00.000 | 1 | 0 | 0 | 0 | python,django,unicode,webfaction | 6,233,867 | 2 | false | 1 | 0 | Yes, u'\u2122' is the trade mark sign. Somewhere in your code, you should be:
encoding your unicode data using a codec (utf8, cp1250 to cp1258, etc) that supports that character
or
avoiding an automatic unexpected decoding (which uses ascii, which doesn't support that character).
Which action is needed and where? N... | 2 | 1 | 0 | I'm trying to create an app using Django on webfaction. I basically was messing around with the Amazon API, and when one of the search results has a trademark symbol, which is passed to my template...the error is thrown. I'm getting the error
Caught UnicodeEncodeError while rendering: 'ascii' codec can't encode charact... | UnicodeEncodeError in django app | 0.099668 | 0 | 0 | 1,361 |
6,233,230 | 2011-06-03T22:22:00.000 | 3 | 0 | 0 | 0 | python,django,unicode,webfaction | 6,233,347 | 2 | true | 1 | 0 | It probably means you are calling str() on a a peice of unicode data - the str function could be called ascii to better describe what it does! Your templates will be totally happy with unicode data so given that you are using Django I suspect the problem is in a __unicode__ method or some such.
Unicode is a tricky subj... | 2 | 1 | 0 | I'm trying to create an app using Django on webfaction. I basically was messing around with the Amazon API, and when one of the search results has a trademark symbol, which is passed to my template...the error is thrown. I'm getting the error
Caught UnicodeEncodeError while rendering: 'ascii' codec can't encode charact... | UnicodeEncodeError in django app | 1.2 | 0 | 0 | 1,361 |
6,233,447 | 2011-06-03T22:59:00.000 | 2 | 0 | 1 | 0 | python,plugins | 6,233,558 | 2 | true | 0 | 0 | Having written quite a few different plugin architectures in different platforms and languages, I will say that you are pretty much on track with how most plugins systems are written.
Basically what it boils down to, is your host and your plugin need to have some kind of common contract to work with; in other words, yo... | 1 | 9 | 0 | I am writing an application (a server wrapper for Minecraft) that I wish to make extensible with plugins. I have a system in place that works, however I think that in the long run it could use improvement.
The way that I have it now, the application calls a "get_plugins" method in the server class that, first imports ... | Implementing a Plugin System in Python | 1.2 | 0 | 0 | 2,253 |
6,233,805 | 2011-06-04T00:12:00.000 | 0 | 0 | 0 | 0 | python,flash,pygame | 8,205,898 | 1 | true | 0 | 1 | Judging from the GUI's features list and usage, it does not appear to support .swf playback. If anyone has evidence to the contrary, an additional answer would be appreciated. | 1 | 1 | 0 | I'm looking at switching programming languages due to some unavoidable roadblocks. However, before I dedicate myself to a whole new language, I need to know if it is possible for me to play .swf or .flv files underneath other GUI elements if I am using OcempGUI and pygame? Will using those two libraries back me into a ... | Play .swf with Python/Pygame/OcempGUI | 1.2 | 0 | 0 | 461 |
6,234,798 | 2011-06-04T04:59:00.000 | 3 | 0 | 0 | 0 | python,turtle-graphics,window-management | 8,966,931 | 5 | false | 0 | 1 | Try adding input() at the end of your code. | 1 | 41 | 0 | I have a small python script which draws some turtle graphics. When my script has finished running, the turtle screen automatically closes, so to be able to see the graphics for a while I have to use time.sleep(5) at the end of the script to delay the closing.
Is there any way I can make this more dynamic, i.e. tell py... | Turtle graphics - How do I control when the window closes? | 0.119427 | 0 | 0 | 113,747 |
6,236,794 | 2011-06-04T12:41:00.000 | 1 | 0 | 0 | 0 | python,django,web-crawler | 6,236,831 | 3 | false | 1 | 0 | HTML parse will parse the page and you can collect the links present in it. These links you can add to queue and visit these pages. Combine these steps in a loop and you made a basic crawler.
Crawling libraries are the ready to use solutions which do the crawling. They provide more features like detection of recursive ... | 1 | 4 | 0 | I need to grab some data from websites in my django website.
Now i am confused whether i should use python parsing libraries or web crawling libraries. Does search engine libraries also fall in same category
I want to know how much is the difference between the two and if i want to use those functions inside my websit... | How much is the difference between html parsing and web crawling in python | 0.066568 | 0 | 1 | 2,480 |
6,239,612 | 2011-06-04T21:49:00.000 | 5 | 0 | 0 | 1 | python,django,google-app-engine,authentication,authorization | 6,246,968 | 2 | true | 1 | 0 | You'll need to do this yourself: Implement the ACL with a datastore model keyed by the user's user_id, and fetch and check it on each request. The Users API doesn't provide anything like this built-in. | 1 | 3 | 0 | I would like to implement ACL with Google Authentication. Need some pointer regarding the possibility of the same.
Use case:
Page X accessible only to myadmin@gmail.com
Page Y accessible for all belong to a group Y. After registration a moderator will add/reject the user to the group Y.
Pages are not accessible if use... | Appengine ACL with Google Authentication | 1.2 | 0 | 0 | 871 |
6,239,737 | 2011-06-04T22:19:00.000 | 5 | 0 | 0 | 1 | python,google-app-engine,datastore,ancestor | 6,243,119 | 1 | true | 1 | 0 | When you create an entity with a parent, the entities are placed in the same Entity Group. Transactions in App Engine can only work within a single entity group, so if you need transactions, you need entity groups. If you don't need transaction, you don't need entity groups (in particular, to build relationships betwee... | 1 | 0 | 0 | I've been developing for Google App Engine for a while. One of the features I've noticed but haven't had an opportunity to use yet is "ancestors" in the data store.
What would be an example of a situation where this is useful? | Ancestors in App Engine data store | 1.2 | 0 | 0 | 300 |
6,239,887 | 2011-06-04T22:56:00.000 | 18 | 0 | 1 | 0 | python,function,printing,python-3.x,python-2.x | 24,438,151 | 5 | false | 0 | 0 | I thought over this question and had no idea about pros of python 3 version. But when I needed to print the columns of pandas.DataFrame (without Index([...])), I've found out that
print *df.columns
throws an exception, while
print(*df.columns)
works fine! And if you want to have same (configurable) print options in sev... | 1 | 72 | 0 | I've heard several times that print being a function (3.x) is better than it being a statement (2.x). But why?
I was a fan of it being a statement mainly because it allowed me to type two less characters (ie, the parentheses).
I'd be interested to see some situations where the print statement just doesn't cut it, and ... | What is the advantage of the new print function in Python 3.x over the Python 2 print statement? | 1 | 0 | 0 | 29,027 |
6,241,245 | 2011-06-05T05:49:00.000 | 1 | 0 | 1 | 0 | python,tree | 6,242,721 | 3 | false | 0 | 0 | That they are trees is not even relevant to the solution. You're looking for how long it takes for two single-linked (the parent link) lists to converge into the same list.
Simply follow the links, but keep a length count for each visited node. Once you reach an already visited node, sum the previously found count and... | 1 | 1 | 0 | I have two trees in python. I need to compare them in a customized way according to the following specifications. Suppose I have a tree for entity E1 and a tree for entity E2. I need to traverse both the trees starting from E1 and E2 and moving upwards till I get to a common root. (Please note that I have to start the ... | Tree traversal in a customised way in Python? | 0.066568 | 0 | 0 | 332 |
6,241,448 | 2011-06-05T06:55:00.000 | 0 | 1 | 1 | 0 | python,class,object,tracking | 6,241,493 | 5 | false | 0 | 0 | What is the scope of your objects? Can you lock down where they are stored and accessed? If so, you should consider creating some kind of special container that will timestamp when the object was last used or accessed. Access to the objects would be tightly controlled by a function which could time-stamp last access... | 4 | 6 | 0 | I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called).
I can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this? | What's the most elegant way of keeping track of the last time a python object is accessed? | 0 | 0 | 0 | 565 |
6,241,448 | 2011-06-05T06:55:00.000 | 2 | 1 | 1 | 0 | python,class,object,tracking | 6,241,583 | 5 | false | 0 | 0 | If you are using python 3.2 then have a look at functions.lru_cache() and see if that does what you want. It won't give you a last modified time, but it will do the cleanup of unused object.
For older versions it might provide the pattern you want to use but you'll have to provide the code. | 4 | 6 | 0 | I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called).
I can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this? | What's the most elegant way of keeping track of the last time a python object is accessed? | 0.07983 | 0 | 0 | 565 |
6,241,448 | 2011-06-05T06:55:00.000 | 0 | 1 | 1 | 0 | python,class,object,tracking | 6,243,773 | 5 | false | 0 | 0 | Keep a dict of the IMAP connections, keyed by the user ID. Write a function, that given a user ID, returns an IMAP connection. The function will look up the user ID in the dict, and if the user ID is there, get the corresponding IMAP connection, and check that it's still alive. If alive, the function returns that co... | 4 | 6 | 0 | I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called).
I can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this? | What's the most elegant way of keeping track of the last time a python object is accessed? | 0 | 0 | 0 | 565 |
6,241,448 | 2011-06-05T06:55:00.000 | 1 | 1 | 1 | 0 | python,class,object,tracking | 6,241,480 | 5 | false | 0 | 0 | Python's highly dynamic nature lets you write proxies that wrap objects in interesting ways. In this case, you could write a proxy that replaces the methods of an object (or an entire class) with wrapper methods that update a timestamp and then delegates the call to the original method.
This is somewhat involved. A sim... | 4 | 6 | 0 | I have a list of objects in python that I would regularly check and destroy some of them - those which haven't been accessed lately (i.e. no method was called).
I can maintain the last time accessed and update it in every method, but is there any more elegant way to achieve this? | What's the most elegant way of keeping track of the last time a python object is accessed? | 0.039979 | 0 | 0 | 565 |
6,243,015 | 2011-06-05T12:55:00.000 | 1 | 0 | 0 | 0 | python,windows,django,apache,mod-wsgi | 6,243,058 | 2 | true | 1 | 0 | The answer is: don't use Apache in development. Use the built-in development server, or perhaps gunicorn. | 1 | 0 | 0 | I finished installing django on my Windows machine using Apache 2.2/Python 2.6/Django 1.3/mod_wsgi. It seems like everytime I change my Python code (such as settings.py), I need to restart Apache in order for changes to take effect.
I understood that using WSGIRestrictEmbedded should solve this issue but the docs for w... | Working with django and mod_wsgi in Windows | 1.2 | 0 | 0 | 543 |
6,243,933 | 2011-06-05T15:42:00.000 | 2 | 1 | 0 | 1 | python,fork,shelve,python-daemon | 6,258,988 | 2 | false | 0 | 0 | For those who came across this post in the future. Python-daemon can still work. It is just that be sure to load the shelve dicts within the same process. So previously the shelve dicts is loaded in parent process, when python-daemon spawns a child process, the dict handler is not passed correctly. When we fix this, ev... | 1 | 3 | 0 | I need to use fabfile to remotely start some program in remote boxes from time to time, and get the results. Since the program takes a long while to finish, I wish to make it run in background and so I dont need to wait. So I tried os.fork() to make it work. The problem is that when I ssh to the remote box, and run the... | remotely start Python program in background | 0.197375 | 0 | 0 | 2,313 |
6,244,799 | 2011-06-05T18:06:00.000 | 2 | 1 | 0 | 1 | python,serialization,32bit-64bit | 6,244,838 | 3 | true | 0 | 0 | As long as your struct format string uses "standard size and alignment" (< or >) rather than "native size and alignment" (@), your files can be used cross-platform. | 1 | 3 | 0 | I am using python struct module to create custom binary files.
The file itself has the following format:
4 bytes (integer)
1 byte (unsigned char)
4 bytes (float)
4 bytes (integer)
1 byte (unsigned char)
4 bytes (float)
.......................... (100000 such lines)
4 bytes (integer)
1 byte (unsigned char)
4 bytes (fl... | Binary Files on 32bit / 64bit systems? | 1.2 | 0 | 0 | 1,348 |
6,244,906 | 2011-06-05T18:25:00.000 | 0 | 1 | 0 | 0 | python,django,wordpress,content-management-system | 6,245,184 | 6 | false | 1 | 0 | Drupal or Joomla are your best bet. Firstly, Joomla allows you to basically drop in these features you're asking for in an install an go manner. This is the easiest way to go.
Now if you want a LOTS and LOTS customization and don't mind getting into a little code then drupal will be perfect.The great thing is that the ... | 2 | 3 | 0 | There's not really anything on my planned site that would require a whole lot of customization but I'm looking for something that has built in functionality for forums, comments, reviews, a blog, a database that can queried by users, and some social networking features.
I have a decent amount of experience using python... | CMS or web framework a simple project | 0 | 0 | 0 | 1,735 |
6,244,906 | 2011-06-05T18:25:00.000 | 1 | 1 | 0 | 0 | python,django,wordpress,content-management-system | 6,244,936 | 6 | false | 1 | 0 | Use a CMS, Drupal is very flexible and you can install another cms like vanilla for the forums options with a plugin.
It's al you need. But if you want a full control of your site, use a framwork like Django and you get all.
Remenber, the CMS is the fastest way to build a site.
Sorry for my english mistakes. | 2 | 3 | 0 | There's not really anything on my planned site that would require a whole lot of customization but I'm looking for something that has built in functionality for forums, comments, reviews, a blog, a database that can queried by users, and some social networking features.
I have a decent amount of experience using python... | CMS or web framework a simple project | 0.033321 | 0 | 0 | 1,735 |
6,246,850 | 2011-06-06T00:22:00.000 | 0 | 1 | 0 | 0 | python,cherrypy,feedparser | 6,279,095 | 2 | true | 0 | 0 | A few reboots later (for unrelated reasons) and it's working again. How odd.... | 1 | 2 | 0 | I have a method in my script that pulls a Twitter RSS feed, parses it with FeedPharser, wraps it in TwiML (Twilio-flavored XML) using the twilio module, and returns the resulting response in a CherryPy method via str(). This works my fine in development environment (Kubuntu 10.10); I have had mixed results on my server... | What could cause a UnicodeEncodeError exception to creep into a working Python environment? | 1.2 | 0 | 1 | 238 |
6,248,347 | 2011-06-06T06:09:00.000 | 2 | 0 | 1 | 0 | c++,python,c,perl,exif | 6,248,916 | 2 | false | 0 | 0 | Unfortunately, most cameras don't actually store enough metadata in the video :(.
If they are storing it, due to the wide variety of video codecs and containers like AVI, MOV, MPG, MP4, etc., a good option will to run ffmpeg -i to read it. | 1 | 3 | 0 | Is there any standard way to get information from a video file? For images we have EXIF data which can be used to get information about the date/time , size etc of the image file. I was wondering if there is such a thing for videos as well.
The use case is - I have lot of videos which I shot from my digital camera. I w... | EXIF like thing for Videos | 0.197375 | 0 | 0 | 2,402 |
6,248,424 | 2011-06-06T06:21:00.000 | 1 | 0 | 0 | 0 | python,parsing,search,web-crawler | 6,248,603 | 2 | true | 1 | 0 | I'm using Beautiful Soup and am very happy with it. So far it answered all my scraping needs. Two main benefits:
It's pretty good at handling non-perfect HTML. Since browsers are quite lax, many HTML documents aren't 100% well-formed
In addition to high-level access APIs, it has low-level APIs which make it extendible... | 2 | 1 | 0 | I need to do lot html parsing / scraping /search engine /crawling.
There are many libraries currently like Scrapy, Beautiful Soup, lxml , lxml2 requests, pyquery.
Now i don't want to try each of these and then decide. basically i want to follow on one and then study in detail and then use that most often.
So which libr... | If i have to choose only one html scraping library for python, which should i choose | 1.2 | 0 | 1 | 162 |
6,248,424 | 2011-06-06T06:21:00.000 | 1 | 0 | 0 | 0 | python,parsing,search,web-crawler | 6,248,605 | 2 | false | 1 | 0 | Since lots of HTML documents are not well-formed but rather a bunch of tags (sometimes not even properly nested) you probably want to go with BeautifulSoup instead of one of the xml-based parsers. | 2 | 1 | 0 | I need to do lot html parsing / scraping /search engine /crawling.
There are many libraries currently like Scrapy, Beautiful Soup, lxml , lxml2 requests, pyquery.
Now i don't want to try each of these and then decide. basically i want to follow on one and then study in detail and then use that most often.
So which libr... | If i have to choose only one html scraping library for python, which should i choose | 0.099668 | 0 | 1 | 162 |
6,248,772 | 2011-06-06T07:06:00.000 | 4 | 0 | 0 | 0 | python,django | 6,248,788 | 4 | true | 1 | 0 | No. WSGI containers don't require the scripts to be in the document root, and so to increase security in case of a transient server error they shouldn't be placed in the document root. | 2 | 2 | 0 | As the title states, I'm trying to figure out the best practice for where to store application files for a Python website on the server. Document root, or no?
I come from a land of PHP. :)
EDIT - To that end, links to any material describing the best practice differences between Python and PHP are hugely appreciated. | Should Django Python apps be stored in the web server document root? | 1.2 | 0 | 0 | 561 |
6,248,772 | 2011-06-06T07:06:00.000 | 0 | 0 | 0 | 0 | python,django | 6,248,805 | 4 | false | 1 | 0 | There's no reason to store it in the document root.
While storing the app in the doc root isn't nessescarily a security problem - if configured correctly and handled carefully - storing it outside will remove a lot of headache and configuration work.
That's the main reason not to do it. | 2 | 2 | 0 | As the title states, I'm trying to figure out the best practice for where to store application files for a Python website on the server. Document root, or no?
I come from a land of PHP. :)
EDIT - To that end, links to any material describing the best practice differences between Python and PHP are hugely appreciated. | Should Django Python apps be stored in the web server document root? | 0 | 0 | 0 | 561 |
6,252,236 | 2011-06-06T12:47:00.000 | 1 | 0 | 0 | 0 | python,nlp,nltk,wordnet | 6,254,429 | 2 | false | 0 | 0 | consider implementing Spotsigs | 1 | 7 | 0 | I want to find whether two web pages are similar or not. Can someone suggest if python nltk with wordnet similarity functions helpful and how? What is the best similarity function to be used in this case? | using python nltk to find similarity between two web pages? | 0.099668 | 0 | 1 | 6,475 |
6,252,588 | 2011-06-06T13:18:00.000 | 1 | 0 | 1 | 0 | python,datetime | 6,252,628 | 3 | false | 0 | 0 | Call the datetime module with an arbitrary date and save the results for the conversions for %a and %u in a map. %a is the key for this map, %u is the value.
Increment the date by one day.
Repeat 7 times.
Now you have a map which returns the value you seek for any possible value of %a. | 1 | 2 | 0 | How would i go about converting a weekday abbreviation (%a) into the weekday number (%u) using python datetime module? | python datetime, convert weekday's abbrv to number? | 0.066568 | 0 | 0 | 5,014 |
6,253,541 | 2011-06-06T14:29:00.000 | 3 | 0 | 0 | 0 | python,parameter-passing,zope | 6,253,856 | 1 | true | 1 | 0 | You're missing rather a lot of detail on your method. Is it a method of a class? Or standalone? Normally, self would refer to an instance of the class PyTest - which would be a subclass of BrowserView.
Then, the data you pass to the view (@@test) is retrieved from the Request object, which is available in self.reques... | 1 | 1 | 0 | In my Zope instance, I have a Python script registered as a browser page. I have the following code as its registry:
<browser:page name="test" for="*" permission="zope2.Public" class="browser.test.PyTest" attribute="CallPy" />
This function, "PyTest.CallPy" is defined as:
def CallPy(self, data): ...
I then use JavaScr... | Pass arguments to Zope browser page | 1.2 | 0 | 0 | 337 |
6,253,613 | 2011-06-06T14:34:00.000 | 1 | 0 | 0 | 1 | python,linux,shell,root,sudo | 6,254,043 | 1 | false | 0 | 0 | I'd put logic in the python_script.py to check its UID and fail if is not executed as root. if os.getuid() != 0:. That will ensure it only runs as root, ether by a root login, or sudo.
If you're getting permission denied when trying to execute the python_script.py, you need to set the execute bit on it. chmod +x pyth... | 1 | 1 | 0 | I'm trying to invoke a shell script shell_script.sh from a python script (python_script.py) using the call command. The shell_script.sh invokes a executable that requires root access to execute.
The python_script.py invokes shell_script.sh using subprocess.call().
See below:
subprocess.call(['/complete_path/shell_s... | Invoking shell script from a python script using root privileges | 0.197375 | 0 | 0 | 2,685 |
6,255,935 | 2011-06-06T17:43:00.000 | 0 | 0 | 1 | 0 | python,multithreading,global-variables,multiprocessing,python-2.3 | 11,786,328 | 2 | true | 0 | 0 | None that I ever found anywhere, I have since moved on to python 2.5 | 1 | 2 | 0 | Is there any multiprocessing type module for Python 2.3? I am stuck using 2.3 for the programs I interface with and would like to be able to setup some multiprocessing as the tasks I do only use one CPU and are really inefficient.
I would like each thread/process to handle its own global variables and each thread/pr... | Python 2.3 multiprocessing | 1.2 | 0 | 0 | 417 |
6,258,064 | 2011-06-06T21:10:00.000 | 1 | 1 | 0 | 0 | python,shutil | 6,258,122 | 1 | true | 0 | 0 | There is a backslash at the end of your file name so it is maybe treated as a path. | 1 | 0 | 0 | I'm copying files from the temporary internet files cache into a folder, in bulk using a python script. Using shutil to copy the full path to the os.cwd, it comes up with this error:
builtins.IOError: [Errno 22] Invalid argument:
'C:\\Users\\NICK\\AppData\\(no whitespace in path; only for readability)
Local\\Microso... | Copying files from temporary internet cache in python | 1.2 | 0 | 0 | 347 |
6,259,775 | 2011-06-07T01:23:00.000 | 50 | 0 | 0 | 0 | python,django | 6,602,387 | 5 | false | 1 | 0 | {% now 'Y' %} is the correct syntax | 1 | 182 | 0 | What is the inbuilt template tag to display the present year dynamically. Like "2011" what would be the template tag to display that? | How to display the current year in a Django template? | 1 | 0 | 0 | 64,035 |
6,260,277 | 2011-06-07T03:17:00.000 | 1 | 0 | 0 | 0 | python,linux,search,beautifulsoup | 6,260,471 | 1 | true | 1 | 0 | No, BeautifulSoup is not a search engine. It is also not a Swiss Army knife, nor can it make you a sandwich. You will need a database (preferably one that's optimized for search, like Sphinx or Lucene) to do that. | 1 | 0 | 0 | I am using Beautiful Soup for parsing web pages.
Are there any functions in BS which i can use i making search engine or crawling the website to index it in database. | Is it possible to code search engine in beautiful Soup | 1.2 | 0 | 1 | 262 |
6,261,244 | 2011-06-07T06:15:00.000 | 0 | 0 | 0 | 1 | python,real-time | 12,251,479 | 3 | false | 0 | 0 | There is definitely a bug in Queue.get, at least in python 2.6.6.
On posix a queue.get(timeout=1) seems to exit (raising the Empty exception) almost immediately, whereas queue.get(timeout=2) is working fine.
I was using a single queue with concurrent threads *get*ing on it... | 2 | 4 | 0 | UPDATE: This question is based on a faulty mental model of how Queue.get() was actually behaving, which was caused by some slightly ambiguous documentation but mainly by a buggy, hand-rolled implementation of timedelta.total_seconds(). I discovered this bug when trying to prove that the original answers where incorrect... | Why does Python's queue.Queue.get() permit returning early from timeouts? | 0 | 0 | 0 | 2,227 |
6,261,244 | 2011-06-07T06:15:00.000 | 5 | 0 | 0 | 1 | python,real-time | 6,261,388 | 3 | true | 0 | 0 | I think you are misinterpreting the documentation. It isn't saying it might raise the Empty exception after less than timeout seconds, it is saying it will block for at most timeout seconds. It might block for less than that, if it can satisfy the get.
I realize you are saying you see it raising Empty early, but hone... | 2 | 4 | 0 | UPDATE: This question is based on a faulty mental model of how Queue.get() was actually behaving, which was caused by some slightly ambiguous documentation but mainly by a buggy, hand-rolled implementation of timedelta.total_seconds(). I discovered this bug when trying to prove that the original answers where incorrect... | Why does Python's queue.Queue.get() permit returning early from timeouts? | 1.2 | 0 | 0 | 2,227 |
6,262,601 | 2011-06-07T08:35:00.000 | 2 | 0 | 0 | 1 | python,google-app-engine,session | 6,264,539 | 2 | false | 1 | 0 | HTTP is stateless, so there's no inherent definition of "online user". You could count the number of non-destroyed sessions you've created, but unless you've got a cron job that destroys old sessions, this won't give an accurate picture.
You basically need to decide how much time without a new page request counts as "o... | 1 | 2 | 0 | I am currently working on an application for Google App Engine, and I need some advice to detect the number of online users in the application. How can I do this?
I am using a session library. Do I need to overwrite the session methods (create_session, destroy_session increment/and decrement a value in datastore) or i... | How to detect online users in a web application in Google App Engine | 0.197375 | 0 | 0 | 548 |
6,265,356 | 2011-06-07T12:45:00.000 | 1 | 0 | 0 | 0 | macos,wxpython | 6,540,867 | 1 | true | 0 | 1 | For the benefit of others that may run into this, I figured out the solution: "wx.App_SetMacPreferencesMenuItemId(wx.ID_NONE)". The trick is to do this before you create the menu, not after. On wxPython 2.9.1.1 it will ghost out the Preferences menu item (which is good enough for me). On 2.9.2 it will remove the item c... | 1 | 1 | 0 | When using wxPython, is it possible to remove or disable the "Preferences" menu item that gets automatically created in the Python menu on OS X? | Remove Preferences menu item on OS X apps | 1.2 | 0 | 0 | 145 |
6,266,641 | 2011-06-07T14:20:00.000 | 6 | 1 | 1 | 0 | python,c,performance,comparison,binary-search | 6,266,843 | 2 | false | 0 | 0 | As DMS says in the comment, there's a built-in set (and the immutable variant, frozenset, which is very useful you don't need to mutate and can fit the generation of the values into a single generator expression). It's hash-based and therefore sacrifices order for amortized O(1) membership testing. It's written in C an... | 2 | 2 | 0 | I'm fairly new to Python and was hoping I could get some advice before moving forward. I have a group of integers and I want to check whether or not a given element is contained within that group as fast as possible (speed does matter here).
With Python, should I be looking at custom data structures tailored for these... | Improving Python Comparison and Existence Operations | 1 | 0 | 0 | 116 |
6,266,641 | 2011-06-07T14:20:00.000 | 6 | 1 | 1 | 0 | python,c,performance,comparison,binary-search | 6,266,828 | 2 | false | 0 | 0 | The most Pythonic way would be to not store them in a sorted container, but to use a set (or the immutable variant frozenset). These are hash-based containers, so lookups are O(1). More importantly, the hashing algorithm is one of the core operations in Python (used for dictionaries, and attribute lookups), so it's w... | 2 | 2 | 0 | I'm fairly new to Python and was hoping I could get some advice before moving forward. I have a group of integers and I want to check whether or not a given element is contained within that group as fast as possible (speed does matter here).
With Python, should I be looking at custom data structures tailored for these... | Improving Python Comparison and Existence Operations | 1 | 0 | 0 | 116 |
6,266,899 | 2011-06-07T14:36:00.000 | 0 | 1 | 0 | 0 | python | 6,271,510 | 1 | false | 0 | 0 | I'm not sure, if I understand your use case. The user sees the source code and has some ways of jumping from a token to the appropriate part or a listing of the possible parts of the documentation, right?
Then a search tool seems to be the right tool for the job, although you could precompile every possible search (the... | 1 | 0 | 0 | I am trying to work out a solution for detecting traceability between source code and documentation. The most important use case is that the user needs to see the a collection of source code tokens (sorted by relevance to the documentation) that can be traced back to the documentation. She is wont be bothered about the... | Design help for static content with fixed keywords search framework | 0 | 0 | 0 | 44 |
6,267,072 | 2011-06-07T14:48:00.000 | 0 | 0 | 1 | 0 | python,mongodb,whoosh | 6,267,471 | 2 | false | 0 | 0 | Whoosh is a fast full-text searching and indexing library. MongoDB does not support full-text search, nor would it be as fast. Whoosh also has a great API and a lot of other features too. It should compliment MongoDB nicely. | 2 | 5 | 0 | I am working on the project that uses MongoDB and Whoosh. I wonder if the Whoosh is necessary if I can use MongoDB search. I am sure Whoosh was setup in the system for good, but I am not sure I understand right its purpose. Please give me some idea about what it gives that MongoDB alone doesn't. | MongoDB and Whoosh. Do I need both? | 0 | 0 | 0 | 1,243 |
6,267,072 | 2011-06-07T14:48:00.000 | 1 | 0 | 1 | 0 | python,mongodb,whoosh | 6,267,691 | 2 | true | 0 | 0 | MongoDB search requires you to add keywords that you can later search on, so it's not really full text search (as Whoosh is). Whoosh can also do stemming (not available out of the box with MongoDB) and flexible scoring of results (including user-defined scoring). | 2 | 5 | 0 | I am working on the project that uses MongoDB and Whoosh. I wonder if the Whoosh is necessary if I can use MongoDB search. I am sure Whoosh was setup in the system for good, but I am not sure I understand right its purpose. Please give me some idea about what it gives that MongoDB alone doesn't. | MongoDB and Whoosh. Do I need both? | 1.2 | 0 | 0 | 1,243 |
6,267,308 | 2011-06-07T15:06:00.000 | 0 | 1 | 1 | 0 | c++,python,debugging,gdb | 6,658,184 | 3 | false | 0 | 0 | You can generate (for example using python) a .gdbrc file with a line containing
'break C::foo'
for every function of your class C and then start gdb. | 1 | 4 | 0 | I would like to be able to set breakpoints to every method of a C++ class in gdb.
I think the easiest way to do this is probably python, since now python has complete access to gdb. I know very little python, and with gdb on top of it, it's even harder. I am wondering if anyone knows how to write a class python code ... | gdb python programming: how to write code that will set breakpoints to every method of a C++ class? | 0 | 0 | 0 | 605 |
6,267,613 | 2011-06-07T15:26:00.000 | 2 | 0 | 1 | 0 | python,virtualenv | 6,267,694 | 2 | true | 0 | 0 | You might consider using zc.buildout. It's more annoying to set up than plain pip/virtualenv, but it gives you more opportunities for automation. If the disk space usage isn't an issue, I'd suggest you just keep using individual environments for each project so you can upgrade them one at a time. | 2 | 6 | 0 | In my workplace, I have to manage many (currently tens, but probably hundreds eventually) Python web applications, potentially running various frameworks, libraries, etc (all at various versions). Virtualenv has been a lifesaver in managing that so far, but I'd still like to be able to manage things better, particular... | Managing many Python projects/virtualenvs | 1.2 | 0 | 0 | 392 |
6,267,613 | 2011-06-07T15:26:00.000 | 0 | 0 | 1 | 0 | python,virtualenv | 6,267,839 | 2 | false | 0 | 0 | We have a requirements.pip file at our project root that contains the packages for pip to install, so upgrading automatically is relatively easy. I'm not sure symlinking would solve the issue - it will make it harder to make upgrades to a subset of your projects. If diskspace isn't an issue, and you can write some simp... | 2 | 6 | 0 | In my workplace, I have to manage many (currently tens, but probably hundreds eventually) Python web applications, potentially running various frameworks, libraries, etc (all at various versions). Virtualenv has been a lifesaver in managing that so far, but I'd still like to be able to manage things better, particular... | Managing many Python projects/virtualenvs | 0 | 0 | 0 | 392 |
6,268,580 | 2011-06-07T16:36:00.000 | 2 | 0 | 0 | 0 | python,beautifulsoup | 6,268,759 | 2 | false | 1 | 0 | You haven't said what the site is so impossible to answer for sure. But a couple of suggestions. If the url does not change when you click the flag, then either:
a) The english is already in the html document, and the relevant content is being switched with javascript
b) The english content is being fetched via an ajax... | 1 | 0 | 0 | I have a website that I'm trying to scrape using Python & BeautifulSoup. The site itself can be viewed in 2 languages(Thai or English); all you have to do is to click on either the Thai or UK flag on the upper right corner of the screen and the data is displayed in the selected language. When in comes to the script tho... | Could not scrape data in English, help! | 0.197375 | 0 | 0 | 98 |
6,269,262 | 2011-06-07T17:31:00.000 | 1 | 0 | 1 | 0 | python,algorithm,list,memory-efficient | 6,269,842 | 5 | false | 0 | 0 | 85 items are not even worth thinking about. Computers are fast, really.
Why would you delete ranges from the list, instead of simply picking the one result?
If there is a good reason why you cant do (2): Keep the original list and change two indices only: The start and end index of the sublist you're looking at. | 4 | 2 | 0 | So I have a list of 85 items. I would like to continually reduce this list in half (essentially a binary search on the items) -- my question is then, what is the most efficient way to reduce the list? A list comprehension would continually create copies of the list which is not ideal. I would like in-place removal of r... | Efficient reduction of a list in python | 0.039979 | 0 | 0 | 1,038 |
6,269,262 | 2011-06-07T17:31:00.000 | 0 | 0 | 1 | 0 | python,algorithm,list,memory-efficient | 6,270,019 | 5 | false | 0 | 0 | On a previous question I compared a number of techniques for removing a list of items given a predicate. (That is, I have a function which returns True or False for whether to keep a particular item.) As I recall using a list comprehension was the fastest. The fact is, copying is really really cheap.
The only thing th... | 4 | 2 | 0 | So I have a list of 85 items. I would like to continually reduce this list in half (essentially a binary search on the items) -- my question is then, what is the most efficient way to reduce the list? A list comprehension would continually create copies of the list which is not ideal. I would like in-place removal of r... | Efficient reduction of a list in python | 0 | 0 | 0 | 1,038 |
6,269,262 | 2011-06-07T17:31:00.000 | 1 | 0 | 1 | 0 | python,algorithm,list,memory-efficient | 6,269,296 | 5 | false | 0 | 0 | collections.deque is implemented via a linked list, hence binary search would be much slower than a linear search. Rethink your approach. | 4 | 2 | 0 | So I have a list of 85 items. I would like to continually reduce this list in half (essentially a binary search on the items) -- my question is then, what is the most efficient way to reduce the list? A list comprehension would continually create copies of the list which is not ideal. I would like in-place removal of r... | Efficient reduction of a list in python | 0.039979 | 0 | 0 | 1,038 |
6,269,262 | 2011-06-07T17:31:00.000 | 3 | 0 | 1 | 0 | python,algorithm,list,memory-efficient | 6,269,632 | 5 | true | 0 | 0 | For a mere 85 items, truthfully, almost any method you want to use would be more than fast enough. Don't optimize prematurely.
That said, depending on what you're actually doing, a list may be faster than a deque. A deque is faster for adding and removing items at either end, but it doesn't support slicing.
With a lis... | 4 | 2 | 0 | So I have a list of 85 items. I would like to continually reduce this list in half (essentially a binary search on the items) -- my question is then, what is the most efficient way to reduce the list? A list comprehension would continually create copies of the list which is not ideal. I would like in-place removal of r... | Efficient reduction of a list in python | 1.2 | 0 | 0 | 1,038 |
6,269,493 | 2011-06-07T17:49:00.000 | 0 | 0 | 1 | 0 | python,eclipse,refactoring,pydev | 17,780,872 | 1 | false | 0 | 0 | delete the project in eclipse and then create a new project in eclipse with the projects new name. This will automatically add the projects contents into the new project | 1 | 6 | 0 | I would expect the pydev package to rename all references in a project when rafactoring a module name. However, this is not the case. Anyone knows how to fix this? | Pydev for Eclipse does not change all reference when renaming package | 0 | 0 | 0 | 616 |
6,269,795 | 2011-06-07T18:16:00.000 | 0 | 1 | 0 | 0 | python,unit-testing,teamcity | 6,269,838 | 3 | false | 0 | 0 | The test reports are to be generated by the test runner, not TeamCity. TeamCity will only look at the test report generated and use it for purposes like displaying info on the tests passed etc. | 1 | 1 | 0 | I have a set of Python tests that run on TeamCity. I am able to get the test to run, however I cannot get TeamCity to produce a test report. How can I get TeamCity to produce a report of my tests?
Thanks | Python Integration Testing on TeamCity | 0 | 0 | 0 | 7,336 |
6,272,091 | 2011-06-07T21:58:00.000 | 2 | 0 | 1 | 0 | python,python-3.x,byte | 6,276,180 | 3 | false | 0 | 0 | It does not make sense to accept Unicode strings, as they are under no circumstances binary data. I would probably accept any sort of sequence, and raise an error if any item in that sequence is not an integer between 0 and 255 (which you'll probably discover during the compression).
If you want to support Python 2, yo... | 1 | 8 | 0 | I'm making a function which will accept either an Unicode string or a bytes (or bytearray) object. I want to make sure only those types get passed. I know I can check whether something is a string by doing isinstance(x, str), and I know I can write isinstance(x, bytes) or isinstance(x, bytearray).
Is there a more conci... | Superclass of bytes and bytearray? | 0.132549 | 0 | 0 | 2,798 |
6,273,573 | 2011-06-08T02:26:00.000 | 0 | 0 | 0 | 0 | python,mongodb,hook,server-side,3-tier | 19,877,756 | 2 | false | 0 | 0 | FWIW, one of the messages in the web UI seems to imply that some hooks do exist ("adding sharding hook to enable versioning and authentication to remote servers"), but they might be only avilable within the compiled binaries, not to clients. | 2 | 2 | 0 | MongoDB performs really well compared to our hacking of MySQL in de-normalized way. After database migration, I realized that we might need some server-side procedures to invoke after/before database manipulation. Some sorta 3-tier architecture. I am just wondering the possible and easy way to prototype it. Are there a... | What is suggested way to have server-side hooks over mongodb? | 0 | 1 | 0 | 1,855 |
6,273,573 | 2011-06-08T02:26:00.000 | 2 | 0 | 0 | 0 | python,mongodb,hook,server-side,3-tier | 6,277,024 | 2 | false | 0 | 0 | No, there are no features currently available in MongoDB equivalent to hooks or triggers. It'd be best to handle this sort of thing from within your application logic. | 2 | 2 | 0 | MongoDB performs really well compared to our hacking of MySQL in de-normalized way. After database migration, I realized that we might need some server-side procedures to invoke after/before database manipulation. Some sorta 3-tier architecture. I am just wondering the possible and easy way to prototype it. Are there a... | What is suggested way to have server-side hooks over mongodb? | 0.197375 | 1 | 0 | 1,855 |
6,273,635 | 2011-06-08T02:38:00.000 | 0 | 1 | 0 | 0 | python,html | 6,274,197 | 1 | false | 0 | 0 | You can't get this information from the text nodes in the HTML, because it isn't there. | 1 | 0 | 0 | Now I use lxml to parse HTML in python. But I haven't found any API to get font information of a text node. Is there any librafy to do that?
Thanks very much! | How to get font of a HTML node with python? | 0 | 0 | 1 | 203 |
6,275,277 | 2011-06-08T07:02:00.000 | 1 | 0 | 0 | 0 | android,python,monkeyrunner | 6,278,753 | 3 | false | 1 | 1 | I want to simulate touch event, keyboard event on mobile device. Can I do it with MonkeyRunner?
From your development machine, yes. Per your question title, you cannot use MonkeyRunner on a device.
Also, I have the impression that it only works with SDK?
Yes.
I want the application to be installed on mobile, which... | 1 | 0 | 0 | I want to simulate touch event, keyboard event on mobile device. Can I do it with MonkeyRunner? Also, I have the impression that it only works with SDK?
I want the application to be installed on mobile, which will perform some random touch, keyboard events. Is it possible with MonkeyRunner?
If yes, please provide me he... | Can I use MonkeyRunner tool to work in mobile as application | 0.066568 | 0 | 0 | 1,492 |
6,276,805 | 2011-06-08T09:39:00.000 | 0 | 1 | 0 | 1 | python,apache,webserver,tornado | 6,289,549 | 3 | false | 0 | 0 | So you have Apache as the web head and Tornado running behind it? Why not just use ProxyPass from port 80 to whatever port Tornado is running on.
You can't get Tornado to serve the .py files like PHP can do with .php files. | 1 | 0 | 0 | How do I get Tornado (or in general another server) to handle the .py files on my host, while Apache still handles the php files? | Installed Tornado and Python but Apache is still handling .py files | 0 | 0 | 0 | 847 |
6,277,257 | 2011-06-08T10:16:00.000 | 2 | 0 | 1 | 1 | python,cython,gevent | 6,315,275 | 2 | true | 0 | 0 | Recompilation gevent-1.0dev and greenlet with flags CFLAGS="-arch i386 -arch x86_64" is a solution to my problem. | 1 | 3 | 0 | When I build gevent, I get an error
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.1/bin/cython", line 7, in
from Cython.Compiler.Main import main
File "/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages/Cython-0.14.1-py2.7-macosx-10.4-i386.egg/Cython/Compiler/Main.py", line... | Build Cython and gevent on OSX | 1.2 | 0 | 0 | 1,248 |
6,280,067 | 2011-06-08T14:10:00.000 | 0 | 0 | 0 | 0 | php,python,model-view-controller,wordpress | 6,283,414 | 4 | false | 1 | 0 | I find putting all reusable template items as separate php, and including presentation logic as a theme function/object and business logic in a plugin in an okay way to separate concerns as such objects/functions are always available if loaded correctly. The template parts do save significant time if you use particular... | 2 | 3 | 0 | I generally work with Python to create web apps and love how I can work separately with the code and presentation layers. I really like working with Jinja2. But, I sometimes have to work with WordPress for my clients. So, I wonder, if there are any ways to make developing for WordPress a less headache with all its head... | Are there any techniques to separate code and markup in WordPress? | 0 | 0 | 0 | 770 |
6,280,067 | 2011-06-08T14:10:00.000 | 3 | 0 | 0 | 0 | php,python,model-view-controller,wordpress | 6,280,300 | 4 | true | 1 | 0 | Agreed with Denis, Wordpress simply is spaghetti, and there's nothing you can do about that. Nonetheless, if you're writing your own code for Wordpress (we make themes and plugins for our customers), there's nothing stopping you from splitting the concerns out into different files, and we found that it's much easier to... | 2 | 3 | 0 | I generally work with Python to create web apps and love how I can work separately with the code and presentation layers. I really like working with Jinja2. But, I sometimes have to work with WordPress for my clients. So, I wonder, if there are any ways to make developing for WordPress a less headache with all its head... | Are there any techniques to separate code and markup in WordPress? | 1.2 | 0 | 0 | 770 |
6,281,732 | 2011-06-08T15:58:00.000 | 0 | 0 | 0 | 0 | python,database,coding-style,mysql-python | 6,282,794 | 2 | false | 0 | 0 | Use a model system/ORM system. | 1 | 3 | 0 | I have a script with several functions that all need to make database calls. I'm trying to get better at writing clean code rather than just throwing together scripts with horrible style. What is generally considered the best way to establish a global database connection that can be accessed anywhere in the script but ... | Proper way to establish database connection in python | 0 | 1 | 0 | 317 |
6,282,891 | 2011-06-08T17:37:00.000 | 0 | 1 | 0 | 1 | php,python,ssh,telnet | 6,283,332 | 1 | false | 0 | 0 | Why don't you redirect your stdout to a file. Then use your php website framework to read the file and display the results | 1 | 0 | 0 | I have a CentOS 5.5 server running a local telnet daemon (which is only accessible from localhost) which prints out a list of active users on our accounting system when sent the correct commands through telnet. I need to make this information available on our intranet website which uses PHP.
I've written a Python scri... | Using PHP/Python to access data from a remote telnet server over SSH | 0 | 0 | 0 | 899 |
6,285,553 | 2011-06-08T21:33:00.000 | 2 | 0 | 0 | 0 | python,udp,pyqt,tkinter | 6,285,587 | 2 | false | 0 | 1 | kinter is included in Python, you need to install PyQt (or PySide) separately. Qt is more modern, so I would probably try it first if deployment isn't problem. | 2 | 0 | 0 | I want to listen on a on a UDP socket for data that will be streamed in and draw it on screen as it comes in. I believe that the socket module with bind will be suitable for receiving the data on the socket, but I am not sure on the best manner to proceed in drawing the data. The image dimensions would be known beforeh... | How would you draw UDP data as it comes in? | 0.197375 | 0 | 0 | 275 |
6,285,553 | 2011-06-08T21:33:00.000 | 2 | 0 | 0 | 0 | python,udp,pyqt,tkinter | 6,291,949 | 2 | true | 0 | 1 | Tkinter has a canvas widget which can be used for drawing. It is vector-based, with primitives for drawing lines, circles, etc. It is very easy to use, and surprisingly powerful.
If your drawing is more like a painting where you are receiving instructions for individual pixels, you can create an image, and with that yo... | 2 | 0 | 0 | I want to listen on a on a UDP socket for data that will be streamed in and draw it on screen as it comes in. I believe that the socket module with bind will be suitable for receiving the data on the socket, but I am not sure on the best manner to proceed in drawing the data. The image dimensions would be known beforeh... | How would you draw UDP data as it comes in? | 1.2 | 0 | 0 | 275 |
6,286,449 | 2011-06-08T23:23:00.000 | 0 | 0 | 0 | 0 | php,python,facebook,facebook-graph-api | 6,337,169 | 2 | true | 1 | 0 | The answer was to use the still not completely deprecated REST api, which has that functionality. | 2 | 2 | 0 | I am trying to use the Facebook graph api to publish a swf file on my wall, and was wondering if there is anyway I can control the height of the swf file. It looks like facebook sets the height to 259px automatically. Any help would be really appreciated!
Thanks. | Controlling size of swf file posted to wall using graph api | 1.2 | 0 | 1 | 570 |
6,286,449 | 2011-06-08T23:23:00.000 | 1 | 0 | 0 | 0 | php,python,facebook,facebook-graph-api | 6,292,361 | 2 | false | 1 | 0 | Facebook will automatically set the size to width:398px;height:259px.
The movie will be stretched to accomodate this.
If your movie is a different size, the best thing to do is to make sure it is at least the same aspect ratio. | 2 | 2 | 0 | I am trying to use the Facebook graph api to publish a swf file on my wall, and was wondering if there is anyway I can control the height of the swf file. It looks like facebook sets the height to 259px automatically. Any help would be really appreciated!
Thanks. | Controlling size of swf file posted to wall using graph api | 0.099668 | 0 | 1 | 570 |
6,286,826 | 2011-06-09T00:30:00.000 | 4 | 0 | 0 | 0 | python,django | 6,286,985 | 2 | true | 1 | 0 | There are in my opinion two cases for necessity of class-based(-generic)-views:
You really need generic functionality in your views and a little bit extra.
You write a resusable Django app and want to make it possible that others can extend your views.
For anything else use what you feel most comfortable with. As you... | 1 | 5 | 0 | I'm coming back to Django after a brief encounter with version 1.2, and now in version 1.3 the favored approach to views seems to be using classes.
Keeping in mind code style, maintainability and modularity: when should I use classes, and when functions? Should I always extend from generic class views (there seems to b... | Django: class views, generic views, etc | 1.2 | 0 | 0 | 743 |
6,286,838 | 2011-06-09T00:31:00.000 | 1 | 0 | 0 | 1 | python,quota | 6,286,944 | 1 | true | 1 | 0 | I'm not aware of any ready-made component, but it should be fairly simple to do this.
I would probably use a database table, containing two columns: user ID and timestamp. Each time a user (IP address?) wants a connection, you find all the entries with that user ID with a timestamp between now and 60 seconds ago. If it... | 1 | 2 | 0 | I need to implement a time-based quota in my python (twisted) application.
Is there an existing module, or other implementation that I should use as a reference?
Specifically, my application needs to ratelimit connections from clients, using rules like '10 connections per minute'.
There is a Google App Engine module na... | Implement time-based quotas in python | 1.2 | 0 | 0 | 232 |
6,289,668 | 2011-06-09T07:50:00.000 | 5 | 1 | 0 | 1 | c++,python,openmp | 6,289,692 | 2 | false | 0 | 0 | There can be a number of reasons for this, for example:
Increased failure rate in the branch prediction
Exhausted CPU cache
Filled up the memory bus
Too much context switching (this have an effect on many things, including all the previous points) | 1 | 1 | 0 | I have an urgent problem because my time is running out: I let my calculations process on a server with 8 cores therefore I'm using openMP in my c++ code and it works fine. Of course I'm not the only one who is using the server, so my capacity is not always 800%CPU.
But it happened now several times that someone who s... | programs paralyzing each other on the server (c++ with openMP and python) | 0.462117 | 0 | 0 | 290 |
6,289,821 | 2011-06-09T08:04:00.000 | 2 | 0 | 1 | 0 | python,multithreading,sqlite | 6,289,986 | 2 | false | 0 | 0 | If you read the sqlite documentation (http://www.sqlite.org/threadsafe.html), you'll see that it says:
SQLite support three different
threading modes:
Single-thread. In this mode, all
mutexes are disabled and SQLite is
unsafe to use in more than a single
thread at once.
Multi-thread. In this mode, SQLite can
... | 2 | 0 | 0 | I'm developing a python code that uses Sqlite in a multi-threaded program. A remote host calls some xmlrpc functions and new threads are created. Each function which is running in a new thread, uses sqlite for either inserting data into or reading data from the database.
My problem is that when call the server more th... | Segmentation Fault in Python multi-threaded Sqlite use! | 0.197375 | 1 | 0 | 1,212 |
6,289,821 | 2011-06-09T08:04:00.000 | 1 | 0 | 1 | 0 | python,multithreading,sqlite | 6,313,973 | 2 | false | 0 | 0 | My APSW module is threadsafe and you can use that. The standard Python SQLite cannot be safely used concurrently across multiple threads. | 2 | 0 | 0 | I'm developing a python code that uses Sqlite in a multi-threaded program. A remote host calls some xmlrpc functions and new threads are created. Each function which is running in a new thread, uses sqlite for either inserting data into or reading data from the database.
My problem is that when call the server more th... | Segmentation Fault in Python multi-threaded Sqlite use! | 0.099668 | 1 | 0 | 1,212 |
6,289,915 | 2011-06-09T08:15:00.000 | 2 | 0 | 0 | 0 | python,string,text,growlnotify | 6,289,976 | 5 | false | 0 | 0 | You can do this using the replace method of strings. | 1 | 0 | 0 | I am currently writing a growl notification plugin for emesene messenger on OS X. It is nearly working except to when it comes to displaying a message snippet.
The message is passed to growlnotify as a variable, however growl does not accept spaces in the displayed message.
So what i need help with is a script to remov... | Python remove spaces and append | 0.07983 | 0 | 0 | 2,767 |
6,292,320 | 2011-06-09T11:51:00.000 | 2 | 0 | 1 | 0 | python,cython,turbogears,turbogears2 | 6,292,855 | 1 | true | 0 | 1 | Without you having additionally specificity in your question and not knowing what exactly you mean by 'integrate', all I can offer is that cython provides a fairly simple way of (often dramatically) speeding up certain code written in python either via static typing or calling external c/c++ libraries. If there is only... | 1 | 0 | 0 | Is it possible to integrate Cython and TG2? I have one computation (written in python) which is heavily numerical and would largly benefit from rewriting into C or cython. | Mixing cython and turbogears 2.1 | 1.2 | 0 | 0 | 74 |
6,292,652 | 2011-06-09T12:17:00.000 | 71 | 0 | 1 | 1 | python,egg,sdist | 6,292,860 | 2 | true | 0 | 0 | setup.py sdist creates a source distribution: it contains setup.py, the source files of your module/script (.py files or .c/.cpp for binary modules), your data files, etc. The result is an archive that can then be used to recompile everything on any platform.
setup.py bdist (and bdist_*) creates a built distribution: i... | 1 | 53 | 0 | I am a bit confused. There seem to be two different kind of Python packages, source distributions (setup.py sdist) and egg distributions (setup.py bdist_egg).
Both seem to be just archives with the same data, the python source files. One difference is that pip, the most recommended package manager, is not able to insta... | What is the difference between an 'sdist' .tar.gz distribution and an python egg? | 1.2 | 0 | 0 | 21,997 |
6,295,440 | 2011-06-09T15:32:00.000 | 2 | 0 | 0 | 0 | python,tkinter | 6,296,428 | 2 | true | 0 | 1 | The way you solve this particular problem is to have a binding on ButtonPress and ButtonRelease that sets a flag. Then, in your binding for <Enter> (or any other event) you check for that flag.
However, while the button is pressed you won't get any <Enter> events. This is because the widget you clicked over grabs the p... | 1 | 2 | 0 | I have multiple Tkinter.labels in a row and i would like the user to be able to click and drag their mouse over each one, activating them in the process.
I know about bindings, but i need multiple events in a single binding. Ive been messing around with <Button-1> and <Enter>, however i need a callback to be called ... | Activate other widgets while mouse dragging | 1.2 | 0 | 0 | 2,142 |
6,297,149 | 2011-06-09T17:56:00.000 | 0 | 0 | 0 | 0 | python,html,django,hyperlink | 6,297,204 | 2 | false | 1 | 0 | You would have to grab the 'sort' variable in your server-side code and resend the query to the data source so your table would be populated in the desired manner.
In order to add the link, you would want to dynamically generate the href so it would append the sort=columnnamehere to the query string.
If you need help c... | 1 | 2 | 0 | I'm dynamically generating a table, as well as the column headers.
How do I make the columns clickable (NO JavaScript!), so that when they're clicked, they add a sort=columnNameHere entry to the query, and reload the current page with that query? | HTML Table -- Putting a Link in the Header for Sorting? (No JavaScript) | 0 | 0 | 0 | 5,055 |
6,297,258 | 2011-06-09T18:07:00.000 | 1 | 0 | 0 | 0 | python,reportlab | 6,306,363 | 2 | false | 0 | 0 | Depending on where this table ends in the document, a quick, hacky solution might be to just stick enough rows in the table to make sure it fills the page and spills over onto the next page. Then, after building the document, cut off the last page and create a new PDF just missing that page.
Of course, this only works... | 1 | 2 | 0 | I'm preparing a PDF report of a list of items, which essentially is a long table, with some cells filled with data and some cells empty. This report will be printed out and the user will fill the empty cells on paper. She will also add new rows and fill in new data.
So I will provide some (e.g. 3) empty rows as a grid ... | In reportlab add as many empty rows to a long table as fit on the last page | 0.099668 | 0 | 0 | 2,042 |
6,298,813 | 2011-06-09T20:25:00.000 | 0 | 0 | 0 | 0 | javascript,python,html,django,http-post | 6,298,838 | 5 | false | 1 | 0 | You can't. There is no way to send a form to two ressources.
What you CAN do is send a HTTP request in your register script to the newsletter script, e.g. using urllib2. | 1 | 2 | 0 | I am developing a django web app in which I would like to have a registration process. In this registration process I have of course a form asking for name, email and password. What I would like to do is, send the form via post to 2 different places. One of which is of course the registration database which saves the ... | html post form different destinations | 0 | 0 | 0 | 2,961 |
6,301,795 | 2011-06-10T03:54:00.000 | 0 | 0 | 0 | 0 | python,sqlite,amazon-s3,amazon-ec2 | 38,705,012 | 5 | false | 0 | 0 | Amazon EFS can be shared among ec2 instances. It's a managed NFS share. SQLITE will still lock the whole DB on write.
The SQLITE Website does not recommend NFS shares, though. But depending on the application you can share the DB read-only among several ec2 instances and store the results of your processing somewhere ... | 2 | 4 | 0 | Suppose that I have a huge SQLite file (say, 500[MB]) stored in Amazon S3.
Can a python script that is run on a small EC2 instance directly access and modify that SQLite file? or must I first copy the file to the EC2 instance, change it there and then copy over to S3?
Will the I/O be efficient?
Here's what I am tryin... | Amazon EC2 & S3 When using Python / SQLite? | 0 | 1 | 0 | 7,758 |
6,301,795 | 2011-06-10T03:54:00.000 | 2 | 0 | 0 | 0 | python,sqlite,amazon-s3,amazon-ec2 | 6,301,870 | 5 | false | 0 | 0 | Since S3 cannot be directly mounted, your best bet is to create an EBS volume containing the SQLite file and work directly with the EBS volume from another (controller) instance. You can then create snapshots of the volume, and archive it into S3. Using a tool like boto (Python API), you can automate the creation of ... | 2 | 4 | 0 | Suppose that I have a huge SQLite file (say, 500[MB]) stored in Amazon S3.
Can a python script that is run on a small EC2 instance directly access and modify that SQLite file? or must I first copy the file to the EC2 instance, change it there and then copy over to S3?
Will the I/O be efficient?
Here's what I am tryin... | Amazon EC2 & S3 When using Python / SQLite? | 0.07983 | 1 | 0 | 7,758 |
6,301,816 | 2011-06-10T03:58:00.000 | 4 | 0 | 1 | 0 | python,sqlite,concurrency | 6,301,903 | 2 | true | 0 | 0 | Updated, thanks to André Caron.
You can do that, but only read operations supports concurrency in SQLite, since entire database is locked on any write operation. SQLite engine will return SQLITE_BUSY status in this situation (if it exceeds default timeout for access). Also consider that this heavily depends on how goo... | 1 | 2 | 0 | Suppose that I have a huge SQLite file (say, 500[MB]). Can 10 different python instances access this file at the same time and update different records of it?. Note, the emphasis here is on different records.
For example, suppose that the SQLite file has say 1M rows:
instance 1 will deal with (and update) rows 0 - 1000... | SQLite Concurrency with Python? | 1.2 | 1 | 0 | 1,234 |
6,302,184 | 2011-06-10T05:05:00.000 | 0 | 0 | 0 | 0 | php,python,mysql,recommendation-engine | 47,667,603 | 3 | false | 0 | 0 | This can be simply achieved by using wildcards in SQL queries. If you have larger texts and the wildcard seems to be unable to capture the middle part of text then check if the substring of one matches the other. I hope this helps.
BTW, your question title asks about implementing recommendation system and the question ... | 1 | 7 | 0 | I've Collective Intelligence book, but I'm not sure how it can be apply in practical.
Let say I have a PHP website with mySQL database. User can insert articles with title and content in the database. For the sake of simplicity, we just compare the title.
How to Make Coffee?
15 Things About Coffee.
The Big Question.
H... | How to Implement A Recommendation System? | 0 | 1 | 0 | 21,630 |
6,302,691 | 2011-06-10T06:23:00.000 | 5 | 0 | 1 | 0 | python,shell,scripting,programming-languages,splunk | 6,303,611 | 4 | false | 0 | 0 | Aloha!
The obnoxious answer is that Python like other languages are turing complete and you can write program in it. But that probably doesn't answer your question. ;-)
First however, a tip: Stop think in terms of scripting vs real programming languages. Python, just like Java, Perl, Ruby, LISP, Scala, Lua, Cloujure ar... | 2 | 0 | 0 | I have been studying Python at work for a week now and it seems very interesting, I started using it in order to create Extra Search functions for Splunk.
My Question is, what else can you do with it?, is it only a Script Language?, if so what type of scripts can I create and use?
To what extent should I learn Python i... | Use of the Python Language | 0.244919 | 0 | 0 | 369 |
6,302,691 | 2011-06-10T06:23:00.000 | 4 | 0 | 1 | 0 | python,shell,scripting,programming-languages,splunk | 6,302,892 | 4 | false | 0 | 0 | To answer your questions in order:
Everything.
No.
Any.
As much as possible.
Yes. | 2 | 0 | 0 | I have been studying Python at work for a week now and it seems very interesting, I started using it in order to create Extra Search functions for Splunk.
My Question is, what else can you do with it?, is it only a Script Language?, if so what type of scripts can I create and use?
To what extent should I learn Python i... | Use of the Python Language | 0.197375 | 0 | 0 | 369 |
6,304,344 | 2011-06-10T09:18:00.000 | 1 | 0 | 1 | 0 | python,validation,forms,pygtk | 6,304,519 | 1 | true | 0 | 0 | You will need to have a copy of the data before and after the form has been submitted. The default __eq__ operator will compare all attributes on of class, so you can probably use before_form == after_form to see if anything has changed. If you need to know what has changed then you will have to iterate over each attri... | 1 | 0 | 0 | I fill a form fields (in pygtk) from a class instance that contains its attributes with their values.
Once the form is submitted, I get this instance updated with new values.
What is the best way to determine if the form has returned different values (ie: been modified) ? Do I have to make a copy of the object instance... | python: comparing attributes values in form before and after submit | 1.2 | 0 | 0 | 212 |
6,305,186 | 2011-06-10T10:38:00.000 | 5 | 0 | 1 | 0 | python,3d,data-visualization | 6,305,401 | 1 | true | 0 | 0 | That's probably because "fully" is hard to define.
Do you mean something like "The C++ of Visualization Libraries", where you can do boolean modeling, ray tracing, pixel shaders, transparent MAX file loading with acceleration structure compiling under the hood? With realtime LOTR-the-movie-battles animation as well as... | 1 | 0 | 0 | As my knowledge there is no fully satisfactory 3d visualization package. I mean fully because it is easily can be seen the following problems with available packages:
lack of flexibility
heavy loading and initializations (ETS-Mayavi2,...)
very slow even with OpenGL implementations (VPython,...)
lots of bugs for exampl... | Why 3D visualization looks difficult in programming languages after half a century? | 1.2 | 0 | 0 | 503 |
6,307,372 | 2011-06-10T13:58:00.000 | 5 | 0 | 1 | 0 | python,licensing,py2exe,py2app | 6,307,725 | 1 | true | 0 | 0 | Why doesn't an if statement comparing the date not trivially solve this for you?
The best way to do this might be to include data into your software that really does need to be kept up to date to be useful to the end user, like the tax forms in TurboTax. Of course the availability of that business strategy depends on ... | 1 | 15 | 0 | Although there are quite a few questions like this, please bear with me as I think mine is different...
I have a $5 Python app that I distribute using py2exe, py2app, and source for Linux. The app has a one-year license so that people need to upgrade to a newer version after one year. I would like to add some kind of... | Simple license protection for Python app | 1.2 | 0 | 0 | 16,106 |
6,307,829 | 2011-06-10T14:34:00.000 | 0 | 0 | 0 | 1 | python,architecture,distributed,environment | 6,331,843 | 1 | false | 0 | 0 | Answer to myself: I found one possible solution..
I'm lucky because the console.py script is actually invoking many slave python scripts, each of them performing one single system check via standard third-party command-line tools which can be fired to check features on remote hosts.
Then, what I did was to modify the g... | 1 | 0 | 0 | This is my scenario: I developed a Python desktop application which I use to probe the status of services/DBs on the very same machine it is running on.
My need is to monitor, using my application, two "brother" Window Server 2003 hosts (Python version is 2.5 for both). One of the hosts lies in my own LAN, the other on... | Python distributed application architecture on constrained corporate environment | 0 | 0 | 0 | 381 |
6,307,992 | 2011-06-10T14:45:00.000 | 1 | 0 | 0 | 0 | jquery,python,ajax,django,json | 6,309,310 | 5 | false | 1 | 0 | Dajax is quite straight forward. You'd better tell us more about what puzzles you in Dajax. | 2 | 8 | 0 | Obviously, horses for courses, but what are some good ways to integrate javascript libraries with one's Django application?
I'm planning on using jQuery, mostly because it seems popular and looks powerful (but I'm open to other suggestions).
Are there python-side libraries that are very helpful or essential? Or is it b... | "Best" way to integrate Django with an Ajax library | 0.039979 | 0 | 0 | 4,724 |
6,307,992 | 2011-06-10T14:45:00.000 | 5 | 0 | 0 | 0 | jquery,python,ajax,django,json | 6,308,115 | 5 | false | 1 | 0 | I would suggest that you simply create your own javascript and AJAX views. Ruby on Rails long had the opposite problem: forcing people to do AJAX in a certain way, and it was always a point of conflict for people. Recently, they finally realized their folly and decoupled AJAX from the framework so you can easily use wh... | 2 | 8 | 0 | Obviously, horses for courses, but what are some good ways to integrate javascript libraries with one's Django application?
I'm planning on using jQuery, mostly because it seems popular and looks powerful (but I'm open to other suggestions).
Are there python-side libraries that are very helpful or essential? Or is it b... | "Best" way to integrate Django with an Ajax library | 0.197375 | 0 | 0 | 4,724 |
6,308,569 | 2011-06-10T15:28:00.000 | 69 | 0 | 1 | 0 | python,list-comprehension,pdb | 6,308,596 | 2 | true | 0 | 0 | You can use the until command. Output of help until in pdb:
unt(il)
Continue execution until the line with a number greater than the current
one is reached or until the current frame returns | 1 | 53 | 0 | In pdb the next instruction does not step over list comprehensions, instead it steps through each iteration. Is there a way to step over them so debugging will continue at the next line after the list comprehension?
I've had to resort to listing the code, setting a breakpoint at the next line, and then continuing execu... | How do you skip over a list comprehension in Python's debugger (pdb)? | 1.2 | 0 | 0 | 5,964 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.