content
stringlengths
85
101k
title
stringlengths
0
150
question
stringlengths
15
48k
answers
list
answers_scores
list
non_answers
list
non_answers_scores
list
tags
list
name
stringlengths
35
137
Q: Where Photologue's Photo.get_previous_by_date_added() method defined? Definition of Photologue model Photo doesn't contain method get_previous_by_date_added, as well as its parent model ImageModel. ImageModel inherits from django models.Model base class which hasn't this method too. But there is usage of this met...
Where Photologue's Photo.get_previous_by_date_added() method defined?
Definition of Photologue model Photo doesn't contain method get_previous_by_date_added, as well as its parent model ImageModel. ImageModel inherits from django models.Model base class which hasn't this method too. But there is usage of this method in Photo model: class Photo: ... def get_previous_in_gallery(self, ...
[ "It's added by the contribute_to_class method of DateField, as documented in the model instance reference - see also the code of django.db.models.fields.__init__.\nA lot of Django's model attributes are added by metaclasses or by external classes, so it doesn't always help to look directly at the models.Model sourc...
[ 3 ]
[]
[]
[ "django", "photologue", "python" ]
stackoverflow_0006569169_django_photologue_python.txt
Q: SSH module for python I have to do a job (using my web server) on a remote machine that takes about 10 minutes. I have used pxssh module in python for the same but it gives me "timeout error"(non blocking). Now, I am using paramiko but that comes back as soon as it gives the instruction. I want the web server to w...
SSH module for python
I have to do a job (using my web server) on a remote machine that takes about 10 minutes. I have used pxssh module in python for the same but it gives me "timeout error"(non blocking). Now, I am using paramiko but that comes back as soon as it gives the instruction. I want the web server to wait till the job is complet...
[ "You can use the recv_exit_status method on the Channel to wait for the command to complete:\n\nrecv_exit_status(self)\n>\nReturn the exit status from the process on the server. This is mostly useful for retrieving the reults of an exec_command. If the command hasn't finished yet, this method will wait until it doe...
[ 9 ]
[]
[]
[ "nonblocking", "paramiko", "python", "ssh", "timeout" ]
stackoverflow_0006569833_nonblocking_paramiko_python_ssh_timeout.txt
Q: Getting name of value from namedtuple I have a module with collection: import collections named_tuple_sex = collections.namedtuple( 'FlightsResultsSorter', ['TotalPriceASC', 'TransfersASC', 'FlightTimeASC', ...
Getting name of value from namedtuple
I have a module with collection: import collections named_tuple_sex = collections.namedtuple( 'FlightsResultsSorter', ['TotalPriceASC', 'TransfersASC', 'FlightTimeASC', 'DepartureTimeASC', ...
[ "If you're trying to get the actual names, use the _fields attribute:\nIn [50]: point = collections.namedtuple('point', 'x, y')\n\nIn [51]: p = point(x=1, y=2)\n\nIn [52]: for name in p._fields:\n ....: print name, getattr(p, name)\n ....:\nx 1\ny 2\n\n", "from itertools import izip\n\nfor x, field in izi...
[ 85, 38 ]
[]
[]
[ "namedtuple", "python" ]
stackoverflow_0006570075_namedtuple_python.txt
Q: Python: svndumpfilter2 and new line characters on Windows When running svndumpfilter2 on Windows, I get a problem that seems to take its origin in the fact that the dump file has sometimes CRLF endings. Some files in the SVN database had CRLF line endings. But it seems that Python counts CRLF as one character (not...
Python: svndumpfilter2 and new line characters on Windows
When running svndumpfilter2 on Windows, I get a problem that seems to take its origin in the fact that the dump file has sometimes CRLF endings. Some files in the SVN database had CRLF line endings. But it seems that Python counts CRLF as one character (not counting the CR character as separate from the following LF in...
[ "Update: One way that occurs to me is to explicitly set the mode of stdin to binary. So something like the following will read CRLF as two characters:\nimport msvcrt, os, sys\n\nmsvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)\nwhile True:\n ch = sys.stdin.read(1)\n print ord(ch) # CRLF should appear as 13 f...
[ 3 ]
[]
[]
[ "python", "svn" ]
stackoverflow_0006569920_python_svn.txt
Q: A smart way to export c++ polymorphic functions with boost.python I have a highly polymorphic c++ function that can be called with nearly 20 diferent types. In order to expose it to python I'm doing something like this: #include originalFunctionNamespace.hpp template<class T> T foo(T x) { return o...
A smart way to export c++ polymorphic functions with boost.python
I have a highly polymorphic c++ function that can be called with nearly 20 diferent types. In order to expose it to python I'm doing something like this: #include originalFunctionNamespace.hpp template<class T> T foo(T x) { return orignalFunctionNamespace::foo(x); } but then to call them from pyth...
[ "Looks like a possible use for typelist magic, to me.\nIf you're using (or can use) the new C++0x standard, you can write something like this:\ntemplate <typename ArgType>\nvoid def_foo_overloads()\n{\n def(\"foo\", foo<ArgType>);\n // last type in list\n}\ntemplate <typename ArgType, typename... MoreArgTypes...
[ 0 ]
[]
[]
[ "boost", "c++", "polymorphism", "python", "templates" ]
stackoverflow_0006569761_boost_c++_polymorphism_python_templates.txt
Q: Python TimedRotatingFileHandler logs to a file and stderr I am trying to include simple logging into my application using TimedRotatingFileHandler. However I get the output both into the designated file and into the standard error. I reduced the problem to a small example: import logging, logging.handlers import s...
Python TimedRotatingFileHandler logs to a file and stderr
I am trying to include simple logging into my application using TimedRotatingFileHandler. However I get the output both into the designated file and into the standard error. I reduced the problem to a small example: import logging, logging.handlers import sys logging.basicConfig(format='%(asctime)s %(message)s') logha...
[ "This is the way you can have the print just on the log files and not to stdout/stderr:\nimport logging\nfrom logging.handlers import TimedRotatingFileHandler\n\nlogHandler = TimedRotatingFileHandler(\"logfile\",when=\"midnight\")\nlogFormatter = logging.Formatter('%(asctime)s %(message)s')\nlogHandler.setFormatter...
[ 16, 4 ]
[]
[]
[ "logging", "python" ]
stackoverflow_0006565256_logging_python.txt
Q: (Are there) PERFORMANCE advantages of python socketserver over regular socket object? thanks for the interesting responses thus far. In light of said responses I have changed my question a bit. guess what I really need to know is, is socketserver as opposed to the straight-up socket library designed to handle bo...
(Are there) PERFORMANCE advantages of python socketserver over regular socket object?
thanks for the interesting responses thus far. In light of said responses I have changed my question a bit. guess what I really need to know is, is socketserver as opposed to the straight-up socket library designed to handle both periods of latency and stress, i.e. does it have additional mechanisms or features that ...
[ "The socket module is a very low-level module for sending and receiving packets. As said in the documentation, it \"provides access to the BSD socket interface\". \nIf you want something more elaborate, there is \"socketserver\" that takes care of the gory details for you, but it is still relatively low level. \nOn...
[ 10 ]
[]
[]
[ "asynchronous", "python", "sockets", "socketserver", "synchronous" ]
stackoverflow_0006540284_asynchronous_python_sockets_socketserver_synchronous.txt
Q: Pulp with Real Numbers in Python I use pulp module to solve my some optimization problems. With integer numbers, it works like a charm. I wonder if it is possible for pulp to work with real numbers. I think this is called mixed integer programming. Here is a sample optimization problem I build for my project. prob...
Pulp with Real Numbers in Python
I use pulp module to solve my some optimization problems. With integer numbers, it works like a charm. I wonder if it is possible for pulp to work with real numbers. I think this is called mixed integer programming. Here is a sample optimization problem I build for my project. prob = pulp.LpProblem("example", pulp.LpMi...
[ "SOLVED\nActually, I didnt need to do anything. Just supplied the real numbers and it worked.\n" ]
[ 0 ]
[]
[]
[ "python" ]
stackoverflow_0005947165_python.txt
Q: Get indices of array where two conditions (on different arrays) are true I have two numpy arrays: a and b. I want to select all of the indices where a == 1 and b == 0. That is, if I have the following arrays: a = [0, 1, 3, 5, 1, 1, 2] b = [1, 0, 2, 5, 3, 0, 6] I would like to get the following indices back: [1, ...
Get indices of array where two conditions (on different arrays) are true
I have two numpy arrays: a and b. I want to select all of the indices where a == 1 and b == 0. That is, if I have the following arrays: a = [0, 1, 3, 5, 1, 1, 2] b = [1, 0, 2, 5, 3, 0, 6] I would like to get the following indices back: [1, 5] How should I do this in numpy? I have tried using the following (suggested...
[ "In []: from numpy import array, logical_and\nIn []: a= array([0, 1, 3, 5, 1, 1, 2])\nIn []: b= array([1, 0, 2, 5, 3, 0, 6])\nIn []: logical_and(a== 1, b== 0).nonzero()[0]\nOut[]: array([1, 5])\n\nObviously this will work as well:\nIn []: ((a== 1)& (b== 0)).nonzero()[0]\nOut[]: array([1, 5])\n\n", "Here's one way...
[ 14, 6, 2, 0 ]
[]
[]
[ "numpy", "python" ]
stackoverflow_0006570473_numpy_python.txt
Q: Multiple socket monitoring I'm designing a python program that'll talk to two other process at the same time through sockets. One of the process is a C daemon so this socket will be alive all the time - no problem there. The other process is a PHP web page. So that socket isn't established all the time. Most of th...
Multiple socket monitoring
I'm designing a python program that'll talk to two other process at the same time through sockets. One of the process is a C daemon so this socket will be alive all the time - no problem there. The other process is a PHP web page. So that socket isn't established all the time. Most of the time, the socket is listen()in...
[ "You can use select() in this case, even in a single-threaded single-process program with only blocking sockets. Here's how you would accept incoming connections with select():\ndaemonSocket = socket.socket()\n...\nphpListenSocket = socket.socket()\nphpListenSocket.bind(...)\nphpListenSocket.listen(...)\nphpSocket ...
[ 2 ]
[]
[]
[ "ipc", "multiprocessing", "python", "select", "sockets" ]
stackoverflow_0006570443_ipc_multiprocessing_python_select_sockets.txt
Q: How to create debian package for offline installation? Here, what I would like : I want to develop debian package of my project for offline installation. Project contains some dependency like python-lxml and etc. I have downloaded required packages from the different machine which have internet connectivity. now o...
How to create debian package for offline installation?
Here, what I would like : I want to develop debian package of my project for offline installation. Project contains some dependency like python-lxml and etc. I have downloaded required packages from the different machine which have internet connectivity. now on another machine (which does not have internet connectivity...
[ "Amazing, just a few seconds ago I recommended apt-offline to a fellow stacker:\nDescription: offline apt package manager\n apt-offline is an Offline APT Package Manager\n .\n apt-offline can fully update and upgrade an APT based distribution without\n connecting to the network, all of it transparent to apt\n .\n a...
[ 2 ]
[]
[]
[ "build", "debian", "package", "python", "ubuntu_10.04" ]
stackoverflow_0006570857_build_debian_package_python_ubuntu_10.04.txt
Q: Compute number of dates between two string dates and return an integer I have a .txt file data-set like this with the date column of interest: 1181206,3560076,2,01/03/2010,46,45,M,F 2754630,2831844,1,03/03/2010,56,50,M,F 3701022,3536017,1,04/03/2010,40,38,M,F 3786132,3776706,2,22/03/2010,54,48,M,F 1430789,3723506...
Compute number of dates between two string dates and return an integer
I have a .txt file data-set like this with the date column of interest: 1181206,3560076,2,01/03/2010,46,45,M,F 2754630,2831844,1,03/03/2010,56,50,M,F 3701022,3536017,1,04/03/2010,40,38,M,F 3786132,3776706,2,22/03/2010,54,48,M,F 1430789,3723506,1,04/05/2010,55,43,F,M 2824581,3091019,2,23/06/2010,59,58,M,F 4797641,47667...
[ "The difference between two dates is a timedelta. Any timedelta instance has days attribute that is an integer value you want.\n", "Using your input (a bit verbose...)\n#!/usr/bin/env python\n\nimport datetime\n\nwith open('input') as fd:\n d_first = datetime.date(2010, 03, 01)\n for line in fd:\n da...
[ 4, 1, 1 ]
[]
[]
[ "datetime", "file", "python" ]
stackoverflow_0006571013_datetime_file_python.txt
Q: Validating mutually exclusive elements in a dictionary I have a dict that can have three keys url. link and path. These three need to be mutually exclusive when I'm validating the dict i.e. If the key url exists in the dict then path and link can't exist and so on... To add to the complication: The main key cant b...
Validating mutually exclusive elements in a dictionary
I have a dict that can have three keys url. link and path. These three need to be mutually exclusive when I'm validating the dict i.e. If the key url exists in the dict then path and link can't exist and so on... To add to the complication: The main key cant be empty (null or '') I've often come across scenarios like t...
[ "To test your condition, you could do something like this:\n# d is your dict\nhas_url = bool(d.get('url', False))\nhas_link = bool(d.get('link', False))\nhas_path = bool(d.get('path', False))\n# ^ is XOR\nif not (has_url ^ has_link ^ has_path):\n # either none of them are present, or there is more than one, or...
[ 4, 1 ]
[ "Maybe you shouldn't be using a dictionary, but rather a tuple:\n(value, \"url\") or (value, \"path\") or (value, \"link\")\n\n" ]
[ -1 ]
[ "python" ]
stackoverflow_0006570921_python.txt
Q: How to periodically check for the current date from within a program? I would like to write a tiny calendar-like application for someone as a birthday present (to be run on Ubuntu). All it should do is display a separate picture each day, so whenever it's invoked it should check the date and select the appropriate...
How to periodically check for the current date from within a program?
I would like to write a tiny calendar-like application for someone as a birthday present (to be run on Ubuntu). All it should do is display a separate picture each day, so whenever it's invoked it should check the date and select the appropriate picture from the collection I would provide, but also, in case it just kee...
[ "Did you think about scheduling the invoke of your script?\nFor me, the best approach is this:\n1.Have two options to run the script:\n\nrun_script\nrun_script --update\n\n2.Schedule the update run in some task scheduler (for example Cron) to be executed daily.\n3.When you would want to check the image for current ...
[ 1, 1 ]
[]
[]
[ "calendar", "date", "perl", "python" ]
stackoverflow_0006570892_calendar_date_perl_python.txt
Q: is List badly performing in python? I was trying to read data from some huge file and write them back, but I realised that the main cost came from assigning data to a list rather then reading or writing data from/to file.... rows = [None] * 1446311 begin = datetime.datetime.now() for i in range( 144631...
is List badly performing in python?
I was trying to read data from some huge file and write them back, but I realised that the main cost came from assigning data to a list rather then reading or writing data from/to file.... rows = [None] * 1446311 begin = datetime.datetime.now() for i in range( 1446311 ): row = csvReader.next() ...
[ "I get similar results, but not quite so dramatic as yours. (Note the use of the timeit module for timing code execution, and note that I've factored out the list creation since its common to both test cases.)\nimport csv\nfrom timeit import Timer\n\ndef write_csv(f, n):\n \"\"\"Write n records to the file named...
[ 6, 0 ]
[]
[]
[ "python" ]
stackoverflow_0006570905_python.txt
Q: "Unhandled exception in thread started by Error in sys.excepthook" during relstorage zodb pack We have a reasonably large Plone instance running on its own mount point. The ZMI interface lists the size of the database as 7101.4M. We run a weekly pack of the database using the Relstorage zodbpack.py script, remov...
"Unhandled exception in thread started by Error in sys.excepthook" during relstorage zodb pack
We have a reasonably large Plone instance running on its own mount point. The ZMI interface lists the size of the database as 7101.4M. We run a weekly pack of the database using the Relstorage zodbpack.py script, removing objects older than 7 days. The last two weeks the cron job that runs the pack has output the fo...
[ "The error is related to Python, not RelStorage. See http://bugs.python.org/issue1722344 for the bugreport I think is relevant here. That bug applies to Python 2.5 and 2.6, but may also be applicable to Python 2.4. Try upgrading Python 2.4 to the latest if it is not already.\nIn any case, the message is harmless in...
[ 2 ]
[]
[]
[ "plone", "python", "relstorage", "zodb", "zope" ]
stackoverflow_0006570495_plone_python_relstorage_zodb_zope.txt
Q: Abort execution of a module in Python I'd like to stop evaluation of a module that is being imported, without stopping the whole program. Here's an example of what I want to achieve: main.py print('main1') import testmodule print('main2') testmodule.py print(' module1') some_condition=True if some_condition: ...
Abort execution of a module in Python
I'd like to stop evaluation of a module that is being imported, without stopping the whole program. Here's an example of what I want to achieve: main.py print('main1') import testmodule print('main2') testmodule.py print(' module1') some_condition=True if some_condition: exit_from_module() # How to do this? print...
[ "There is no good way to stop execution of a module. You can raise an exception, but then your importing module will need to deal with it. Perhaps just refactor like this:\nprint(' module1')\nsome_condition = True\nif not some_condition:\n print(' module2')\n\nUpdate: Even better would be to change your module t...
[ 9, 5, 2 ]
[]
[]
[ "python", "python_3.x", "python_module" ]
stackoverflow_0006571476_python_python_3.x_python_module.txt
Q: GPS co-ordinate search --R-trees I have a list of lists in the form of [ [ x1,.....,x8],[x1,.......,x8],...............,[x1,.....x[8]] ] . The number of lists in that list can go upto a million. Each list has 4 gps co-ordinates which show the four points of a rectangle ( assumed that each segment is in the form...
GPS co-ordinate search --R-trees
I have a list of lists in the form of [ [ x1,.....,x8],[x1,.......,x8],...............,[x1,.....x[8]] ] . The number of lists in that list can go upto a million. Each list has 4 gps co-ordinates which show the four points of a rectangle ( assumed that each segment is in the form of a rectangle]. Problem : Given a ne...
[ "Isn't the problem \"find whether a given point falls within a certain rectangle in 2D space\"?\nThat could be separated dimensionally, couldn't it? Give each rectangle an ID, then separate into lists of one-dimensional ranges ((id, x0, x1), (id, y0, y1)) and find all the ranges in both dimensions the point falls i...
[ 1, 0 ]
[]
[]
[ "gps", "python" ]
stackoverflow_0006568109_gps_python.txt
Q: Python time module won't handle year before 1900 I want to convert date of birth from a text file.Let's say, I have data fjsffk 1985-01-30 fkgskgks 1899-02-20 I have tried with the following code, still getting error: import datetime months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', ...
Python time module won't handle year before 1900
I want to convert date of birth from a text file.Let's say, I have data fjsffk 1985-01-30 fkgskgks 1899-02-20 I have tried with the following code, still getting error: import datetime months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'De...
[ "As per python tutorial\n\nThe exact range of years for which\n strftime() works also varies across\n platforms. Regardless of platform,\n years before 1900 cannot be used.\n\nPlease bear with me - i have tried the following solution and it works fine for me:\nfrom datetime import datetime\n\nmDt = datetime(1900...
[ 8, 0 ]
[]
[]
[ "datetime", "python" ]
stackoverflow_0006571562_datetime_python.txt
Q: python parsing a datetime with a timezone I am trying to parse an string from a log file in the format: 2011-06-27 10:29:56+0200 If I use datetime.datetime.strptime('%Y-%m-%d %H:%M:%S%z') I get ValueError("'z' is a bad directive in format '%Y-%m-%d %H:%M:%S%z'") thrown How can I parse a date in this format? A: T...
python parsing a datetime with a timezone
I am trying to parse an string from a log file in the format: 2011-06-27 10:29:56+0200 If I use datetime.datetime.strptime('%Y-%m-%d %H:%M:%S%z') I get ValueError("'z' is a bad directive in format '%Y-%m-%d %H:%M:%S%z'") thrown How can I parse a date in this format?
[ "Try using dateutil.\nfrom dateutil.parser import parse \ndt = parse(\"2011-06-27 10:29:56+0200\")\n\n" ]
[ 8 ]
[]
[]
[ "date", "python", "time" ]
stackoverflow_0006571419_date_python_time.txt
Q: How do you extract an embedded attribute value from a previous attribute value in an XPath query? I'm trying to "select" the link from the onclick attribute in the following portion of html <span onclick="Javascript:document.quickFindForm.action='/blah_blah'" class="specialLinkType"><img src="blah"></span> but...
How do you extract an embedded attribute value from a previous attribute value in an XPath query?
I'm trying to "select" the link from the onclick attribute in the following portion of html <span onclick="Javascript:document.quickFindForm.action='/blah_blah'" class="specialLinkType"><img src="blah"></span> but can't get any further than the following XPath //span[@class="specialLinkType"]/@onclick which only r...
[ "I tried the XPath in a Java application and it worked ok:\n import java.io.IOException;\n import java.io.StringReader;\n\n import javax.xml.parsers.DocumentBuilder;\n import javax.xml.parsers.DocumentBuilderFactory;\n import javax.xml.parsers.ParserConfigurationException;\n import javax.xml.xpath...
[ 1, 0, 0 ]
[]
[]
[ "html", "python", "scraper", "scrapy", "xpath" ]
stackoverflow_0006554539_html_python_scraper_scrapy_xpath.txt
Q: my python client for magento is not installing I downloaded the python client for magento from Here But When I am downloading is using python setup.py install then it shows following error. How can i rectify this error? error: File "setup.py", line 31, in <module> import magento File "/home/sam/Downloads/...
my python client for magento is not installing
I downloaded the python client for magento from Here But When I am downloading is using python setup.py install then it shows following error. How can i rectify this error? error: File "setup.py", line 31, in <module> import magento File "/home/sam/Downloads/magento-0.1.1/magento/__init__.py", line 21, in <mod...
[ "Are you getting\nImportError: No module named suds.client\n\nas the last line of the error message? If so, perhaps you need to install this.\n", "You need to install suds.\nbetter to use pip for it\npip install suds\n\nIt is easier to use with virtualenv\n" ]
[ 3, 0 ]
[]
[]
[ "magento", "python" ]
stackoverflow_0004015926_magento_python.txt
Q: Geo Django mac OS X I am trying to use Geodjango on mac os, i use postgresql and I installed GEOS but i got this error : dlopen(/usr/local/lib/libgeos_c.dylib, 6): no suitable image found. Did find: /usr/local/lib/libgeos_c.dylib: mach-o, but wrong architecture Any idea? Thank you A: Ok, I have my answer. My M...
Geo Django mac OS X
I am trying to use Geodjango on mac os, i use postgresql and I installed GEOS but i got this error : dlopen(/usr/local/lib/libgeos_c.dylib, 6): no suitable image found. Did find: /usr/local/lib/libgeos_c.dylib: mach-o, but wrong architecture Any idea? Thank you
[ "Ok, I have my answer. My MAMP uses 32-bit Python and I compiled my library for 64-bit Python.\nSo I recompiled it for 32-bit Python. To do this, I used these commands in my library folder: \nexport CFLAGS=-m32\nexport CXXFLAGS=-m32\n\n./configure\nmake\nmake install\n\n" ]
[ 0 ]
[]
[]
[ "django", "geodjango", "macos", "postgresql", "python" ]
stackoverflow_0006564114_django_geodjango_macos_postgresql_python.txt
Q: MoveWindow() missing in C++ OpenCV 2.3 I am using the C++ version of OpenCV 2.3 and am struggling to do a basic task. What I would like to do is create a window and move it to a specific location on the screen using for example: cv::namedWindow("My Window", 1); cv::MoveWindow("My Window", 10, 10); However, it app...
MoveWindow() missing in C++ OpenCV 2.3
I am using the C++ version of OpenCV 2.3 and am struggling to do a basic task. What I would like to do is create a window and move it to a specific location on the screen using for example: cv::namedWindow("My Window", 1); cv::MoveWindow("My Window", 10, 10); However, it appears that the MoveWindow() function is not a...
[ "You are supposed to use the C function for this:\ncvMoveWindow(const char* name, int x, int y);\n\nYou can verify this info by downloading OpenCV 2.3 for *nix, and under the C++ samples directory OpenCV-2.3.0/samples/cpp/tutorial_code/Basic/ search for a file named Drawing_1.cpp. It uses the C++ interface for ever...
[ 11 ]
[]
[]
[ "c", "c++", "opencv", "python" ]
stackoverflow_0006570205_c_c++_opencv_python.txt
Q: Python, pyPdf, Adobe PDF OCR error: unsupported filter /lzwdecode My stuff: python 2.6 64 bit (with pyPdf-1.13.win32.exe installed). Wing IDE. Windows 7 64 bit. I got the following error: NotImplementedError: unsupported filter /LZWDecode When I ran the following code: from pyPdf import PdfFileWriter, PdfFileReade...
Python, pyPdf, Adobe PDF OCR error: unsupported filter /lzwdecode
My stuff: python 2.6 64 bit (with pyPdf-1.13.win32.exe installed). Wing IDE. Windows 7 64 bit. I got the following error: NotImplementedError: unsupported filter /LZWDecode When I ran the following code: from pyPdf import PdfFileWriter, PdfFileReader import sys, os, pyPdf, re path = 'C:\\Users\\Homer\\Documents\\' # T...
[ "Replace pyPdf's filter.py with http://vaitls.com/treas/pdf/pyPdf/filters.py in your pyPdf source folder. That worked for me.\n", "LZW is a compression format used in GIFs and sometimes in PDFs. If you look at the filters available in pyPdf.filters you'll see that LZW is not there, hence the NotImplementedError. ...
[ 2, 1 ]
[]
[]
[ "ocr", "pypdf", "python" ]
stackoverflow_0006053064_ocr_pypdf_python.txt
Q: Problem with grid_forget in Tkinter - Python Basically, it seems that the grid_forget() method in Tkinter only works for some widgets in my program and not for others. I want the screen to clear when I press a "restart" button, and then the starting widgets appear again, as if the user had closed and reopened the ...
Problem with grid_forget in Tkinter - Python
Basically, it seems that the grid_forget() method in Tkinter only works for some widgets in my program and not for others. I want the screen to clear when I press a "restart" button, and then the starting widgets appear again, as if the user had closed and reopened the program. Unfortunately, when I press the button, ...
[ "grid_forget is a method. When you call it like self.textEntryIndiv.grid_forget you aren't calling the method, you are just asking for a reference. You need to call it like self.textEntryIndiv.grid_forget() (note the trailing ())\n" ]
[ 6 ]
[]
[]
[ "grid", "python", "tkinter" ]
stackoverflow_0006572209_grid_python_tkinter.txt
Q: How can I find out what class I was called as from a @staticmethod function in python? When a static method is called, is there any way for it to know which subclass it was invoked from? (I'm aware that this is very un-OO and probably never useful in a well written program, but I'd like to know if the language pro...
How can I find out what class I was called as from a @staticmethod function in python?
When a static method is called, is there any way for it to know which subclass it was invoked from? (I'm aware that this is very un-OO and probably never useful in a well written program, but I'd like to know if the language provides it) For example: class A(object): @staticmethod def foo(): print 'bar' # *...
[ "You have to use a @classmethod instead of a @staticmethod for this. With a class method, you get a reference to the class passed in as first argument:\nclass A(object):\n @classmethod\n def foo(cls):\n print cls.__name__\n # *** I would like to print either 'A' or 'B' here\n\nclass B(A):\n pass\n\nA.foo()...
[ 9 ]
[]
[]
[ "inheritance", "python" ]
stackoverflow_0006572856_inheritance_python.txt
Q: Django: Strange import error I'm deploying a (proprietary) Django application (with bad support ;-)). The only thing I need to do is setup a new Django project and implement the app's urls. So my url config is as follows: 1 from django.conf.urls.defaults import patterns, include, url 2 3 urlpatterns = patte...
Django: Strange import error
I'm deploying a (proprietary) Django application (with bad support ;-)). The only thing I need to do is setup a new Django project and implement the app's urls. So my url config is as follows: 1 from django.conf.urls.defaults import patterns, include, url 2 3 urlpatterns = patterns('', 4 url(r'^', include(...
[ "I would debug this like this:\nYou need to know where the ImportError gets raised. Then add something like this:\nimport sys\nraise Exception(sys.path)\n\n\nIs the directory above \"ap01\" in sys.path?\nDoes the directory ap01 contain a __init__.py file? \nWhat user-id has you python interpreter (the one which rai...
[ 2 ]
[]
[]
[ "django", "python" ]
stackoverflow_0006505651_django_python.txt
Q: Retry with celery Http Callback Tasks I looking at the http callback tasks - http://celeryproject.org/docs/userguide/remote-tasks.html in celery. They work well enough when the remote endpoint is available - but when it is unavailable I would like it to retry (as per retry policy) - or even if the remote endpoint ...
Retry with celery Http Callback Tasks
I looking at the http callback tasks - http://celeryproject.org/docs/userguide/remote-tasks.html in celery. They work well enough when the remote endpoint is available - but when it is unavailable I would like it to retry (as per retry policy) - or even if the remote endpoint returns a failure. at the moment it seems t...
[ "You should be able to define your task like:\nclass RemoteCall(Task):\n default_retry_delay = 30 * 60 # retry in 30 minutes\n\n def Run(self, arg, **kwargs):\n try:\n res = URL(\"http://example.com/\").get_async(arg)\n except (InvalidResponseError, RemoteExecuteError), exc:\n ...
[ 1 ]
[]
[]
[ "celery", "django", "python" ]
stackoverflow_0006568151_celery_django_python.txt
Q: How to change the filefield directory in change form I wrote my application on django and I have one question that is quite hard to find answer for via google. I have one form in admin with the filefield containing the file to upload to the /root/test/. The problem is that on admin change_form, the filefield with ...
How to change the filefield directory in change form
I wrote my application on django and I have one question that is quite hard to find answer for via google. I have one form in admin with the filefield containing the file to upload to the /root/test/. The problem is that on admin change_form, the filefield with the label "Currently" have the path to the file with is in...
[ "A FileField takes what is given in upload_to and appends it to what's in the settings.py MEDIA_ROOT/MEDIA_URL variable.\nWhat you probably want to do is to define your MEDIA_URL to be '' or to define it as being 'test/' and set the MEDIA_ROOT to 'test/' as well. See the Storage portion of the documentation\n" ]
[ 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0006573043_django_python.txt
Q: os.fork problem I am working on a mission-critical program and my boss asked me to write a program that would protect this mission-critical program from being terminated for a long time. This mission-critical program is written with python. And I wrote a protector program in C. But I encounter a problem when deal...
os.fork problem
I am working on a mission-critical program and my boss asked me to write a program that would protect this mission-critical program from being terminated for a long time. This mission-critical program is written with python. And I wrote a protector program in C. But I encounter a problem when dealing with os.fork. Ple...
[ "Options:\nhttp://supervisord.org/\nhttp://pypi.python.org/pypi/zdaemon/2.0.4\n" ]
[ 1 ]
[]
[]
[ "linux", "python" ]
stackoverflow_0006573183_linux_python.txt
Q: Python Webkit making web-site screenshots using virtual framebuffer The problem is that I need capture web-site screenshots without running X server. So theoretically it's possible to create a virtual frame buffer and to use it to capture screenshot. Is there any similar solutions, any advice would be appreciated?...
Python Webkit making web-site screenshots using virtual framebuffer
The problem is that I need capture web-site screenshots without running X server. So theoretically it's possible to create a virtual frame buffer and to use it to capture screenshot. Is there any similar solutions, any advice would be appreciated? Sultan
[ "you can use a combination of Selenium WebDriver and pyvirtualdisplay (which uses xvfb) to run your browser in a virtual display and capture screenshots.\nso, the setup you need is:\n\nSelenium Python bindings\npyvirtualdisplay Python package (depends on xvfb)\n\nOn Debian/Ubuntu Linux systems, you can setup everyt...
[ 8 ]
[]
[]
[ "framebuffer", "pyqt4", "python", "webkit" ]
stackoverflow_0006572575_framebuffer_pyqt4_python_webkit.txt
Q: Fullscreen Windows with Tkinter How can one get a frame in Tkinter to display in fullscreen mode? I'm working on a program that will have two windows. The main window will house the settings options, and the 2nd window will open at a specific time and should be displayed in fullscreen mode. A: This worked pretty...
Fullscreen Windows with Tkinter
How can one get a frame in Tkinter to display in fullscreen mode? I'm working on a program that will have two windows. The main window will house the settings options, and the 2nd window will open at a specific time and should be displayed in fullscreen mode.
[ "This worked pretty well for me:\n>>> import Tkinter\n>>> root = Tkinter.Tk()\n>>> root.overrideredirect(True)\n>>> root.geometry(\"{0}x{1}+0+0\".format(root.winfo_screenwidth(),\n root.winfo_screenheight()))\n\nI'm using OS X -- the title bar and top-level menu bar remained, b...
[ 6 ]
[]
[]
[ "python", "tkinter" ]
stackoverflow_0006573207_python_tkinter.txt
Q: Tkinter app does not run - Why? I am in over my head - a friend requires help with a Tkinter app, but while I am a seasoned C developer I have no experience of python. I have read the Tkinter manual and have got so far: from Tkinter import * class Application(Frame): def __init__(self, master=None): fr...
Tkinter app does not run - Why?
I am in over my head - a friend requires help with a Tkinter app, but while I am a seasoned C developer I have no experience of python. I have read the Tkinter manual and have got so far: from Tkinter import * class Application(Frame): def __init__(self, master=None): frame = Frame(master) frame.pac...
[ "You're not running anything, only defining functions and classes.\nTry adding a line app = Application() at the end, and let me know how that goes - I don't know Tkinter, but I do know python well enough to know that you're not doing anything :P.\n\nOK I've had a good look over your code. Try this:\ndef janelaempr...
[ 1 ]
[]
[]
[ "menu", "python", "tkinter" ]
stackoverflow_0006573794_menu_python_tkinter.txt
Q: Python: Avoid DTD validation with LXML I am parsing USPTO patents from 2001 in SGML format. At top of each file, an external DTD is referenced. Unfortunately, this DTD seems to be invalid. A validity check confirms that: Line 361 Error: A '(' character or an element type is required within declaration of element t...
Python: Avoid DTD validation with LXML
I am parsing USPTO patents from 2001 in SGML format. At top of each file, an external DTD is referenced. Unfortunately, this DTD seems to be invalid. A validity check confirms that: Line 361 Error: A '(' character or an element type is required within declaration of element type "ADR". <!ELEMENT ADR - - (OMC?,STR*,CIT...
[ "As Chrono Kitsune already noted: the problem lies with xml versus sgml: the DTD is not a correct xml dtd, because it is an sgml dtd. \nI'd suggest converting the sgml documents to xml first, for example using sx.\n" ]
[ 5 ]
[]
[]
[ "dtd", "lxml", "python" ]
stackoverflow_0006572556_dtd_lxml_python.txt
Q: organizing all the words in a text file in an array or linked list using python I have a text file of the following format. <InitialNode>-><MergeNode *merge>->("Prepare for election") ->["Equipment, voter lists, ballot styles and/or ballots"]-><ForkNode> { ->("Prepare for voting (precinct)")-><ForkNode> { ->("Gath...
organizing all the words in a text file in an array or linked list using python
I have a text file of the following format. <InitialNode>-><MergeNode *merge>->("Prepare for election") ->["Equipment, voter lists, ballot styles and/or ballots"]-><ForkNode> { ->("Prepare for voting (precinct)")-><ForkNode> { ->("Gather in-person vote") // Includes early voting. ->["Ballots and/or ballot images"]->(Co...
[ "If your initial string is stored in x.\nTo get all the text in x,do\nx = open(\"/tmp/filename\").read()\n\nThis should do the trick\nimport re\nsplitter = re.compile('->')\narray = splitter.split(x)\n\n", "I would just use the built-in split method of strings. \n>>> with open('txtfile.txt', 'r') as f:\n... t...
[ 0, 0 ]
[]
[]
[ "arrays", "file", "linked_list", "python", "split" ]
stackoverflow_0006574165_arrays_file_linked_list_python_split.txt
Q: pygtk: how to switch window_state from popup_menu This is my code: def configure_event(self, widget): if self.is_hiding: self.window.present() else: self.window.iconify() def delete_event(self, widget, data=None): gtk.main_quit() return True def popup_menu(self): self.menu = g...
pygtk: how to switch window_state from popup_menu
This is my code: def configure_event(self, widget): if self.is_hiding: self.window.present() else: self.window.iconify() def delete_event(self, widget, data=None): gtk.main_quit() return True def popup_menu(self): self.menu = gtk.Menu() self.about = gtk.MenuItem("about") if...
[ "look at the signatures of both of them:\ndef configure_event(self, widget):\ndef delete_event(self, widget, data=None):\n\ndelete_event has a third argument data (that has a default of None) but configure_event only has two.\nalthough i don't know what the exception was i bet that the exception was:\nTypeError: co...
[ 0 ]
[]
[]
[ "gtk", "menu", "pygtk", "python", "tray" ]
stackoverflow_0006573455_gtk_menu_pygtk_python_tray.txt
Q: Assuming a many to many relationship (sqlalchemy, python), how to avoid adding duplicates? The tables authors and books are in a many to many relationship. A book can have many authors. An author has possibly written many books. author_1 = Author('Dan') session.add(author_1) author_1.books = [Paper('Illuminati'), ...
Assuming a many to many relationship (sqlalchemy, python), how to avoid adding duplicates?
The tables authors and books are in a many to many relationship. A book can have many authors. An author has possibly written many books. author_1 = Author('Dan') session.add(author_1) author_1.books = [Paper('Illuminati'), Book('Sacrileg')] session.commit() This adds two books and an author to the database and links ...
[ "This is basically the long version of @renatopp comment\n\nThis results in a duplicate Error! Why is that?\n\nYou create a new book/paper that is similar to the one you have in the db. I take it you set paper/book's name with unique constraint\n\nDo I have to query for Paper('Illuminati') first?\n\nLet's see what ...
[ 2 ]
[]
[]
[ "duplicates", "many_to_many", "python", "sqlalchemy" ]
stackoverflow_0006558672_duplicates_many_to_many_python_sqlalchemy.txt
Q: Google Data API - Trying to exchange an authsub_token for a session_token via upgradetosessiontoken results in "NonAuthSubToken" I'm using exactly the code in the examples from here: http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_python.html#Auth Still no dice. Here is the exact code I've got (thi...
Google Data API - Trying to exchange an authsub_token for a session_token via upgradetosessiontoken results in "NonAuthSubToken"
I'm using exactly the code in the examples from here: http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_python.html#Auth Still no dice. Here is the exact code I've got (this is all running on a web server): #!/usr/bin/python import gdata.photos.service import gdata.media import gdata.geo print "content-...
[ "I'm answering my own question so that others can benefit from it:\nThe google documentation is out of date. Found the answer here: http://www.mail-archive.com/google-calendar-help-dataapi@googlegroups.com/msg09180.html\nThis is what the code should look like:\nIt does need the actual value. So either give it a ....
[ 5 ]
[]
[]
[ "google_api_client", "python" ]
stackoverflow_0006566896_google_api_client_python.txt
Q: How to multiply a numpy tuple array by scalar array I have a numpy array A of shape(N,2) and a numpy array S of shape(N). How do I multiply both arrays? Currently I am using this code: tupleS = numpy.zeros( (N , 2) ) tupleS[:,0] = S tupleS[:,1] = S product = A * tupleS I am a python beginner. Is there a better wa...
How to multiply a numpy tuple array by scalar array
I have a numpy array A of shape(N,2) and a numpy array S of shape(N). How do I multiply both arrays? Currently I am using this code: tupleS = numpy.zeros( (N , 2) ) tupleS[:,0] = S tupleS[:,1] = S product = A * tupleS I am a python beginner. Is there a better way to do this?
[ "Numpy uses row-major order, so you have to explicitly create a column. As in:\n>> A = numpy.array(range(10)).reshape(5, 2)\n>>> B = numpy.array(range(5))\n>>> B\narray([0, 1, 2, 3, 4])\n>>> A * B\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nValueError: shape mismatch: objects canno...
[ 6, 3, 1, 1 ]
[ "I can think of:\nproduct = A * numpy.tile(S, (2,1)).T\n\nA faster solution might be:\nproduct = [d * S for d in A.T]\n\nthough that doesn't get you a numpy array as output, and it's transposed. So to get a similar numpy array (note that this is slower than the first solution):\nproduct = numpy.array([d * S for d i...
[ -1 ]
[ "arrays", "numpy", "python", "tuples" ]
stackoverflow_0006573166_arrays_numpy_python_tuples.txt
Q: separate django projects on different machines using a common database Our site has two separate projects connected to the same database. This is implemented by importing the models from project1 into project2 and using it to access and manipulate data. This works fine on our test server, but we are planning deplo...
separate django projects on different machines using a common database
Our site has two separate projects connected to the same database. This is implemented by importing the models from project1 into project2 and using it to access and manipulate data. This works fine on our test server, but we are planning deployment and we decided we would rather have the projects on two separate machi...
[ "This isn't really a Django question. It is more a Python Question.\nHowever to answer your question Django is going to have to be able to import these files one way or another. If they are on seperate machines you really should refactor the code out into it's own app and then install this app on each of the machin...
[ 1 ]
[]
[]
[ "amazon_web_services", "architecture", "deployment", "django", "python" ]
stackoverflow_0006572203_amazon_web_services_architecture_deployment_django_python.txt
Q: sqlalchemy compiler question I have a custom InsertFromSelect class which does exactly what it's name says. The output query is exactly what I need, problem is that I can't seem to execute it. Class: from sqlalchemy.ext.compiler import compiles from sqlalchemy.sql.expression import Executable, ClauseElement class...
sqlalchemy compiler question
I have a custom InsertFromSelect class which does exactly what it's name says. The output query is exactly what I need, problem is that I can't seem to execute it. Class: from sqlalchemy.ext.compiler import compiles from sqlalchemy.sql.expression import Executable, ClauseElement class InsertFromSelect( Executable, Cla...
[ "since you're not using a transaction, add the \"autocommit\" option to your construct:\nclass InsertFromSelect( Executable, ClauseElement ):\n _execution_options = \\\n Executable._execution_options.union({'autocommit': True})\n def __init__( self, table, select ):\n self.table = table\n ...
[ 2 ]
[]
[]
[ "python", "sqlalchemy" ]
stackoverflow_0006574347_python_sqlalchemy.txt
Q: Storing a list of modules I recently learned of the __ import__ function and found that I could store a module in a variable, so I was thinking of making a list of modules and then calling the appropriate one when necessary. So I might have three modules test1, test2, test3, each containing a single function "prin...
Storing a list of modules
I recently learned of the __ import__ function and found that I could store a module in a variable, so I was thinking of making a list of modules and then calling the appropriate one when necessary. So I might have three modules test1, test2, test3, each containing a single function "print_hello" that simply prints "he...
[ "I use this sort of approach in some of my testing code. I want to test output from one version of a module against a different versions of the same module. Being able to iterate over different module instances makes the code cleaner.\nBut this sort of code is the exception to the rule. It's very infrequently tha...
[ 1 ]
[]
[]
[ "import", "python" ]
stackoverflow_0006574701_import_python.txt
Q: Math Intensive, Calculation Based Website - Which Language Should I Use? I am very new to programming. I am familiar with HTML, C++ and learning PHP to start a database. I want to make a website which tracks a stock price. I have written various algorithms in Matlab however, MATLAB only has a to-Java conversion....
Math Intensive, Calculation Based Website - Which Language Should I Use?
I am very new to programming. I am familiar with HTML, C++ and learning PHP to start a database. I want to make a website which tracks a stock price. I have written various algorithms in Matlab however, MATLAB only has a to-Java conversion. I was wondering what language would be the best to do a lot of calculations. ...
[ "My advice: write the website code in Python with Django and do the calculations in Numpy/Scipy. Those two libraries provide a very Matlab-like API for heavy computations. Their performance is excellent. Matplotlib is the associated plotting library.\n", "It's not so much the language that matters, it's making su...
[ 7, 1, 0, 0, 0 ]
[]
[]
[ "c++", "java", "math", "matlab", "python" ]
stackoverflow_0006574740_c++_java_math_matlab_python.txt
Q: How to rewrite the code more elegant I wrote this function. The input and expected results are indicated in the docstring. def summarize_significance(sign_list): """Summarizes a series of individual significance data in a list of ocurrences. For a group of p.e. 5 measurements and two diferent states, the ...
How to rewrite the code more elegant
I wrote this function. The input and expected results are indicated in the docstring. def summarize_significance(sign_list): """Summarizes a series of individual significance data in a list of ocurrences. For a group of p.e. 5 measurements and two diferent states, the input data has the form: sign_lis...
[ "Here's one that uses less code and is probably more efficient because it just iterates through sign_list once without calling swapaxes, and doesn't build a bunch of dictionaries.\nsummary = [[0,0,0] for _ in sign_list[0]]\n\nfor row in sign_list:\n for index,sign in enumerate(row):\n summary[index][sign+1] += ...
[ 3, 1, 1 ]
[]
[]
[ "arrays", "list", "python" ]
stackoverflow_0006574692_arrays_list_python.txt
Q: Setting a property from the Pylons .ini file Let's say I have a settings.py file in my app's root folder (/myapp/myapp/settings.py) with just a bunch of variables in it: var1 = '' var2 = '' Can I automatically set one of those variables from the .ini file? I tried this: myapp.settings.var1 = 'this is from develop...
Setting a property from the Pylons .ini file
Let's say I have a settings.py file in my app's root folder (/myapp/myapp/settings.py) with just a bunch of variables in it: var1 = '' var2 = '' Can I automatically set one of those variables from the .ini file? I tried this: myapp.settings.var1 = 'this is from development.ini' But when I call var1 it is still the em...
[ "You can find relevant information at this page: \nGetting Data from the Configuration File\n", ".ini is one way only communication. Django uses settings.py which is a normal python module that can be manipulated on-the-fly (causing many obscure errors). Setup your settings in .ini and use config.get to access v...
[ 1, 0 ]
[]
[]
[ "configuration", "pylons", "python" ]
stackoverflow_0002336878_configuration_pylons_python.txt
Q: Install libxml2 bindings for python3 The Problem I’m trying to build libxml (libxml2-2.7.8) bindings for Python 3.2. When I run the following: ./configure --with-python=/usr/bin/python3.2 The compilation of libxml2-2.7.8 works...but the Python bindings for libxml2-2.7.8 don’t! Attempted Fixes Ported setup.py an...
Install libxml2 bindings for python3
The Problem I’m trying to build libxml (libxml2-2.7.8) bindings for Python 3.2. When I run the following: ./configure --with-python=/usr/bin/python3.2 The compilation of libxml2-2.7.8 works...but the Python bindings for libxml2-2.7.8 don’t! Attempted Fixes Ported setup.py and generator.py (using 2to3, and some basic...
[ "The PyInstanceObject is a part of the support for old style types, which is gone in Python 3, and has been deprecated since Python 2.2. The trick here is to first update the bindings to use new-style classes, and then port to Python 3.\n(Or use lxml, which wraps the libxml2 in a Pythonic XML classes).\nI'm not 100...
[ 3 ]
[]
[]
[ "libxml2", "python", "python_3.x" ]
stackoverflow_0006573819_libxml2_python_python_3.x.txt
Q: How to avoid splitting on a delimiter if it appears inside quotes? I have problem in splitting data. I have data as follows in CSV file: "a";"b";"c;d";"e" The problem is when I used line.split(";") function, it splits even between c and d. I don't want c and d to be separated. Later I need to store these four va...
How to avoid splitting on a delimiter if it appears inside quotes?
I have problem in splitting data. I have data as follows in CSV file: "a";"b";"c;d";"e" The problem is when I used line.split(";") function, it splits even between c and d. I don't want c and d to be separated. Later I need to store these four values in four different columns in a table, but using this function I get...
[ "import csv\nreader = csv.reader(open(\"yourfile.csv\", \"rb\"), delimiter=';')\nfor row in reader:\n print row\n\nTry this out.\nimport csv\nreader = csv.reader(open(\"yourfile.csv\", \"rb\"), delimiter=';', quoting=csv.QUOTE_NONE )\nfor row in reader:\n print row\n\nThis ^^^ if you want quotes preserved\nEd...
[ 12, 0 ]
[]
[]
[ "python" ]
stackoverflow_0005552364_python.txt
Q: How do coroutines improve performance I've been seeing a lot of talks and articles on coroutines in python. They are considered to be "microthreads" and I've heard they improve performance. How do coroutines improve performance? From what I've seen so far, they are single threaded and execute in sequence. I agree...
How do coroutines improve performance
I've been seeing a lot of talks and articles on coroutines in python. They are considered to be "microthreads" and I've heard they improve performance. How do coroutines improve performance? From what I've seen so far, they are single threaded and execute in sequence. I agree that from a design perspective they are qui...
[ "Coroutines don't really improve performance except in a very limited sense: multi-threaded programs have a certain overhead and coroutines provide some of the benefit of threading without incurring those overheads. However, most multi-threaded applications (even in C-Python with its GIL) benefit from the overlap w...
[ 11, 8 ]
[]
[]
[ "coroutine", "python" ]
stackoverflow_0006574274_coroutine_python.txt
Q: Cocoa - maximum depth for nested loops? I am trying to write an algorithm that locates the possible solutions for choosing 10 values from a 10x10 grid. No two values can share the same row or column. There are 10! combinations (just over 3,600,000). My initial algorithm uses 10 nested for loops and simply checks...
Cocoa - maximum depth for nested loops?
I am trying to write an algorithm that locates the possible solutions for choosing 10 values from a 10x10 grid. No two values can share the same row or column. There are 10! combinations (just over 3,600,000). My initial algorithm uses 10 nested for loops and simply checks each possible combination of 10 squares. Whe...
[ "Your immediate problem is nothing to do with the maximum depth of nested for loops, just basic Cocoa memory management. You create, and then accumulate millions of objects in the current AutoreleasePool. \nFor further info try http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articl...
[ 2, 2, 1, 0 ]
[]
[]
[ "cocoa", "objective_c", "python" ]
stackoverflow_0006562560_cocoa_objective_c_python.txt
Q: Efficient way to use python's lambda, map I need to store a big list of integers in Bigtable(db). For efficiency I am storing them as diff between 2 consecutive items. for eg: original_list = [1005, 1004, 1003, 1004, 1006] Storing the above list(which actually contains more than 1000k items) as start = 1005 dif...
Efficient way to use python's lambda, map
I need to store a big list of integers in Bigtable(db). For efficiency I am storing them as diff between 2 consecutive items. for eg: original_list = [1005, 1004, 1003, 1004, 1006] Storing the above list(which actually contains more than 1000k items) as start = 1005 diff = [-1, -1, 1, 2] The closest I could manage i...
[ "For such large data structures numpy will work well. For this example, it's over 200x faster (see below), and a bit easier to code, basically just\nadd.accumulate(diff)\n\nComparison between numpy and direct list manipulation:\nimport numpy as nx\nimport timeit\n\nN = 10000\n\ndiff_nx = nx.zeros(N, dtype=nx.int)\...
[ 7, 6, 4, 2, 2, 1, 0, 0, 0 ]
[]
[]
[ "lambda", "list", "map_function", "performance", "python" ]
stackoverflow_0001363413_lambda_list_map_function_performance_python.txt
Q: error installing mod_wsgi on SUSE 11 server apache version :2.2.6 python versoin :2.6 result of ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python is ok but just got some errors as follows when make: .... mod_wsgi.c:14430: error: expected expression before âmoduleâ mod_wsgi.c:14431: ...
error installing mod_wsgi on SUSE 11 server
apache version :2.2.6 python versoin :2.6 result of ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python is ok but just got some errors as follows when make: .... mod_wsgi.c:14430: error: expected expression before âmoduleâ mod_wsgi.c:14431: error: expected identifier or â(â before â=â toke...
[ "i had the same error; i solved it by compileing python 2.7.2 from scratch; if you look around different forums you will see that some libraries of python where compiled on a 32 bit system and you problably are using a 64 bit system. \ngo for 2.7 or above 2.6 is a pain to compile due to all the missing dependencie...
[ 1 ]
[]
[]
[ "django", "mod_wsgi", "python" ]
stackoverflow_0006053981_django_mod_wsgi_python.txt
Q: How do define which spider the scrapy shell uses? I'm trying to test out some XPaths using the Scrapy shell, but it seems to be calling on my incomplete spider module to do the scraping, which is not what I want. Is there a way to define which spider scrapy uses with its shell? Even more, why is Scrapy doing this;...
How do define which spider the scrapy shell uses?
I'm trying to test out some XPaths using the Scrapy shell, but it seems to be calling on my incomplete spider module to do the scraping, which is not what I want. Is there a way to define which spider scrapy uses with its shell? Even more, why is Scrapy doing this; shouldn't it know the spider is not ready for use? Tha...
[ "Scrapy automatically selects the spider based on the allowed_domains attribute. If there are more than one spider for given domain Scrapy will use BaseSpider.\nBut, it's just a python shell, you can instantiate any spider you want.\n\n>>> from myproject.spiders.myspider import MySpider\n>>> spider = MySpider()\n>>...
[ 6, 1, 1 ]
[]
[]
[ "python", "scrapy", "web_crawler" ]
stackoverflow_0006559670_python_scrapy_web_crawler.txt
Q: Modeling a database many to many relationship between three tables using sqlalchemy in python Let's consider the following table models for sqlalchemy in python. class Worker(Base): id Column(Integer, primary = True) name Column(String, nullable = False) class Project(Base): id Column(Integer, primary...
Modeling a database many to many relationship between three tables using sqlalchemy in python
Let's consider the following table models for sqlalchemy in python. class Worker(Base): id Column(Integer, primary = True) name Column(String, nullable = False) class Project(Base): id Column(Integer, primary = True) name Column(String, nullable = False) class Rating(Base): id Column(Integer, prim...
[ "Make the ratings table something like this.\n Rating\n---------------------\n rating_id (primary key) \n worker_id (foreign key - worker(worker_id)) \n project_id (foreign key - project(project_id)) \n description\n\nIf I'm understanding this correctly that is.\n" ]
[ 4 ]
[]
[]
[ "database_design", "model", "python", "relationship", "sqlalchemy" ]
stackoverflow_0006575396_database_design_model_python_relationship_sqlalchemy.txt
Q: Bit of python help I've tried to get this to work, but it just freezes. It should display a pyramid, but all it does is.. halts. from graphics import * valid_colours = ['red', 'blue', 'yellow', 'green'] colour = ['', '', ''] while True: colour[0] = raw_input("Enter your first colour: ") colour[1] = raw_...
Bit of python help
I've tried to get this to work, but it just freezes. It should display a pyramid, but all it does is.. halts. from graphics import * valid_colours = ['red', 'blue', 'yellow', 'green'] colour = ['', '', ''] while True: colour[0] = raw_input("Enter your first colour: ") colour[1] = raw_input("Enter your second...
[ "\nWell first the color-input loop does not do what you want it to do.\n\nThe 'and' in if ((colour[0] and colour[1] and colour[2]) in valid_colours):\ncompares their string values to each other, where any non-empty string evaluates as True. The expression evaluates to colour[2], assuming it is the last non-empty st...
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0002821290_python.txt
Q: String to DATETIME in MySQL I would like to convert strings to datetime objects to be used in the insert statement for MySQL. The strings are received in the following format : 2010-12-21T22:57:04.000Z The data type of the MySQL column is DATETIME. A: You can use the strptime function. For instance, that would ...
String to DATETIME in MySQL
I would like to convert strings to datetime objects to be used in the insert statement for MySQL. The strings are received in the following format : 2010-12-21T22:57:04.000Z The data type of the MySQL column is DATETIME.
[ "You can use the strptime function.\nFor instance, that would give:\nmyDatetime = datetime.strptime(myString.split(\".\")[0], \"%Y-%m-%dT%H:%M:%S\")\n\n[EDIT] Well, I've seen this has been treated in another thread with a better answer than mine: How to parse an ISO 8601-formatted date?\n" ]
[ 4 ]
[]
[]
[ "datetime", "mysql", "python", "sql" ]
stackoverflow_0006575896_datetime_mysql_python_sql.txt
Q: UnicodeDecodeError in Python with codecs module I have a text file which comprises unicode strings "aBiyukÙwa", "varcasÙva" etc. When I try to decode them in the python interpreter using the following code, it works fine and decodes to u'aBiyuk\xd9wa': "aBiyukÙwa".decode("utf-8") But when I read it from a file in...
UnicodeDecodeError in Python with codecs module
I have a text file which comprises unicode strings "aBiyukÙwa", "varcasÙva" etc. When I try to decode them in the python interpreter using the following code, it works fine and decodes to u'aBiyuk\xd9wa': "aBiyukÙwa".decode("utf-8") But when I read it from a file in a python program using the codecs module in the foll...
[ "Your file is not encoded in UTF-8. Find out what it is encoded in, and then use that.\n" ]
[ 5 ]
[]
[]
[ "python", "regex", "unicode" ]
stackoverflow_0006575933_python_regex_unicode.txt
Q: python regular expressions to return complete result How can I get what was matched from a python regular expression? re.match("^\\\w*", "/welcome") All python returns is a valid match; but I want the entire result returned; how do I do that? A: Just use re.findall function. >>> re.findall("a+", 'sdaaddaa') ['...
python regular expressions to return complete result
How can I get what was matched from a python regular expression? re.match("^\\\w*", "/welcome") All python returns is a valid match; but I want the entire result returned; how do I do that?
[ "Just use re.findall function.\n>>> re.findall(\"a+\", 'sdaaddaa')\n['aa', 'aa']\n\n", "You could use a group.\nres = re.search(\"^(\\\\\\w*)\", \"/welcome\")\nif res:\n res.group(1);\n\n", "Calling the group() method of the returned match object without any arguments will return the matched portion of the s...
[ 3, 0, 0, 0, 0 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0006574845_python_regex.txt
Q: python - simple syntax question I'm getting a python syntax error for the following line of code: orientations = [[(ants[0].loc, 0, {i: i for i in range(self.num_players)})]] ^ This is from someone else's script that I'm pretty sure should work, so I suspect the problem m...
python - simple syntax question
I'm getting a python syntax error for the following line of code: orientations = [[(ants[0].loc, 0, {i: i for i in range(self.num_players)})]] ^ This is from someone else's script that I'm pretty sure should work, so I suspect the problem might be the version of python I'm usi...
[ "As others said, you have to use Python 2.7 if you want to make this syntax work.\nAlternatively you can use tuples to initialize the dictionary:\n[[(ants[0].loc, 0, dict((i, i) for i in range(self.num_players)))]]\n\nBut there might be other parts of the code that would have to be changed as well. It might be easi...
[ 3, 2, 0 ]
[]
[]
[ "python", "syntax" ]
stackoverflow_0006576052_python_syntax.txt
Q: Evolutionary Algorithm for the Theo Jansen Walking Mechanism There is a Dutch artist/engineer who created a very elaborate walking mechanism. The working principle can be seen here: http://www.strandbeest.com/beests_leg.php The curious part is that he used a self-made Evolutionary Algorithm to calculate the ideal ...
Evolutionary Algorithm for the Theo Jansen Walking Mechanism
There is a Dutch artist/engineer who created a very elaborate walking mechanism. The working principle can be seen here: http://www.strandbeest.com/beests_leg.php The curious part is that he used a self-made Evolutionary Algorithm to calculate the ideal link lengths, which are described at the bottom of the page. I cre...
[ "Try the demo!\n\nThis is a fascinating question, though I think somewhat beyond the scope of Stack Overflow: it's not something that going to be solved in a few minutes, so I'll stick an outline here and update it if I make any progress. There are going to be three parts to any approach:\n\nScoring the footprint: ...
[ 17 ]
[]
[]
[ "evolutionary_algorithm", "genetic_algorithm", "geometry", "math", "python" ]
stackoverflow_0006573415_evolutionary_algorithm_genetic_algorithm_geometry_math_python.txt
Q: Regex case-insensitive searches not matching the exact word I'm using the following regex to search for 3 different string formats, concurrently. Additionally, I'm using re.IGNORECASE to match upper and lower case strings. However, when I perform a search (e.g. 'locality'), I'm able to get string matches for 'loca...
Regex case-insensitive searches not matching the exact word
I'm using the following regex to search for 3 different string formats, concurrently. Additionally, I'm using re.IGNORECASE to match upper and lower case strings. However, when I perform a search (e.g. 'locality'), I'm able to get string matches for 'localit', 'locali', 'local' and so on and so forth. I want to match ...
[ "There is no such flag in re, so either:\n\nconstruct a regex with explicit whitespace-matching after every char:\nr'\\s*'.join(c for c in userStrASCII)\nThis works: myre.findall(line) finds 'l Oc ALi ty'\nor (if you only need to detect matches to the pattern, but not do anything further with the actual match text)...
[ 2 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0005810537_python_regex.txt
Q: In Python, what are the cons of calling os.waitpid in a program with multiple threads? I've heard there are problems when calling os.waitpid from within a thread. I have not experienced such problems yet (especially using os.WNOHANG option). However I have not paid much attention to the performance implications of...
In Python, what are the cons of calling os.waitpid in a program with multiple threads?
I've heard there are problems when calling os.waitpid from within a thread. I have not experienced such problems yet (especially using os.WNOHANG option). However I have not paid much attention to the performance implications of such use. Are there any performance penalties or any other issues one should be aware of? D...
[ "My guess: people are just referring to calling waitpid() without WNOHANG, which of course obviates the reason you use multiple threads in the first place. (That is, of course, unless you are just using it to reap the zombies).\n", "By default, a child process dies, the parent is sent a SIGCHLD signal. Concern fo...
[ 0, 0 ]
[]
[]
[ "multiprocessing", "multithreading", "operating_system", "optimization", "python" ]
stackoverflow_0005691309_multiprocessing_multithreading_operating_system_optimization_python.txt
Q: Overwriting class methods without inheritance (python) First, if you guys think the way I'm trying to do things is not Pythonic, feel free to offer alternative suggestions. I have an object whose functionality needs to change based on outside events. What I've been doing originally is create a new object that inhe...
Overwriting class methods without inheritance (python)
First, if you guys think the way I'm trying to do things is not Pythonic, feel free to offer alternative suggestions. I have an object whose functionality needs to change based on outside events. What I've been doing originally is create a new object that inherits from original (let's call it OrigObject()) and overwrit...
[ "You want the Strategy Pattern.\n", "Use the types module to create an instance method for a particular instance.\neg.\nimport types\n\ndef strategyA(possible_self):\n pass\n\ninstance = OrigObject()\n\ninstance.strategy = types.MethodType(strategyA, instance)\n\ninstance.strategy()\n\nNote that this only effe...
[ 6, 5, 2, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0006575279_python.txt
Q: Some Google App Engine BlobStore Problems I have googled and read the docs on Google App Engine official site about BlobStore but there are some problems that I still dont understand. My Platform is webapp. Docs I have read: webapp Blobstore Handlers Blobstore Python API Overview The Blobstore Python API After r...
Some Google App Engine BlobStore Problems
I have googled and read the docs on Google App Engine official site about BlobStore but there are some problems that I still dont understand. My Platform is webapp. Docs I have read: webapp Blobstore Handlers Blobstore Python API Overview The Blobstore Python API After reading all these docs, I still have some proble...
[ "\nsend_blob() doesn't involve your application reading the file from the API, so the 1MB limit doesn't apply. The frontend service that returns the response to the user will read the entire blob and return all of it in the response (it most likely does the reading in chunks, but this is an implementation detail th...
[ 2 ]
[]
[]
[ "blobstore", "google_app_engine", "python", "web_applications" ]
stackoverflow_0006575839_blobstore_google_app_engine_python_web_applications.txt
Q: Complicated regex to extract author name in python I'm trying to create a regex quite unsuccessfully, what I'm looking to do is get the content of any html element that has a class of (author|byline|writer) Here is what I have so far <([A-Z][A-Z0-9]*)class=\"(byLineTag|byline|author|by)\"[^>]*>(.*?)</\1> examples...
Complicated regex to extract author name in python
I'm trying to create a regex quite unsuccessfully, what I'm looking to do is get the content of any html element that has a class of (author|byline|writer) Here is what I have so far <([A-Z][A-Z0-9]*)class=\"(byLineTag|byline|author|by)\"[^>]*>(.*?)</\1> examples of what I need to match to <h6 class="byline">By <a r...
[ "Regex is not particularly well-suited to parsing HTML.\nThankfully there are tools specifically created for parsing HTML, e.g. BeautifulSoup and lxml; the latter of which is demonstrated below:\nmarkup = '''<h6 class=\"byline\">By <a rel=\"author\" href=\"http://topics.nytimes.com/top/reference/timestopics/people/...
[ 2, 2, 0, 0 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0006576358_python_regex.txt
Q: Match longest substring in Python Consider I have following string with a tab in between left & right part in a text file: The dreams of REM (Geo) sleep The sleep paralysis I want to match the above string that match both left part & right part in each line of another following file: The pons also contai...
Match longest substring in Python
Consider I have following string with a tab in between left & right part in a text file: The dreams of REM (Geo) sleep The sleep paralysis I want to match the above string that match both left part & right part in each line of another following file: The pons also contains the sleep paralysis center of the br...
[ "(Ok, you clarified most of what you want. Let me restate, then clarify the points I listed below as remaining unclear... Also take the starter code I show you, adapt it, post us the result.) \nYou want to search, line-by-line, case-insensitive, for the longest contiguous matches to each of a pair of match-pattern...
[ 3 ]
[]
[]
[ "python", "substring" ]
stackoverflow_0006576181_python_substring.txt
Q: what is the neat way to divide huge nested loops to 8(or more) processes using Python? this time i'm facing a "design" problem. Using Python, I have a implement a mathematical algorithm which uses 5 parameters. To find the best combination of these 5 parameters, i used 5-layer nested loop to enumerate all possible...
what is the neat way to divide huge nested loops to 8(or more) processes using Python?
this time i'm facing a "design" problem. Using Python, I have a implement a mathematical algorithm which uses 5 parameters. To find the best combination of these 5 parameters, i used 5-layer nested loop to enumerate all possible combinations in a given range. The time it takes to finish appeared to be beyond my expecta...
[ "You can try using jug, a library I wrote for very similar problems. Your code would then look something like\nfrom jug import TaskGenerator\nevaluate = TaskGenerator(evaluate)\n\nfor p0 in [1,2,3]:\n for p1 in xrange(10):\n for p2 in xrange(10,20):\n for p3 in [True, False]:\n ...
[ 8, 7, 3 ]
[]
[]
[ "multiprocessing", "python" ]
stackoverflow_0006576515_multiprocessing_python.txt
Q: multiple and/or in an expression foo() is NOT defined. >>> 0 and foo() (1) 0 # trivial >>> 0 and foo() or 1 (2) # expecting it as 0 and (foo() or 1) 1 # does NOT short-circuit on 0 >>> 1 or foo() ...
multiple and/or in an expression
foo() is NOT defined. >>> 0 and foo() (1) 0 # trivial >>> 0 and foo() or 1 (2) # expecting it as 0 and (foo() or 1) 1 # does NOT short-circuit on 0 >>> 1 or foo() (3) # trivial 1 >>> 1 or foo() ...
[ "and has higher precedence than or.\n(2)\n0 and foo() or 1 == (0 and foo()) or 1\n == 0 or 1 # short-circuited, foo() never evaluated\n == 1\n\n(4)\n1 or foo() and 0 == 1 or (foo() and 0)\n == 1 # short-circuited, foo() never evaluated\n\n", "Check precedence...
[ 5, 2, 1 ]
[]
[]
[ "python" ]
stackoverflow_0006576815_python.txt
Q: How to trim the longest match from beginning of a string (using python) In recent bash versions, I can do this: $ string="Universe.World.Country.State.City.Street" $ echo $string Universe.World.Country.State.City.Street $ newString="${string##*.}" $ echo $newString Street Using Python, what is a succinct way to d...
How to trim the longest match from beginning of a string (using python)
In recent bash versions, I can do this: $ string="Universe.World.Country.State.City.Street" $ echo $string Universe.World.Country.State.City.Street $ newString="${string##*.}" $ echo $newString Street Using Python, what is a succinct way to doing the same? I am interested in the last substring after the last period. ...
[ "How about\nx[x.rfind('.') + 1 : ]\n\nTo me, that expresses what you're interested in (find the last dot, then take everything after it) more simply than a pattern or the concept of a \"longest match\".\n", ">>> 'Universe.World.Country.State.City.Street'.rpartition('.')[2]\n'Street'\n\n", ">>> \"Universe.World....
[ 3, 3, 1, 0, 0, 0 ]
[]
[]
[ "python", "string" ]
stackoverflow_0001603076_python_string.txt
Q: Accessing forms from one website to another, python/django I'm trying to make a website that requires users to enter information about themselves. In order to check to see if this information is correct, it needs to enter the information on another website (that has an entire database of these types of users). It ...
Accessing forms from one website to another, python/django
I'm trying to make a website that requires users to enter information about themselves. In order to check to see if this information is correct, it needs to enter the information on another website (that has an entire database of these types of users). It will then return the results found. How do I do such a thing? Wh...
[ "Not really sure what you're looking to do as it doesn't make much sense. But you need to validate data provided by users on your site against data available in another database that isn't accessible to your app. \nThis means you need to send the data your users are providing to you to the other service that is p...
[ 0 ]
[]
[]
[ "authentication", "django", "python", "web_services" ]
stackoverflow_0006576909_authentication_django_python_web_services.txt
Q: Debugging sample pygame code. Possibly error with super(), yet again Can't figure out what's wrong. All I know is that it doesn't execute. Find the trackback at the bottom. EDIT: UPDATED, still doesn't run as should... from livewires import games SCREENWIDTH = 666 SCREENHEIGHT = 461 games.init (screen_width = SCR...
Debugging sample pygame code. Possibly error with super(), yet again
Can't figure out what's wrong. All I know is that it doesn't execute. Find the trackback at the bottom. EDIT: UPDATED, still doesn't run as should... from livewires import games SCREENWIDTH = 666 SCREENHEIGHT = 461 games.init (screen_width = SCREENWIDTH, screen_height = SCREENHEIGHT, fps = 100) backgroundimage = games...
[ "It's the images = PhelpsAnimation.thePhelpsfiles parameter. thePhelpsfiles is not an attribute of the PhelpsAnimation class you've defined. It should work if you change that to just images=thePhelpsfiles.\n" ]
[ 1 ]
[]
[]
[ "animation", "debugging", "livewires", "pygame", "python" ]
stackoverflow_0006576811_animation_debugging_livewires_pygame_python.txt
Q: Datetime iteration for KML placemarks All, I am writing an app that produces 64800 polygons and I want each of them to have a unique time stamp. The problem is that my script runs in about 3 seconds which means that there are exactly 3 unique dates spread across all 64k polygons. I've tried going back in time usin...
Datetime iteration for KML placemarks
All, I am writing an app that produces 64800 polygons and I want each of them to have a unique time stamp. The problem is that my script runs in about 3 seconds which means that there are exactly 3 unique dates spread across all 64k polygons. I've tried going back in time using timedelta() which does actually go back i...
[ "You could add a polygon counter to the generated timestamp to differentiate each polygon from the previous one. As a matter of fact, if you do not need accurate wall-clock timestamps - and your messing with the timestamps with timedelta() indicates that you do not - you could even use an abritrary counter as your ...
[ 1 ]
[]
[]
[ "datetime", "kml", "python" ]
stackoverflow_0006576887_datetime_kml_python.txt
Q: Is enforcing an abstract method implementation unpythonic? When designing classes abstract methods can be very helpful. From what I know, Python does not have a mechanism for enforcing an inherited class to implement the abstract method. In my code (see example below) I enter a failed assertion in the base class t...
Is enforcing an abstract method implementation unpythonic?
When designing classes abstract methods can be very helpful. From what I know, Python does not have a mechanism for enforcing an inherited class to implement the abstract method. In my code (see example below) I enter a failed assertion in the base class to cause a runtime error if not implemented. Is this unpythonic? ...
[ "Python actually does have abstract classes with abstact methods:\n>>> import abc\n>>> \n>>> class IFoo(object):\n... __metaclass__ = abc.ABCMeta\n... \n... @abc.abstractmethod\n... def foo(self):\n... pass\n... \n>>> foo = IFoo()\nTraceback (most recent call last):\n File \"<stdin>\", line...
[ 14, 5, 2, 0 ]
[]
[]
[ "oop", "python" ]
stackoverflow_0006576837_oop_python.txt
Q: python what is this line doing? I cannot find out what this line is doing: p = struct.pack(">b", x)+p[1:] can you help me on this? I think it is placing sth at the end of the struct. Is is also possible to place sth in the middle of that struct? Things like: p = struct.pack(">b", x)+p[2:] don't seem to help. Any i...
python what is this line doing?
I cannot find out what this line is doing: p = struct.pack(">b", x)+p[1:] can you help me on this? I think it is placing sth at the end of the struct. Is is also possible to place sth in the middle of that struct? Things like: p = struct.pack(">b", x)+p[2:] don't seem to help. Any ideas on this? Regards
[ "It replaces the first byte of p with a byte representing the value of x. You may or may not have already read this, but here is the documentation for the struct module.\nEdit: To replace the second byte, try this:\np = p[:1] + struct.pack(\">b\", x) + p[2:]\n\n", "As an alternative to all that string slicing, wh...
[ 3, 1 ]
[]
[]
[ "python", "struct" ]
stackoverflow_0006576163_python_struct.txt
Q: Render Template Exactly with Django I'm a complete newb to Django working on a sample app. It appears that I am missing something with how templates work in Django. I have a template file as follows: <!DOCTYPE HTML> <html> <head> <title>Zabba Dabba Doo</title> </head> <body> <h1>Zabba Dabba Doo</h1> <form action=...
Render Template Exactly with Django
I'm a complete newb to Django working on a sample app. It appears that I am missing something with how templates work in Django. I have a template file as follows: <!DOCTYPE HTML> <html> <head> <title>Zabba Dabba Doo</title> </head> <body> <h1>Zabba Dabba Doo</h1> <form action="/comparison/search/" method="get"> Searc...
[ "You forgot to render it.\n" ]
[ 8 ]
[]
[]
[ "django", "django_templates", "django_views", "python" ]
stackoverflow_0006577159_django_django_templates_django_views_python.txt
Q: Can I have some code constantly run inside Django like a daemon I'm using mod_wsgi to serve a django site through Apache. I also have some Python code that runs as a background process (dameon?). It keeps polling a server and inserts data into one of the Django models. This works fine but can I have this code be a...
Can I have some code constantly run inside Django like a daemon
I'm using mod_wsgi to serve a django site through Apache. I also have some Python code that runs as a background process (dameon?). It keeps polling a server and inserts data into one of the Django models. This works fine but can I have this code be a part of my Django application and yet able to constantly run in the ...
[ "You could either set up a cron job that runs some function you have defined, or - the more advanced and probably recommended method, integrate celery in your project (which is quite easy, actually).\n", "You could create a background thread from the WSGI script when it is first being imported.\nimport threading\...
[ 14, 11, 0 ]
[]
[]
[ "daemon", "daemons", "django", "python", "python_daemon" ]
stackoverflow_0006532744_daemon_daemons_django_python_python_daemon.txt
Q: loading all the files on a folder I am trying to load all the txt files from the folder and plot them. Which way is the easiest to load all txt files? A: If you want to match all the files in a particular folder that are .txt files, why not use the glob module? import pylab, glob txt_files = glob.iglob("./*.txt...
loading all the files on a folder
I am trying to load all the txt files from the folder and plot them. Which way is the easiest to load all txt files?
[ "If you want to match all the files in a particular folder that are .txt files, why not use the glob module?\nimport pylab, glob\n\ntxt_files = glob.iglob(\"./*.txt\")\n\nfor data in txt_files:\n data = pylab.loadtxt(data)\n pylab.plot(data[:,1], data[:,2])\n\npylab.show()\n\n" ]
[ 3 ]
[]
[]
[ "file_io", "matplotlib", "python" ]
stackoverflow_0006577330_file_io_matplotlib_python.txt
Q: Google App Engine Query Limit and Timeout I am using App Engine to build a site, and now I worry about the 30 seconds Time per request limit. For example, I have more than 10,000 members or even more, and I do the following: # class Member(db.Model): ... # Start a query result = Member.all().filter('username =','...
Google App Engine Query Limit and Timeout
I am using App Engine to build a site, and now I worry about the 30 seconds Time per request limit. For example, I have more than 10,000 members or even more, and I do the following: # class Member(db.Model): ... # Start a query result = Member.all().filter('username =','example').filter('password = ','123456').get() ...
[ "To be short:\n\nthe first two fetch query will be completed within 1 second. Actually, it should be completed within several hundreds of ms or dozens of ms.\nthe '.all().filter().order()' has not tried to fetch any data at all, so don't worry about the time.\n\n" ]
[ 1 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0006577147_google_app_engine_python.txt
Q: String formatting for hex colors in Python I modified a function from PHP to return a color gradient (http://www.herethere.net/~samson/php/color_gradient/color_gradient_generator.php.txt). I am having issues when returning color hex codes ending in 0s. This is the function: def _get_color(current_step=0, start='00...
String formatting for hex colors in Python
I modified a function from PHP to return a color gradient (http://www.herethere.net/~samson/php/color_gradient/color_gradient_generator.php.txt). I am having issues when returning color hex codes ending in 0s. This is the function: def _get_color(current_step=0, start='000000', end='ffffff', max_steps=16): ''' ...
[ ">>> print '{0:06x}'.format(123)\n00007b\n\n" ]
[ 9 ]
[]
[]
[ "hex", "python", "string" ]
stackoverflow_0006577759_hex_python_string.txt
Q: Python list comprehension logic error I'm trying to weed out strings that contains "msi" using regular expressions and a list comprehension. However, when I print the list, strings that contain "msi" are still in the list. What exactly would the error be? This is my code: spam_list = [l for l in spam_list if not r...
Python list comprehension logic error
I'm trying to weed out strings that contains "msi" using regular expressions and a list comprehension. However, when I print the list, strings that contain "msi" are still in the list. What exactly would the error be? This is my code: spam_list = [l for l in spam_list if not re.match("msi", l)]
[ "re.match() matches from the beginning of the string. Use re.search(), or even better, in.\nL = [l for l in L if \"msi\" not in l]\n\n", "Since you're apparently looking through a list of filenames, you could also use endswith:\nlist = [l for l in list if l.endswith('.msi')]\n\n", "Here is one way to filter a l...
[ 10, 5, 4 ]
[]
[]
[ "logic", "python", "regex" ]
stackoverflow_0006577585_logic_python_regex.txt
Q: Matching Mercurial/Python/PyWin32 Component Versions I'm looking at two different guides for Windows HgWeb installation on IIS. The first from mercurial developers says: On Windows, your Python version must match the version used to compile Mercurial. Otherwise, you'll get "Invalid Magic Number" errors whe...
Matching Mercurial/Python/PyWin32 Component Versions
I'm looking at two different guides for Windows HgWeb installation on IIS. The first from mercurial developers says: On Windows, your Python version must match the version used to compile Mercurial. Otherwise, you'll get "Invalid Magic Number" errors when trying to run the CGI. The second guide says: Don’t ...
[ "HgWeb\nFor HgWeb, this Mercurial download page recommends using the version that installs Mercurial as python modules, requiring Python 2.6.\nFrom that, you would select a build of PyWin32 and choose the download for Python 2.6, as they build it for several versions.\nBoth decisions also have 32bit and 64bit versi...
[ 0 ]
[]
[]
[ "hgweb", "mercurial", "python", "pywin32" ]
stackoverflow_0006575825_hgweb_mercurial_python_pywin32.txt
Q: Multi-Core Python: multiprocessing Vs. zeroMQ? I'd like to write python code that loads a data set as input and analyzes it. There will be 5 parallel processes that will analyze the data -- each process will be processing the data differently -- in a unique way. Before any processing will begin, the master script...
Multi-Core Python: multiprocessing Vs. zeroMQ?
I'd like to write python code that loads a data set as input and analyzes it. There will be 5 parallel processes that will analyze the data -- each process will be processing the data differently -- in a unique way. Before any processing will begin, the master script (the one that will 'start' all the different sub-pr...
[ "You can't compare apples and oranges.\nmultiprocessing is a library to fork many processes.\nzmq is a library that allows processes to use messages to communicate.\nThey do different jobs.\n", "If these are your only two choices and you know for sure that you're going to be distributing your load across multiple...
[ 5, 1 ]
[]
[]
[ "multiprocessing", "python", "zeromq" ]
stackoverflow_0006566880_multiprocessing_python_zeromq.txt
Q: Searching through a website directory, validate, then place URL in a list depending on content I've been working on a script and I thought I would ask for help. I'm looking to search a series of websites, check if the site is valid. Then the next step would be to check for specific content on the site. If the site...
Searching through a website directory, validate, then place URL in a list depending on content
I've been working on a script and I thought I would ask for help. I'm looking to search a series of websites, check if the site is valid. Then the next step would be to check for specific content on the site. If the site holds that content, place the URL in a list. import urllib2 def getPage(): url="import ur...
[ "Here's my answer to the question of how to validate a given web site.\npython check html valid\nFor checking the context of the page the tools consist of basic string methods, regex, or more sophisticated tools like lxml or beautifulsoup.\nmatchingSites = []\nmatchingSites.append(url) #Since you asked. :-p\n\n" ]
[ 0 ]
[]
[]
[ "iteration", "list", "python", "url", "validation" ]
stackoverflow_0006576199_iteration_list_python_url_validation.txt
Q: Basic GUI for shell commands with Python Tk threading and os.system calls I'm doing a basic GUI to provide some user feedback after some shell commands, a little interface for a shell script really. Showing a TK window, waiting for a os.system call to complete and updating the TK window multiple times, after each ...
Basic GUI for shell commands with Python Tk threading and os.system calls
I'm doing a basic GUI to provide some user feedback after some shell commands, a little interface for a shell script really. Showing a TK window, waiting for a os.system call to complete and updating the TK window multiple times, after each os.system call. How does threading work with tk? That's it, thanks!
[ "The standard threading library should be perfectly okay if you run it with Tk. This source says, that you should just let the main thread run the gui and create threads for your os.system() calls.\nYou could write an abstraction like this which updates your GUI upon finishing the task:\ndef worker_thread(gui, task...
[ 1, 0 ]
[]
[]
[ "command_line", "python", "shell", "tk_toolkit" ]
stackoverflow_0006575973_command_line_python_shell_tk_toolkit.txt
Q: How to Open & Modify an Attribute of a Files' Properties using Python? I've been having some troubles trying to determine a method in which I can open a files' property window, go to the Details tab and then edit one of the values of a specific value. In more detail, I have over 200 Mp3 files in a folder which I'd...
How to Open & Modify an Attribute of a Files' Properties using Python?
I've been having some troubles trying to determine a method in which I can open a files' property window, go to the Details tab and then edit one of the values of a specific value. In more detail, I have over 200 Mp3 files in a folder which I'd like to edit the Number Property Value to an increasing variable. Basically...
[ "You might want to try eyeD3 which allows you to modify mp3 ID3 attributes:\n import eyeD3\n tag = eyeD3.Tag()\n tag.link(\"/some/file.mp3\")\n print tag.getArtist()\n print tag.getAlbum()\n print tag.getTitle()\n tag.setArtist(u\"Cro-Mags\")\n tag.setAlbum(u\"Age of Quarrel\")\n tag.update()\n\nOr you could use mu...
[ 3 ]
[]
[]
[ "properties", "python" ]
stackoverflow_0006577469_properties_python.txt
Q: Detecting an arbittrary button press on a USB joystick WITHOUT pygame Is there anyway I could register button pushes on a joystick without using any function from pygame? A: If you're looking for a way to do it with just the standard Python library, the answer is probably "no" - or at the very least, "not in an...
Detecting an arbittrary button press on a USB joystick WITHOUT pygame
Is there anyway I could register button pushes on a joystick without using any function from pygame?
[ "If you're looking for a way to do it with just the standard Python library, the answer is probably \"no\" - or at the very least, \"not in any straightforward manner\". There are many things in the standard library, but gaming hardware support is not one of them.\n", "If your on linux, you could check out Python...
[ 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0004415649_python.txt
Q: pygtk: Draw lines onto a gtk.gdk.Pixbuf I'm using pygtk with PIL. I've already figured out a way to convert PIL Images to gtk.gdk.Pixbufs. What I do to display the pixbuf is I create a gtk.gdk.Image, and then use img.set_from_pixbuf. I now want to draw a few lines onto this image. Apparently I need a Drawable to d...
pygtk: Draw lines onto a gtk.gdk.Pixbuf
I'm using pygtk with PIL. I've already figured out a way to convert PIL Images to gtk.gdk.Pixbufs. What I do to display the pixbuf is I create a gtk.gdk.Image, and then use img.set_from_pixbuf. I now want to draw a few lines onto this image. Apparently I need a Drawable to do that. I've started looking through the docs...
[ "I was doing something similar (drawing to a gdk.Drawable), and I found that set_foreground doesn't work. To actually draw using the color I wanted, I used the following:\n# Red!\ngc.set_rgb_fg_color(gtk.gdk.Color(0xff, 0x0, 0x0))\n\n", "Oh my god. So painful. Here it is:\n w,h = pixbuf.get_width(), pixbuf.get...
[ 4, 3, 1, 1, 1 ]
[]
[]
[ "drawing", "gtk", "pygtk", "python" ]
stackoverflow_0001213090_drawing_gtk_pygtk_python.txt
Q: pip package dependency problem take this as example: https://github.com/bitprophet/fabric/blob/master/setup.py#L41 so Fabric requires pycrypto >= 1.9 and paramiko >=1.7.6 what if pycrypto update version to 2.1, and change their api, it will affect my package. this is not the result i want. so is their a convention...
pip package dependency problem
take this as example: https://github.com/bitprophet/fabric/blob/master/setup.py#L41 so Fabric requires pycrypto >= 1.9 and paramiko >=1.7.6 what if pycrypto update version to 2.1, and change their api, it will affect my package. this is not the result i want. so is their a convention that, package can't change api, or ...
[ "how about this?\nan excerpt\n\nSo what are requirements files? They are very simple: lists of packages to install. Instead of running something like pip MyApp and getting whatever libraries come along, you can create a requirements file something like:\n\nMyApp\nFramework==0.9.4\nLibrary>=0.2\n\n\nThen, regardless...
[ 0 ]
[]
[]
[ "package", "pip", "python" ]
stackoverflow_0006577191_package_pip_python.txt
Q: Efficient calculation of Sobel gradient magnitude I'm currently using this code to calculate the magnitude of the Sobel gradient: sobel_x = cv.CreateImage(cv.GetSize(im), cv.IPL_DEPTH_16S, 1) sobel_y = cv.CreateImage(cv.GetSize(im), cv.IPL_DEPTH_16S, 1) cv.Sobel(im, sobel_x, 1, 0, 3) cv.Sobel(im, sobel_y, 0, 1, 3)...
Efficient calculation of Sobel gradient magnitude
I'm currently using this code to calculate the magnitude of the Sobel gradient: sobel_x = cv.CreateImage(cv.GetSize(im), cv.IPL_DEPTH_16S, 1) sobel_y = cv.CreateImage(cv.GetSize(im), cv.IPL_DEPTH_16S, 1) cv.Sobel(im, sobel_x, 1, 0, 3) cv.Sobel(im, sobel_y, 0, 1, 3) width, height = cv.GetSize(im) for i in range(width*h...
[ "As you've already noted, cv.Sqrt() only accepts a scalar in the Python bindings. Since there is an equivalent function, cv::sqrt(), that performs an element-wise square-root, it should also be in the mostly auto-generated Python bindings. Perhaps this is a bug in the version of OpenCV that you are using.\nRegardle...
[ 3 ]
[]
[]
[ "image_processing", "opencv", "python" ]
stackoverflow_0006577836_image_processing_opencv_python.txt
Q: Replace with newline python I have a string a=">NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS" I want print a as "> NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS" I did a=a.replace(">","> \n") but it doesn't work. Where am I going wrong? A: One thing is the internal representation of the string: >>> a=">NKMFFALGLLGDGVIGALDTVVSSMG...
Replace with newline python
I have a string a=">NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS" I want print a as "> NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS" I did a=a.replace(">","> \n") but it doesn't work. Where am I going wrong?
[ "One thing is the internal representation of the string:\n>>> a=\">NKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS\"\n>>> a.replace(\">\",\"> \\n\")\n'> \\nNKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS'\n\nanother one is how it will be shown on screen:\n>>> print(a.replace(\">\",\"> \\n\"))\n> \nNKMFFALGLLGDGVIGALDTVVSSMGAVGASGLS\n\n" ]
[ 24 ]
[]
[]
[ "python" ]
stackoverflow_0006579129_python.txt
Q: import file in same dir Both files are in the same directory. How can I make the Axe class available to main.py ? # axe.py class Axe: name = 'Name' # main.py import axe my_axe = Axe() NameError: "name 'Axe' is not defined" A: You either want from axe import Axe, or my_axe = axe.Axe(). A: Either: # main.p...
import file in same dir
Both files are in the same directory. How can I make the Axe class available to main.py ? # axe.py class Axe: name = 'Name' # main.py import axe my_axe = Axe() NameError: "name 'Axe' is not defined"
[ "You either want from axe import Axe, or my_axe = axe.Axe().\n", "Either:\n# main.py\nimport axe\nmy_axe = axe.Axe()\n\nor:\n# main.py\nfrom axe import * # Or \"import Axe\" to just get Axe and not everything\nmy_axe = Axe()\n\nThe former is preferred, because if two modules have the same name defined, they won't...
[ 3, 1, 1, 0 ]
[]
[]
[ "import", "python" ]
stackoverflow_0006579307_import_python.txt
Q: how to encrypt python source code? we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled...
how to encrypt python source code?
we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but ...
[ "I would suggest you go back into thinking about this, considering:\n\nUse the right tool for the job\nObfuscation is hard\nOther means to achieve your goals\n\nFirstly, Python was not designed to be obfuscated. Every aspect of the language is free and accessible to anybody who wants to inspect or modify it. Being ...
[ 13, 4, 3 ]
[]
[]
[ "obfuscation", "python" ]
stackoverflow_0006578452_obfuscation_python.txt
Q: Find out the number of arguments passed to a function consisting of default values for arguments in python Consider the following python function: def fun(x=0,y=1,z=1): print x,y,z fun(2) Is there a way i can find out within the function how many arguments were actually passed to it,which in the above case is ...
Find out the number of arguments passed to a function consisting of default values for arguments in python
Consider the following python function: def fun(x=0,y=1,z=1): print x,y,z fun(2) Is there a way i can find out within the function how many arguments were actually passed to it,which in the above case is 1 ? Please Help Thank You
[ "Have a look at the inspect module\nimport inspect\ninspect.getargspec(someMethod)\n\n\nGet the names and default values of a Python function’s arguments. A tuple of four things is returned: (args, varargs, keywords, defaults). args is a list of the argument names (it may contain nested lists). varargs and keywords...
[ 1, 1, 0 ]
[]
[]
[ "python" ]
stackoverflow_0006579703_python.txt
Q: Python help Advanced Objects: Special Methods I am hoping someone can give me some advice on my code? I am learning python via a self study course and one of the assgnments requirements is as below: create a program named centipede.py, including a class named "Centipede." This class has the following requirements:...
Python help Advanced Objects: Special Methods
I am hoping someone can give me some advice on my code? I am learning python via a self study course and one of the assgnments requirements is as below: create a program named centipede.py, including a class named "Centipede." This class has the following requirements: Once instantiated if called with a value, it appe...
[ "\nlegs and stomach have to be assigned in the constructor. If you assign them at class level, they are class variables (roughly equivalent to java's static members). Do it like this\ndef __init__(self):\n self.legs = []\n self.stomach = []\n\nyour __call__ method is a little too complicated. this should be...
[ 5 ]
[]
[]
[ "python" ]
stackoverflow_0006580018_python.txt
Q: What type to store time length in python? I was using : total_time=datetime.time(int(total_time_text.replace("h","").replace("m","").split(" ")[0]),int(total_time_text.replace("h","").replace("m","").split(" ")[1]),0) to store the time length. But when I have : total_time_text ="26h 50m" I get an exception that...
What type to store time length in python?
I was using : total_time=datetime.time(int(total_time_text.replace("h","").replace("m","").split(" ")[0]),int(total_time_text.replace("h","").replace("m","").split(" ")[1]),0) to store the time length. But when I have : total_time_text ="26h 50m" I get an exception that 'hour must be in 0..23' so the type "time" i...
[ "datetime.timedelta\n", "Have a look at PLEAC for a lot of date/time examples.\n", "If you want to store a time length, you probably don't want to use datetime.time (which is inteded to be a specific time in a day rather than a duration). You should use datetime.timedelta instead, or even a simple integer repre...
[ 13, 0, 0 ]
[]
[]
[ "datetime", "python" ]
stackoverflow_0006580168_datetime_python.txt
Q: multiprocessing import modules on mac modules exists inside new processes before import, using python-multiprocessing on osx. Here's an example: import multiprocessing import sys import os print 'importing module' def main(): import uuid print 'setting var' uuid.some_variable = True def process(n...
multiprocessing import modules on mac
modules exists inside new processes before import, using python-multiprocessing on osx. Here's an example: import multiprocessing import sys import os print 'importing module' def main(): import uuid print 'setting var' uuid.some_variable = True def process(name): print 'uuid module loaded:', 'uu...
[ "The problem is that multiprocessing uses os.fork on unix. So the sub-process becomes a copy of the main process. Dont know what's going on with Fedora, but it shouldn't work on linux either. \nThere doesn't seem to be any easy way to get around it.\n", "It seems that mac implementation treats imports differentl...
[ 1, 0 ]
[]
[]
[ "macos", "multiprocessing", "python" ]
stackoverflow_0006573646_macos_multiprocessing_python.txt
Q: Can a create a site with a custom URI in Google Sites with Python? Using Google Appengine running the Python GDATA setup. I'm a member of the volunteer programming team for DPAU, which runs on Google Apps Education and has a Google Appengine running Python with help from the GDATA library. I'm using the create_sit...
Can a create a site with a custom URI in Google Sites with Python?
Using Google Appengine running the Python GDATA setup. I'm a member of the volunteer programming team for DPAU, which runs on Google Apps Education and has a Google Appengine running Python with help from the GDATA library. I'm using the create_site function in the SitesClient class. I know there is an input called uri...
[ "The initial site URL is determined by the site name, using a simple stripping algorithm (all lowercase, no spaces or special chars except - I believe)\nChange this into a two-step process:\n\ncreate the site using a munged name that corresponds to the URL you want\nupdate the site title, which retains the URL but ...
[ 0 ]
[]
[]
[ "gdata", "gdata_api", "google_apps", "python" ]
stackoverflow_0005426967_gdata_gdata_api_google_apps_python.txt
Q: matplotlib.pyplot how to add labels with .clabel? How can I use pyplot.clabel to attach the file names to the lines being plotted? plt.clabel(data) line gives the error A: Helou, plt.clabel is only used with contour lines, according to documentation: "adds labels to line contours in cs, where cs is a ContourSet ...
matplotlib.pyplot how to add labels with .clabel?
How can I use pyplot.clabel to attach the file names to the lines being plotted? plt.clabel(data) line gives the error
[ "Helou,\nplt.clabel is only used with contour lines, according to documentation: \"adds labels to line contours in cs, where cs is a ContourSet object returned by contour (axes_api). Please check contour example:\n", "You may use plt.annotate or plt.text. \nAnd, as an aside, 1) you probably want to use different ...
[ 0, 0 ]
[]
[]
[ "matplotlib", "python" ]
stackoverflow_0006577807_matplotlib_python.txt
Q: Detect users already exist in database on user registration I'm writing my first web site, and am dealing with user registration. One common problem to me like to everyone else is to detect user already exist. I am writing the app with python, and postgres as database. I have currently come up with 2 ideas: 1) lo...
Detect users already exist in database on user registration
I'm writing my first web site, and am dealing with user registration. One common problem to me like to everyone else is to detect user already exist. I am writing the app with python, and postgres as database. I have currently come up with 2 ideas: 1) lock(mutex) u = select from db where name = input_name if u == null...
[ "I think both will work, and both are equally bad ideas. :) My point is that implementing user authentication in python/pg has been done so many times in the past that there's hardly justification for writing it yourself. Have you had a look at Django, for example? It will take care of this for you, and much more, ...
[ 2, 0 ]
[]
[]
[ "database", "python", "sql" ]
stackoverflow_0006580723_database_python_sql.txt
Q: Getting top 10 sequences of BLAST results Bio Python I want to get top 10 sequences of BLAST results (just the sequences, no alignment or score or e-value etc). I am inputting a text file containing 5 fasta file. So my output should be top 10 blast hits of each fasta file.. therefore my output file will have 50 se...
Getting top 10 sequences of BLAST results Bio Python
I want to get top 10 sequences of BLAST results (just the sequences, no alignment or score or e-value etc). I am inputting a text file containing 5 fasta file. So my output should be top 10 blast hits of each fasta file.. therefore my output file will have 50 sequences. I am reading each of my input fasta file through ...
[ "Solutions on BioStar StackExchange:\nhttp://biostar.stackexchange.com/questions/9880/getting-top-10-sequences-of-blast-results-bio-python\nhttp://biostar.stackexchange.com/questions/9882/parsing-blast-output-biopython-error\n" ]
[ 4 ]
[]
[]
[ "biopython", "blast", "ncbi", "python", "sequence" ]
stackoverflow_0006577975_biopython_blast_ncbi_python_sequence.txt