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:
How to execute a python cgi-script under Linux
I have a python cgi script which executed fine on a Windows machine simply by starting CGIHTTPServer in the console, opening the html page to pass the data to the script and submitting the data.
I now need to do this under Linux but this is proving more difficult. So... | How to execute a python cgi-script under Linux | I have a python cgi script which executed fine on a Windows machine simply by starting CGIHTTPServer in the console, opening the html page to pass the data to the script and submitting the data.
I now need to do this under Linux but this is proving more difficult. Some web searching has given this script to start the ... | [
"The server only executes scripts under the directories /cgi-bin and /htbin relative to the server root. In contrast to Windows, these names are case-sensitive on Linux.\n"
] | [
0
] | [] | [] | [
"cgi",
"linux",
"python"
] | stackoverflow_0005857663_cgi_linux_python.txt |
Q:
How to capture a command prompt window close event in python
I want to capture command window close event from Python.
In other words, when the user tries to close the command prompt window, script should detect it and display a message like Do you really want to exit - Yes/No
Any suggestions about how to implemen... | How to capture a command prompt window close event in python | I want to capture command window close event from Python.
In other words, when the user tries to close the command prompt window, script should detect it and display a message like Do you really want to exit - Yes/No
Any suggestions about how to implement this?
Please help me in doing this.
| [
"define like this:\nimport time\n\ndef on_exit(sig, func=None):\n print(\"exit handler\")\n time.sleep(10) # so you can see the message before program exits\n\n\nWindows:\n\nif you install pywin32 package, you can :\nimport win32api\nwin32api.SetConsoleCtrlHandler(on_exit, True)\n\n\nUn*x:\n\nOr, using pytho... | [
4
] | [] | [] | [
"python"
] | stackoverflow_0005180440_python.txt |
Q:
facial shape segmentation
I need to know if it's there a way, with AForge or similar libraries, to develop an application that extract from a picture the facial shape. I mean: the application take a picture, detect the face, recognize face contour, trace this contour and delete what's inside. So at the end the app... | facial shape segmentation | I need to know if it's there a way, with AForge or similar libraries, to develop an application that extract from a picture the facial shape. I mean: the application take a picture, detect the face, recognize face contour, trace this contour and delete what's inside. So at the end the application return an image (a por... | [
"OpenCV is a very good generic computer vision library which includes face detection. It also has Python bindings, so you're good to go. There are plenty of tutorials on using it (just Google around). I wish you the best of luck with your project.\n"
] | [
1
] | [] | [] | [
"aforge",
"c#",
"java",
"python"
] | stackoverflow_0005857685_aforge_c#_java_python.txt |
Q:
How to move all attributes in a datastore with value True to another datastore?
Is there a way of moving all attributes within a model with a value set to True to another model?
I am writing in Python and have the following:
class crimechecker(webapp.RequestHandler):
def get(self):
#Checks for crime
... | How to move all attributes in a datastore with value True to another datastore? | Is there a way of moving all attributes within a model with a value set to True to another model?
I am writing in Python and have the following:
class crimechecker(webapp.RequestHandler):
def get(self):
#Checks for crime
articles = Article.all().filter('crime = ', None)
for article in artic... | [
"I don't see anything obviously wrong with your code. Since we've already established that there are no errors, my advice would be to add more logging.info calls higher up to see which if statement is evaluating to false, or which for loop is iterating over an empty set. Also, have you confirmed that crimechecker i... | [
1
] | [] | [] | [
"cron",
"google_app_engine",
"google_cloud_datastore",
"gql",
"python"
] | stackoverflow_0005856271_cron_google_app_engine_google_cloud_datastore_gql_python.txt |
Q:
Python 3: Determine if object supports IO
Some Python methods work on various input sources. For example, the XML element tree parse method takes an object which can either be a string, (in which case the API treats it like a filename), or an object that supports the IO interface, like a file object or io.StringI... | Python 3: Determine if object supports IO | Some Python methods work on various input sources. For example, the XML element tree parse method takes an object which can either be a string, (in which case the API treats it like a filename), or an object that supports the IO interface, like a file object or io.StringIO.
So, obviously the parse method is doing some... | [
"Python strongly encourages duck typing: Just assume the object that was passed in is valid and try to use it. This way, your code is as flexible as possible. Of course, if the actions of your code depend on the type of the object that is passed in, you do need some kind of type checking. I suggest to keep this ... | [
3,
1,
0
] | [] | [] | [
"interface",
"python",
"python_3.x"
] | stackoverflow_0005857951_interface_python_python_3.x.txt |
Q:
GUI development with IronPython and Visual Studio 2010
I'm teaching an introductory class to programming and GUI development using Python, and have found that the least overwhelming solution for students new to programming is to use Visual Studio for GUI development.
While the GUI development experience with C# an... | GUI development with IronPython and Visual Studio 2010 | I'm teaching an introductory class to programming and GUI development using Python, and have found that the least overwhelming solution for students new to programming is to use Visual Studio for GUI development.
While the GUI development experience with C# and VB is pleasant, I couldn't find a way to do the same with ... | [
"In IronPython 2.7 the wpf.LoadComponent method will wire up any properties with the same name as the XAML UI elements. If you are using IronPython 2.6 then you would need to use the code as suggested by WombatPM. So with IronPython 2.7 if you use the following XAML:\n<Window \n xmlns=\"http://schemas.microso... | [
6,
0
] | [] | [] | [
"ironpython",
"python",
"user_interface",
"visual_studio_2010"
] | stackoverflow_0005853812_ironpython_python_user_interface_visual_studio_2010.txt |
Q:
I want to retrieve multiple logs from a server with minimum lines of code
I would like to retrieve multiple log files from an Ubuntu server (using Python 2.7 on win 7 machine) without having to write verbose, repetitive code. I'm sure I can use a loop to accomplish this, but I can't come up with any valid solution... | I want to retrieve multiple logs from a server with minimum lines of code | I would like to retrieve multiple log files from an Ubuntu server (using Python 2.7 on win 7 machine) without having to write verbose, repetitive code. I'm sure I can use a loop to accomplish this, but I can't come up with any valid solutions (neophyte programmer). I need the direction of someone more seasoned than I. ... | [
"Instead of \nfilepath = '/var/log/apache2/error.log'\nlocalpath = 'C:\\\\remote\\\\NewFile.log'\nsftp.get(filepath, localpath)\n\nI propose this :\nlog_names = {\n \"/var/log/apache2/error.log\" : 'C:\\\\remote\\\\NewFile.log',\n \"/var/log/apache/a.log\" : 'C:\\\\remote\\\\NewFile_a.log',\n} # add here all ... | [
6,
1
] | [] | [] | [
"file",
"get",
"paramiko",
"python"
] | stackoverflow_0005857465_file_get_paramiko_python.txt |
Q:
Using Django minus the web server
I'm writing a syndication client, with the aim being to have a client for devices, and a web site that has the same functionality. I shall develop the website using Django - this is already decided; the client shall be written in python with both a CLI and a PyQt4 GUI. I have been... | Using Django minus the web server | I'm writing a syndication client, with the aim being to have a client for devices, and a web site that has the same functionality. I shall develop the website using Django - this is already decided; the client shall be written in python with both a CLI and a PyQt4 GUI. I have been writing the clinet first, and it's fai... | [
"Read up on standalone Django scripts and you'll be on your path to victory. Basically all you're really doing is referencing the Django settings.py (which Django expects) and then using models without web views or urls.\nIf all you're really interested in is using Django's ORM to manage your models and database in... | [
21,
0
] | [] | [] | [
"django",
"hybrid",
"model_view_controller",
"python",
"qt"
] | stackoverflow_0005858392_django_hybrid_model_view_controller_python_qt.txt |
Q:
Cannot install python packages from source-code
I need to install PIL (python imaging library) on my Ubunto10.4-32bit (EDIT:64bit) machine on my python2.5.4-32bit.
This question is also relevant to any other source package I guess (among those that I need are RPyC,psyco and numpy).
I downloaded the source-code si... | Cannot install python packages from source-code | I need to install PIL (python imaging library) on my Ubunto10.4-32bit (EDIT:64bit) machine on my python2.5.4-32bit.
This question is also relevant to any other source package I guess (among those that I need are RPyC,psyco and numpy).
I downloaded the source-code since I can't find any neat package to do the job and d... | [
"In short:\nTry using the Ubuntu repository first. If the package isn't there, use easy_install. If all fails, download the package directly to your source folder.\nUbuntu repository (the apt-get approach)\nUbuntu (10.04 and newer) has most mainstream packages are available with apt-get. The naming convention is py... | [
3,
2,
0
] | [] | [] | [
"linux",
"python"
] | stackoverflow_0005858170_linux_python.txt |
Q:
An easy way to deploy Django without Internet access?
What I have is development version of intranet site developed with Django and some external libraries placed in virtualenv. It runs fine and I can easily set up virtualenv with the same parameters (using pip) on any computer with internet connection. But, unfor... | An easy way to deploy Django without Internet access? | What I have is development version of intranet site developed with Django and some external libraries placed in virtualenv. It runs fine and I can easily set up virtualenv with the same parameters (using pip) on any computer with internet connection. But, unfortunately it needs to be deployed on computer without :( Any... | [
"You can create PIP bundle.\nUpdate: pip bundle has been deprecated, and removed from PIP since version 1.5\nWith PIP 1.5 you should instead create local cache of the packages. \n\ndownload packages: pip install --download <DIR> -r requirements.txt\nuse them: pip install --no-index --find-links=<DIR> -r requiremen... | [
5
] | [] | [] | [
"deployment",
"django",
"python"
] | stackoverflow_0005858567_deployment_django_python.txt |
Q:
what is the get_eval equivalent for selenium webdriver in python
The following works fine in selenium-1:
sel = self.selenium
sel.get_eval("window.$('body form div ul li').html()")
When I try to the same in selenium-2 webdriver in python, I get a error.
wd = webdriver.Firefox()
wd.execute_script("window.$('body ... | what is the get_eval equivalent for selenium webdriver in python | The following works fine in selenium-1:
sel = self.selenium
sel.get_eval("window.$('body form div ul li').html()")
When I try to the same in selenium-2 webdriver in python, I get a error.
wd = webdriver.Firefox()
wd.execute_script("window.$('body form div ul li').html()")
selenium.webdriver.common.exceptions.WebDri... | [
"In selenium1 get_eval() evaluates a script and returns the result.\nWhen you use execute_script() you have to explicitly return the value in which you are interested.\n"
] | [
4
] | [] | [] | [
"python",
"selenium",
"webdriver"
] | stackoverflow_0005251079_python_selenium_webdriver.txt |
Q:
What do python sockets do with EINTR?
So far my networking code works fine, but I'm a bit worried about something I hid under the carpet:
The man pages for accept, close, connect, recv and send mention that errno.EINTR can show up when a system call was interrupted by a signal.
I am quite clueless here.
What does ... | What do python sockets do with EINTR? | So far my networking code works fine, but I'm a bit worried about something I hid under the carpet:
The man pages for accept, close, connect, recv and send mention that errno.EINTR can show up when a system call was interrupted by a signal.
I am quite clueless here.
What does python do with that ? Does it automaticall... | [
"Python simply retries the call and hides the signal from the user (helps with cross-platform consistency where -EINTR doesn't exist). You can safely ignore the EINTR issue but if you'd like to test it anyway, it's easy to do. Just set up a blocking operation that will not return (such as a socket.accept with no in... | [
2
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0005858460_python_sockets.txt |
Q:
Add some model reference to an existing model
I have created a module that serves my own authentication and users system. It's a universal module that I use in different applications. In this module a User model is described, like this:
class User(db.Model):
email = db.EmailProperty()
password = db.StringP... | Add some model reference to an existing model | I have created a module that serves my own authentication and users system. It's a universal module that I use in different applications. In this module a User model is described, like this:
class User(db.Model):
email = db.EmailProperty()
password = db.StringProperty()
role = db.StringProperty(default=role... | [
"If I had a users module that I imported accross several projects I would treat this shared module just as a base to build my apps on.\nSo you might have a baseuser.py module containing:\nclass UserModel(db.Model):\n email = db.EmailProperty()\n password = db.StringProperty()\n role = db.StringProperty(def... | [
2,
1,
0
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0005856681_google_app_engine_python.txt |
Q:
Download multiple dynamic webpages with BeautifulSoup
I'm trying to find a way to download multiple web pages that looks like this:
https://domain.index.aspx?place=&time=123
How can I download each page that ends with a three digit number?
I tried https://domain.index.aspx?place=&time=+[0-9]
and '\d{3} but both do... | Download multiple dynamic webpages with BeautifulSoup | I'm trying to find a way to download multiple web pages that looks like this:
https://domain.index.aspx?place=&time=123
How can I download each page that ends with a three digit number?
I tried https://domain.index.aspx?place=&time=+[0-9]
and '\d{3} but both do not work.
thanks
| [
"You must know the ending numbers of the different pages you want to download and do, for exemple:\nfor numb in ('458', '123', '453'):\n sock = urllib.urlopen('https://domain.index.aspx?place=&time=' + numb)\n\nor if you want to try all the numbers with 3 digits:\nfor numb in xrange(0,1000):\n sock = urllib.ur... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0005858675_python.txt |
Q:
Python smtplib, timeout on starttls
I'm trying to set up some basic email functionality for a small monitoring script I'm running on our office network. Running the script (see below) on my Ubuntu 10.10 server works fine, but when I run it on my Windows desktop machine it times out on send: 'STARTTLS\r\n' with rep... | Python smtplib, timeout on starttls | I'm trying to set up some basic email functionality for a small monitoring script I'm running on our office network. Running the script (see below) on my Ubuntu 10.10 server works fine, but when I run it on my Windows desktop machine it times out on send: 'STARTTLS\r\n' with reply: '451 4.7.0 Timeout waiting for client... | [
"The first thing that comes to mind is that the Windows Firewall is blocking outbound socket connections from the Python.exe executable. Have you tried using Python to establish any other types of connections, such as using urllib2? If so, what are the results?\nAssuming you cannot connect out using Python, then ma... | [
1
] | [] | [] | [
"python",
"smtplib"
] | stackoverflow_0005854749_python_smtplib.txt |
Q:
Confusing Python install in user local (virtualenv, pip, distribute)
I tried to install python below way. But this did not work.
This take "error: bad install directory or PYTHONPATH".
What's the proper way to install pip, virtualenv, and distribute for Python?
Make directory
$ mkdir -p ~/.python
Add .bashrc
#Use... | Confusing Python install in user local (virtualenv, pip, distribute) | I tried to install python below way. But this did not work.
This take "error: bad install directory or PYTHONPATH".
What's the proper way to install pip, virtualenv, and distribute for Python?
Make directory
$ mkdir -p ~/.python
Add .bashrc
#Use local python
export PATH=$HOME/.python/bin:$PATH
export PYTHONPATH=$HOME/... | [
"Usually I installed distributed/easy_install aka setuptools in my global Python installation together with virtualenv. From this point on I can created dedicated virtualalized environments using\nvirtualenv --no-site-packages name-of-environment\n\nReally no idea why to fiddle around with PYTHONPATH here. \nAdding... | [
0,
0
] | [] | [] | [
"distribute",
"installation",
"pip",
"python",
"virtualenv"
] | stackoverflow_0005369546_distribute_installation_pip_python_virtualenv.txt |
Q:
Embed Python in NI CVI(LabWindows)
I need to access LabWindows API and/or functions written in labwindows from Python.
My approach so far
I have been able to do so in Visual studio using SWIG to some extent, but my dll creation fails when i try to generate it in Labwindows using the source file and the SWIG genera... | Embed Python in NI CVI(LabWindows) | I need to access LabWindows API and/or functions written in labwindows from Python.
My approach so far
I have been able to do so in Visual studio using SWIG to some extent, but my dll creation fails when i try to generate it in Labwindows using the source file and the SWIG generated wrapper file.
| [
"These links are essentially pointing to the same answer. Hope it is helpful...\nhttp://decibel.ni.com/content/docs/DOC-1494\nNI CVI with Python\n"
] | [
0
] | [] | [] | [
"labwindows",
"python",
"swig"
] | stackoverflow_0001611050_labwindows_python_swig.txt |
Q:
How to communicate between process in real time?
I have two processes and the data of one process has to be communicated to the other. I wrote a basic queue in order to communicate in real time but it doesn't serve the purpose.
The following is example code:
from multiprocessing import Process , Pipe , Queue
a , ... | How to communicate between process in real time? | I have two processes and the data of one process has to be communicated to the other. I wrote a basic queue in order to communicate in real time but it doesn't serve the purpose.
The following is example code:
from multiprocessing import Process , Pipe , Queue
a , b = Pipe()
q = Queue()
def f(name):
i = 0
while i < 4... | [
"You're only calling get() once. It returns one item at a time.\n(As an aside, your function f is very non-Pythonic, ty:\ndef f(name):\n for i in range(4):\n q.put(i)\n\nYou're also using q as a global...\n",
"try with this version : \ndef t():\n while True:\n try:\n print q.get(tim... | [
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0005859182_python.txt |
Q:
Scripting language choice
I am evaluating options for a scripting language to embed at my company.
We mostly make indie games, and we use managed frameworks (Unity and XNA). This means that we need a solution that works with both Mono and .Net, and we'd rather avoid stuff that is too slow.
The possibilities we are... | Scripting language choice | I am evaluating options for a scripting language to embed at my company.
We mostly make indie games, and we use managed frameworks (Unity and XNA). This means that we need a solution that works with both Mono and .Net, and we'd rather avoid stuff that is too slow.
The possibilities we are considering are the following:... | [
"As you're using .net anyway, any of the .net languages might allow you the easiest implementations. From a learning perspective etc. I'd prefer Lua any time due to it's rather simple basic constructs and syntax rules.\n",
"I have a weird-er suggestion for you. How about using C# or VB.NET?\nYou can dynamically c... | [
2,
1
] | [] | [] | [
"f#",
"lua",
"python",
"scripting",
"xna"
] | stackoverflow_0005859408_f#_lua_python_scripting_xna.txt |
Q:
python mechanize follow_link fails
I'm trying to access search results on the NCBI Images search page (http://www.ncbi.nlm.nih.gov/images) in a script. I want to feed it a search term, report on all of the results, and then move on to the next search term. To do this I need to get to results pages after the firs... | python mechanize follow_link fails | I'm trying to access search results on the NCBI Images search page (http://www.ncbi.nlm.nih.gov/images) in a script. I want to feed it a search term, report on all of the results, and then move on to the next search term. To do this I need to get to results pages after the first page, so I'm trying to use python mech... | [
"Unfortunately that page uses Javascript to POST 2459 bytes of form variables to the server, just to navigate to a subsequent page. Here are a few of the variables (I count 38 vars in total):\nEntrezSystem2.PEntrez.ImagesDb.Images_SearchBar.Term=drug\nEntrezSystem2.PEntrez.ImagesDb.Images_SearchBar.CurrDb=images\n... | [
6
] | [] | [] | [
"hyperlink",
"mechanize",
"python"
] | stackoverflow_0005859434_hyperlink_mechanize_python.txt |
Q:
Python 2.7 & MySQL Ubuntu Installation - ZipImportError
I already have MySQL5 installed on my Ubuntu 10.
I have installed python2.7 with these commands:
$ tar xfz Python-2.7.1.tgz
$ cd Python-2.7.1
$ ./configure && make && sudo make install
$ sudo rm /usr/bin/python
$ sudo ln -s /usr/local/python2.7 /usr/bin/pytho... | Python 2.7 & MySQL Ubuntu Installation - ZipImportError | I already have MySQL5 installed on my Ubuntu 10.
I have installed python2.7 with these commands:
$ tar xfz Python-2.7.1.tgz
$ cd Python-2.7.1
$ ./configure && make && sudo make install
$ sudo rm /usr/bin/python
$ sudo ln -s /usr/local/python2.7 /usr/bin/python
I read that I need mysqldb also. So I tried to install mys... | [
"You forgot to install libz-dev or zlib-dev or whatnot before building Python.\n",
"When you run this command in python folder\n$ ./configure && make && sudo make install\n\nwhat you are actually doing is building the the pythonn from source and then installing. So just basically re-run the process for installing... | [
2,
0,
0
] | [] | [] | [
"installation",
"mysql",
"python",
"python_2.7",
"ubuntu"
] | stackoverflow_0005855906_installation_mysql_python_python_2.7_ubuntu.txt |
Q:
Resolving header dependencies in setup.py
I'm having difficulty installing a Python module on Windows. There are dependencies with the libpcap and winpcap libraries.
When trying to run 'setup.py' I receive fatal errors and the script aborts like the one below
Cannot open include file: 'pcap.h': No such file or ... | Resolving header dependencies in setup.py | I'm having difficulty installing a Python module on Windows. There are dependencies with the libpcap and winpcap libraries.
When trying to run 'setup.py' I receive fatal errors and the script aborts like the one below
Cannot open include file: 'pcap.h': No such file or directory
I downloaded the source files and in... | [
"Have you tried the build instructions?\nwinpcap development is free. http://www.winpcap.org/install/bin/WpdPack_4_0_2.zip\n\n1) Download MinGW32. Install to c:\\wingw32\n2) path=%path%;c:\\wingw32\\bin\n3) Download winpcap development pack from above. Unzip to c:\\WpdPack\n4) From pypcap-1.1 directory. \n > pyth... | [
1
] | [] | [] | [
"packet_construction_set",
"pcap",
"python",
"windows",
"winpcap"
] | stackoverflow_0005852773_packet_construction_set_pcap_python_windows_winpcap.txt |
Q:
Find array item in a string
I know can use string.find() to find a substring in a string.
But what is the easiest way to find out if one of the array items has a substring match in a string without using a loop?
Pseudocode:
string = 'I would like an apple.'
search = ['apple','orange', 'banana']
string.find(search)... | Find array item in a string | I know can use string.find() to find a substring in a string.
But what is the easiest way to find out if one of the array items has a substring match in a string without using a loop?
Pseudocode:
string = 'I would like an apple.'
search = ['apple','orange', 'banana']
string.find(search) # == True
| [
"You could use a generator expression (which somehow is a loop)\nany(x in string for x in search)\n\nThe generator expression is the part inside the parentheses. It creates an iterable that returns the value of x in string for each x in the tuple search. x in string in turn returns whether string contains the subst... | [
23,
3,
1
] | [] | [] | [
"arrays",
"find",
"match",
"python",
"string"
] | stackoverflow_0005858916_arrays_find_match_python_string.txt |
Q:
Is there an advantage to using Bash over Perl or Python?
Hey I've been using Linux for a while and thought it was time to finally dive into shell scripting.
The problem is I've failed to find any significant advantage of using Bash over something like Perl or Python. Are there any performance or power differences ... | Is there an advantage to using Bash over Perl or Python? | Hey I've been using Linux for a while and thought it was time to finally dive into shell scripting.
The problem is I've failed to find any significant advantage of using Bash over something like Perl or Python. Are there any performance or power differences between the two? I'd figure Python/Perl would be more well sui... | [
"Two advantages come to mind:\n\nSimplicity: direct access to all wonderful linux tools wc, ls, cat, grep, sed... etc.\nWhy constantly use python's subprocess module?\n\nI'm increasingly fond of using gnu parallel, with which you can execute your bash scripts in parallel. E.g. from the man page, batch create thumbs... | [
28,
12,
12,
6,
4,
4,
3,
2
] | [] | [] | [
"bash",
"linux",
"perl",
"python",
"scripting"
] | stackoverflow_0005858877_bash_linux_perl_python_scripting.txt |
Q:
Gql Query on ReferenceProperty()
Short version of my question: What is the Gql syntax for a query filtering based on a reference property?
Long version of my question:
Assume the following model:
Class User(db.Model):
username = db.StringProperty()
password = db.StringProperty()
Class Portfolios(db.Model)... | Gql Query on ReferenceProperty() | Short version of my question: What is the Gql syntax for a query filtering based on a reference property?
Long version of my question:
Assume the following model:
Class User(db.Model):
username = db.StringProperty()
password = db.StringProperty()
Class Portfolios(db.Model):
portname = db.StringProperty()
... | [
"So aglwb3J0Zm9saW9yCwsSBFVzZXIY6gEM is your user key, right? Let's start with this:\nuser = db.Key('aglwb3J0Zm9saW9yCwsSBFVzZXIY6gEM')\nque = db.GqlQuery(\"SELECT * FROM Portfolio_Owners WHERE user_id = :1\", user)\n\nThis should give you any Portfolio_Owners entities that refer to this user.\nYou can shorten that... | [
1
] | [] | [] | [
"google_app_engine",
"gql",
"python"
] | stackoverflow_0005860396_google_app_engine_gql_python.txt |
Q:
Building a background image from smaller images in PyGame
I have a selection of images that I will build a backdrop to a game from (it's a TD game but each level will be built from walls, walkways etc). I'm trying to work out how to dynamically build a single image to use as a background rather than having 100+ sp... | Building a background image from smaller images in PyGame | I have a selection of images that I will build a backdrop to a game from (it's a TD game but each level will be built from walls, walkways etc). I'm trying to work out how to dynamically build a single image to use as a background rather than having 100+ sprites for a background.
| [
"you will have to make pygame.surface with your images.\nimages = []\nfor image_name in image_names:\n images.append(pygame.image.load(image_name))\n\nbackground = pygame.display.get_surface()\nfor image in images:\n back.blit(image, image_position) # how you compute the image position is your stuff ;)\n\npyg... | [
3,
1
] | [] | [] | [
"pygame",
"python"
] | stackoverflow_0005859630_pygame_python.txt |
Q:
Django QuerySet order_by string evaluation
I'm trying to sort my QuerySet based on how the objects in the QuerySet are evaluated as Strings.
So my model looks something like this:
class System(models.Model):
operating_system = models.CharField(...)
language = models.CharField(...)
locale = models.CharField(.... | Django QuerySet order_by string evaluation | I'm trying to sort my QuerySet based on how the objects in the QuerySet are evaluated as Strings.
So my model looks something like this:
class System(models.Model):
operating_system = models.CharField(...)
language = models.CharField(...)
locale = models.CharField(...)
def __unicode__(self):
def __clean(or... | [
"In __unicode__ you eventually end up with a single string that represents a System object. Instead of calculating it every time you need it, calculate it once and save it onto the model.\nclass System(models.Model):\n operating_system = models.CharField(...)\n language = models.CharField(...)\n locale= mo... | [
1
] | [] | [] | [
"django",
"django_models",
"django_queryset",
"python"
] | stackoverflow_0005839372_django_django_models_django_queryset_python.txt |
Q:
Python 3.2 crashing when I try to save file
Running Mac OSX 10.6.6.
I installed python 3.2 last night on my computer. I played with some code in IDLE, but never ended up saving any of my work.
This morning, I tried to set up my Interactive Start Up File, as recommended here, but when I save the file as startup.py... | Python 3.2 crashing when I try to save file | Running Mac OSX 10.6.6.
I installed python 3.2 last night on my computer. I played with some code in IDLE, but never ended up saving any of my work.
This morning, I tried to set up my Interactive Start Up File, as recommended here, but when I save the file as startup.py (or anything really) the entire application cras... | [
"You likely need to install ActiveState Tcl/Tk 8.5 as explained in detail here. As described, there are serious known problems with the Apple-supplied Tcl/Tk 8.5 in Mac OS 10.6. In fact, you should have seen a warning in the IDLE shell about not using the Apple-supplied Tcl/Tk and you should have seen a warning w... | [
2
] | [] | [] | [
"activetcl",
"macos",
"python",
"python_idle"
] | stackoverflow_0005858772_activetcl_macos_python_python_idle.txt |
Q:
Data transformation in numpy
Input data are lists of 1-D numpy arrays e.g. x[0] = [ array([1.0,1.0,1.0]), array([2.0,2.0,2.0]), ...]
len(x) is on the order of a few thousand (rows) while len(x[n]) is a fixed number (columns), but may change from run to run (so I don't want to hard-code a number of columns).
Functi... | Data transformation in numpy |
Input data are lists of 1-D numpy arrays e.g. x[0] = [ array([1.0,1.0,1.0]), array([2.0,2.0,2.0]), ...]
len(x) is on the order of a few thousand (rows) while len(x[n]) is a fixed number (columns), but may change from run to run (so I don't want to hard-code a number of columns).
Function f(x[n][col]) transforms each a... | [
"How about:\nnumpy.tile(numpy.arange(1,12).reshape(11,1),20)\n\n"
] | [
1
] | [] | [] | [
"data_structures",
"numpy",
"python"
] | stackoverflow_0005860703_data_structures_numpy_python.txt |
Q:
Two one-to-many relations with three tables
import sqlite3
# get connection and cursor objects
conn = sqlite3.connect('iodatabase.sdb')
c = conn.cursor()
# create tables
c.execute('''create table grand_parent (
id integer primary key autoincrement,
name text
)''')
c.execute('''create table parent (
... | Two one-to-many relations with three tables | import sqlite3
# get connection and cursor objects
conn = sqlite3.connect('iodatabase.sdb')
c = conn.cursor()
# create tables
c.execute('''create table grand_parent (
id integer primary key autoincrement,
name text
)''')
c.execute('''create table parent (
id integer primary key autoincrement,
name t... | [
"If I understanded:\nthe problem is here: FOREIGN KEY(parent_id) REFERENCES parent(name) and would be FOREIGN KEY(parent_id) REFERENCES parent(id). Reference ID instead NAME.\nReferencing the parent table, through a query you is able to return the grandparent record from the child table.\nPlease comment if it is no... | [
2
] | [] | [] | [
"database_design",
"python",
"sqlite"
] | stackoverflow_0005752884_database_design_python_sqlite.txt |
Q:
Django forms error 'got multiple values for keyword argument 'choices''
Getting a strange error when defining my django forms. I get the error:
__init__() got multiple values for keyword argument 'choices'
This happens with both TestForm and SpeciesForm (quoted below); basically both forms with the 'choices' keyw... | Django forms error 'got multiple values for keyword argument 'choices'' | Getting a strange error when defining my django forms. I get the error:
__init__() got multiple values for keyword argument 'choices'
This happens with both TestForm and SpeciesForm (quoted below); basically both forms with the 'choices' keyword argument. init() is never explicitly called, and the forms aren't even in... | [
"http://code.djangoproject.com/browser/django/trunk/django/forms/fields.py#L647\n647 def __init__(self, choices=(), required=True, widget=None, label=None,\n648 initial=None, help_text=None, *args, **kwargs):\n649 super(ChoiceField, self).__init__(required=required, widget=widget, label... | [
7
] | [] | [] | [
"django",
"forms",
"python"
] | stackoverflow_0005861053_django_forms_python.txt |
Q:
Passing keyword arguments to a function when local variable names are same as function parameter names
Is there a more succint way to write this?
f(a=a, b=b, c=c, d=d, e=e)
Background: I have a function with too many arguments
f(a, b, c, d, e):
pass
I my program I have local variables that are named exactly ... | Passing keyword arguments to a function when local variable names are same as function parameter names | Is there a more succint way to write this?
f(a=a, b=b, c=c, d=d, e=e)
Background: I have a function with too many arguments
f(a, b, c, d, e):
pass
I my program I have local variables that are named exactly same as the function parameters.
a, b, c, d, e = range(5)
I would like to call the function with keyword a... | [
"You could do something like the following:\na, b, c, d, e = range(5)\narg_dict = lambda l: dict((k, globals()[k]) for k in l.split(', '))\n\narg_dict('a, b, c, d, e') => {'a': 0, 'c': 2, 'b': 1, 'e': 4, 'd': 3}, so you can call your function like this:\nf(**arg_dict('a, b, c, d, e'))\n\nThis gives you the ability ... | [
7,
4,
1
] | [] | [] | [
"function_calls",
"keyword_argument",
"python"
] | stackoverflow_0005860974_function_calls_keyword_argument_python.txt |
Q:
Python - Read a complicated file into dictionary
My input file is:
-150 150 -90 130 1
-150 150 -150 170 1
-150 150 -110 140 1
-150 160 -80 -20 1
-150 170 -140 160 1
-150 170 -70 -40 1
-140 -170 -110 150 1
-140 1... | Python - Read a complicated file into dictionary | My input file is:
-150 150 -90 130 1
-150 150 -150 170 1
-150 150 -110 140 1
-150 160 -80 -20 1
-150 170 -140 160 1
-150 170 -70 -40 1
-140 -170 -110 150 1
-140 130 -120 110 1
-140 140 160 -150 ... | [
"from collections import defaultdict\n\nbigdict = defaultdict(dict)\nfor ln in file:\n a,b,c,d,e = ln.split()\n bigdict[(a,b)][(c,d)] = e\n\nIf you want string keys, replace (a,b) with '%s %s' % (a, b) and similarly for (c,d).\n",
"This should work:\nf = open('file')\ndictionary = {}\nfor line in f:\n a,... | [
7,
1
] | [] | [] | [
"dictionary",
"file_io",
"python"
] | stackoverflow_0005861303_dictionary_file_io_python.txt |
Q:
Cad plotters and Python
I'm wandering what the best way is to send a fully scaled (1:1) dxf drawing to a cad plotter using python. Has anyone here ever done this?
For those who want to know why:
I've written a program for my employer that automates the drawing of detailed
schematics, apparently so our engineerin... | Cad plotters and Python | I'm wandering what the best way is to send a fully scaled (1:1) dxf drawing to a cad plotter using python. Has anyone here ever done this?
For those who want to know why:
I've written a program for my employer that automates the drawing of detailed
schematics, apparently so our engineering dept can spend more time do... | [
"In case anyone else runs into this problem (pretty unlikely) I though I'd post briefly what I did in the end:\n1.) Wrote a short script to capture the dxf as a BMP (basicaly just a screen grab that appends the scale to the drawing) \n2.) Wrote a print dialog with PyQt4 that's a clone of Autocads plot window excep... | [
0
] | [] | [] | [
"cad",
"printing",
"python"
] | stackoverflow_0005808236_cad_printing_python.txt |
Q:
Histogram Equalization of matplotlib color tables
I'm new to python and matplotlib and I was wondering whether anyone knew if there were any utilities available to do the equavalent of histogram equalization but to a matplotlib color table? There is a function called matplotlib.colors.Normalize which, if given a i... | Histogram Equalization of matplotlib color tables | I'm new to python and matplotlib and I was wondering whether anyone knew if there were any utilities available to do the equavalent of histogram equalization but to a matplotlib color table? There is a function called matplotlib.colors.Normalize which, if given a image array, will automatically set the bottom and top l... | [
"You have to create your own image-specific colormap, but it's not too tricky:\nimport pylab\nimport matplotlib.colors\nimport numpy\n\nim = pylab.imread('lena.png').sum(axis=2) # make grayscale\npylab.imshow(im, cmap=pylab.cm.gray)\npylab.title('orig')\nimvals = numpy.sort(im.flatten())\nlo = imvals[0]\nhi = imval... | [
3,
0
] | [] | [] | [
"matplotlib",
"python"
] | stackoverflow_0005858902_matplotlib_python.txt |
Q:
MySQL connection error with Django
I get the following error when I run the Django command "python manage.py syncdb"
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
I have installed python, django and py26-mysql using macpo... | MySQL connection error with Django | I get the following error when I run the Django command "python manage.py syncdb"
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)
I have installed python, django and py26-mysql using macports. I ran in to issues installing mysql... | [
"Use the HOST setting in your settings file:\n\"HOST\": '/path/to/your/socket.sock'\n\n"
] | [
5
] | [] | [] | [
"django",
"mysql",
"python"
] | stackoverflow_0005860464_django_mysql_python.txt |
Q:
Twisted logging
I have 3 processes running under my twisted reactor: Orbited, WSGI (running django), and Twisted itself.
I am currently using
log.startLogging(sys.stdout)
When all the log are directed to the same place, there is too much flooding.
One line of my log from WSGI is like this:
2010-08-16 02:21:12-05... | Twisted logging | I have 3 processes running under my twisted reactor: Orbited, WSGI (running django), and Twisted itself.
I am currently using
log.startLogging(sys.stdout)
When all the log are directed to the same place, there is too much flooding.
One line of my log from WSGI is like this:
2010-08-16 02:21:12-0500 [-] 127.0.0.1 - - ... | [
"You can use the system keyword argument to twisted.python.log.msg to customize the message. \nAssuming you've got:\nlog.msg(\"Service ready for eBusiness!\", system=\"enterprise\")\n\nYou'll get logging output like this:\n2010-08-16 02:21:12-0500 [enterprise] Service ready for eBusiness!\n\nYou could then have ea... | [
11,
1
] | [] | [] | [
"python",
"twisted"
] | stackoverflow_0003491294_python_twisted.txt |
Q:
python string formatting: way to not use two lists?
With the following code:
a = ['foo', 'bar', 'doh', 'rae']
I'd like the string SUM(foo) AS foo, SUM(bar) AS bar, SUM(doh) AS doh, SUM(rae) AS rae. This works:
Tried something clever like 'SUM(%s) AS %s' % ([x for x in a], [x for x in a]) but obviously it didn't w... | python string formatting: way to not use two lists? | With the following code:
a = ['foo', 'bar', 'doh', 'rae']
I'd like the string SUM(foo) AS foo, SUM(bar) AS bar, SUM(doh) AS doh, SUM(rae) AS rae. This works:
Tried something clever like 'SUM(%s) AS %s' % ([x for x in a], [x for x in a]) but obviously it didn't work, and using two list comprehensions felt woefully inef... | [
"Why not use the str.format method?\n\", \".join(['SUM({n}) AS {n}'.format(n=x) for x in a])\n# Returns SUM(foo) AS foo, SUM(bar) AS bar, SUM(doh) AS doh, SUM(rae) AS rae\n\nIf a is a large list, you may want to use a generator instead, in order to avoid creating the whole list in memory first, as GWW points out.\n... | [
4,
0
] | [] | [] | [
"python"
] | stackoverflow_0005861907_python.txt |
Q:
Pylons on OS X: proper launchd plist to start and keep alive pylons server?
Update: It was simply an import error in the Pylons app (because $PYTHONPATH is different when running a launchd job) that was causing a fail-respawn cycle. Many thanks for those who told me to look at my logs.
Hi all,
I'm on OS X, trying ... | Pylons on OS X: proper launchd plist to start and keep alive pylons server? | Update: It was simply an import error in the Pylons app (because $PYTHONPATH is different when running a launchd job) that was causing a fail-respawn cycle. Many thanks for those who told me to look at my logs.
Hi all,
I'm on OS X, trying to set up a launchd job to start and keep alive my pylons application.
I load the... | [
"When I've seen \"respawning too fast\" on SysV init systems (/etc/inittab entries) it's been because the program in question was using the traditional \"double fork, then exec\" strategy to become a daemon. Many such programs (such as sshd and sylogd) support command line switches (-D for sshd, for example) which... | [
2,
1
] | [] | [] | [
"launchd",
"macos",
"plist",
"pylons",
"python"
] | stackoverflow_0005645394_launchd_macos_plist_pylons_python.txt |
Q:
Why is this python code taking so long?
Alright, I have this python code that compares merge sort and selection sort, but it is taking forever. When done from n = 0 to 90,000 (the size of the list), it only takes about 3 seconds to sort the list. By this logic, it would take about 10 * 3 * 9 seconds (number of r... | Why is this python code taking so long? | Alright, I have this python code that compares merge sort and selection sort, but it is taking forever. When done from n = 0 to 90,000 (the size of the list), it only takes about 3 seconds to sort the list. By this logic, it would take about 10 * 3 * 9 seconds (number of run throughs * duration * incremented run thro... | [
"Because you are using O(n^2) sorting algorithms. This means that if you double n, the algorithm takes 4 times longer to run. Note that you are starting at 100,000 not 10,000\n"
] | [
4
] | [] | [] | [
"python",
"sorting"
] | stackoverflow_0005861997_python_sorting.txt |
Q:
Python: Efficient Way to Substitute an Item of a List into a String
I'm creating a wrapper for a Minecraft Server that is supposed to take new commands from a directory called commands, which contains files named after the command, all containing the server commands used to make up that command. For example, the f... | Python: Efficient Way to Substitute an Item of a List into a String | I'm creating a wrapper for a Minecraft Server that is supposed to take new commands from a directory called commands, which contains files named after the command, all containing the server commands used to make up that command. For example, the following snippet is from the file that defines the "tell" command:
tell <... | [
"Here is a solution that doesn't require you to change your format (it is all done programatically).\nsender = 's0lder'\nargs = ['jim', 'hello']\n\nformat = \"tell <1> <sender> says: <2>\".replace(\"<\", \"%(<\").replace(\">\", \">)s\")\n# format == 'tell %(<1>)s %(<sender>)s says: %(<2>)s'\nsubs = {\"<sender>\": s... | [
1,
0
] | [] | [] | [
"list",
"python",
"substitution"
] | stackoverflow_0005862109_list_python_substitution.txt |
Q:
Tkinter: Determine Widget Position relative to Root Window
The tkinter MouseWheel event can only be bound to the root window. Thus the event position is also relative to the root position.
For a canvas zooming operation, I would like to get the MouseWheel-event with information about the cursor-position within th... | Tkinter: Determine Widget Position relative to Root Window | The tkinter MouseWheel event can only be bound to the root window. Thus the event position is also relative to the root position.
For a canvas zooming operation, I would like to get the MouseWheel-event with information about the cursor-position within the canvas. To calculate this I thought I would simply subtract th... | [
"You want to use the winfo_x and winfo_y methods to get the x/y position relative to the parent.\n"
] | [
3
] | [] | [] | [
"python",
"tkinter"
] | stackoverflow_0005860491_python_tkinter.txt |
Q:
Scopes in a class in Python
Please have a look at this:
class Car:
def __init__(self, bid_code):
self.__bid = bid_code
def doit(self, cry):
self.bid_it = cry
def show_bid(self):
print self.__bid
def show_it(self):
print self.bid_it
a = Car("ok")
a.show_bid()
a.do... | Scopes in a class in Python | Please have a look at this:
class Car:
def __init__(self, bid_code):
self.__bid = bid_code
def doit(self, cry):
self.bid_it = cry
def show_bid(self):
print self.__bid
def show_it(self):
print self.bid_it
a = Car("ok")
a.show_bid()
a.doit("good")
a.show_it()
What is t... | [
"By using self, you've bound it to the instance. It's now an instance variable. Instance variables are local to their instances. If the variable were unbound (no self prefix), it'd have function scope and go out of scope once the method call is over, but you've bound it to something else (the instance).\n",
"def ... | [
5,
0
] | [] | [] | [
"function",
"python",
"scope"
] | stackoverflow_0005861875_function_python_scope.txt |
Q:
Can set any property of Python object
For example, this code is Python:
a = object()
a.b = 3
throws AttributeError: 'object' object has no attribute 'b'
But, this piece of code:
class c(object): pass
a = c()
a.b = 3
is just fine. Why can I assign property b, when class x does not have that property? How can I ma... | Can set any property of Python object | For example, this code is Python:
a = object()
a.b = 3
throws AttributeError: 'object' object has no attribute 'b'
But, this piece of code:
class c(object): pass
a = c()
a.b = 3
is just fine. Why can I assign property b, when class x does not have that property? How can I make my classes have only properties defined?... | [
"The object type is a built-in class written in C and doesn't let you add attributes to it. It has been expressly coded to prevent it.\nThe easiest way to get the same behavior in your own classes is to use the __slots__ attribute to define a list of the exact attributes you want to support. Python will reserve sp... | [
12,
3,
2,
1
] | [
"This happens because when you say a.b = 3, it creates a variable in a that represents b. For example,\nclass a: pass\nprint a.b\n\nreturns AttributeError: class a has no attribute b\nHowever this code,\nclass a: pass\na.b = 3\nprint a.b\n\nreturns 3 as it sets the value of b in a, to 3.\n"
] | [
-1
] | [
"class",
"object",
"properties",
"python"
] | stackoverflow_0005862159_class_object_properties_python.txt |
Q:
Variable size list of Checkboxes in Tkinter?
I'm working on a programming task. I'm working in Python, and using Tkinter for our GUI. I cannot change language or GUI tool, nor can I use any additional packages (for example Tix).
I need to make a list of items to pull. The first thing I thought of was a check box.... | Variable size list of Checkboxes in Tkinter? | I'm working on a programming task. I'm working in Python, and using Tkinter for our GUI. I cannot change language or GUI tool, nor can I use any additional packages (for example Tix).
I need to make a list of items to pull. The first thing I thought of was a check box. However, so far as I know, Tkinter does not have ... | [
"Tkinter supports a relatively unlimited number of checkboxes, limited mostly by practical matters such as system memory and usability constraints.\nThere are at least three techniques for making a scrollable container for widgets. Both canvases and text widgets support scrolling, so the generally accepted practice... | [
19
] | [] | [] | [
"checkbox",
"python",
"tkinter"
] | stackoverflow_0005860675_checkbox_python_tkinter.txt |
Q:
What's the best practice for incorporating third-party libraries in a python program?
Good afternoon.
I am writing a small to medium-sized python program for my job. The task requires me to use the Excel libraries xlwt and xlrd, as well as a library for querying Oracle databases, called cx_Oracle. I am developing ... | What's the best practice for incorporating third-party libraries in a python program? | Good afternoon.
I am writing a small to medium-sized python program for my job. The task requires me to use the Excel libraries xlwt and xlrd, as well as a library for querying Oracle databases, called cx_Oracle. I am developing the project through a version control system, namely CVS.
I was wondering what is the stand... | [
"You basically have two options (just like you might recognize from Java).\nOne is to packaged the external dependencies in your app, meaning you copy all the dependencies into your apps directory structure. This is usually not recommended unless you must be able to ship a single installation or binary. In this cas... | [
6
] | [] | [] | [
"python",
"python_module"
] | stackoverflow_0005862566_python_python_module.txt |
Q:
Get text from popup window
I'm trying to read the text from a popup window.
The title is always the same. I've managed to identify the hwnd and get the title with the code below, but I can't figure out how to read the contents.
import time
import win32gui, win32con
windows = []
def _MyCallback( hwnd, extra )... | Get text from popup window | I'm trying to read the text from a popup window.
The title is always the same. I've managed to identify the hwnd and get the title with the code below, but I can't figure out how to read the contents.
import time
import win32gui, win32con
windows = []
def _MyCallback( hwnd, extra ):
extra.append(hwnd)
win32gui... | [
"You will only be able to read this text programmatically if it is contained in a windowed control. You can easily check this with Spy++. Many GUI frameworks don't use windowed controls for their child controls, or only use windowed controls for some children.\nIf it is a windowed control then you can identify it... | [
5,
4
] | [] | [] | [
"python",
"win32gui",
"winapi"
] | stackoverflow_0005862454_python_win32gui_winapi.txt |
Q:
Django filter sub-class models
I have (essentially) the following models:
class foo(models.model):
name = models.CharField(max_length=255)
size = models.PositiveIntegerField()
class bar(foo):
colour = models.CharField(max_length=25)
class baz(foo):
material = models.CharField(max_length=25)
What... | Django filter sub-class models | I have (essentially) the following models:
class foo(models.model):
name = models.CharField(max_length=255)
size = models.PositiveIntegerField()
class bar(foo):
colour = models.CharField(max_length=25)
class baz(foo):
material = models.CharField(max_length=25)
What I want to do is filter these models... | [
"(Update: This Answer on a previously asked question is better than what I've written below.)\nThis article explains why this is inefficient in Django -- basically, because it would require expensive joins across the tables for all the subclasses. (I've written an ORM that does polymorphism like that, and the queri... | [
2
] | [] | [] | [
"django",
"filter",
"parameters",
"python",
"url"
] | stackoverflow_0005861861_django_filter_parameters_python_url.txt |
Q:
Using Django template functions in App Engine scripts
I want to use Django's slugify template function in my GAE script. When I use it in a HTML template, it works fine. But when trying the following import:
from django.template.defaultfilters import slugify
got this error:
File "/home/karlis/bin/google_appengine... | Using Django template functions in App Engine scripts | I want to use Django's slugify template function in my GAE script. When I use it in a HTML template, it works fine. But when trying the following import:
from django.template.defaultfilters import slugify
got this error:
File "/home/karlis/bin/google_appengine/lib/django_0_96/django/conf/__init__.py", line 53, in _imp... | [
"This might work (without actually creating a settings module):\nimport os\nos.environ['DJANGO_SETTINGS_MODULE'] = 'settings'\n\nfrom django.template.defaultfilters import slugify\n\n"
] | [
1
] | [] | [] | [
"django",
"django_templates",
"google_app_engine",
"python"
] | stackoverflow_0005862791_django_django_templates_google_app_engine_python.txt |
Q:
Compiled python script returns WindowsError: [Error 3] after using py2exe
So I have been writing this game for a while now and finally have it finished. However due to the fact that the game is meant for a class and I used libraries that my teacher isn't going to bother installing I need to make a single executabl... | Compiled python script returns WindowsError: [Error 3] after using py2exe | So I have been writing this game for a while now and finally have it finished. However due to the fact that the game is meant for a class and I used libraries that my teacher isn't going to bother installing I need to make a single executable that will run independent of python and the games dependencies. I ran py2exe ... | [
"I think I ran into a similar problem a couple years ago, and I solved it by getting rid of zip files in the distribution.\nWith py2exe options, try setting zipfile=None or maybe turn off compression and turn off bundling.\nNote that creating a Windows exe that will run on all Windows OS's is a pain. I got good fe... | [
0
] | [] | [] | [
"py2exe",
"pygame",
"python"
] | stackoverflow_0005824859_py2exe_pygame_python.txt |
Q:
LLVM, Parrot, JVM, PyPy + python
What is the problem in developing some languages, for example python for some optimized techniques with some of LLVM / Parrot.
PyPy, LLVM, Parrot are the main technologies for common platform development.
I see this like:
PyPy - framework to build VM with build in optimized VM f... | LLVM, Parrot, JVM, PyPy + python | What is the problem in developing some languages, for example python for some optimized techniques with some of LLVM / Parrot.
PyPy, LLVM, Parrot are the main technologies for common platform development.
I see this like:
PyPy - framework to build VM with build in optimized VM for python
So it quite general solutio... | [
"That not stuff anybody can possible answer in a stackoverflow questions but i give it a minmal shot.\nFirst what problems do the 3 projects solve?\n\npypy allows you to implement an interpreter in a high level language and you get a generated jit for free. The good thing about this is that you don't have a depende... | [
25,
11,
7
] | [] | [] | [
"jvm",
"llvm",
"parrot",
"pypy",
"python"
] | stackoverflow_0005328295_jvm_llvm_parrot_pypy_python.txt |
Q:
Adding in hidden input types changes my css
My code looks like this:
<form name="deleteUser" action="/groupmanager" method="post"><div id="x"> {% csrf_token %}
<input type="hidden" name="username" value = "{{name}}"></input>
<input type="hidden" name="groupName" value = "{{group}}"></input>
<input type="submit" ... | Adding in hidden input types changes my css | My code looks like this:
<form name="deleteUser" action="/groupmanager" method="post"><div id="x"> {% csrf_token %}
<input type="hidden" name="username" value = "{{name}}"></input>
<input type="hidden" name="groupName" value = "{{group}}"></input>
<input type="submit" name="xButton" id="xButton" value="x"></div></for... | [
"I beleave the change is in IE only ? Try adding position:relative; float:left to the css of hidden inputs.\n"
] | [
1
] | [] | [] | [
"html",
"python"
] | stackoverflow_0005862965_html_python.txt |
Q:
Newbie python - replace in an array
In a file, I have the following lines
NetConn_msa[0].time=0.0
NetConn_msa[1].time=0.0 etc for 60 elements.
I need to write a script to change the time from 0.0 to 0.5.
I started with st.replace("delay=0.0","delay=0.05") and then tried to find the string to replace
sub=re.com... | Newbie python - replace in an array | In a file, I have the following lines
NetConn_msa[0].time=0.0
NetConn_msa[1].time=0.0 etc for 60 elements.
I need to write a script to change the time from 0.0 to 0.5.
I started with st.replace("delay=0.0","delay=0.05") and then tried to find the string to replace
sub=re.compile("\[\d+\]\.\w+=[0]\.[0]")
result=sub.... | [
"Why not do this the really easy way: manually edit the file so that the offending 60 lines are replaced by:\nfor x in range(60):\n NetConn_msa[x].time = 0.5\n\n",
"Script:\nimport re\n\nx = \"\"\"NetConn_msa[0].time=0.0\nNetConn_msa[59].time=0.0\nNetConn_msa[0].time=9.9\nNetConn_msa[60].time=0.0\nNetConn_msa[... | [
2,
1,
0,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0005862310_python_regex.txt |
Q:
How much does importing entire modules such as wxpython effect the size of the application when built using py2app?
Does using, for example, import TextCrtl from wx make the application smaller when built as a stand alone app?
A:
Whether you import a module, or import something from a module, the entire module i... | How much does importing entire modules such as wxpython effect the size of the application when built using py2app? | Does using, for example, import TextCrtl from wx make the application smaller when built as a stand alone app?
| [
"Whether you import a module, or import something from a module, the entire module is always executed. The only difference is what is added to the namespace.\nHere's a nice SO answer on this subject: Does \"from-import\" exec the whole module?\nSo the answer is no, the entire module will always be included.\n"
] | [
2
] | [] | [] | [
"py2app",
"python",
"wxpython"
] | stackoverflow_0005863144_py2app_python_wxpython.txt |
Q:
Python string assignment issue!
So I'm fairly new to Python but I have absolutely no idea why this strong oldUser is changing to current user after I make the parse call. Any help would be greatly appreciated.
while a < 20:
f = urllib.urlopen("SITE")
a = a+1
for i, line in enumerate(f):
if i ... | Python string assignment issue! | So I'm fairly new to Python but I have absolutely no idea why this strong oldUser is changing to current user after I make the parse call. Any help would be greatly appreciated.
while a < 20:
f = urllib.urlopen("SITE")
a = a+1
for i, line in enumerate(f):
if i == 187:
print line
... | [
"Don’t compare strings with is. That checks if they’re the same object, not two copies of the same string. See:\n>>> string = raw_input()\nhello\n>>> string is 'hello'\nFalse\n>>> string == 'hello'\nTrue\n\nAlso, the definition of myparser would be useful.\n",
"I'm not quite sure what your code is doing, but I su... | [
5,
1
] | [] | [] | [
"parsing",
"python",
"string",
"variable_assignment"
] | stackoverflow_0005863276_parsing_python_string_variable_assignment.txt |
Q:
Trigger event on app engine
I'm looking for a way to trigger an event on app engine when a User is created. I have something like
def create_user(data):
user = new User(data)
user.put()
trigger('user_created', user)
return user
This way, external modules may be able to modify the entity when a new... | Trigger event on app engine | I'm looking for a way to trigger an event on app engine when a User is created. I have something like
def create_user(data):
user = new User(data)
user.put()
trigger('user_created', user)
return user
This way, external modules may be able to modify the entity when a new user is created. I imagine I cou... | [
"Generally this is something you would handle with the task queue. When you create a new user, fire off a batch of tasks to do whatever follow-up work is appropriate. You can define the list of tasks elsewhere, and override the put() method of your User model to enqueue them.\nThis is kind of a hook enforced within... | [
1
] | [] | [] | [
"events",
"google_app_engine",
"python"
] | stackoverflow_0005863170_events_google_app_engine_python.txt |
Q:
storing MIME type with blobstore
How can I also store the MIME type of incoming blobs to the blobstore? I now neither get the name nor the MIME type stored which using the handler blobstore_handlers.BlobstoreUploadHandler it can. Here's my code that doesn't use blobstore_handlers.BlobstoreUploadHandler:
def cr... | storing MIME type with blobstore | How can I also store the MIME type of incoming blobs to the blobstore? I now neither get the name nor the MIME type stored which using the handler blobstore_handlers.BlobstoreUploadHandler it can. Here's my code that doesn't use blobstore_handlers.BlobstoreUploadHandler:
def create_image(number, self, file, ad):
... | [
"Both name and mime type can be passed as arguments to create:\ndef create(mime_type='application/octet-stream',\n _blobinfo_uploaded_filename=None):\n \"\"\"Create a writable blobstore file.\n\n Args:\n mime_type: Resulting blob content MIME type as string.\n _blobinfo_uploaded_filename: Resultin... | [
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0005863305_google_app_engine_python.txt |
Q:
python: how to get the class of a calling method through inspection?
For my exception class I'd like to find out whether the function which instantiated the exception object is a method and if so, show the class name.
So in the init method of my exception class I get the name of the calling function:
frame, module... | python: how to get the class of a calling method through inspection? | For my exception class I'd like to find out whether the function which instantiated the exception object is a method and if so, show the class name.
So in the init method of my exception class I get the name of the calling function:
frame, module, line, function, context, index = inspect.stack()[1]
But is there any wa... | [
"Assuming the frame is for an instance method:\nself_argument = frame.f_code.co_varnames[0] # This *should* be 'self'.\ninstance = frame.f_locals[self_argument]\nclass_name = instance.__class__.__name__\n\n"
] | [
2
] | [] | [] | [
"python"
] | stackoverflow_0005863512_python.txt |
Q:
python index error: 2 lists that are inside a list
def main():
L=[]
list1=[5,1,3]
list2=[4,6,2]
L.append(list1)
L.append(list2)
f(L)
def f(L):
for i in range(6)
print L[i]
IndexError: list index out of range
A:
You're just appending the lists onto L so you get something lik... | python index error: 2 lists that are inside a list | def main():
L=[]
list1=[5,1,3]
list2=[4,6,2]
L.append(list1)
L.append(list2)
f(L)
def f(L):
for i in range(6)
print L[i]
IndexError: list index out of range
| [
"You're just appending the lists onto L so you get something like [[5, 1, 3], [4, 6, 2]]. You need to use extend like so:\nL.extend(list1)\nL.extend(list2)\nprint L # [5, 1, 3, 4, 6, 2]\n\n",
"Appending two items to an empty list makes a 2-element list. Perhaps you wanted L.extend() instead?\n"
] | [
5,
2
] | [] | [] | [
"list",
"python"
] | stackoverflow_0005863629_list_python.txt |
Q:
python tcp/ip socket datastream gets interupted
I use a tcp/ip to rs232 converter from expert EX-9132 where i connect to a datalogger to receive data, after sending a request (chr27 via tcp) for requesting data, the transmission is interupted before receiving all the available data. I like to finish the transmissi... | python tcp/ip socket datastream gets interupted | I use a tcp/ip to rs232 converter from expert EX-9132 where i connect to a datalogger to receive data, after sending a request (chr27 via tcp) for requesting data, the transmission is interupted before receiving all the available data. I like to finish the transmission after all data has been received. The below code i... | [
"Your code only calls recv(200) once. The way recv() works is it will return at least 1 byte and at most 200 (in this case) bytes. It will block if there is no data available. It will return an empty string when the server closes the connection.\nWithout knowing the full protocol, I can only guess, but you at le... | [
3
] | [] | [] | [
"python",
"sockets"
] | stackoverflow_0005862724_python_sockets.txt |
Q:
avoiding code duplication in Python code
Consider the following Python snippet:
af=open("a",'r')
bf=open("b", 'w')
for i, line in enumerate(af):
if i < K:
bf.write(line)
Now, suppose I want to handle the case where K is None,
so the writing continues to the end of the file.
I'm currently doing
if K... | avoiding code duplication in Python code | Consider the following Python snippet:
af=open("a",'r')
bf=open("b", 'w')
for i, line in enumerate(af):
if i < K:
bf.write(line)
Now, suppose I want to handle the case where K is None,
so the writing continues to the end of the file.
I'm currently doing
if K is None:
for i, line in enumerate(af):
... | [
"for i, line in enumerate(af): \n if K is None or i < K:\n bf.write(line)\n else:\n break\n\n",
"itertools.takewhile will apply your condition, and then break out of the loop the first time the condition fails.\nfrom itertools import takewhile\n\nif K is None:\n condition = lambda x: True\... | [
5,
2,
1,
1,
0
] | [] | [] | [
"code_duplication",
"control_flow",
"python"
] | stackoverflow_0005863272_code_duplication_control_flow_python.txt |
Q:
Hosting a non-trivial python program on the web?
I'm a complete novice in this area, so please excuse my ignorance.
I have three questions:
What's the best (fastest, easiest, headache-free) way of hosting a python program online?
I'm currently looking at Google App Engine and Web Frameworks for Python, but all ... | Hosting a non-trivial python program on the web? | I'm a complete novice in this area, so please excuse my ignorance.
I have three questions:
What's the best (fastest, easiest, headache-free) way of hosting a python program online?
I'm currently looking at Google App Engine and Web Frameworks for Python, but all the options are a bit overwhelming.
Which gui/viz libr... | [
"Depending on your knowledge with server administration, you should consider a dedicated server. I was doing running some custom Python modules with Numpy, Scipy, Pandas, etc. on some data on a shared server with Godaddy. One program I wrote took 120 seconds to complete. Recently we switched to a dedicated server a... | [
1,
0,
0
] | [] | [] | [
"google_app_engine",
"python",
"user_interface",
"visualization",
"web_applications"
] | stackoverflow_0005657023_google_app_engine_python_user_interface_visualization_web_applications.txt |
Q:
Is it possible to reconcile github and docutils buildhtml?
Github will parse a reStructuredText file if its extension is .rst. The docutils buildhtml.py will only parse files with the extension .txt, and I can't see an option to change that. This is massively annoying. Is there any way to get Github to recognise .... | Is it possible to reconcile github and docutils buildhtml? | Github will parse a reStructuredText file if its extension is .rst. The docutils buildhtml.py will only parse files with the extension .txt, and I can't see an option to change that. This is massively annoying. Is there any way to get Github to recognise .txt files as RST or buildhtml to recognise .rst files?
| [
"Perhaps you can just use a symlink?\n",
"buildhtml.py appears to just be a directory walker wrapped around docutils' internals. Considering its small size, the simplest solution is probably to just modify it to suit your needs by replacing the .txt test with a .rst test.\n"
] | [
1,
0
] | [] | [] | [
"docutils",
"github",
"python",
"restructuredtext"
] | stackoverflow_0005818242_docutils_github_python_restructuredtext.txt |
Q:
Replace fullwidth punctuation characters with normal width equivalents
file1 contains some :s (that's fullwidth) I'd like to turn into regular :s (that's our regular colon). How do I do this in bash? Perhaps a python script?
A:
With all due respect, python isn’t the right tool for this job; perl is:
perl -CSAD -... | Replace fullwidth punctuation characters with normal width equivalents | file1 contains some :s (that's fullwidth) I'd like to turn into regular :s (that's our regular colon). How do I do this in bash? Perhaps a python script?
| [
"With all due respect, python isn’t the right tool for this job; perl is:\nperl -CSAD -i.orig -pe 'tr[:][:]' file1\n\nor\nperl -CSAD -i.orig -pe 'tr[\\x{FF1A}][:]' file1\n\nor\nperl -CSAD -i.orig -Mcharnames=:full -pe 'tr[\\N{FULLWIDTH COLON}][:]' file1\n\nor \nperl -CSAD -i.orig -Mcharnames=:full -pe 'tr[\\N{FULLW... | [
4,
3,
2,
0,
0
] | [] | [] | [
"bash",
"python",
"unicode"
] | stackoverflow_0005860728_bash_python_unicode.txt |
Q:
I am a php programmer converting to python. Please explain the importance (or non importance) of unit testing. I never unit tested with php!
I am at a point in my learning about solid software development where I realize that the "pedal-to-the-medal code at light speed and pray for good results with no real plan" ... | I am a php programmer converting to python. Please explain the importance (or non importance) of unit testing. I never unit tested with php! | I am at a point in my learning about solid software development where I realize that the "pedal-to-the-medal code at light speed and pray for good results with no real plan" approach does not work.
I am seeking to replace my old (and admittedly not exactly great) ways with solid practices. I have never used unit testi... | [
"Unit testing gives you some certainty that you code meets your expectations. Unit testing is not a holy grail, it is simply one of the tools you can use to attain a good level of accuracy and modularity with your code.\nThe unit test is your expectation. In other words, your test will call or invoke the piece of c... | [
7
] | [] | [] | [
"nose",
"php",
"pyramid",
"python",
"unit_testing"
] | stackoverflow_0005864019_nose_php_pyramid_python_unit_testing.txt |
Q:
python calendar to calculate month backwards
we are trying to create a calendar function in python. we have created a small content management system, the requirement is, there will be a drop down list on the top right hand corner of the website, which will give the options - Months - 1 month, 2 months, 3 months a... | python calendar to calculate month backwards | we are trying to create a calendar function in python. we have created a small content management system, the requirement is, there will be a drop down list on the top right hand corner of the website, which will give the options - Months - 1 month, 2 months, 3 months and so on..., if the user selects 8 months then it ... | [
"The relativedelta function in the python-dateutil package does the trick:\nfrom dateutil.relativedelta import *\nimport datetime\n\nfive_months_ago = datetime.datetime.now() - relativedelta(months=5)\n\n",
"This is an awkward problem because months have different lengths. What is July 31 minus one month? I had a... | [
7,
1,
-2
] | [] | [] | [
"calendar",
"python"
] | stackoverflow_0002643155_calendar_python.txt |
Q:
Using functions to print lowest,highest, and averages of a list
Using functions, how would I print the lowest, highest, and average of my PAY list that I read from a file?
try:
text_file = open ("Pay.txt", "w")
text_file.writelines(Pay)
text_file.close()
except (IOError):
print 'Error opening/writi... | Using functions to print lowest,highest, and averages of a list | Using functions, how would I print the lowest, highest, and average of my PAY list that I read from a file?
try:
text_file = open ("Pay.txt", "w")
text_file.writelines(Pay)
text_file.close()
except (IOError):
print 'Error opening/writing Pay.txt'
try:
text_file= open("Pay.txt","r")
PAY_= text_f... | [
"Presuming that you have one number per line:\nnumbers = [float(line) for line in open('Pay.txt') if line.strip()]\nif numbers:\n print 'min', min(numbers)\n print 'max', max(numbers)\n print 'avg', sum(numbers) / len(numbers)\nelse:\n print 'file is empty or all lines are blank'\n\n"
] | [
2
] | [] | [] | [
"function",
"list",
"printing",
"python"
] | stackoverflow_0005864195_function_list_printing_python.txt |
Q:
How do I set up add, delete, update and view permissions for a particular model instance?
I am a Python and Django newbie working on a Django app and I have a requirement in which I have to manage permissions for model instance Foo in my Django. There are other model instances available but the permissions only ... | How do I set up add, delete, update and view permissions for a particular model instance? | I am a Python and Django newbie working on a Django app and I have a requirement in which I have to manage permissions for model instance Foo in my Django. There are other model instances available but the permissions only apply for foo.
I have overridden has_add_permission, has_delete_permission in my FooAdmin class... | [
"After a bit of Googling and random hacks, I have able to come up with a solution. I don't know what the protocol is to answer to your question.\n\nCreate a Middle ware implementation (threadlocals.py) that stores the user information in a thread local object.\ntry:\n from threading import local\nexcept ImportErro... | [
1
] | [] | [] | [
"authorization",
"django",
"django_admin",
"permissions",
"python"
] | stackoverflow_0005723199_authorization_django_django_admin_permissions_python.txt |
Q:
How can I split this comma-delimited string in Python?
Hi I have been reading up about regular expressions, I have got some basic res working. I now have been trying to use Re to sort out data like this:
"144,1231693144,26959535291011309493156476344723991336010898738574164086137773096960,2695953529101130949315647... | How can I split this comma-delimited string in Python? | Hi I have been reading up about regular expressions, I have got some basic res working. I now have been trying to use Re to sort out data like this:
"144,1231693144,26959535291011309493156476344723991336010898738574164086137773096960,26959535291011309493156476344723991336010898738574164086137773096960,1.00,4295032833,... | [
"You don't want regular expressions here.\ns = \"144,1231693144,26959535291011309493156476344723991336010898738574164086137773096960,26959535291011309493156476344723991336010898738574164086137773096960,1.00,4295032833,1563,2747941 288,1231823695,26959535291011309493156476344723991336010898738574164086137773096960,2... | [
65,
18,
2
] | [] | [] | [
"python",
"regex",
"string"
] | stackoverflow_0005864485_python_regex_string.txt |
Q:
Converting characters to their python escape sequences
Is it possible to take a string, and convert all the characters into their Python escape sequences?
A:
repr() escapes all the characters that need to be escaped
repr(string)
There are other methods in the standard library for the likes of escaping URIs and ... | Converting characters to their python escape sequences | Is it possible to take a string, and convert all the characters into their Python escape sequences?
| [
"repr() escapes all the characters that need to be escaped\nrepr(string)\n\nThere are other methods in the standard library for the likes of escaping URIs and so on\n",
"Supports full escaping of both str and unicode (now produces the shortest escape sequence):\ndef escape(s):\n ch = (ord(c) for c in s)\n r... | [
5,
3
] | [] | [] | [
"escaping",
"python"
] | stackoverflow_0005864279_escaping_python.txt |
Q:
Embed Strings as a Resource
I'm writing a DLL, and I would like to, post-compilation, add some strings to it as an embedded resource.
To do that, I'm using a Python script that looks similar to the following:
hRes = win32api.BeginUpdateResource(myFile, 0)
win32api.UpdateResource(hRes, win32con.RT_STRING, 409, buf,... | Embed Strings as a Resource | I'm writing a DLL, and I would like to, post-compilation, add some strings to it as an embedded resource.
To do that, I'm using a Python script that looks similar to the following:
hRes = win32api.BeginUpdateResource(myFile, 0)
win32api.UpdateResource(hRes, win32con.RT_STRING, 409, buf, 1033)
win32api.EndUpdateResource... | [
"You can do it manually, by taking the DLL, appending the data you want to store to it, and after it a 4byte integer containing the size of the appended data in bytes.\nNow, if you want to read the data, read the latest 4 bytes of the file, interpret it as an integer (watch byte order), and read that amount of byte... | [
1,
0
] | [] | [] | [
"c",
"python",
"resources",
"string",
"windows"
] | stackoverflow_0005820616_c_python_resources_string_windows.txt |
Q:
Twisted - how to create multi protocol process and send the data between the protocols
Im trying to write a program that would be listening for data (simple text messages) on some port (say tcp 6666) and then pass them to one or more different protocols - irc, xmpp and so on. I've tried many approaches and digged ... | Twisted - how to create multi protocol process and send the data between the protocols | Im trying to write a program that would be listening for data (simple text messages) on some port (say tcp 6666) and then pass them to one or more different protocols - irc, xmpp and so on. I've tried many approaches and digged the Internet, but I cant find easy and working solution for such task.
The code I am current... | [
"Here is sample code to read from multiple connections to port 9001 and write out to a connection on port 9000. You would need multiple \"PutLine\" implementations, one for XMPP, IRC, MSN, etc.\nI used a global to store the output connection PutLine but you would want to create a more complex Factory object that w... | [
5,
3,
1
] | [] | [] | [
"irc",
"python",
"twisted",
"xmpp"
] | stackoverflow_0002525644_irc_python_twisted_xmpp.txt |
Q:
How to capture output of a shell script running in a separate process, in a wxPython TextCtrl?
A long running shell script produces stdout and stderr, which I would like to show on a textctrl in a GUI. This is possible using threading and separating the GUI thread from the shell script's thread. However when I imp... | How to capture output of a shell script running in a separate process, in a wxPython TextCtrl? | A long running shell script produces stdout and stderr, which I would like to show on a textctrl in a GUI. This is possible using threading and separating the GUI thread from the shell script's thread. However when I implement multiprocessing, I hit a roadblock. Here's my -stripped down- code:
#!/usr/bin/env python
im... | [
"I don't know if this will help you or not, but I have an example of something like this using subprocess here:\nhttp://www.blog.pythonlibrary.org/2010/06/05/python-running-ping-traceroute-and-more/\nSee the pingIP and tracertIP methods. If your shell script is written in Python, you can probably add some kind of g... | [
1,
1
] | [] | [] | [
"multiprocessing",
"multithreading",
"python",
"wxpython"
] | stackoverflow_0005833716_multiprocessing_multithreading_python_wxpython.txt |
Q:
Getting TCP packet payload from Python and impacket
I've been able to find packets of interest using code based on this example:
How can I filter a pcap file by specific protocol using python?
The next child from the TCP packet is the actual data:
if isinstance(child1, TCP):
if child1.get_th_dport() == ... | Getting TCP packet payload from Python and impacket | I've been able to find packets of interest using code based on this example:
How can I filter a pcap file by specific protocol using python?
The next child from the TCP packet is the actual data:
if isinstance(child1, TCP):
if child1.get_th_dport() == 80:
x = child1.child()
print x
Thi... | [
"You can use packet.get_data_as_string() to get the raw bytes, and then display it however you like. I've replicated the \"hex column\" output produced by print child. Should be easy to tweak to produce ASCII columns as well:\ndef display_hex(pkt, cols=8):\n size = cols * 4\n data = ''.join('%02x' % ord(b) f... | [
2
] | [] | [] | [
"impacket",
"python"
] | stackoverflow_0005864632_impacket_python.txt |
Q:
Database modeling in django
I have a situation I don´t know how to model correctly. I want every child of a class to be associated with a media object (photo, video or music). I want to know which is the preffered approach to this problem. What I have right now is:
class Something(models.Model):
media = model... | Database modeling in django | I have a situation I don´t know how to model correctly. I want every child of a class to be associated with a media object (photo, video or music). I want to know which is the preffered approach to this problem. What I have right now is:
class Something(models.Model):
media = models.ForeignKey(Media)
class Media... | [
"I still think the question is a little hard to understand - the title is Database modelling in Django after all...However, this is a perfectly valid and reasonable thing to do, and seems to fit your intent:\nThe recommended way to do this is multi table inheritance - example:\nclass Media(models.Model):\n pass\... | [
2,
0
] | [] | [] | [
"database_design",
"django",
"python",
"relational_database"
] | stackoverflow_0005864053_database_design_django_python_relational_database.txt |
Q:
BeautifulSoup Error (CGI Escape)
Getting the following error:
Traceback (most recent call last):
File "stack.py", line 31, in ?
print >> out, "%s" % escape(p) File
"/usr/lib/python2.4/cgi.py", line
1039, in escape
s = s.replace("&", "&") # Must be done first! TypeError: 'NoneType'
object is ... | BeautifulSoup Error (CGI Escape) | Getting the following error:
Traceback (most recent call last):
File "stack.py", line 31, in ?
print >> out, "%s" % escape(p) File
"/usr/lib/python2.4/cgi.py", line
1039, in escape
s = s.replace("&", "&") # Must be done first! TypeError: 'NoneType'
object is not callable
For the following code... | [
"You have to investigate (using pdb) why one of your links is returned as None instance.\nIn particular: the traceback is self-speaking. The escape() is called with None. So you have to investigate which argument is None...it's one of of your items in 'links'. So why is one of your items None?\nLikely because one o... | [
1
] | [] | [] | [
"beautifulsoup",
"python"
] | stackoverflow_0005865081_beautifulsoup_python.txt |
Q:
python to capture output of another windows - GUI program
The situation is like this:
I want to capture the pop-ups of IPmsg.exe in my python program.
There is an easy way of doing it, which is reading from the log file. But I would like to know if this can be done without bringing log files into discussion.
For m... | python to capture output of another windows - GUI program | The situation is like this:
I want to capture the pop-ups of IPmsg.exe in my python program.
There is an easy way of doing it, which is reading from the log file. But I would like to know if this can be done without bringing log files into discussion.
For more on IPmsg.exe: http://ipmsg.org/index.html.en
That was being... | [
"There are generally two ways to talk to GUI programs on Windows, if you hate the log files:\n\nUse their command line interface! I doubt this has one that outputs to stdout as messages come in\nUse the win32 api or a wrapper for it to search for specific windows (polling as necessary or installing hooks to find ou... | [
1,
1
] | [] | [] | [
"python",
"windows"
] | stackoverflow_0005865222_python_windows.txt |
Q:
How to combine two list that contain intervals
I have list 1 and 2 and I would like to get list 3. If anyone can suggest python or awk script, that would be great.
List 1
A 100-160
B 200-500
C 800-1500
D 1600-2000
E 2500-3000
List 2
150
600
900
1700
2400
List 3
A 100-160 150
B 200-500
C ... | How to combine two list that contain intervals | I have list 1 and 2 and I would like to get list 3. If anyone can suggest python or awk script, that would be great.
List 1
A 100-160
B 200-500
C 800-1500
D 1600-2000
E 2500-3000
List 2
150
600
900
1700
2400
List 3
A 100-160 150
B 200-500
C 800-1500 900
D 1600-2000 1700
E 2500-3000 ... | [
"You could make a dictionary from list 1 that contains the intervals then loops through it to see if any value in list 2 is inside the range. For example,\nlist1 = {\"A\": [100, 160], \"B\": [200, 500], \"C\": [800, 1500],\n \"D\": [1600, 2000], \"E\": [2500,3000]}\n\nlist2 = [150, 600, 900, 1700, 2400]\n\n... | [
2,
2,
1,
1,
0,
0,
0
] | [] | [] | [
"awk",
"linux",
"python"
] | stackoverflow_0005861745_awk_linux_python.txt |
Q:
Problem when invoking command prompt from a python script
I would like some help towards invoking a command prompt (& passing some argument to the command prompt) from a python script.
I use pyqt4 for developing the UI and on the UI I have a run button. On selection of run button, I would like to invoke a command ... | Problem when invoking command prompt from a python script | I would like some help towards invoking a command prompt (& passing some argument to the command prompt) from a python script.
I use pyqt4 for developing the UI and on the UI I have a run button. On selection of run button, I would like to invoke a command prompt and pass on some script name as the argument.
self.conne... | [
"To correctly define file paths in Python on Windows, you need to do one of three things:\n\nUse forward slashes: \"C:/PerfLocal_PAL\" (Python understands forward slashes regardless of platform)\nUse raw strings: r\"C:\\PerfLocal_PAL\"\nEscape the backslashes: \"C:\\\\PerfLocal_PAL\"\n\nThis affects both your chdir... | [
2,
0,
0,
0
] | [] | [] | [
"pyqt",
"pyqt4",
"python"
] | stackoverflow_0005864989_pyqt_pyqt4_python.txt |
Q:
What regex matches this type of timestamp
I've got a log file with the following time stamp format:
May 02 13:27:15.722996
What regex should I use to match that? i.e. from a two hundred character line I just want to return this particular string - it's always at the beginning of the line...
A:
A simple pattern ... | What regex matches this type of timestamp | I've got a log file with the following time stamp format:
May 02 13:27:15.722996
What regex should I use to match that? i.e. from a two hundred character line I just want to return this particular string - it's always at the beginning of the line...
| [
"A simple pattern can be:\n^\\w+\\s\\d\\d\\s\\d\\d:\\d\\d:\\d\\d\\.\\d+\n\nNot much to it, really. You can replace \\d with [0-9], or maybe compact it a little, but it's pretty straightforward. You may also want to make some of the digits optional, in case you don't have leading zeros (May 3 1:2:3.34, for example):... | [
3,
2
] | [] | [] | [
"python",
"regex",
"timestamp"
] | stackoverflow_0005865898_python_regex_timestamp.txt |
Q:
How do I read data from a file using Python?
I am looking for a lookup function for print corresponding names. I have a list file
a Chief manager
b Assistant general manager
c general manager
D CTO
E CEO
I have a variable “user” in my script
I want to check the variable in first column, if the value match then ... | How do I read data from a file using Python? | I am looking for a lookup function for print corresponding names. I have a list file
a Chief manager
b Assistant general manager
c general manager
D CTO
E CEO
I have a variable “user” in my script
I want to check the variable in first column, if the value match then print corresponding name
Eg if “user”==a then p... | [
"Using a dictionary will be easier.\nd = { 'a': 'Chief Manager', 'b': 'Assistant General Manager', 'c': 'General Manager', 'D': 'CTO', 'E': 'CEO' }\nuser = 'a'\nprint(d[user])\n# Chief Manager\n\nTo load that file into a dictionary, you could do this:\nwith open('/path/to/my/file') as myFile:\n d = dict(line.str... | [
5,
1
] | [] | [] | [
"python",
"scripting"
] | stackoverflow_0005866049_python_scripting.txt |
Q:
swig, python and wchar_t problem
I am new to the Python C binding swig and have been trying to solve this problem for a while now. I have an external C library (Example.c) that I would like to call from Python. I read Swig tutorial and able to generate the wrapper in no time. The problem now is that when I invoke ... | swig, python and wchar_t problem | I am new to the Python C binding swig and have been trying to solve this problem for a while now. I have an external C library (Example.c) that I would like to call from Python. I read Swig tutorial and able to generate the wrapper in no time. The problem now is that when I invoke the API and I got this:
>>> import Exa... | [
"Last time I used wchat_t with SWIG+Python I ended up needing to add something like:\n%include \"pywstrings.swg\"\n%include \"pystrings.swg\"\n%include \"std_string.i\"\n%include \"typemaps.i\" \n\n%fragment(\"SWIG_AsVal_wchar_t\", \"header\", fragment=\"<wchar.h>\") {\n SWIGINTERN int SWIG_AsVal_wchar_t(PyObje... | [
2
] | [] | [] | [
"macos",
"python",
"swig"
] | stackoverflow_0004995764_macos_python_swig.txt |
Q:
How do you store a non-ASCII character in Google App Engine Datastore
I've tried no less then 5 different "solutions" and i cant get it to work, please help.
This is the error
'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
Traceback (most recent call last):
File "/base/python_r... | How do you store a non-ASCII character in Google App Engine Datastore | I've tried no less then 5 different "solutions" and i cant get it to work, please help.
This is the error
'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line... | [
"The exception is raised by this line of code:\npbvalue.set_stringvalue(unicode(value).encode('utf-8'))\n\nWhen you pass a value to movie.director , that value is first converted in unicode with:\nunicode(value)\n\nthen it is encoded with encode('utf-8').\nThe unicode() function tipically uses ASCII as default deco... | [
4,
2
] | [] | [] | [
"ascii",
"google_app_engine",
"google_cloud_datastore",
"python"
] | stackoverflow_0005845799_ascii_google_app_engine_google_cloud_datastore_python.txt |
Q:
How to check the ranges of numbers in ANTLR 3?
I know this might end up being language specific, so a Java or Python solution would be acceptable.
Given the grammar:
MONTH : DIGIT DIGIT ;
DIGIT : ('0'..'9') ;
I want a check constraint on MONTH to ensure the value is between 01 and 12. Where do I start looking... | How to check the ranges of numbers in ANTLR 3? | I know this might end up being language specific, so a Java or Python solution would be acceptable.
Given the grammar:
MONTH : DIGIT DIGIT ;
DIGIT : ('0'..'9') ;
I want a check constraint on MONTH to ensure the value is between 01 and 12. Where do I start looking, and how do I specify this constraint as a rule?
| [
"You can embed custom code by wrapping { and } around it. So you could do something like:\nMONTH \n : DIGIT DIGIT \n {\n int month = Integer.parseInt(getText());\n // do your check here\n } \n ;\n\nAs you can see, I called getText() to get a hold of the matched text of the token.\nNote that I... | [
2
] | [
"You can use this free online utility Regex_For_Range to generate a regular expression for any continuous integer range. For the values 01-12 (with allowed leading 0's) the utility gives:\n0*([1-9]|1[0-2])\n\nFrom here you can see that if you want to constrain this to just the 2-digit strings '01' through '12', th... | [
-1
] | [
"antlr",
"antlr3",
"java",
"parsing",
"python"
] | stackoverflow_0005865797_antlr_antlr3_java_parsing_python.txt |
Q:
How use group complement in Python?
I am looking for something like r"[^\1]" in Python.
For example, I want to match words like "hello" in a text where every letter has been replaced by one other (ex: "a" by "z", "b" by "r", ...). "hello" can be "zcuuj", "prvva", ... I want to say to Python: "find me a word which ... | How use group complement in Python? | I am looking for something like r"[^\1]" in Python.
For example, I want to match words like "hello" in a text where every letter has been replaced by one other (ex: "a" by "z", "b" by "r", ...). "hello" can be "zcuuj", "prvva", ... I want to say to Python: "find me a word which begins with [a-z], then a letter which is... | [
"Try this here\n^([a-z])(?!\\1)([a-z])(?!(?:\\1|\\2))(([a-z])\\4)(?!(?:\\1|\\2|\\4))[a-z]\n\nI tested it online here on rubular\nThe problem with your second example is, the negative lookahead assertion are non consuming. That means you need to consum the characters after you checked them. I do this here after ever... | [
1,
0
] | [] | [] | [
"python",
"regex"
] | stackoverflow_0005866555_python_regex.txt |
Q:
django module already import and python egg warnings
Can anyone help me get rid of these warnings in Django please?
/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/_speedups.py:3: UserWarning: Module taggit was already imported from /var/www/html/matilah/taggit/__init__.py, but ... | django module already import and python egg warnings | Can anyone help me get rid of these warnings in Django please?
/usr/lib/python2.6/site-packages/simplejson-2.1.5-py2.6-linux-x86_64.egg/simplejson/_speedups.py:3: UserWarning: Module taggit was already imported from /var/www/html/matilah/taggit/__init__.py, but /usr/lib/python2.6/site-packages/django_taggit-0.9.3-py2.6... | [
"When you get a message like \"Perhaps your account does not have write access to this directory?\" it's best to do a quick test. Try changing it to \"/tmp\" (which is writable by everyone) and see if things start working. If that fixes it, you can then identify a more appropriate directory and make sure that you (... | [
2,
0
] | [] | [] | [
"django",
"egg",
"module",
"python"
] | stackoverflow_0005864868_django_egg_module_python.txt |
Q:
time.localtime() question beginner python
I'm having a syntax error on the second line of this code, I'm trying to make a counter with the winsound beep.
I think the problem is with the format() part, but i get a highlighted =, equals sign when i try to run the program. syntax error
def print_time(secs):
print('... | time.localtime() question beginner python | I'm having a syntax error on the second line of this code, I'm trying to make a counter with the winsound beep.
I think the problem is with the format() part, but i get a highlighted =, equals sign when i try to run the program. syntax error
def print_time(secs):
print('{0}:{1:02}'.format(secs//60,secs%60),end=' ')
... | [
"It sounds like you're reading documentation for Python 3.x, but running Python 2.x. Try this instead:\ndef print_time(secs):\n print '{0}:{1:02}'.format(secs//60,secs%60),\n print \"left to wait...\"\n\nAlso, divmod().\n",
"def print_time(secs):\n print '{0}:{1:02}'.format(secs//60,secs%60),\n print \"le... | [
1,
0
] | [] | [] | [
"datetime",
"python"
] | stackoverflow_0005866466_datetime_python.txt |
Q:
Graph layout and rearrangement
I'm trying to do a semi-automated graph layout program. After reading the input, the program should generate a graph (with a specified layout). The tricky part is that the user should be able to choose a subset of the nodes and rearrange those with another algorithm (while saving the... | Graph layout and rearrangement | I'm trying to do a semi-automated graph layout program. After reading the input, the program should generate a graph (with a specified layout). The tricky part is that the user should be able to choose a subset of the nodes and rearrange those with another algorithm (while saving the rest in their original position). I... | [
"\nFor python see answers to this question\nFor java see ansers to this question\n\nIf you're happy with semi-automated graph layout, then what you might do is the following (which I did in the past):\n\ndownload yEd (also from yworks)\nsave a graph and look at the file: its XML, and the format is not too complex\n... | [
3
] | [] | [] | [
"c#",
"graph",
"java",
"layout",
"python"
] | stackoverflow_0005866645_c#_graph_java_layout_python.txt |
Q:
Pickling an object on appengine
I have an object with an __init__ procedure that requires at least one parameter and
I want to store in the cache.
When trying to getting the object from the cache I get an error that the I didn't pass enough parameters to the ___init___ method.
Someone told me I need to pickle ... | Pickling an object on appengine | I have an object with an __init__ procedure that requires at least one parameter and
I want to store in the cache.
When trying to getting the object from the cache I get an error that the I didn't pass enough parameters to the ___init___ method.
Someone told me I need to pickle the object before sending it to the c... | [
"You can use pickle without any filesystem, using pickle.loads / pickle.dumps. For example:\nimport pickle\nobj = YourClass(yourparam=...)\ndata = pickle.dumps(obj)\n# and now, store \"data\" into the cache\n\n# later, get \"data\" from the cache\nobj = pickle.loads(data)\n\n# and tada, obj if the same as before :)... | [
3,
0
] | [] | [] | [
"google_app_engine",
"pickle",
"python"
] | stackoverflow_0005866475_google_app_engine_pickle_python.txt |
Q:
How to use Bottle with Sina Weibo API for Web-login
I'm trying to write a third party app of Sina Weibo using bottle.
However, the SDK they provided for Python does not seem to have the function of "web login".
I have done take a look at their PHP SDK which has the function for web oauth login.
I tried wrote one m... | How to use Bottle with Sina Weibo API for Web-login | I'm trying to write a third party app of Sina Weibo using bottle.
However, the SDK they provided for Python does not seem to have the function of "web login".
I have done take a look at their PHP SDK which has the function for web oauth login.
I tried wrote one myself, but the only problem is, bottle has no session sup... | [
"You can either use middleware like Beaker to add session support to Bottle or replace Bottle with a Python webserver with support for sessions and oAuth like Tornado.\nIf you were drawn to Bottle for its simplicity you'll love Tornado.\n\nBeaker for Python: http://beaker.groovie.org/\nTornado: http://www.tornadowe... | [
2
] | [] | [] | [
"bottle",
"python",
"sinaweibo",
"social_networking",
"weibo"
] | stackoverflow_0005864827_bottle_python_sinaweibo_social_networking_weibo.txt |
Q:
How to change docstring of TestCase Class in Python?
In Python 2.5 (Jython actually), for the UnitTest TestCase Class - there's is no SetUpClass method, and __init__ is not really acceptable (no refference to self).
When I try to change docstring inside the TestCase:
import os
fileName = os.path.split(__file__)[1]... | How to change docstring of TestCase Class in Python? | In Python 2.5 (Jython actually), for the UnitTest TestCase Class - there's is no SetUpClass method, and __init__ is not really acceptable (no refference to self).
When I try to change docstring inside the TestCase:
import os
fileName = os.path.split(__file__)[1]
testCaseName = os.path.splitext(fileName)[0]
setattr(__na... | [
"Updated - __file__ is the path name from which the current module was loaded, so naturally using __file__ inside DynamicTestCase.py will result in the path DynamicTestCase.py. However, you can just pass the path into setDocstring() from subclasses like this:\nDynamicTestCase.py:\nclass DynamicTestCase(unittest.Te... | [
1,
0
] | [] | [] | [
"class",
"docstring",
"python",
"testcase",
"unit_testing"
] | stackoverflow_0005848248_class_docstring_python_testcase_unit_testing.txt |
Q:
easy_install eggs not importing on my mac
I've got python 2.6 up and running on the ol' macbook, but for whatever reason my easy_installs aren't importing correctly.
WAT DO? pwd
/Library/Python/2.6/site-packages
WAT DO? ls
Django-1.2.1-py2.6.egg
PIL-1.1.7-py2.6-macosx-10.6-universal.egg
README
easy-install.pth
py... | easy_install eggs not importing on my mac | I've got python 2.6 up and running on the ol' macbook, but for whatever reason my easy_installs aren't importing correctly.
WAT DO? pwd
/Library/Python/2.6/site-packages
WAT DO? ls
Django-1.2.1-py2.6.egg
PIL-1.1.7-py2.6-macosx-10.6-universal.egg
README
easy-install.pth
pyserial-2.5-py2.6.egg
WAT DO? echo $PATH
/Libra... | [
"I don't know what easy_install's problem with PySerial is, but I decided to try an alternative route. Just installed from source. Works. \n"
] | [
0
] | [] | [] | [
"easy_install",
"macos",
"python"
] | stackoverflow_0005867202_easy_install_macos_python.txt |
Q:
Python Blender math.trunc()
iam trying to use the math.trunc in Blender 2.49b Python
but iam getting this error
AttributeError: 'module' object has no attribute 'trunc'
i also imported math
its on line
uv[i][0] = trunc(uv[i][0] * 100000) / 100000
i also tryied it via the int, like
uv[i][0] = int(uv[i][0] * 1000... | Python Blender math.trunc() | iam trying to use the math.trunc in Blender 2.49b Python
but iam getting this error
AttributeError: 'module' object has no attribute 'trunc'
i also imported math
its on line
uv[i][0] = trunc(uv[i][0] * 100000) / 100000
i also tryied it via the int, like
uv[i][0] = int(uv[i][0] * 100000) / 100000
which gives me an e... | [
"The second error seems to imply that uv in your code is a float object and you are trying to subscript it uv[i]. Try to math.trunc(uv) and see. Also you can check if trunc is available by doing hasattr(math,'trunc')\n",
"It might depend what verson of Python is used by Blender (I imagine that would be Python 2.5... | [
1,
1
] | [] | [] | [
"blender",
"python"
] | stackoverflow_0005866548_blender_python.txt |
Q:
Opencv: import highgui with python
With the following code:
import cv
cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
camera_index = 0
capture = cv.CaptureFromCAM(camera_index)
def repeat():
global capture #declare as globals since we are assigning to them now
global camera_index
frame = cv.QueryFrame(capture)... | Opencv: import highgui with python | With the following code:
import cv
cv.NamedWindow("w1", cv.CV_WINDOW_AUTOSIZE)
camera_index = 0
capture = cv.CaptureFromCAM(camera_index)
def repeat():
global capture #declare as globals since we are assigning to them now
global camera_index
frame = cv.QueryFrame(capture)
cv.ShowImage("w1", frame)
c = highg... | [
"There have been quite a few changes in the new API. The following will work:\nimport cv\n\ncv.NamedWindow(\"w1\", cv.CV_WINDOW_AUTOSIZE)\ncamera_index = 0\ncapture = cv.CaptureFromCAM(camera_index)\n\ndef repeat():\n global capture #declare as globals since we are assigning to them now\n global camera_index\n f... | [
6,
0
] | [] | [] | [
"macos",
"opencv",
"python"
] | stackoverflow_0005831693_macos_opencv_python.txt |
Q:
[][] gives a SyntaxError in Python
I wrote this code but it gives an error SyntaxError: invalid syntax on the first line:
a =[][]
for i in range(3):
for j in range(3):
a[i][j] = i+j
A:
[][] is not valid syntax. There are no true multi-dimensional arrays in Python, only lists of lists. Also, lists do ... | [][] gives a SyntaxError in Python | I wrote this code but it gives an error SyntaxError: invalid syntax on the first line:
a =[][]
for i in range(3):
for j in range(3):
a[i][j] = i+j
| [
"[][] is not valid syntax. There are no true multi-dimensional arrays in Python, only lists of lists. Also, lists do not automatically expand to any index you throw at them. You have to expand them manually by using, for instance, the appendmethod.\nIf you want a \"two-dimensional array\", first create the top-leve... | [
6,
2,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0005867569_python.txt |
Q:
Python - looking for a way to stop a function being called temporarily in a infinte while loop
i have a while loop as my main function. within it i check several IF statements and call functions accordingly. one particular function i dont want to call if it has been run already within the last two minutes. i dont ... | Python - looking for a way to stop a function being called temporarily in a infinte while loop | i have a while loop as my main function. within it i check several IF statements and call functions accordingly. one particular function i dont want to call if it has been run already within the last two minutes. i dont want to put a WAIT() statement in the function because i want the other IF tests to be performed dui... | [
"I think you're basically on the right track, but here's how I'd implement it:\nimport time\n\nMIN_TIME_DELTA = 120\n\nlast_call = time.clock() - (MIN_TIME_DELTA+1) # init to longer than delta ago\nwhile not exit_condition:\n if test:\n otherFunction()\n if test:\n anotherFunction()\n if tes... | [
2,
0
] | [] | [] | [
"python",
"sikuli"
] | stackoverflow_0005866875_python_sikuli.txt |
Q:
python parallel programming
hi i need some guidelines how to write programm that executes other python programm but in maximum for example 6 times at once and always try to be 6 process be running even if one ends up
also i would like to know what is happening to those processes right know but i dont want to wait ... | python parallel programming | hi i need some guidelines how to write programm that executes other python programm but in maximum for example 6 times at once and always try to be 6 process be running even if one ends up
also i would like to know what is happening to those processes right know but i dont want to wait to any process to finish
what is ... | [
"Use celery.\n",
"Have a look at supervisord. It sounds like it will do what you want.\n",
"Maybe you can try with the multiprocessing module, it can handles pool of worker processes that seems similar to what you try to achieve.\n",
"You can use the poll() method to check if a process is still running. You'd... | [
4,
1,
1,
0
] | [] | [] | [
"jobs",
"parallel_processing",
"python",
"subprocess"
] | stackoverflow_0005867635_jobs_parallel_processing_python_subprocess.txt |
Q:
Installing P4Python on Mac OS 10.6.7
I've found this link and it seems a bit out of date. So I'm hoping someone else has had this same problem.
I'm trying to install P4Python using these instructions.
After running the setup.py script, when I try to run p4test.py as the instructions request, I fail all but 4 test... | Installing P4Python on Mac OS 10.6.7 | I've found this link and it seems a bit out of date. So I'm hoping someone else has had this same problem.
I'm trying to install P4Python using these instructions.
After running the setup.py script, when I try to run p4test.py as the instructions request, I fail all but 4 tests.
I've downloaded the 10.2/bin.macosx105... | [
"Do you have the p4d executable on your machine? See the Note in step 4 of the installation instructions. If p4d isn't there, it's quite possible that a lot of tests fail.\nIf you indeed don't have it (and don't want to or can't install it), then go ahead and continue with the installation and see if the P4API work... | [
4
] | [] | [] | [
"perforce",
"python"
] | stackoverflow_0005863947_perforce_python.txt |
Q:
Python changes are not reflected
I have a example.py file. loaded on a linux server. I put some prints in this file and saved it.
When I call this .py file I am not getting these changes.
Do I need to do something (Like for C we need to compile the .c file and put the .so to LD_LIBRARY_PATH) for python also.
Than... | Python changes are not reflected | I have a example.py file. loaded on a linux server. I put some prints in this file and saved it.
When I call this .py file I am not getting these changes.
Do I need to do something (Like for C we need to compile the .c file and put the .so to LD_LIBRARY_PATH) for python also.
Thanks,
| [
"\nI have a example.py file. loaded on a linux server.\n\nMany linux servers including Apache and Nginx load the files they need to serve when they start for performance sake. So, you may need to restart the server to pickup the latest python file.\n"
] | [
2
] | [] | [] | [
"python"
] | stackoverflow_0005867762_python.txt |
Q:
extracting data from matchobjects
I have a long sequence with multiple repeats of a specific string( 'say GAATTC') randomly throughout the sequence string. I'm currently using the regular expression .span() to provide with me with the indices of where the pattern 'GAATTC' is found. Now I want to use those indices ... | extracting data from matchobjects | I have a long sequence with multiple repeats of a specific string( 'say GAATTC') randomly throughout the sequence string. I'm currently using the regular expression .span() to provide with me with the indices of where the pattern 'GAATTC' is found. Now I want to use those indices to slice the pattern between the G and ... | [
"If what you want to do is replace the 'GAATTC' by the 'G|AATTC' one (not sure of what you want to do in the end), I think that you can manage this without regex:\n>>> string = 'GAATTCAAGAATTCTTGAATTCGAATTCAATATATA'\n>>> string.replace('GAATTC', 'G|AATTC')\n'G|AATTCAAG|AATTCTTG|AATTCG|AATTCAATATATA'\n\nEDIT: ok, th... | [
0,
0
] | [] | [] | [
"bioinformatics",
"python",
"regex"
] | stackoverflow_0005867583_bioinformatics_python_regex.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.