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:
Beautiful Soup string method behaving weirdly
I'm trying to get an image in this page -
http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId=10161&langId=-1&programId=562&termId=100020629&divisionDisplayName=Stanford&departmentDisplayName=MATH&courseDisp... | Beautiful Soup string method behaving weirdly | I'm trying to get an image in this page -
http://www.bkstr.com/webapp/wcs/stores/servlet/CourseMaterialsResultsView?catalogId=10001&categoryId=9604&storeId=10161&langId=-1&programId=562&termId=100020629&divisionDisplayName=Stanford&departmentDisplayName=MATH&courseDisplayName=51§ionDisplayName=01&demoKey=d&purpose=... | [
"the findAll returns a list of matches, not a single match. A Python list does not have the attribute \"string\", however. \nTry data[0] instead.\nEdit:\nString only seems to work if the tag has one child and its a string.\n<div>something</div> would work, but <div><p>something</p></div> wouldn't.\nUse more selecto... | [
1
] | [] | [] | [
"beautifulsoup",
"python",
"screen_scraping"
] | stackoverflow_0007378733_beautifulsoup_python_screen_scraping.txt |
Q:
how to make web framework based on Python like django?
I'm just wondering what knowledge or techniques are needed to make a web framework like django.
so the webframework is able to serve as a cloud computing (a website can be scaled horizontally by sending some stuffs that must be solved to other server.) when n... | how to make web framework based on Python like django? | I'm just wondering what knowledge or techniques are needed to make a web framework like django.
so the webframework is able to serve as a cloud computing (a website can be scaled horizontally by sending some stuffs that must be solved to other server.) when needed, and can be used to build a website fast like django i... | [
"You're asking a few questions here:\nHow to Make a Web Framework like Django\nFirst, check out this article, How to use Python on the Web. It provides very good ideas on the various pieces that go into a framework.\nNext, you need to ask yourself how much you want to create yourself.\nFrom Scratch\nIf you're doing... | [
45,
4,
1,
1
] | [] | [] | [
"django",
"python"
] | stackoverflow_0007378398_django_python.txt |
Q:
how to send ctrl a+c using python?
I need to find out how to send ctrl a+c using python to make a new screen using GNU Screen I'm lost i have not found any code that will get this working. I need to control GNU Screen using python.
More info
http://lifehacker.com/5652409/how-to-run-multiple-applications-in-a-singl... | how to send ctrl a+c using python? | I need to find out how to send ctrl a+c using python to make a new screen using GNU Screen I'm lost i have not found any code that will get this working. I need to control GNU Screen using python.
More info
http://lifehacker.com/5652409/how-to-run-multiple-applications-in-a-single-terminal-window
| [
"try with sendcontrol() from pexpext module.\nimport pexpect\n\nchild = pexpect.spawn ('screen')\nchild.sendcontrol('a');\nchild.send('c');\n\nThe documentation has many examples. \n"
] | [
1
] | [] | [] | [
"gnu_screen",
"python",
"terminal"
] | stackoverflow_0007378906_gnu_screen_python_terminal.txt |
Q:
Having persistent runtime objects with Tornado
I'm working on a project in Tornado that relies heavily on the asynchronous features of the library. By following the chat demo, I've managed to get long-polling working with my application, however I seem to have run into a problem with the way it all works.
Basicall... | Having persistent runtime objects with Tornado | I'm working on a project in Tornado that relies heavily on the asynchronous features of the library. By following the chat demo, I've managed to get long-polling working with my application, however I seem to have run into a problem with the way it all works.
Basically what I want to do is be able to call a function on... | [
"Don't use instance methods - use class methods (after all, you're already using class attributes, you just might not realize it). That way, you don't have to instantiate the object, and can instead just call the methods of the class itself, which acts as a singleton:\nclass UpdateManager(object):\n waiters = []\n... | [
4
] | [] | [] | [
"python",
"tornado"
] | stackoverflow_0007379031_python_tornado.txt |
Q:
PyOpenCl benchmark questions
I was a little modified the standard code from https://github.com/inducer/pyopencl/blob/master/examples/benchmark-all.py
Replaced by numbers, the variable zz
import pyopencl as cl
import numpy
import numpy.linalg as la
import datetime
from time import time
zz=100
a = numpy.random.rand(... | PyOpenCl benchmark questions | I was a little modified the standard code from https://github.com/inducer/pyopencl/blob/master/examples/benchmark-all.py
Replaced by numbers, the variable zz
import pyopencl as cl
import numpy
import numpy.linalg as la
import datetime
from time import time
zz=100
a = numpy.random.rand(zz).astype(numpy.float32)
b = nump... | [
"Well, the growth is unlikely to be linear, since algorithm complexity is O(zz^2).\nTo draw conclusions about 'linearity' you should have more than 3 points (and error bar is also quite useful when doing such analysis), because for GPU 100 threads is by far not enough to fully utilize it computational power (as you... | [
2
] | [] | [] | [
"benchmarking",
"opencl",
"python"
] | stackoverflow_0007376616_benchmarking_opencl_python.txt |
Q:
How to call C++ functions from Python code in linux?
I want to call functions of a C++ program from Python code.
How can make C++ functions available in a Python program?
A:
http://www.boost.org/doc/libs/1_47_0/libs/python/doc/
Boost.Python, a C++ library which enables seamless interoperability between C++ and t... | How to call C++ functions from Python code in linux? | I want to call functions of a C++ program from Python code.
How can make C++ functions available in a Python program?
| [
"http://www.boost.org/doc/libs/1_47_0/libs/python/doc/\nBoost.Python, a C++ library which enables seamless interoperability between C++ and the Python programming language.\n",
"You can find a simple example of Python's native C API (works just as well for C++) here\nIf you deal with numerical calculations and yo... | [
4,
1
] | [] | [] | [
"c++",
"include",
"python"
] | stackoverflow_0007379090_c++_include_python.txt |
Q:
python add elements in a tuple
i have done the following code in order to fill a tuple with user input and then add the elements of the tuple.For example giving as input 1,2 and 3,4 i have the tuple :
((1,2),(3,4)).Then i want to add 1+2 and 3+4.
This is the first part which works ok:
data=[]
mytuple=()
while Tr... | python add elements in a tuple | i have done the following code in order to fill a tuple with user input and then add the elements of the tuple.For example giving as input 1,2 and 3,4 i have the tuple :
((1,2),(3,4)).Then i want to add 1+2 and 3+4.
This is the first part which works ok:
data=[]
mytuple=()
while True:
myinput=raw_input("Enter two... | [
"You need:\nmyinput = myinput.split(\",\")\n\nand\ndata.append( (int(myinput[0]), int(myinput[1])) )\n\nand\nfor adding in mytuple:\n print(\"{0:4d}\".format(adding[0] + adding[1]))\n\n",
"Using the built-in map function:\ndata=[]\nmytuple=()\n\nwhile True:\n myinput=raw_input(\"Enter two integers: \")\n ... | [
1,
1
] | [] | [] | [
"python",
"tuples"
] | stackoverflow_0007379282_python_tuples.txt |
Q:
Accessing grouped items in arrays
I'm new to Python and have a list of numbers. e.g.
5,10,32,35,64,76,23,53....
and I've grouped them into fours (5,10,32,35, 64,76,23,53 etc..) using the code from this post.
def group_iter(iterator, n=2, strict=False):
""" Transforms a sequence of values into a sequence of n-... | Accessing grouped items in arrays | I'm new to Python and have a list of numbers. e.g.
5,10,32,35,64,76,23,53....
and I've grouped them into fours (5,10,32,35, 64,76,23,53 etc..) using the code from this post.
def group_iter(iterator, n=2, strict=False):
""" Transforms a sequence of values into a sequence of n-tuples.
e.g. [1, 2, 3, 4, ...] => [... | [
"Let's say you have the following tuple of tuples:\na=((5,10,32,35), (64,76,23,53)) \n\nTo access the first element of each tuple, use a for-loop:\nfor i in a:\n print i[0]\n\nTo calculate average for the first values:\nelements=[i[0] for i in a]\n\navg=sum(elements)/float(len(elements))\n\n",
"Ok, this is yi... | [
2,
1,
1,
1
] | [] | [] | [
"arrays",
"grouping",
"list",
"python"
] | stackoverflow_0007374523_arrays_grouping_list_python.txt |
Q:
launch program in new shell window from python
I am trying to launch a python script from another python script in a new shell window. So far I'm unable to do it. Does anyone knows how can I accomplish this?
for example
import subprocess
process = subprocess.Popen('test.py', shell=True, stdout=subprocess.PIPE)
pro... | launch program in new shell window from python | I am trying to launch a python script from another python script in a new shell window. So far I'm unable to do it. Does anyone knows how can I accomplish this?
for example
import subprocess
process = subprocess.Popen('test.py', shell=True, stdout=subprocess.PIPE)
process.wait()
print (process.returncode)
when I'll ru... | [
"Here's how you could do it on Debian-like systems:\nimport subprocess\nimport shlex\nprocess = subprocess.Popen(\n shlex.split(\"\"\"x-terminal-emulator -e 'bash -c \"test.py\"'\"\"\"), stdout=subprocess.PIPE)\nprocess.wait()\nprint (process.returncode)\n\nSomething like it should work for any *nix system.\nMan... | [
3,
1
] | [] | [] | [
"python",
"subprocess"
] | stackoverflow_0007379576_python_subprocess.txt |
Q:
creepy design in python
can somebody help me with the following piece of the code:
try:
#do some things
myClass.close()
except Exception, error:
myClass.close()
raise error
as You see I can't use here finally because in that case I will not know if an error actually occured, and I need to raise th... | creepy design in python | can somebody help me with the following piece of the code:
try:
#do some things
myClass.close()
except Exception, error:
myClass.close()
raise error
as You see I can't use here finally because in that case I will not know if an error actually occured, and I need to raise this error (raise error)
my que... | [
"You can use finally :)\nThis should do what you want:\ntry:\n #do some things\nfinally:\n myClass.close()\n\n",
"This is equivalent to your code:\ntry:\n #do some things\nfinally:\n myClass.close()\n\nFirst it calls myClass.close() and if there was a error it is raised again.\nYou can also have this ... | [
2,
2,
1,
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0007379596_python.txt |
Q:
High multi-threading using Python
I want to running large-scale mathematical operations using Python multi-threading; I need software for many computer to do this. What is the best way?
Thanks.
This is my idea:
use c to handle the core code of python
setup a software to handle the multi-threading
and so on
A:
I... | High multi-threading using Python | I want to running large-scale mathematical operations using Python multi-threading; I need software for many computer to do this. What is the best way?
Thanks.
This is my idea:
use c to handle the core code of python
setup a software to handle the multi-threading
and so on
| [
"IPython has a module for parallel computing that sounds like it would fit the bill.\n",
"You should check this Post regarding parallel and cluster computing, as for using c check Cython\n",
"Python threads are good for IO bound loads, but CPU bound loads end up fighting over processor time as the global interp... | [
0,
0,
0
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0005482893_multithreading_python.txt |
Q:
axis range in scatter graphs
I have been using the code below to plot the time spent to run 4 functions. The x axis represents the number of executions whereas the y axis represents the time spent
running a function.
I was wondering if you could help me accomplish the following:
1) set the limits of the x axis s... | axis range in scatter graphs | I have been using the code below to plot the time spent to run 4 functions. The x axis represents the number of executions whereas the y axis represents the time spent
running a function.
I was wondering if you could help me accomplish the following:
1) set the limits of the x axis so that only positive values are sh... | [
"You need to call legend for the legend to appear. The label kwarg only sets the _label attribute on the artist object in question. It's there for convenience, so that the label in the legend can be clearly associated with the plotting command. It won't add the legend to the plot without explicitly calling ax.legen... | [
25
] | [] | [] | [
"limit",
"matplotlib",
"python",
"scatter"
] | stackoverflow_0007376330_limit_matplotlib_python_scatter.txt |
Q:
Python Pickle Not Storing Data
I have a dictionary containing { Name : Email Address }
I have a seperate .py to pickle this:
emailDict = {'Kilizo': 'info%40kilizo.com' , 'about': 'about%40google.com' }
# write python dict to a file
output = open('orig.pkl', 'wb')
pickle.dump(emailDict, output)
output.close()
wh... | Python Pickle Not Storing Data | I have a dictionary containing { Name : Email Address }
I have a seperate .py to pickle this:
emailDict = {'Kilizo': 'info%40kilizo.com' , 'about': 'about%40google.com' }
# write python dict to a file
output = open('orig.pkl', 'wb')
pickle.dump(emailDict, output)
output.close()
which works, in that it pickles the o... | [
"\nAny ideas to get me started?\n\nUsing pickle as a dynamically updated data store for a website isn't great. In order to avoid concurrency issues you'll have to implement a lockfile mechanism and hope that everything else that accesses the file will respect it.\nI strongly suggest that you use a data store that s... | [
2,
0,
0
] | [] | [] | [
"dictionary",
"pickle",
"python"
] | stackoverflow_0007360939_dictionary_pickle_python.txt |
Q:
Python Exception Error
I have never done Python programming before but I have done a lot of .NET in C#
There is a need to do some Python and was trying to learn how to throw exceptions in Python.
from __future__ import with_statement
import dbi
import timeit
import datetime
import win32com.client
import os
impor... | Python Exception Error | I have never done Python programming before but I have done a lot of .NET in C#
There is a need to do some Python and was trying to learn how to throw exceptions in Python.
from __future__ import with_statement
import dbi
import timeit
import datetime
import win32com.client
import os
import datetime
import sys
import... | [
"Check the indentation at retCode=1. If this line has 4 spaces but the line above a tab, it will look the same in your editor but python will complain.\n",
"In your original code, did you mix tabs and spaces? Make sure each line has the same number of spaces per indentation. \n"
] | [
3,
1
] | [] | [] | [
"python"
] | stackoverflow_0007379988_python.txt |
Q:
Are there any widely used wrappers/API's for MySQL in python?
I'm a PHP guy trying out Python with cherryPy. Whenever I work with PHP I use my own simmple wrapper for mysql functions in a form of a class to make things easier to maintain. There is also PDO layer that is widely used but I never really used it in an... | Are there any widely used wrappers/API's for MySQL in python? | I'm a PHP guy trying out Python with cherryPy. Whenever I work with PHP I use my own simmple wrapper for mysql functions in a form of a class to make things easier to maintain. There is also PDO layer that is widely used but I never really used it in any of my projects. Do people building applications in Python using m... | [
"SQLAlchemy is a common choice. It can also be used as a ORM.\n"
] | [
3
] | [] | [] | [
"mysql",
"mysql_python",
"python"
] | stackoverflow_0007380044_mysql_mysql_python_python.txt |
Q:
Selecting folders using strings in Python
Simple question here: I'm trying to identify folders with a specific string in their name, but I want to specify some additional exclusion criteria. Right now, I'm looking for all folders that begin with a specific string using this syntax:
import os
parent_cause = 'B03... | Selecting folders using strings in Python | Simple question here: I'm trying to identify folders with a specific string in their name, but I want to specify some additional exclusion criteria. Right now, I'm looking for all folders that begin with a specific string using this syntax:
import os
parent_cause = 'B03'
path = ('filepath')
child_causes = [x for x i... | [
"NOt sure I fully understand the issues, but I suggest os.walk\ngood_dirs = []\nbad_dirs = []\n\nfor root, files, dirs in os.walk(\"/tmp/folder/B03\"):\n # this will walk recursively depth first into B03 \n # root will be the pwd, so we can test for that\n if root.count(\".\") == 1: ###i think aregex here ... | [
0,
0
] | [] | [] | [
"directory",
"python",
"string"
] | stackoverflow_0007380391_directory_python_string.txt |
Q:
GDB Support STL visualisation (pretty printing)
GDB 7.0 added pretty prnting for STL object. However this implementation supports only GCC version of STL. If you are using Dinkum STL implementation for example, you probably see this message:
File "c:/development/bbndk/python\libstdcxx\v6\printers.py", line 588, ... | GDB Support STL visualisation (pretty printing) | GDB 7.0 added pretty prnting for STL object. However this implementation supports only GCC version of STL. If you are using Dinkum STL implementation for example, you probably see this message:
File "c:/development/bbndk/python\libstdcxx\v6\printers.py", line 588, in to_string
ptr = self.val ['_M_dataplus']['_M_p... | [] | [] | [
"Modifying libstdcxx/v6/printers.py to work with Dinkum STL ought to be pretty trivial.\n\nDoes anybody knows about open source or commertial implementation of pretty printer library compatible with Dinkum\n\nAsk Dinkum?\n"
] | [
-1
] | [
"c++",
"gdb",
"python",
"stl"
] | stackoverflow_0007380088_c++_gdb_python_stl.txt |
Q:
Django form object has no attribute issue
I have a simple form and am trying to POST it to a simple service.
The form model:
class order_form(forms.Form):
name = forms.CharField(max_length=100)
phone = forms.CharField(max_length=20)
email = forms.CharField(max_length=100)
address = forms.CharField(... | Django form object has no attribute issue | I have a simple form and am trying to POST it to a simple service.
The form model:
class order_form(forms.Form):
name = forms.CharField(max_length=100)
phone = forms.CharField(max_length=20)
email = forms.CharField(max_length=100)
address = forms.CharField(max_length=200)
ordered_picture = forms.Cha... | [
"Time to sort out all the \"cleaned_data bits\", since that's how you access the field values.\n if not picture.objects.filter(id=form.cleaned_data['ordered_picture']).exists():\n\n"
] | [
4
] | [] | [] | [
"django",
"forms",
"python"
] | stackoverflow_0007380563_django_forms_python.txt |
Q:
Alternative to using 'in' with numpy.where()
Lets say I have an array, 'foo', with two columns. Column 0 has values 1 to 12 indicating months. Column 1 has the corresponding measurement values. If I wanted to create a mask of measurement values from December, January and February (12,1,2) I would suspect that I co... | Alternative to using 'in' with numpy.where() | Lets say I have an array, 'foo', with two columns. Column 0 has values 1 to 12 indicating months. Column 1 has the corresponding measurement values. If I wanted to create a mask of measurement values from December, January and February (12,1,2) I would suspect that I could:
numpy.where(foo[:,1] in (12, 1, 2), False, Tr... | [
"I think the reason the 'in (12, 1, 2)' does not work is that the element before the 'in' has to be a single element. \nBut for this, numpy has the function in1d (documentation) to do a 'in' with a numpy array. With your code:\nnp.where(np.in1d(foo[:,0], [12, 1, 2]), False, True)\n\n\nTo complete the answer with th... | [
4
] | [] | [] | [
"numpy",
"python",
"scipy"
] | stackoverflow_0007380490_numpy_python_scipy.txt |
Q:
How to parse this huge XML file with nested elements using lxml the efficient way?
I tried parsing this huge XML document using XML minidom. While it worked fine on a sample file, it choked the system when trying to process the real file (about 400 MB).
I tried adapting code (it processes data in a streaming fash... | How to parse this huge XML file with nested elements using lxml the efficient way? | I tried parsing this huge XML document using XML minidom. While it worked fine on a sample file, it choked the system when trying to process the real file (about 400 MB).
I tried adapting code (it processes data in a streaming fashion rather than in-memory load at once) from codereview for my xml file, I am having tro... | [
"You might try something like this:\nimport MySQLdb\nfrom lxml import etree\nimport config\n\ndef fast_iter(context, func, args=[], kwargs={}):\n # http://www.ibm.com/developerworks/xml/library/x-hiperfparse/\n # Author: Liza Daly \n for event, elem in context:\n func(elem, *args, **kwargs)\n ... | [
7,
1
] | [] | [] | [
"iterparse",
"lxml",
"python",
"xml"
] | stackoverflow_0007380215_iterparse_lxml_python_xml.txt |
Q:
Python: How to make interactive tools when our script fire and forget?
I have a software in which support Python for scripting, but just fire and forget scripts, is there anyway to track memory (or something like that) to make more interactive tools?, OR is it possible to track memory by some external tools, somet... | Python: How to make interactive tools when our script fire and forget? | I have a software in which support Python for scripting, but just fire and forget scripts, is there anyway to track memory (or something like that) to make more interactive tools?, OR is it possible to track memory by some external tools, something like key-logger but more advanced?
for example...
> Run script
|
... | [
"Yes. There are a number of ways to do this. If you are running this on Linux, you can look at the /proc directory for some of this information. A more generic solution might be to listen to a socket in your script, and provide an HTTP interface for querying the state of your continuously runing script. For example... | [
1
] | [] | [] | [
"python"
] | stackoverflow_0007380649_python.txt |
Q:
How to add data to a relationship with multiple foreign keys in Django?
How to add data to a relationship with multiple foreign keys in Django?
I'm building a simulation written in python and would like to use django's orm to store (intermediate and final) results in a database. Therefore I am not concerned with u... | How to add data to a relationship with multiple foreign keys in Django? | How to add data to a relationship with multiple foreign keys in Django?
I'm building a simulation written in python and would like to use django's orm to store (intermediate and final) results in a database. Therefore I am not concerned with urls and views.
The problem I am having is the instantiation of an object with... | [
"First, you might want to use a ManyToMany-relationship for the the StepAgent-Class. You can also have extra fields on many-to-many relationships and it will be better design.\nFor your error you have to export DJANGO_SETTINGS_MODULE=settings or however the settingsmodule can be reached from the current PYTHONPATH,... | [
0,
0
] | [] | [] | [
"database",
"django",
"python"
] | stackoverflow_0007378431_database_django_python.txt |
Q:
PHP exec() command wont launch python script using sendkeys
First Note: Sorry this is long. Wanted to be thorough.
I really hate to ask a question when there's so much out there online but its been a week of searching and I have nothing to show for it. I'd really appreciate some help. I am a noob but I learn very ... | PHP exec() command wont launch python script using sendkeys | First Note: Sorry this is long. Wanted to be thorough.
I really hate to ask a question when there's so much out there online but its been a week of searching and I have nothing to show for it. I'd really appreciate some help. I am a noob but I learn very fast and am more than willing to try alternate languages or whate... | [
"The PHP server running the script is most likely running as a different user (Network Service) than the account logged in at the GUI Console. I think this kind of setup might work under XP, and/or with the \"interactive\" field enabled on the service. However, I believe in Vista/7 it is blocked on security groun... | [
2,
0
] | [] | [] | [
"apache",
"exec",
"php",
"python",
"windows"
] | stackoverflow_0007375924_apache_exec_php_python_windows.txt |
Q:
Is there any Ruby or Python interpreter for Lego Mindstorm?
I want to start coding in Python or Ruby. Since I own a Lego Midstorms kit I thought it would be nice to program against it. Are there any good translators / interpeters for the Mindstorms brick?
A:
The nxt-python and ruby-nxt projects are remote contro... | Is there any Ruby or Python interpreter for Lego Mindstorm? | I want to start coding in Python or Ruby. Since I own a Lego Midstorms kit I thought it would be nice to program against it. Are there any good translators / interpeters for the Mindstorms brick?
| [
"The nxt-python and ruby-nxt projects are remote control interfaces to the NXT. They both run on a PC and remotely control the NXT via Bluetooth or USB.\nIf you are looking for running alternative firmware on the NXT, there are several different alternatives. \nSteve Hassenplug has a webpage with a comprehensive l... | [
7,
3,
1,
1
] | [] | [] | [
"interpreter",
"lego_mindstorms",
"python",
"robotics",
"ruby"
] | stackoverflow_0001017429_interpreter_lego_mindstorms_python_robotics_ruby.txt |
Q:
Printing list with set width in python
quick and hopefully easy question.
Let's say I have a variable that is equal to a numerical width value
i.e.: size_x = 50
I want to print the list, wrapping to a width of 50 elements. How do I do this?
A:
guess 1: print lines containing only size_x elements of the original ... | Printing list with set width in python | quick and hopefully easy question.
Let's say I have a variable that is equal to a numerical width value
i.e.: size_x = 50
I want to print the list, wrapping to a width of 50 elements. How do I do this?
| [
"guess 1: print lines containing only size_x elements of the original list\nfor i in range(len(mylist)/size_x):\n print(mylist[i*size_x:(i+1)*size_x])\n\nguess 2: a new list of which the elements are strings of only size_x characters\nnewlist = []\nfor i in range(len(mylist)/size_x):\n newlist.append(''.join... | [
4
] | [] | [] | [
"list",
"parsing",
"python"
] | stackoverflow_0007381021_list_parsing_python.txt |
Q:
Guide on using different types of variables in a python class?
I've spent some time looking for a guide on how to decide how to store data and functions in a python class. I should point out that I am new to OOP, so answers such as:
data attributes correspond to “instance variables”
in Smalltalk, and to “data... | Guide on using different types of variables in a python class? | I've spent some time looking for a guide on how to decide how to store data and functions in a python class. I should point out that I am new to OOP, so answers such as:
data attributes correspond to “instance variables”
in Smalltalk, and to “data members” in C++. (as seen in http://docs.python.org/tutorial/classe... | [
"a, b, and c show different scopes of variables. Meaning, these variables have a different visibility and environment in which they are valid.\nAt first, you need to understand the difference between a class and an object. A class is a vehicle to describe some generic behavior. An object is then created based on th... | [
3,
2,
2
] | [] | [] | [
"oop",
"python"
] | stackoverflow_0007381095_oop_python.txt |
Q:
python - How to parse an HTML table
I have a HTML page with about 50 tables on it. Each table has the same layout, but with different values, eg:
<table align="right" class="customTableClass">
<tr align="center">
<td width="25" height="25" class="usernum">value1</td>
<td width="25" height="25" class="usernum">valu... | python - How to parse an HTML table | I have a HTML page with about 50 tables on it. Each table has the same layout, but with different values, eg:
<table align="right" class="customTableClass">
<tr align="center">
<td width="25" height="25" class="usernum">value1</td>
<td width="25" height="25" class="usernum">value2</td>
<td width="25" height="25" class=... | [
"Check out BeautifulSoup\nhere is the documentation http://www.crummy.com/software/BeautifulSoup/documentation.html.\nPS: It will be much more flexible including future requirements!\n",
"You are printing the beginning of the answer to stdout, not django. Here is how to get HTMLParser to do your bidding:\nimport... | [
5,
5
] | [] | [] | [
"django",
"parsing",
"python",
"rest"
] | stackoverflow_0007381089_django_parsing_python_rest.txt |
Q:
using list index lookup within a template loop in django
Basically, what I want to do is have the template system loop through two independent lists to fill two columns of a table. My approach was to use an index list (numList) as a way to access the same index of the two lists. I tried using the dot notation fo... | using list index lookup within a template loop in django | Basically, what I want to do is have the template system loop through two independent lists to fill two columns of a table. My approach was to use an index list (numList) as a way to access the same index of the two lists. I tried using the dot notation for list index lookup within a template loop but it doesn't seem... | [
"The easiest thing is probably to combine your lists in python and then just look through the combined list in the template:\ncombinedList = [(placeList[i],speakerList[i]) for i in range(4)]\n\n{% for entry in combinedList %}\n<tr>\n<td>{{ entry.0 }}</td>\n<td>1:30</td>\n<td>{{ entry.1 }}</td>\n</tr>\n{% endfor %}\... | [
5,
0
] | [] | [] | [
"django",
"django_templates",
"list",
"python"
] | stackoverflow_0007381081_django_django_templates_list_python.txt |
Q:
How do I setup a local Django development environment on Ubuntu?
Finally made the switch from Windows to Linux (Ubuntu). I am teaching myself Python + Django.
GOAL: I want to setup a local development environment where I can build a django application and run it locally before deploying it live online.
SO FAR: Pyt... | How do I setup a local Django development environment on Ubuntu? | Finally made the switch from Windows to Linux (Ubuntu). I am teaching myself Python + Django.
GOAL: I want to setup a local development environment where I can build a django application and run it locally before deploying it live online.
SO FAR: Python comes installed with Linux. Gedit does also. Ok great. After that ... | [
"Quick answer:\nJust install django via their documentation, and you will not even need apache running as it will run its own server. You can use sqlite as a db and you won't even have to worry about mysql. This is if your goal is to learn django and get things running asap.\nOtherwise, if you want to take the full... | [
4,
0
] | [] | [] | [
"apache",
"django",
"python",
"ubuntu"
] | stackoverflow_0007381575_apache_django_python_ubuntu.txt |
Q:
python-choose random member in one array and remove it in the other identical array
i have 2 arrays, one is the main array, other is temp, that temp array chooses 1 random number and then its supposed to remove that member in the main array, since the content of both arrays is identical . how to do that ? down is ... | python-choose random member in one array and remove it in the other identical array | i have 2 arrays, one is the main array, other is temp, that temp array chooses 1 random number and then its supposed to remove that member in the main array, since the content of both arrays is identical . how to do that ? down is the code
import random
spil=['1t','2t','3t','4t','5t','6t','7t','8t','9t','10t','12t','13... | [
"Your problem is that random.sample returns a list, you really want to do something like this:\nizvucena = random.sample(spil, 1)[0] # grab only element from list returned\n\nAlthough it'd be simpler to use random.choice instead:\nizvucena = random.choice(spil)\n\n",
"The problem is that random.sample() returns a... | [
4,
2,
1
] | [] | [] | [
"arrays",
"list",
"python",
"string",
"variables"
] | stackoverflow_0007381317_arrays_list_python_string_variables.txt |
Q:
How to externalize JSON
I have the following JSON in my view (simplified for this example):
video =
{
'label': 'hd',
'url': 'google',
'format': 'mp4',
'video_codec': 'h264',
'audio_codec': 'aac',
'size': '1080x720',
}
And I can call a function like so: do_something(video)
... | How to externalize JSON | I have the following JSON in my view (simplified for this example):
video =
{
'label': 'hd',
'url': 'google',
'format': 'mp4',
'video_codec': 'h264',
'audio_codec': 'aac',
'size': '1080x720',
}
And I can call a function like so: do_something(video)
However, when I try and extra... | [
"It's easy once you have actual JSON, preferably from json.dump().\n$ cat t.json\n{\n \"label\": \"hd\",\n \"url\": \"google\",\n \"format\": \"mp4\",\n \"video_codec\": \"h264\",\n \"audio_codec\": \"aac\",\n \"size\": \"1080x720\"\n}\n$ python << EOF\n> import json\n> f = open('t.json')\n> print json.load(f... | [
4
] | [] | [] | [
"json",
"python"
] | stackoverflow_0007381680_json_python.txt |
Q:
Modifying array for pygame to blit
I have a medium sized array of tiles represented as numbers that pygame blits to the surface each tick. My array looks like this:
chipset = [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,... | Modifying array for pygame to blit | I have a medium sized array of tiles represented as numbers that pygame blits to the surface each tick. My array looks like this:
chipset = [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,... | [
"An easy approach would be to use a list comprehension and replace chipset[19] with the new list:\nchipset[19] = [4 for element in chipset[19]]\n\nWhen you iterate through and do element = 4 you are just re-assigning the name element to 4, not replacing the element in the list.\n",
"another approach might be to i... | [
2,
2
] | [] | [] | [
"arrays",
"pygame",
"python",
"vector"
] | stackoverflow_0007381942_arrays_pygame_python_vector.txt |
Q:
scrapy is using HTTP 1.0 by default
It looks like Scrapy is using HTTP 1.0 by default. Is there a setting to make it use HTTP 1.1 to send request?
Thanks.
A:
From http://dev.scrapy.org/wiki/ScrapyRecipes:
How to spoof requests to be HTTP 1.1 compliant
You can do this by overriding the Scrapy HTTP Client Factory,... | scrapy is using HTTP 1.0 by default | It looks like Scrapy is using HTTP 1.0 by default. Is there a setting to make it use HTTP 1.1 to send request?
Thanks.
| [
"From http://dev.scrapy.org/wiki/ScrapyRecipes:\nHow to spoof requests to be HTTP 1.1 compliant\nYou can do this by overriding the Scrapy HTTP Client Factory, with the following (undocumented) setting:\nDOWNLOADER_HTTPCLIENTFACTORY = 'myproject.downloader.HTTPClientFactory'\n\nHere's a possible implementation of my... | [
4
] | [] | [] | [
"python",
"scrapy"
] | stackoverflow_0007382008_python_scrapy.txt |
Q:
Parsing blog posts for common links
(Neophyte post, apologies and thanks up front!)
My goal is to build a small app that monitors and parses a set of blogs' posts for outbound links, so I can then:
Display top linked-to articles among the blogs in one frame; and,
For a given linked-to article, display the posts ... | Parsing blog posts for common links | (Neophyte post, apologies and thanks up front!)
My goal is to build a small app that monitors and parses a set of blogs' posts for outbound links, so I can then:
Display top linked-to articles among the blogs in one frame; and,
For a given linked-to article, display the posts (in my blogosphere) that link to it.
So ... | [
"I would go for the same setup. You'll probably need lxml to parse and manipulate the post content HTML (extract a tags).\n"
] | [
1
] | [] | [] | [
"blogs",
"python",
"rss",
"url",
"xml"
] | stackoverflow_0007381848_blogs_python_rss_url_xml.txt |
Q:
Pydevd with virtual code or (source provider)
we´re having python source code stored in a sql database, the code is build together to a virtual python module and can be executed.
We want to debug this modules but then of course the Eclipse debugger host doesnt know where to find the source code for these modules.
... | Pydevd with virtual code or (source provider) | we´re having python source code stored in a sql database, the code is build together to a virtual python module and can be executed.
We want to debug this modules but then of course the Eclipse debugger host doesnt know where to find the source code for these modules.
Is there a way to provide pydevd with the location ... | [
"Write it to the disk and when doing the compile pass the filename for the code (and, when you're not in debug mode, just don't write it and pass '<string>' as the filename).\nSee the example below:\nfrom tempfile import mktemp\n\nmy_code = '''\na = 10\nprint a\n'''\n\ntmp_filename = mktemp('.py', 'temp_file_')\nwi... | [
1,
0
] | [] | [] | [
"debugging",
"eclipse",
"pydev",
"python",
"remote_debugging"
] | stackoverflow_0007362444_debugging_eclipse_pydev_python_remote_debugging.txt |
Q:
How to evaluate if a variable is equal to user input without having several if statements
I'm fairly new to python and for the life of me I can't get this to work. I want to set this little script to check to see if what the user types in is equal to any of the names on the list and if it is execute a function. If... | How to evaluate if a variable is equal to user input without having several if statements | I'm fairly new to python and for the life of me I can't get this to work. I want to set this little script to check to see if what the user types in is equal to any of the names on the list and if it is execute a function. If what the user types in isn't one of the names it should do a different function. This seems li... | [
"if typedname in ['Scott', 'Doug', 'Sam', 'Harry']:\n print('You are', typedname):\nelse:\n print('You are not in the names list')\n\nPython 3.2 brings an optmization for that cases: \nif typedname in {'Scott', 'Doug', 'Sam', 'Harry'}:\n\nwill be translated to a frozenset and the search will be in constant ti... | [
5,
3
] | [] | [] | [
"python"
] | stackoverflow_0007382212_python.txt |
Q:
How Do I create a list from numpy array?
How do I get numpy array into python list?
looking for ('foo', 1, 2, 3, 4)
series is a numpy array
symbol = 'foo'
def rowp (symbol,series):
rowp=[]
series = series[0:4]
ss = series.tolist
rowp.append(symbol)
... | How Do I create a list from numpy array? | How do I get numpy array into python list?
looking for ('foo', 1, 2, 3, 4)
series is a numpy array
symbol = 'foo'
def rowp (symbol,series):
rowp=[]
series = series[0:4]
ss = series.tolist
rowp.append(symbol)
rowp.append(ss)
print r... | [
"As you can already see by the error message, tolist [docs] is a method. That means you have to call it: \nss = series.tolist()\n\nUpdate: Use extend instead of append:\nrowp.extend(series.tolist())\n\n\nBtw, the result you get is not an error.\n"
] | [
6
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0007382279_numpy_python.txt |
Q:
Django testing with assertRaises fails to realise that exception raised is the one expected
I have the following test code snippet
with self.assertRaises(models.NotEnoughInventorySpace):
self.inv2.add_item(self.item2, 1)
The test fails:
Creating test database for alias 'default'...
E.
========================... | Django testing with assertRaises fails to realise that exception raised is the one expected | I have the following test code snippet
with self.assertRaises(models.NotEnoughInventorySpace):
self.inv2.add_item(self.item2, 1)
The test fails:
Creating test database for alias 'default'...
E.
======================================================================
ERROR: test_limited_inventory (wotw_project.game.t... | [
"The problem is not with assertRaises, the problem will be that your exception class has been imported differently in your product code than in your test code.\nDouble check your imports. Make sure the name is imported from the same module in both cases. Frequently in Django projects, the same module is importabl... | [
-1
] | [] | [] | [
"django",
"django_1.3",
"django_testing",
"python",
"python_2.7"
] | stackoverflow_0007380889_django_django_1.3_django_testing_python_python_2.7.txt |
Q:
PyQt window focus events not called
I have a PyQt4 program where I'm trying to get notified when a window gets focus, following the advice in the QUndoGroup docs:
It is the programmer's responsibility to specify which stack is active by calling QUndoStack::setActive(), usually when the associated document window ... | PyQt window focus events not called | I have a PyQt4 program where I'm trying to get notified when a window gets focus, following the advice in the QUndoGroup docs:
It is the programmer's responsibility to specify which stack is active by calling QUndoStack::setActive(), usually when the associated document window receives focus.
But I have a weird probl... | [
"I'm actually not quite sure why it doesn't work, might be an issue in how qt handles focus transition between windows. Anyways, below is how you might fix this, I've changed your code a bit\nfrom PyQt4.QtCore import *\nfrom PyQt4.QtGui import *\n\nimport sys\n\nclass MyWindow(QMainWindow):\n def __init__(self, ... | [
9
] | [] | [] | [
"focus",
"pyqt",
"python",
"qt"
] | stackoverflow_0007377397_focus_pyqt_python_qt.txt |
Q:
Encrypting large files with Pycrypto by streaming the file rather than one big string
I'm encrypting/decrypting files of all sizes and kinds, from small text files to video files of a few GB. The Pycrypto classes just have encode(string) as the only encoding method, implying I must pass the whole file as one big s... | Encrypting large files with Pycrypto by streaming the file rather than one big string | I'm encrypting/decrypting files of all sizes and kinds, from small text files to video files of a few GB. The Pycrypto classes just have encode(string) as the only encoding method, implying I must pass the whole file as one big string (a Python 2.7 bytes/string, that is). This seems less than ideal. How can I feed Pycr... | [
"OK, duh, quick experiment:\n>>> obj = AES.new('blablablablablab', AES.MODE_CBC, 'a' * 16)\n>>> obj.encrypt('z' * 16)\n\"?R\\xd9/\\xc2\\xcb\\x98\\x8cL\\xd4\\xe3M\\r'-k\"\n>>> obj.encrypt('z' * 16)\n'\\xa0QL\\x92\\xcb\\xac{y\\xceG\\xce\\xe2\\x05t\\xe8\\xc3'\n>>> obj.encrypt('z' * 16)\n'\\xc4x\\x87L\\x025\\xbc\\xe6\\... | [
5,
0
] | [] | [] | [
"cryptography",
"python"
] | stackoverflow_0007382314_cryptography_python.txt |
Q:
How to distinguish between inherited models in Django templates?
I have 2 Django models - model A and model B. Model B inherits from model A.
class ModelA(models.Model):
# Fields
class ModelB(ModelA):
# More fields
I want to be able to treat each model differently in a templates as shown:
{% if obj.is_mo... | How to distinguish between inherited models in Django templates? | I have 2 Django models - model A and model B. Model B inherits from model A.
class ModelA(models.Model):
# Fields
class ModelB(ModelA):
# More fields
I want to be able to treat each model differently in a templates as shown:
{% if obj.is_modelA %} <-- This is where my problem lies
Do something
{% elif obj... | [
"I'd say do it in your model rather than as a comparison in the template as @zeekay suggests. That leads to an unpleasant dependency on an internal detail (if you changed your class name things would break).\nI'd do it rather like this:\nclass ModelA(models.Model):\n is_such_and_such = False\n\nclass ModelB(Mode... | [
1,
0
] | [] | [] | [
"django",
"models",
"python",
"templates"
] | stackoverflow_0007382241_django_models_python_templates.txt |
Q:
Generating all terminal strings in Python with grammar/rules?
I'm trying to generate all terminal strings from a given file up to a certain length. So for instance, if you have something like
A = A B
A = B
B = 0
B = 1
Then you would get something like
0
1
0 0
0 1
1 0
1 1
This is something that I thought wouldn't... | Generating all terminal strings in Python with grammar/rules? | I'm trying to generate all terminal strings from a given file up to a certain length. So for instance, if you have something like
A = A B
A = B
B = 0
B = 1
Then you would get something like
0
1
0 0
0 1
1 0
1 1
This is something that I thought wouldn't be overly difficult but I'm getting stuck. I can currently read th... | [
"Pseudocode:\nfor each symbol:\n push that symbol onto the stack\n\nwhile an item X can be popped off the stack:\n if X contains a non-terminal\n calculate each possible result with variation of the leftmost nonterminal\n if that variation is lower than the max length\n push it to th... | [
1
] | [] | [] | [
"bnf",
"context_free_grammar",
"grammar",
"python"
] | stackoverflow_0007382399_bnf_context_free_grammar_grammar_python.txt |
Q:
Does xlwt module support INDIRECT?
I used the following codes, but it doesn't work. I checked the xls. The formula is filled in correctly, but remains as a text entry. If to press ENTER to active this cell, it works.
sheet1.write(1, 1, xlwt.Formula('INDIRECT(\"\'sheet1\'!B1\")'))
I find INDIRECT is declared in xl... | Does xlwt module support INDIRECT? | I used the following codes, but it doesn't work. I checked the xls. The formula is filled in correctly, but remains as a text entry. If to press ENTER to active this cell, it works.
sheet1.write(1, 1, xlwt.Formula('INDIRECT(\"\'sheet1\'!B1\")'))
I find INDIRECT is declared in xlwt\ExcelMagic.py:
all_funcs_by_name = {
... | [
"xlwt has issues with compiling formulas that contain some functions that should return references. This doesn't matter in OpenOffice Calc and Gnumeric, which appear to operate on a \"do what I mean\" philosophy. In Excel 2003, you need to select the cell then hit F2 (forces it to decompile the formula from xlwt-ge... | [
0
] | [] | [] | [
"indirection",
"python",
"xlwt"
] | stackoverflow_0007306929_indirection_python_xlwt.txt |
Q:
Python variable scope in if-statements
In Python, are variable scopes inside if-statements visible outside of the if-statement? (coming from a Java background, so find this a bit odd)
In the following case, name is first defined inside the if-block but the variable is visible outside of the if-block as well. I was... | Python variable scope in if-statements | In Python, are variable scopes inside if-statements visible outside of the if-statement? (coming from a Java background, so find this a bit odd)
In the following case, name is first defined inside the if-block but the variable is visible outside of the if-block as well. I was expecting an error to occur but 'joe' gets ... | [
"if statements don't define a scope in Python.\nNeither do loops, with statements, try / except, etc.\nOnly modules, functions and classes define scopes.\nSee Python Scopes and Namespaces in the Python Tutorial.\n",
"Yes, in Python, variable scopes inside if-statements are visible outside of the if-statement.\nTw... | [
68,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0007382638_python.txt |
Q:
Debug: find the middle word(s) in a list of words
Purpose: find the middle word(s) in a list of words
Attempt:
words = ['Baa', 'Baa', 'black', 'sheep', 'have', 'you', 'any', 'wool']
s=words.split('')
length = len(words)
if length % 2 == 1:
print s(length/2)
else:
print s((length/2) + ((length/2) +1))
Error... | Debug: find the middle word(s) in a list of words | Purpose: find the middle word(s) in a list of words
Attempt:
words = ['Baa', 'Baa', 'black', 'sheep', 'have', 'you', 'any', 'wool']
s=words.split('')
length = len(words)
if length % 2 == 1:
print s(length/2)
else:
print s((length/2) + ((length/2) +1))
Error: Traceback (most recent call last):
File "<web se... | [
".split() is a method used for a string, to break it into an array. Your words are already in an array and do not need to be split.\nRead the error message you are receiving; it will usually give you a clue what's going on.\n"
] | [
2
] | [] | [] | [
"python"
] | stackoverflow_0007382979_python.txt |
Q:
Ascii art in Python PPM format
Possible Duplicate:
PPM image to ASCII art in Python
This is the updated code. I just need it to print the characters on the same line and break at the end
import sys
def main(filename):
image = open(filename)
#reads through the first three lines
color = image.readline().spl... | Ascii art in Python PPM format |
Possible Duplicate:
PPM image to ASCII art in Python
This is the updated code. I just need it to print the characters on the same line and break at the end
import sys
def main(filename):
image = open(filename)
#reads through the first three lines
color = image.readline().splitlines()
size_width, size_height... | [
"I'm guessing the error stems from:\n for j in len(r_g_b_value):\n\n(len returns an int).\nYou probably want to say\n for j in r_g_b_value\n\n"
] | [
0
] | [] | [] | [
"ascii",
"ascii_art",
"python",
"python_3.x"
] | stackoverflow_0007382997_ascii_ascii_art_python_python_3.x.txt |
Q:
python list question
Possible Duplicate:
Overriding the newline generation behaviour of Python's print statement
PPM image to ASCII art in Python
This is my code, I have the characters printing but I need them to be on the same line and break at the end of the line.
import sys
def main(filename):
image = op... | python list question |
Possible Duplicate:
Overriding the newline generation behaviour of Python's print statement
PPM image to ASCII art in Python
This is my code, I have the characters printing but I need them to be on the same line and break at the end of the line.
import sys
def main(filename):
image = open(filename)
#reads t... | [
"Specify the end parameter for print() to be an empty string, and it won't automatically add a newline:\n>>> print('foo', end=''); print('bar'); print('baz')\nfoobar\nbaz\n\nThe default value for end is '\\n'; end is added after all of the regular arguments passed to print() have been output. For instance, print('f... | [
3
] | [] | [] | [
"list",
"python",
"python_3.x"
] | stackoverflow_0007383389_list_python_python_3.x.txt |
Q:
Using the python gdal module to open images in the same projection but different sizes
I'm not sure this is the correct site for this but,
I'm using the gdal.Open() module on python 2.7 to open Landsat GeoTIFF images. They have the same UTM map projection, but different image sizes.
How do I fix the image sizes ... | Using the python gdal module to open images in the same projection but different sizes | I'm not sure this is the correct site for this but,
I'm using the gdal.Open() module on python 2.7 to open Landsat GeoTIFF images. They have the same UTM map projection, but different image sizes.
How do I fix the image sizes to be the same? I'd like to make direct pixel-by-pixel comparisons.
| [
"gdal_translate can be used simply to change the size of an image using the -outsize parameter, which takes two integer values as the xsize and ysize respectively, or two percentage values to scale the image. see here\ngdal_translate -outsize newxsize newysize imageFile outputFile\n\n",
"You need to reproject all... | [
0,
0
] | [] | [] | [
"gdal",
"landsat",
"python"
] | stackoverflow_0007178316_gdal_landsat_python.txt |
Q:
Fetching data from the Wiki
I am currently developing a wiki and will keep posting information into the wiki. However, I'll have to fetch the information from the wiki using a python code. For example, if I have a wiki page about a company, say Coca Cola, I will need all the information (text) that I have posted o... | Fetching data from the Wiki | I am currently developing a wiki and will keep posting information into the wiki. However, I'll have to fetch the information from the wiki using a python code. For example, if I have a wiki page about a company, say Coca Cola, I will need all the information (text) that I have posted on the wiki to be parsed to my pyt... | [
"You can use the api.php to get the Wikipedia Source text. It includes only the actual article. \nI have written this one for the german wikipedia, so it works with umlauts. Some special characters of some other languages don't work (russian works, so it might be some asian languages). This is a working example:\ni... | [
2,
1,
0
] | [] | [] | [
"mediawiki",
"python"
] | stackoverflow_0005099674_mediawiki_python.txt |
Q:
How do I have a program reference an internal random result and apply it to a list to print a result?
Ok, I need some help here. I'm attempting to write a program that rolls a die internally (randrange), which is referenced to a list that will then print the result onto the screen
Example: User inputs "1", activat... | How do I have a program reference an internal random result and apply it to a list to print a result? | Ok, I need some help here. I'm attempting to write a program that rolls a die internally (randrange), which is referenced to a list that will then print the result onto the screen
Example: User inputs "1", activating the dice roll. The program rolls a 2 and checks a list to see what 2 means. 2 means Medium, so it then ... | [
"May be you can leverage from this example:\nimport random\n\ndef roll(num):\n return {\n 1: \"Small\",\n 2: \"Medium\",\n 3: \"Large\",\n 4: \"Huge\",\n 5: \"Huge+\",\n 6: \"Huge++\"\n }[num]\n\nprint roll(random.randrange(1, 7))\n\n",
"Aside from a few small deta... | [
2,
1,
1
] | [] | [] | [
"dice",
"python",
"random"
] | stackoverflow_0007383460_dice_python_random.txt |
Q:
Play audio through muliple channels with python
Is there a way in python to play two different mono mp3 files through the left and right channels?
I have two mp3 files and I want to play one through the left speaker and the other mp3 through the right speaker, programatically in python. Any solution is OK. If it ... | Play audio through muliple channels with python | Is there a way in python to play two different mono mp3 files through the left and right channels?
I have two mp3 files and I want to play one through the left speaker and the other mp3 through the right speaker, programatically in python. Any solution is OK. If it is a cross-platform solution, then great. Does any on... | [
"For a simple solution, download and try the audiere module. This will open the first available audio device:\nimport audiere\nds = audiere.open_device()\nos = ds.open_array(input_array, sampling_frequency)\nos.play()\n\nWhere your input_array should be 2-dim numpy array of floats, you could e.g. decompress your i... | [
2
] | [] | [] | [
"audio",
"mixer",
"mp3",
"python",
"python_gstreamer"
] | stackoverflow_0007383268_audio_mixer_mp3_python_python_gstreamer.txt |
Q:
fetching data from datastore without refresh the page
Is there any good way to fetch the data from the datastroe in app engine without refreshing the whole page , like twitter when new tweets come , or facebook like when comments or status appears
Thanks
A:
It sounds like you're talking about asynchronous notifi... | fetching data from datastore without refresh the page | Is there any good way to fetch the data from the datastroe in app engine without refreshing the whole page , like twitter when new tweets come , or facebook like when comments or status appears
Thanks
| [
"It sounds like you're talking about asynchronous notifications, where the server notifies the client when new data is available. This can be done on App Engine by using the Channel API.\n",
"Use AJAX.\n"
] | [
6,
2
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0007383596_google_app_engine_python.txt |
Q:
In Python, None evaluates to less than zero?
In Python, None evaluates to less than zero?
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> None < 0... | In Python, None evaluates to less than zero? | In Python, None evaluates to less than zero?
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> None < 0
True
>>> None == 0
False
>>> None > 0
False
>>>
... | [
"See the manual:\n\nObjects of different types, except different numeric types and different string types, never compare equal; such objects are ordered consistently but arbitrarily (so that sorting a heterogeneous array yields a consistent result).\n\nand\n\nCPython implementation detail: Objects of different type... | [
15,
5,
3
] | [] | [] | [
"python",
"python_2.x"
] | stackoverflow_0007383782_python_python_2.x.txt |
Q:
Get all possible matches for regex (in python)?
I have a regex that can match a string in multiple overlapping possible ways. However, it seems to only capture one possible match in the string, how can I get all possible matches? I've tried finditer with no success, but maybe I'm using it wrong.
The string I'm try... | Get all possible matches for regex (in python)? | I have a regex that can match a string in multiple overlapping possible ways. However, it seems to only capture one possible match in the string, how can I get all possible matches? I've tried finditer with no success, but maybe I'm using it wrong.
The string I'm trying to parse is:
foo-foobar-foobaz
The regex I'm usi... | [
"No problem:\n>>> regex = \"([^-]*-)(?=([^-]*))\"\n>>> for result in re.finditer(regex, \"foo-foobar-foobaz\"):\n>>> print(\"\".join(result.groups()))\nfoo-foobar\nfoobar-foobaz\n\nBy putting the second capturing parenthesis in a lookahead assertion, you can capture its contents without consuming it in the over... | [
5,
2,
1
] | [] | [] | [
"pattern_matching",
"python",
"regex"
] | stackoverflow_0007383818_pattern_matching_python_regex.txt |
Q:
email.header.decode_headers() throws an HeaderParseError
I'm trying to decode email Subject headers.
I'm doing this (the regex is for adding a space between the two = 's:
header = '=?iso-8859-1?B?TU9UT1IubmwgbmlldXdzYnJpZWYgPiBOaWV1d2UgdmVya29vcHRvcHBl?==?iso-8859-1?B?ciBTdXp1a2kg?='
header = re.sub(r"(==)(?!$)", ... | email.header.decode_headers() throws an HeaderParseError | I'm trying to decode email Subject headers.
I'm doing this (the regex is for adding a space between the two = 's:
header = '=?iso-8859-1?B?TU9UT1IubmwgbmlldXdzYnJpZWYgPiBOaWV1d2UgdmVya29vcHRvcHBl?==?iso-8859-1?B?ciBTdXp1a2kg?='
header = re.sub(r"(==)(?!$)", u"\0= =", header)
email.header.decode_header(header)
But that... | [
"You lack a space between the RFC2047 tokens in the example which doesn't work. Your attempt to repair it is, however, also incorrect; you should be replacing with u\"= =\", not u\"\\0= =\".\nIt would be much better if you could find the source of such errors and correct it, rather than attempt to fix it up afterwa... | [
2
] | [] | [] | [
"email",
"email_headers",
"python"
] | stackoverflow_0007384006_email_email_headers_python.txt |
Q:
How do I remove an item from db.ListProperty?
In a Google App Engine solution (Python), I've used the db.ListProperty as a way to describe a many-to-many relation, like so:
class Department(db.Model):
name = db.StringProperty()
@property
def employees(self):
return Employee.all().filter('departments', s... | How do I remove an item from db.ListProperty? | In a Google App Engine solution (Python), I've used the db.ListProperty as a way to describe a many-to-many relation, like so:
class Department(db.Model):
name = db.StringProperty()
@property
def employees(self):
return Employee.all().filter('departments', self.key())
class Employee(db.Model):
name = db.S... | [
"The ListProperty is just a Python list with some helper methods to make it work with GAE, so anything that applies to a list applies to a ListProperty.\nemployee.departments.remove(department.key())\nemployee.put()\n\nKeep in mind that the data must be deserialized/reserialized every time a change is made, so if y... | [
3,
1
] | [] | [] | [
"google_app_engine",
"python"
] | stackoverflow_0007370488_google_app_engine_python.txt |
Q:
Does Python's read() always return requested size except at EOF?
Does the Python read() method behave like C's read? Might it return less than the requested number of bytes before the last chunk of the file is reached? Or does it guarantee to always return the full amount of bytes when those bytes exist to be read... | Does Python's read() always return requested size except at EOF? | Does the Python read() method behave like C's read? Might it return less than the requested number of bytes before the last chunk of the file is reached? Or does it guarantee to always return the full amount of bytes when those bytes exist to be read?
| [
"Well, the Python Standard library says this about file.read([size]):\nRead at most size bytes from the file (less if the read hits EOF before obtaining size bytes). If the size argument is negative or omitted, read all data until EOF is reached. ... An empty string is returned when EOF is encountered immediately. ... | [
3,
1
] | [] | [] | [
"file_io",
"python"
] | stackoverflow_0007383464_file_io_python.txt |
Q:
What is the fastest method to check if two conditions are True?
For large arrays, what is the fastest way of checking whether multiple conditions are both True or both False? Does the choice of operator make a difference? Why or why not? Here is a dummy example:
import numpy
a = numpy.ones((1000000,))
b = numpy.ze... | What is the fastest method to check if two conditions are True? | For large arrays, what is the fastest way of checking whether multiple conditions are both True or both False? Does the choice of operator make a difference? Why or why not? Here is a dummy example:
import numpy
a = numpy.ones((1000000,))
b = numpy.zeros((1000000,))
#c = (a == 1) * (b == 0)
#c = (a == 1) & (b == 0)
# ... | [
"I'm not so sure this will matter for speed, but you can save memory by using in-place operations in this case.\nTry something like:\nc = a == 1\nc &= b == 0 # (Or *=)\n\nThis should require one fewer temporary copies of the array and use less memory.\n",
"You might take advantage of Short-circuiting of operators... | [
0,
0
] | [] | [] | [
"logical_operators",
"numpy",
"python"
] | stackoverflow_0007382792_logical_operators_numpy_python.txt |
Q:
Why do we add this code when using mmap in Google Maps API?
net, cid, lac = 404415, 40962, 128
import urllib
# net = MCC 404 & MNC 415
a = '000E00000000000000000000000000001B0000000000000000000000030000'
b =hex(cid)[2:].zfill(8) + hex(lac)[2:].zfill(8)
c = hex(divmod(net,100)[1])[2:].zfill(8) + hex(divmod(net,10... | Why do we add this code when using mmap in Google Maps API? | net, cid, lac = 404415, 40962, 128
import urllib
# net = MCC 404 & MNC 415
a = '000E00000000000000000000000000001B0000000000000000000000030000'
b =hex(cid)[2:].zfill(8) + hex(lac)[2:].zfill(8)
c = hex(divmod(net,100)[1])[2:].zfill(8) + hex(divmod(net,100)[0])[2:].zfill(8)
string = (a + b + c+ 'FFFFFFFF00000000').deco... | [
"This is just a guess.\nBut i'm assuming the a = '...' is the location string and the FFFFFF0000000 is just a padding at the end to tell the API that this is the end of your request?\nAnd the reason to why the \"a\" string looks so odd is most likely because google maps supports a hughe bunch of things such as Stre... | [
0
] | [] | [] | [
"maps",
"python"
] | stackoverflow_0007383613_maps_python.txt |
Q:
Pyramid/Pylons Framework - opinion on how am I using 'helpers' to accomplish certain tasks
In pyramid, I have created a 'helpers' functionality similar to that in pylons.
one particular function in my helpers.py file is like this:
from pyramid.renderers import render_to_response
def createBlog():
## lots of c... | Pyramid/Pylons Framework - opinion on how am I using 'helpers' to accomplish certain tasks | In pyramid, I have created a 'helpers' functionality similar to that in pylons.
one particular function in my helpers.py file is like this:
from pyramid.renderers import render_to_response
def createBlog():
## lots of code here ##
return render_to_response('blog.mako', {'xyz':xyz})
And then in my other applic... | [
"It really depends on how much stuff you want to expose globally. Obviously anything you put into h is available throughout the application, whereas you could return the createBlog function just in the views you want it to be in. One little-known tidbit is that if you use class-based views, the actual class instanc... | [
4
] | [] | [] | [
"helpers",
"pylons",
"pyramid",
"python"
] | stackoverflow_0007379668_helpers_pylons_pyramid_python.txt |
Q:
libusb seems to fail under a class coding structure but works without one?
I have a simple working example using Python/NXT/libusb as follows (note: using Lego's NXT which has a USB interface):
import nxt.locator
from nxt.motor import *
def flip_cube(b):
m_arm = Motor(b, PORT_B)
m_arm.turn(75, 85)
m_arm.... | libusb seems to fail under a class coding structure but works without one? | I have a simple working example using Python/NXT/libusb as follows (note: using Lego's NXT which has a USB interface):
import nxt.locator
from nxt.motor import *
def flip_cube(b):
m_arm = Motor(b, PORT_B)
m_arm.turn(75, 85)
m_arm.turn(-50, 85)
b = nxt.locator.find_one_brick()
flip_cube(b)
Above works fine.
... | [
"When you create your BasicRobotTestCase, you lose the b variable if you don't store it as a member of your instance (ie self.b)\nEDIT: well, the missing self weren't the origin of the problem, maybe the way nose instanciate your class change something to the USB grabbing, try to instanciate the class directlry. \n... | [
1
] | [] | [] | [
"libusb",
"nxt",
"python"
] | stackoverflow_0007383508_libusb_nxt_python.txt |
Q:
SQL_CALC_FOUND_ROWS in mysql stored procedure with python
See this stored procedure
-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` ... | SQL_CALC_FOUND_ROWS in mysql stored procedure with python | See this stored procedure
-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `get_followers`(in _user_id int,in _topic_id int,in _... | [
"You'll have to try this to see if it works - I can't test it at the moment...\nresults = cursor.fetchallDict() is returning the first result set, as far as mysqldb is concerned. I.e. the result from the first SELECT. Try adding a nextset() call, like this:\ndef execute_sp( sp_name, paramaters ):\n #helper metho... | [
1
] | [] | [] | [
"mysql",
"python",
"stored_procedures"
] | stackoverflow_0007384066_mysql_python_stored_procedures.txt |
Q:
How can you limit the maximum number of tags an object can have in django-taggit?
I've been really impressed with the implementation of django-taggit as an application for handling tags within Django. However, I have been unable to find a way to set a maximum number of tags which can be applied to an object - a '... | How can you limit the maximum number of tags an object can have in django-taggit? | I've been really impressed with the implementation of django-taggit as an application for handling tags within Django. However, I have been unable to find a way to set a maximum number of tags which can be applied to an object - a 'MAX_TAG' if you will. Is this possible? I'd like to limit my application to, for exampl... | [
"I've solved this in the admin model:\nclass MyObjectAdminForm(forms.ModelForm):\n class Meta:\n model = MyModel\n\n def clean_tags(self):\n tags = self.cleaned_data['tags']\n if len(tags) > 3:\n raise ValidationError(\"....\")\n return tags\n\nclass MyObjectAdmin(admin.... | [
5,
1
] | [] | [] | [
"django",
"django_taggit",
"python",
"tags"
] | stackoverflow_0006574012_django_django_taggit_python_tags.txt |
Q:
Indexing numpy arrays with different number of dimensions
I am using numpy and I want to store the result of a calculation inside a three or four-dimensional matrix. I want to do something like this:
result[:, indices, iteration] = some_function() # won't work
where the dimension is understood from the length of... | Indexing numpy arrays with different number of dimensions | I am using numpy and I want to store the result of a calculation inside a three or four-dimensional matrix. I want to do something like this:
result[:, indices, iteration] = some_function() # won't work
where the dimension is understood from the length of the indices tuple. So if indices equals, say, (6,) or (8, 5) t... | [
"Try using result[(slice(None),) + indices + (iteration,)]\n",
"If you need to know the length of indices :\nlen(indices)\n\nBut is it this your question ?\n"
] | [
2,
1
] | [] | [] | [
"numpy",
"python"
] | stackoverflow_0007385492_numpy_python.txt |
Q:
Error Installing Python MySQLdb on Windows 7
Please see the following stacktrace, is this a permissions issue?
C:\Project\MySQL-python-1.2.3>python setup.py
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "C:\Project\MySQL-python-1.2.3\setup_wi... | Error Installing Python MySQLdb on Windows 7 | Please see the following stacktrace, is this a permissions issue?
C:\Project\MySQL-python-1.2.3>python setup.py
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "C:\Project\MySQL-python-1.2.3\setup_windows.py", line 7, in get_config
serverKey = _... | [
"MySQL is a prerequisite, as said in the README of MySQLDb\n",
"Same issue here, with same version of Python and MySQL installed (as part of XAMPP). Presumably the pre-requisite is for the \"vanilla\" MySQL installation and not one included in an *AMP package.\nIt's not an answer to the problem of installing from... | [
3,
1,
0
] | [] | [] | [
"activestate",
"mysql_python",
"python",
"windows_7"
] | stackoverflow_0005678121_activestate_mysql_python_python_windows_7.txt |
Q:
Python Regex String Extraction
I'm trying to extract two strings from this string using Regular Expressions -
'<img src="http://images.efollett.com/books/978/047/012/9780470129296.gif" width="80" height="100" alt="Organic Chemistry I (as Second Language)" />'
I want the URL after src and the text after alt (so O... | Python Regex String Extraction | I'm trying to extract two strings from this string using Regular Expressions -
'<img src="http://images.efollett.com/books/978/047/012/9780470129296.gif" width="80" height="100" alt="Organic Chemistry I (as Second Language)" />'
I want the URL after src and the text after alt (so Organic Chemistry I (as Second Langua... | [
"Use lxml.\nimport lxml.html\n\nhtml_string = '<img src=\"http://images.efollett.com/books/978/047/012/9780470129296.gif\" width=\"80\" height=\"100\" alt=\"Organic Chemistry I (as Second Language)\" />'\n\nimg = lxml.html.fromstring(html_string)\n\nprint \"src:\", img.get(\"src\")\nprint \"alt:\", img.get(\"alt\")... | [
3,
2,
1,
0
] | [] | [] | [
"python",
"regex",
"string"
] | stackoverflow_0007384275_python_regex_string.txt |
Q:
Simple questions about python Jabber, Twisted, XMLRPC, and SCP
I have a few questions about these protocols that I am having a really hard time answering just searching the web. So here goes. Please excuse my ignorance in advance, I know at least one of these questions will make you cringe.
SCP: Does the SSH file ... | Simple questions about python Jabber, Twisted, XMLRPC, and SCP | I have a few questions about these protocols that I am having a really hard time answering just searching the web. So here goes. Please excuse my ignorance in advance, I know at least one of these questions will make you cringe.
SCP: Does the SSH file transfer protocol guarantee the correct data will get there is the s... | [
"\nSCP: Does the SSH file transfer protocol guarantee the correct data will get there is the server is running? In essence, if I write a script with scp is it redundant to check a hash of the file after I receive it.\n\nGenerally, guarantee is a strong word.\nTCP alone endeavours to provide reliable delivery, check... | [
2
] | [] | [] | [
"python",
"scp",
"twisted",
"xmpp"
] | stackoverflow_0007385211_python_scp_twisted_xmpp.txt |
Q:
Segment tree implementation in Python
I am trying to code new data structures I learn in Python, and the following function is part of segment tree.
def query(root,interval,xy=ref_ll([False,False])):
print interval,root
if root.interval == interval or point(root.interval):
return root.quadrant.refl... | Segment tree implementation in Python | I am trying to code new data structures I learn in Python, and the following function is part of segment tree.
def query(root,interval,xy=ref_ll([False,False])):
print interval,root
if root.interval == interval or point(root.interval):
return root.quadrant.reflect(root.xy * xy) #Is always gonna be of th... | [
"It's probably because you are extending a list for every level of the tree. The average time complexity of extending a list is O(k) where k is the size of the list on the right hand side. The size of the list on the right hand side is O(h) so the average overall time complexity is then O(h2).\n"
] | [
0
] | [] | [] | [
"algorithm",
"data_structures",
"python",
"tree"
] | stackoverflow_0007385823_algorithm_data_structures_python_tree.txt |
Q:
close button in pygtk about dialog not closing dialog
I'm drawing an interface for a pygtk application using glade, and I've made an about dialog. I'm having trouble with the close button in the about dialog. The close button in the credits operates as expected, but in the about dialog the button does nothing, so ... | close button in pygtk about dialog not closing dialog | I'm drawing an interface for a pygtk application using glade, and I've made an about dialog. I'm having trouble with the close button in the about dialog. The close button in the credits operates as expected, but in the about dialog the button does nothing, so it has to be closed with the windows manager. I went to sel... | [
"Try this page : http://zetcode.com/tutorials/pygtktutorial/dialogs/\nHope this helps.\n"
] | [
-2
] | [] | [] | [
"glade",
"pygtk",
"python"
] | stackoverflow_0007385817_glade_pygtk_python.txt |
Q:
Django display contents of list in a template
I'm pretty new to Django's template system-
Basically, I'm trying to print out all the contents of a list that I'm passing to django in a context.
The relevant part of my urls.py is here-
url(r'^class/$', twobooks.classes.views.getAllInformation, {'template_name':'cl... | Django display contents of list in a template | I'm pretty new to Django's template system-
Basically, I'm trying to print out all the contents of a list that I'm passing to django in a context.
The relevant part of my urls.py is here-
url(r'^class/$', twobooks.classes.views.getAllInformation, {'template_name':'classes/displayBooks.html'}),
Now, in my views getAl... | [
"Applying the safe filter will turn anything into a string. If you start with the literal [1, 2, 'foo', u'bar'], you're going to end up with approximately the literal u\"[1, 2, 'foo', u'bar']\" (or something like it—I'm not quite certain of how it's rendered as I've never tried doing it; also I say \"approximately\... | [
4,
2
] | [] | [] | [
"django",
"list",
"python",
"templates"
] | stackoverflow_0007386512_django_list_python_templates.txt |
Q:
How to define a global list in python
I have two methods that should write to the same list.
class MySpider():
def parse_post(self, response):
commentList = []
...
commentList.append(someData)
def parse_comments(self, response):
commentList = []
...
com... | How to define a global list in python | I have two methods that should write to the same list.
class MySpider():
def parse_post(self, response):
commentList = []
...
commentList.append(someData)
def parse_comments(self, response):
commentList = []
...
commentList.append(someData)
In this code the... | [
"One way is to simply refer to the variable by its full name (MySpider.commentList):\nclass MySpider(object):\n\n commentList = []\n\n def parse_post(self, response):\n ... \n MySpider.commentList.append(someData)\n\n def parse_comments(self, response):\n ... \n MySpider.comme... | [
5,
2,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0007385997_python.txt |
Q:
Is it worthwhile using IMAP COMPRESS (DEFLATE)?
Gmail supports the IMAP COMPRESS Extension (RFC4978), specifically the DEFLATE algorithm (RFC1951) aka zlib/gzip.
I'm not normally a Python programmer but I threw a quick test script together using Piers Lauder's imaplib2 to determine performance with or without comp... | Is it worthwhile using IMAP COMPRESS (DEFLATE)? | Gmail supports the IMAP COMPRESS Extension (RFC4978), specifically the DEFLATE algorithm (RFC1951) aka zlib/gzip.
I'm not normally a Python programmer but I threw a quick test script together using Piers Lauder's imaplib2 to determine performance with or without compression enabled.
from time import time
import imaplib... | [
"I don't think enabling compression will make a great difference, simply because 100 messages is a tiny amount of data. Suppose one message is 1KB (a long plaintext message), so that your inbox is 100KB. Let's assume a compression ratio of 5:1 (which is unlikely at best), so that the compressed download is now 20KB... | [
0
] | [] | [] | [
"gmail_imap",
"imap",
"imaplib",
"jakarta_mail",
"python"
] | stackoverflow_0007386268_gmail_imap_imap_imaplib_jakarta_mail_python.txt |
Q:
How do I dynamically switch between default Python versions?
I know this question already exists, but it's really old and I know what I'm looking for. I've used an application earlier that let me very easily install any version of Python and set it to default with one command. I can't for the life of me remember t... | How do I dynamically switch between default Python versions? | I know this question already exists, but it's really old and I know what I'm looking for. I've used an application earlier that let me very easily install any version of Python and set it to default with one command. I can't for the life of me remember the name, and for some reason I can't find it via Google either!
| [
"You're looking for PythonBrew, perhaps?\n"
] | [
3
] | [] | [] | [
"dynamic",
"linux",
"python",
"switching",
"version"
] | stackoverflow_0007387026_dynamic_linux_python_switching_version.txt |
Q:
Center Qt child windows relative to parent
I have a QMainWindow, which creates multiple QDialog child windows and sets itself as their parent. When there is a single monitor, everything is OK and windows are centered correctly in the current monitor. But when I have multiple monitors, child windows tend to open on... | Center Qt child windows relative to parent | I have a QMainWindow, which creates multiple QDialog child windows and sets itself as their parent. When there is a single monitor, everything is OK and windows are centered correctly in the current monitor. But when I have multiple monitors, child windows tend to open on the primary monitor, and not on the monitor whe... | [
"Your code seems to be a good attempt to achieve the desired behavior. Two suggestions:\n\nInstead of taking the desktop parameters, try to directly find the left, top, width and height of your QMainWindow.\nUse this geometric information to move (and potentially size) your dialog to the center of your application,... | [
4,
3
] | [] | [] | [
"python",
"qt"
] | stackoverflow_0007381998_python_qt.txt |
Q:
Add an attribute to a class dynamically at runtime in Python
When I do the following:
def Welcome(email, temporaryPassword):
model = object()
model.TemporaryPassword = temporaryPassword
model.Email = email
I get an error:
AttributeError: 'object' object has no attribute 'TemporaryPassword'
How do I d... | Add an attribute to a class dynamically at runtime in Python | When I do the following:
def Welcome(email, temporaryPassword):
model = object()
model.TemporaryPassword = temporaryPassword
model.Email = email
I get an error:
AttributeError: 'object' object has no attribute 'TemporaryPassword'
How do I dynamically create an object like I am doing?
| [
"use lambda object : ( http://codepad.org/ITFhNrGi )\ndef Welcome(email, temporaryPassword):\n model = type('lamdbaobject', (object,), {})()\n model.TemporaryPassword = temporaryPassword\n model.Email = email\n return model\n\n\nt = Welcome('a@b.com','1234')\nprint(str(t.TemporaryPassword))\n\n",
"you... | [
1,
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0007383505_python.txt |
Q:
New Folder.exe regsvr.exe deleter in python
I would like to write script which deletes New Folder.exe regsvr.exe viruses:
My algorithm is following:
1. Get current working directory
2. check if this directory contains file with extension .exe and size = 646656 bytes
3. if there is/are such file/s delete
recursivel... | New Folder.exe regsvr.exe deleter in python | I would like to write script which deletes New Folder.exe regsvr.exe viruses:
My algorithm is following:
1. Get current working directory
2. check if this directory contains file with extension .exe and size = 646656 bytes
3. if there is/are such file/s delete
recursiveley do the steps 1-3 to subfolders of parent folde... | [
"Just use os.walk() to recursively walk the file tree, and os.stat() on the file paths it gives you as it goes.\n"
] | [
1
] | [] | [] | [
"python"
] | stackoverflow_0007387488_python.txt |
Q:
accessing elements in simplejson.load() output
i have a dictionary(?) of data returned from the simplejson.load() function. it looks like this...
{'status': 'OK', 'results': [{'geometry': {'location_type': 'APPROXIMATE', 'bounds': {'northeast': {'lat': 53.86121, 'lng': -2.045072}, 'southwest': {'lat': 53.80570600... | accessing elements in simplejson.load() output | i have a dictionary(?) of data returned from the simplejson.load() function. it looks like this...
{'status': 'OK', 'results': [{'geometry': {'location_type': 'APPROXIMATE', 'bounds': {'northeast': {'lat': 53.86121, 'lng': -2.045072}, 'southwest': {'lat': 53.80570600000001, 'lng': -2.162588}}, 'viewport': {'northeast'... | [
"Yes, it is. If you store it in a variable named d, then you would use...\nd['results'][0]['geometry']['location']\n\net cetera. Notice the [0] there due to the fact that the dict with key 'geometry' is inside a list.\nsimplejson.load() maps JSON objects to Python dicts and JSON lists to lists. Very straightforward... | [
4
] | [] | [] | [
"json",
"python",
"simplejson"
] | stackoverflow_0007387549_json_python_simplejson.txt |
Q:
parse variables file in Python
I wish to send Python script a definition file (with key and value pairs) which it should translate into an html table using templates.
For example:
say that the definitions file def.txt contain the following lines:
build number: 5513
build date: 12/09/2011
I want it to be able to ... | parse variables file in Python | I wish to send Python script a definition file (with key and value pairs) which it should translate into an html table using templates.
For example:
say that the definitions file def.txt contain the following lines:
build number: 5513
build date: 12/09/2011
I want it to be able to read it easily (iterate on each line... | [
">>> l = [i.split(\": \") for i in open(\"def.txt\")] #read and parse the input\n>>> l #here is what we got\n[['build number', '5513'], ['build date', '12/09/2011']]\n>>> with open(\"out.txt\", \"w\") as f: #open the out file\n... f.write(\"<tbl>\\n\") \n... for k, v in l: #iterate and write\n... f.wr... | [
3,
1
] | [] | [] | [
"definition",
"python",
"templates"
] | stackoverflow_0007387520_definition_python_templates.txt |
Q:
How do you find out what the "system default encoding" is?
The documentation for fileobject.encoding mentions that it can be None, and in that case, the "system default encoding" is used.
How can I find out what this encoding is?
A:
You should use sys.getdefaultencoding()
| How do you find out what the "system default encoding" is? | The documentation for fileobject.encoding mentions that it can be None, and in that case, the "system default encoding" is used.
How can I find out what this encoding is?
| [
"You should use sys.getdefaultencoding()\n"
] | [
78
] | [] | [] | [
"character_encoding",
"python",
"python_2.x",
"unicode"
] | stackoverflow_0007387744_character_encoding_python_python_2.x_unicode.txt |
Q:
How to reset site-packages
Is there a way to "reset" C:\Python26\Lib\site-packages? i.e. to remove all packages and modules installed either by setup.py install or using easy_install?
Motivation: something went wrong with all the package versions and dependencies and I rather reset and reinstall everything than sp... | How to reset site-packages | Is there a way to "reset" C:\Python26\Lib\site-packages? i.e. to remove all packages and modules installed either by setup.py install or using easy_install?
Motivation: something went wrong with all the package versions and dependencies and I rather reset and reinstall everything than spend the time in figuring out wha... | [
"You could just delete all the contents in the folder, although there may still be files in Tools/Scripts and other places left over.\nHave a look here:StackOverflow: uninstall a python package\n",
"Take a look at virtualenv for future reference.\n",
"Does a simple rm -rf * in the site-packages directory do wha... | [
2,
1,
0
] | [] | [] | [
"python",
"windows"
] | stackoverflow_0007387453_python_windows.txt |
Q:
The best way to get the naked domain
Possible Duplicate:
Python extract domain name from URL
I'm thinking about the best way to get a naked domain from an host.
def naked_domain(host):
"""Returns a naked domain from an host.
Doctests:
>>> naked_domain("google.com")
'google.com'
>>> nak... | The best way to get the naked domain |
Possible Duplicate:
Python extract domain name from URL
I'm thinking about the best way to get a naked domain from an host.
def naked_domain(host):
"""Returns a naked domain from an host.
Doctests:
>>> naked_domain("google.com")
'google.com'
>>> naked_domain("www.google.com")
'google... | [
"The urlparse module can split it up into it's components. You can then access the domain with 'netloc'.\n"
] | [
2
] | [] | [] | [
"dns",
"python"
] | stackoverflow_0007388072_dns_python.txt |
Q:
session in webpy - getting username in all classes
I am using webpy framework for my project. I am logging in from my 'login' class of main.py program. I want to get the username in some other class. I tried with session and experimented with it for a long time. I have implemented session like below.
store = web.... | session in webpy - getting username in all classes | I am using webpy framework for my project. I am logging in from my 'login' class of main.py program. I want to get the username in some other class. I tried with session and experimented with it for a long time. I have implemented session like below.
store = web.session.DiskStore('sessions')
session = web.session.Sess... | [
"I have made the following changes in my main.py program.\nChanges made : Instead of just giving \nsession = web.session.Session(app,store,initializer={'login': 0,'privilege': 0,'user':'anonymous','loggedin':False}) \n\nI added following lines of code,\nif web.config.get('_session') is None:\n session = web.sess... | [
3,
2
] | [] | [] | [
"post",
"python",
"session",
"web.py"
] | stackoverflow_0007382886_post_python_session_web.py.txt |
Q:
Retrieve user's information from Facebook or Twitter in Django
I have created Django's registration process using django.contrib.auth and have also set up user profiles. Now I want to add an option to fetch the profile's information from third-party sites like Facebook, Twitter, and LinkedIn. I have found django-s... | Retrieve user's information from Facebook or Twitter in Django | I have created Django's registration process using django.contrib.auth and have also set up user profiles. Now I want to add an option to fetch the profile's information from third-party sites like Facebook, Twitter, and LinkedIn. I have found django-socialregistration, but I don't know how to override the default setu... | [
"Here's the basic idea of the setup that I use, although it's only for Facebook:\n\nIntegrate the Facebook JavaScript SDK\nBind a JavaScript function which calls FB.login to a \"login with Facebook\" button, request all the permissions that you need for that user\nIn the function(response) section of the FB.login c... | [
3
] | [] | [] | [
"django",
"facebook",
"python"
] | stackoverflow_0007386849_django_facebook_python.txt |
Q:
Interactive console in Eclipse, any way to make it more interactive?
Is there any way to use more interactive console than the one already available? Right now, I can run console and check whether everything is working fine but when I make a change to code I need to terminate existing console and create new one - ... | Interactive console in Eclipse, any way to make it more interactive? | Is there any way to use more interactive console than the one already available? Right now, I can run console and check whether everything is working fine but when I make a change to code I need to terminate existing console and create new one - this is really painful when making small changes.
Another problem I have ... | [
"It's not 100% related to Eclise but I think it's a good suggestion in general.\nUse python unittest library, write your test you want your code pass like this\nclass MyTest(unittest.TestCase):\n def test_some_code(self):\n import a\n import b\n ... lots of lines that i need to prep the whol... | [
0
] | [] | [] | [
"eclipse",
"pydev",
"python"
] | stackoverflow_0007386748_eclipse_pydev_python.txt |
Q:
file error in python
I have the following script:
import os
import stat
curDir = os.getcwd()+'/test'
for (paths, dirs, files) in os.walk(curDir):
for f in files:
if os.stat(f)[stat.ST_SIZE]>0:
print f
and the folder test/:
test_folder:
--test.wav
a.exe
t1
t2
rain.wav
whe... | file error in python | I have the following script:
import os
import stat
curDir = os.getcwd()+'/test'
for (paths, dirs, files) in os.walk(curDir):
for f in files:
if os.stat(f)[stat.ST_SIZE]>0:
print f
and the folder test/:
test_folder:
--test.wav
a.exe
t1
t2
rain.wav
when i run this script with g... | [
"You need to specify a full path for os.stat, unless the file is in the current working directory. The simplest way to fix this is to change the WD before trying to access the files:\ncurDir = os.getcwd()+'/test'\nos.chdir(curDir)\n\nA more general solution is to pass the full path to os.stat:\nif os.stat(os.path.j... | [
1,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0007388460_python.txt |
Q:
Script to validate domains
Objective is to read a list of domains from a file and perform lookup to confirm reachability and resolution from my end.
This is what I have written:
#!/usr/bin/python
import os
import socket
f = open('file1.lst', 'r')
s = f.readlines()
for i in s:
print i
socket.gethostbynam... | Script to validate domains | Objective is to read a list of domains from a file and perform lookup to confirm reachability and resolution from my end.
This is what I have written:
#!/usr/bin/python
import os
import socket
f = open('file1.lst', 'r')
s = f.readlines()
for i in s:
print i
socket.gethostbyname(i.strip())
f.close()
socket.... | [
"for i in s:\n print i\n try:\n socket.gethostbyname(i.strip())\n except socket.gaierror:\n print \"unable to get address for\", i\n\nIf an address could not be found, then gethostbyname will raise an exception (not throw). This is the way error handling is done in Python. If you know how t... | [
3,
2,
1,
1
] | [] | [] | [
"dns",
"file_io",
"python",
"sockets"
] | stackoverflow_0007387721_dns_file_io_python_sockets.txt |
Q:
Detecting focus-out event on a frame
I have a GtkFrame containing a set of GtkEntries. I want to hide this GtkFrame when the focus is removed from the GtkFrame.
I connected an handler to the "focus-out-event" signal of the frame, but it nevers get's invoked.
Any ideas on how to achieve this ?
A:
Probably that yo... | Detecting focus-out event on a frame | I have a GtkFrame containing a set of GtkEntries. I want to hide this GtkFrame when the focus is removed from the GtkFrame.
I connected an handler to the "focus-out-event" signal of the frame, but it nevers get's invoked.
Any ideas on how to achieve this ?
| [
"Probably that your frame just never had the focus !\nTry to give it the focus first :\n theFrame.grab_focus()\n\nHope it works (I didn't test it)\n\n\"So what I need to \"detect\" is when the focus moves out of an element contained on the frame\"\nYou may connect an event \"focus-out-event\" to every entry of your... | [
1
] | [] | [] | [
"gtk",
"pygtk",
"python"
] | stackoverflow_0007387091_gtk_pygtk_python.txt |
Q:
python 2.6 vs 2.7, for pylons/pyramid projects
What problems can I have if I will use python 2.7 instead python 2.6 for my pylons/pyramid projects? Before I use python 2.6 on my ubuntu 10.04 but now I have ubuntu 11.04 on my laptop with python 2.7.
A:
If you're using Ubuntu the package manager will fix most of t... | python 2.6 vs 2.7, for pylons/pyramid projects | What problems can I have if I will use python 2.7 instead python 2.6 for my pylons/pyramid projects? Before I use python 2.6 on my ubuntu 10.04 but now I have ubuntu 11.04 on my laptop with python 2.7.
| [
"If you're using Ubuntu the package manager will fix most of the minor issues such as finding the packages you used to have in 2.6.\nBut there are some Packages that isn't compliant with Python2.7.\nMainly Python2.7 is a backwards compatible version from 3.X, or at least Python 2.7 was an upgrade from 2.6 towards t... | [
3,
1,
0
] | [] | [] | [
"pylons",
"pyramid",
"python"
] | stackoverflow_0007384150_pylons_pyramid_python.txt |
Q:
Django Templates display list
This is sort of a follow up to a previous question, but I'll repost all of my code here-
I want to display the contents of a list in Django and I'm using this in my template -
<body>
<h1>Testing the class page backend</h1>
<ul>
{ % for author in authors% }
<li>{{ autho... | Django Templates display list | This is sort of a follow up to a previous question, but I'll repost all of my code here-
I want to display the contents of a list in Django and I'm using this in my template -
<body>
<h1>Testing the class page backend</h1>
<ul>
{ % for author in authors% }
<li>{{ author|safe }}</li>
{ % endfor % }
... | [
"The problem is because mistyping. Some spaces are in the wrong place. use this\n{% for author in authors %}\n <li>{{ author|safe }}</li>\n{% endfor %}\n\n",
"The cleanest way to display a list in django is:\n{{ var|unordered_list }}\n\nYou can also add safeif you want to display html:\n{{ mylist|safe|unordere... | [
4,
2
] | [] | [] | [
"django",
"python",
"templates"
] | stackoverflow_0007388159_django_python_templates.txt |
Q:
How to reset the file.stream in flask / werkzeug?
It seems to me, that you cannot access file.stream.read() after the file has been written with file.save('path',filename') and vice versa.
Example code (derived from the file uploading pattern):
import os
from flask import Flask, request, redirect, url_for, send_fr... | How to reset the file.stream in flask / werkzeug? | It seems to me, that you cannot access file.stream.read() after the file has been written with file.save('path',filename') and vice versa.
Example code (derived from the file uploading pattern):
import os
from flask import Flask, request, redirect, url_for, send_from_directory
from werkzeug import secure_filename
UPLO... | [
"You should be able to seek back to the start of the stream. (See Werkzeug's docs on werkzeug.datastructures.FileStorage). When you try to read the file a second time you start reading from the end of the file.\nfile.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))\nfile.stream.seek(0) # Go back to the st... | [
23
] | [] | [] | [
"flask",
"python",
"werkzeug"
] | stackoverflow_0007368061_flask_python_werkzeug.txt |
Q:
Python - Order nested list in alphabetical way
I have the following list:
["stephane", "philippe", "hélène", ["hugo", "jean-michel", "fernand"], "gustave"]
And I would like to order it like this:
["gustave", "hélène", ["fernand", "hugo", "jean-michel"], "philippe", "stephane"]
NB: If there is a nested list follo... | Python - Order nested list in alphabetical way | I have the following list:
["stephane", "philippe", "hélène", ["hugo", "jean-michel", "fernand"], "gustave"]
And I would like to order it like this:
["gustave", "hélène", ["fernand", "hugo", "jean-michel"], "philippe", "stephane"]
NB: If there is a nested list following a user, this list must stay to the right of thi... | [
"Your data sounds like it would be better represented as a dictionary. Lists where consecutive elements have a special relationship sound odd.\nIf you instead represented your data like this:\n{\n \"stephane\": {}, \n \"philippe\": {}, \n \"hélène\": {\n \"hugo\": {}, \n \"jean-michel\": {},\n \"fernan... | [
6,
2
] | [] | [] | [
"alphabetical",
"list",
"nested",
"python",
"sorting"
] | stackoverflow_0007388446_alphabetical_list_nested_python_sorting.txt |
Q:
Python envisage framework
I just started with envisage framework. In the 4.x version I saw a few example, but I need a good documentation: link.
How can I add custom buttons to the envisage workbench, or how can I create a similar one?
A:
The best place look for documentation is the Acmelab example in the Envis... | Python envisage framework | I just started with envisage framework. In the 4.x version I saw a few example, but I need a good documentation: link.
How can I add custom buttons to the envisage workbench, or how can I create a similar one?
| [
"The best place look for documentation is the Acmelab example in the Envisage source tree.\nI'm assuming when you talk about custom buttons you mean buttons on a toolbar. First you need to create a WorkbenchActionSet, add your toolbar there, and then define your actions and assign them a button image. Here is the... | [
2
] | [] | [] | [
"enthought",
"frameworks",
"python",
"user_interface"
] | stackoverflow_0007387161_enthought_frameworks_python_user_interface.txt |
Q:
WxWidget/WxPython; 3 column resizable layout
I'm trying to figure out how i can have a 3 column layout where the (smaller) left and right columns are resizable with a draggable separator on each side of the center/main area. I've tried using splitwindow but that seems to only split in two parts.
Hope someone can g... | WxWidget/WxPython; 3 column resizable layout | I'm trying to figure out how i can have a 3 column layout where the (smaller) left and right columns are resizable with a draggable separator on each side of the center/main area. I've tried using splitwindow but that seems to only split in two parts.
Hope someone can give me pointers on how it can be done.
| [
"I susggest that you create three panels, side by side. When one of the panels is resized by the user, you will have to adjust the size of the other panels to compensate - so that there are no gaps or overlaps. You can do this by handling the resize event, probably in the parent windows of the three panels.\nAnot... | [
0
] | [] | [] | [
"python",
"user_interface",
"wxpython",
"wxwidgets"
] | stackoverflow_0007389417_python_user_interface_wxpython_wxwidgets.txt |
Q:
django model field limit choice from other model fields
Well Im doing a football application and I have a fixture or game model, what this does is gets two teams, and well it adds a time and stuff for the game to happen, but I also have FixtureRedCard and FixtureGoals, what is happening now is that FixtureGoals an... | django model field limit choice from other model fields | Well Im doing a football application and I have a fixture or game model, what this does is gets two teams, and well it adds a time and stuff for the game to happen, but I also have FixtureRedCard and FixtureGoals, what is happening now is that FixtureGoals and FixtureRedCard have 3 fields, the foreign key to fixtures a... | [
"Check out this Django Snippet for an example.\n"
] | [
0
] | [] | [] | [
"django",
"django_admin",
"django_models",
"python"
] | stackoverflow_0007352121_django_django_admin_django_models_python.txt |
Q:
Output images to html using python
I have a webpage generated from python that works as it should, using:
print 'Content-type: text/html\n\n'
print "" # blank line, end of headers
print '<link href="default.css" rel="stylesheet" type="text/css" />'
print "<html><head>"
I want to a... | Output images to html using python | I have a webpage generated from python that works as it should, using:
print 'Content-type: text/html\n\n'
print "" # blank line, end of headers
print '<link href="default.css" rel="stylesheet" type="text/css" />'
print "<html><head>"
I want to add images to this webpage, but when I do... | [
"You can use this code to directly embed the image in your HTML:\nPython 3\nimport base64\ndata_uri = base64.b64encode(open('Graph.png', 'rb').read()).decode('utf-8')\nimg_tag = '<img src=\"data:image/png;base64,{0}\">'.format(data_uri)\nprint(img_tag)\n\nPython 2.7\ndata_uri = open('11.png', 'rb').read().encode('b... | [
59,
2,
0
] | [] | [] | [
"cgi",
"html",
"http_headers",
"python"
] | stackoverflow_0007389567_cgi_html_http_headers_python.txt |
Q:
Python Arabic NLP
I'm in the process of assessing the capabilities of the NLTK in processing Arabic text in a research to analyze and extract sentiments.
Question is as follows:
Is the NTLK capable of handling and allows the analysis of Arabic text?
Is python capable of manipulating\tokenizing Arabic text?
Will I... | Python Arabic NLP | I'm in the process of assessing the capabilities of the NLTK in processing Arabic text in a research to analyze and extract sentiments.
Question is as follows:
Is the NTLK capable of handling and allows the analysis of Arabic text?
Is python capable of manipulating\tokenizing Arabic text?
Will I be able to parse and s... | [
"A simple google search lead to these links:\nArabic Natural Language Processing\nUsing Python with the Quranic Arabic Corpus\nHOWTO: Working with Python, Unicode, and Arabic\nAre any of these useful?\n"
] | [
6
] | [] | [] | [
"arabic",
"nlp",
"python"
] | stackoverflow_0007386856_arabic_nlp_python.txt |
Q:
Plone call python function from login_next script
I have my Plone instance setup. I am trying to call custom python script function from my login_next script.
How would I do that ?
say for eg:
Custom_print.py
def disp():
return 'Hello world'
How would I call this disp() inside my login_next script ?
A:
So ... | Plone call python function from login_next script | I have my Plone instance setup. I am trying to call custom python script function from my login_next script.
How would I do that ?
say for eg:
Custom_print.py
def disp():
return 'Hello world'
How would I call this disp() inside my login_next script ?
| [
"So this Custom_print.py is in a skins directory that is available in portal_skins and is used in the default skin? In other words: visiting http://your-plone-site/Custom_print returns the string 'Hello world'?\nThen you can customize the login_next script (in the custom map of portal_skins or in your own skin on ... | [
1,
1,
1
] | [] | [] | [
"plone",
"python",
"zope"
] | stackoverflow_0007385725_plone_python_zope.txt |
Q:
Python - how to get a list of all global names I have ever defined?
I work in a python shell and some weeks ago I have defined a variable which refers to a very important list. The shell stays always open, but I have forgotten this name. How to get a list of all global names I have ever defined?
A:
Use dir()
Fo... | Python - how to get a list of all global names I have ever defined? | I work in a python shell and some weeks ago I have defined a variable which refers to a very important list. The shell stays always open, but I have forgotten this name. How to get a list of all global names I have ever defined?
| [
"Use dir()\nFor example,\n>>> x = 666\n>>> dir()\n['__builtins__', '__doc__', '__name__', '__package__', 'x']\n\n",
"All of the globals or just the user-defined ones?\n>>> globals()\n{'__builtins__': <module '__builtin__' (built-in)>, '__name__': '__main__', '__doc__': None, '__package__': None}\n>>> x=2\n>>> glo... | [
6,
6,
2,
2
] | [] | [] | [
"python"
] | stackoverflow_0007390016_python.txt |
Q:
using python to open a device for raw writing
I'm writing some code to read and interpret the MBR and then the FAT of a pen drive formatted with fat32, everything is going fine, I now want to write to the device at a specific position, so after closing the device I'd opened to read, I try again like this:
dr = fil... | using python to open a device for raw writing | I'm writing some code to read and interpret the MBR and then the FAT of a pen drive formatted with fat32, everything is going fine, I now want to write to the device at a specific position, so after closing the device I'd opened to read, I try again like this:
dr = file("/dev/disk5","r+")
Traceback (most recent call la... | [
"You should unmount the block device before opening it in Python. \n"
] | [
1
] | [] | [] | [
"device",
"macos",
"python"
] | stackoverflow_0007389466_device_macos_python.txt |
Q:
Macro or equivalent in reStructuredText?
I have a <form> like this all the times.
.. raw:: html
<form action="txmt://open/?url=file:///Users/smcho/smcho/works/prgtask/ni/gtest_boost_options/readme.txt">
<button type="submit">Edit</button>
</form>
Is there any macro or equivalent in reStructuredText ... | Macro or equivalent in reStructuredText? | I have a <form> like this all the times.
.. raw:: html
<form action="txmt://open/?url=file:///Users/smcho/smcho/works/prgtask/ni/gtest_boost_options/readme.txt">
<button type="submit">Edit</button>
</form>
Is there any macro or equivalent in reStructuredText so that I can get the same result, for example... | [
"You could implement your own \"form\" directive in python. For instructions on how to do that, see\nhttp://docutils.sourceforge.net/docs/howto/rst-directives.html\n",
"You can use any template engine to generate your restructured text, and that gives you macros, loops, and much more. It will require some effort ... | [
5,
0
] | [] | [] | [
"python",
"restructuredtext"
] | stackoverflow_0005046402_python_restructuredtext.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.