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:
What is a good Django workflow?
I'm a beginner to Python and Django.
When starting a new project what do you do first before diving into the code?
For example, one could take the following steps:
Configure the settings.py file first
Configure models.py to lay out data structure
Create template files
Define the v... | What is a good Django workflow? | I'm a beginner to Python and Django.
When starting a new project what do you do first before diving into the code?
For example, one could take the following steps:
Configure the settings.py file first
Configure models.py to lay out data structure
Create template files
Define the views/pages
Syncdb
etc
So my questio... | [
"Follow the Agile approach. Finish one small case, from the start to the end. From the models to the tests to user experience. Then build on it. Iterate.\nThats the right way to software development.\nTo do it efficiently, you need: (don't bother right away, you will need it.)\nAutomated schema migration, automated... | [
20,
8,
2,
0,
0,
0
] | [] | [] | [
"django",
"python"
] | stackoverflow_0005268588_django_python.txt |
Q:
Problem in reading till EOF in python
i have a python code which should read in 2 integers from standard input till user presses Ctrl+D (i.e EOF)
and do some processing .I tried the following code :
n,k=map(int,[a for a in sys.stdin.read().split()])
Here , when i enter two integers the programme accepts it and w... | Problem in reading till EOF in python | i have a python code which should read in 2 integers from standard input till user presses Ctrl+D (i.e EOF)
and do some processing .I tried the following code :
n,k=map(int,[a for a in sys.stdin.read().split()])
Here , when i enter two integers the programme accepts it and when i press Ctrl+D it shows the correct out... | [
">>> x=map(int,[a for a in sys.stdin.read().split()])\n2 3 4 5\n>>> x\n[2, 3, 4, 5]\n\nand work against the list; this so you will accept a variable number of ints if required to do so\n",
"The problem is not in how you read from stdin. Entering 6 3 essentially makes your code equivalent to\nn, k = [6, 3]\n\nwhi... | [
4,
3
] | [] | [] | [
"python"
] | stackoverflow_0005471748_python.txt |
Q:
dynamic dictionary to JSON problem
I'm currently working on a project using javascript and python with Jquery Datatables plugin and Django. My problem is that I am trying to create a dictionary in Python which I then wish to perform a json.dumps(dictionary) in order to send it across to the JQuery.
The conversion ... | dynamic dictionary to JSON problem | I'm currently working on a project using javascript and python with Jquery Datatables plugin and Django. My problem is that I am trying to create a dictionary in Python which I then wish to perform a json.dumps(dictionary) in order to send it across to the JQuery.
The conversion is performed and I can using a debugger ... | [
"If it's malformed then you're malforming it. Did you mean:\n array.append([item['mac_addr'],\n item['ip_addr'],\n item['name'],\n item['os'],\n item['os_version'],\n '--',\n status\n ])\n\n",
"The code in your questio... | [
2,
0,
0,
0
] | [] | [] | [
"django",
"javascript",
"jquery",
"json",
"python"
] | stackoverflow_0005470985_django_javascript_jquery_json_python.txt |
Q:
Trying to convert php to python and getting a syntax error
I'm trying to convert some php code into python and am using curl. I've gotten most of it to be accepted, but when it gets to the result = pycurl.exec(Moe) it keeps throwing a syntax error. I guess that I'm not filling out the exec field correctly, but I... | Trying to convert php to python and getting a syntax error | I'm trying to convert some php code into python and am using curl. I've gotten most of it to be accepted, but when it gets to the result = pycurl.exec(Moe) it keeps throwing a syntax error. I guess that I'm not filling out the exec field correctly, but I can't seem to figure out where it is going wrong.
from urllib2... | [
"Use result = Moe.perform() to execute your request.\n\nPS:\nMoe.setopt(pycurl.POSTFIELDS, Larry)\n\nIs Larry actually a variable? If it's a string, quote it.\n",
"exec is a reserved word in Python, you cannot have a function of that name. Try reading the pycurl documentation to see what function you should be ca... | [
1,
1
] | [] | [] | [
"curl",
"python",
"syntax"
] | stackoverflow_0005471899_curl_python_syntax.txt |
Q:
convert list of values from a txt file to dictionary
So i have this txt file called "Students.txt", I want to define a function called load(student)
so i have this code:
def load(student):
body
im not quite sure what to write for the body of code so that it reads the file and returns the value from the file... | convert list of values from a txt file to dictionary | So i have this txt file called "Students.txt", I want to define a function called load(student)
so i have this code:
def load(student):
body
im not quite sure what to write for the body of code so that it reads the file and returns the value from the file as dictionary. I know it would be something like readline... | [
"Looks like a CSV file. You can use the csv module then:\nimport csv\nstudentReader = csv.reader(open('Students.txt', 'rb'), delimiter=',', skipinitialspace=True)\nd = dict()\nfor row in studentReader:\n d[row[0]] = tuple(row[1:])\n\nThis won't give you the year as integer, you have to transform it yourself:\nfo... | [
3,
2,
1,
0
] | [] | [] | [
"dictionary",
"file_io",
"list",
"python",
"readfile"
] | stackoverflow_0005472238_dictionary_file_io_list_python_readfile.txt |
Q:
Python lxml (objectify): Xpath troubles
I am attempting to parse an xml document, extracting data using lxml objectify and xpath. Here is a snip of the document:
<?xml version="1.0" encoding="UTF-8"?>
<Assets>
<asset name="Adham">
<pos>
<x>27913.769923</x>
<y>5174.627773</y>
</pos>
<description>Ba bl... | Python lxml (objectify): Xpath troubles | I am attempting to parse an xml document, extracting data using lxml objectify and xpath. Here is a snip of the document:
<?xml version="1.0" encoding="UTF-8"?>
<Assets>
<asset name="Adham">
<pos>
<x>27913.769923</x>
<y>5174.627773</y>
</pos>
<description>Ba bla bla</description>
<bar>(null)</bar>
</... | [
"/pos/x and /pos/y are absolute XPath expressions and they don't select any element because the provided XML document doesn't have a pos top element.\nTry:\npos/x\n\nand\npos/y\n\n"
] | [
4
] | [] | [] | [
"lxml",
"objectify",
"python",
"xml",
"xpath"
] | stackoverflow_0005467468_lxml_objectify_python_xml_xpath.txt |
Q:
Python: function returning numbers in ascending order
How can I write a function that would give me a new number in ascending order every time i call it?
For example, if I call it for the first time it returns "1", if I call again, it returns "2".
A:
How about itertools.count()?
counter = itertools.count()
prin... | Python: function returning numbers in ascending order | How can I write a function that would give me a new number in ascending order every time i call it?
For example, if I call it for the first time it returns "1", if I call again, it returns "2".
| [
"How about itertools.count()?\ncounter = itertools.count()\nprint next(counter)\nprint next(counter)\nprint next(counter)\n\nprints\n0\n1\n2\n\nIf you want your counter to start from 1, use\ncounter = itertools.count(1)\n\n"
] | [
7
] | [] | [] | [
"python"
] | stackoverflow_0005472830_python.txt |
Q:
Python decorator, self is mixed up
I am new to Python decorators (wow, great feature!), and I have trouble getting the following to work because the self argument gets sort of mixed up.
#this is the decorator
class cacher(object):
def __init__(self, f):
self.f = f
self.cache = {}
def __ca... | Python decorator, self is mixed up | I am new to Python decorators (wow, great feature!), and I have trouble getting the following to work because the self argument gets sort of mixed up.
#this is the decorator
class cacher(object):
def __init__(self, f):
self.f = f
self.cache = {}
def __call__(self, *args):
fname = self.... | [
"Use the descriptor protocol like this:\nimport functools\n\nclass cacher(object):\n\n def __init__(self, f):\n self.f = f\n self.cache = {}\n\n def __call__(self, *args):\n fname = self.f.__name__\n if (fname not in self.cache):\n self.cache[fname] = self.f(self,*args)\... | [
37,
4,
1
] | [] | [] | [
"python",
"python_decorators"
] | stackoverflow_0005469956_python_python_decorators.txt |
Q:
Removing leading whitespace from a string
Hi I have list of strings in python
[" 0", " 1", " 2"]
and I want to remove the whitespace from the start of one of them.
How would I do this?
A:
If you want to remove the whitespace from all of them, you could use
a = [" 0", " 1", " 2"]
b = [s.lstrip() for s in a]
I... | Removing leading whitespace from a string | Hi I have list of strings in python
[" 0", " 1", " 2"]
and I want to remove the whitespace from the start of one of them.
How would I do this?
| [
"If you want to remove the whitespace from all of them, you could use\na = [\" 0\", \" 1\", \" 2\"]\nb = [s.lstrip() for s in a]\n\nIf you really only want to strip one of them, use\na[i] = a[i].lstrip()\n\nwhere i is the index of the one you want to strip.\n",
"To remove the spaces you can use the strip method, ... | [
6,
2,
2,
1
] | [
"If you want the the result to be a list of intergers then try this \n>>> w = [\" 0\", \" 1\" ,\" 2\"]\n>>> map(lambda a:eval(a),w)\n[0, 1, 2]\n\nelse if you want it to be a list of string\n>>> w = [\" 0\", \" 1\" ,\" 2\"]\n>>> map(lambda a:a.strip(),w)\n['0', '1', '2']\n>>>\n\n"
] | [
-1
] | [
"python",
"removing_whitespace",
"string"
] | stackoverflow_0005472151_python_removing_whitespace_string.txt |
Q:
Test a string for a substring
Is there an easy way to test a Python string "xxxxABCDyyyy" to see if "ABCD" is contained within it?
A:
if "ABCD" in "xxxxABCDyyyy":
# whatever
A:
There are several other ways, besides using the in operator (easiest):
index()
>>> try:
... "xxxxABCDyyyy".index("test")
... e... | Test a string for a substring | Is there an easy way to test a Python string "xxxxABCDyyyy" to see if "ABCD" is contained within it?
| [
"if \"ABCD\" in \"xxxxABCDyyyy\":\n # whatever\n\n",
"There are several other ways, besides using the in operator (easiest):\n\nindex()\n\n>>> try:\n... \"xxxxABCDyyyy\".index(\"test\")\n... except ValueError:\n... print \"not found\"\n... else:\n... print \"found\"\n...\nnot found\n\n\nfind()\n\n>>> if ... | [
221,
35
] | [] | [] | [
"python",
"string"
] | stackoverflow_0005473014_python_string.txt |
Q:
tweepy time filtering(python)
I'm using tweepy which is a Python library for Twitter, to get the tweets of an account. problem is- it shows all the tweets the user has tweeted regardless of the time.
How can I filter it so it only shows tweets tweeted in the past 10 minutes(even somthing like 'tweeted at 5:30' wo... | tweepy time filtering(python) | I'm using tweepy which is a Python library for Twitter, to get the tweets of an account. problem is- it shows all the tweets the user has tweeted regardless of the time.
How can I filter it so it only shows tweets tweeted in the past 10 minutes(even somthing like 'tweeted at 5:30' would work)? I've checked the documen... | [
"There's no way of searching by time directly through the API, but you can use API.user_timeline to get the most recent tweets for a user. You can then store these in a local database and do what you like with them (e.g. select just tweets since a particular time).\nI don't know what you mean by \"all tweets the u... | [
0
] | [] | [] | [
"python",
"twitter"
] | stackoverflow_0005469744_python_twitter.txt |
Q:
django one session per user
based on docs ( http://docs.djangoproject.com/en/1.1/topics/http/sessions/ ) (yes - 1.1) Django creates unique sessions to all users. Logged user contains _auth_user_id. How can i achieve such check in login:
If new_login._auth_user_id in database:
delete(sessions_containing_same_id_... | django one session per user | based on docs ( http://docs.djangoproject.com/en/1.1/topics/http/sessions/ ) (yes - 1.1) Django creates unique sessions to all users. Logged user contains _auth_user_id. How can i achieve such check in login:
If new_login._auth_user_id in database:
delete(sessions_containing_same_id_except_new_one)
The main idea is... | [
"I created extra field for user (userattributes extends user):\nclass UserAttributes(User):\n last_session_key = models.CharField(blank=True, null=True, max_length=40)\n\nand method:\ndef set_session_key(self, key):\n if self.last_session_key and not self.last_session_key == key:\n Session.objects.get(... | [
4
] | [] | [] | [
"authentication",
"django",
"django_1.1",
"python"
] | stackoverflow_0005470210_authentication_django_django_1.1_python.txt |
Q:
How to check a string for emptyness or length zero
I recently asked a question about converting list of values from txt file to dictionary list. You can see it from the link here: See my question here
P883, Michael Smith, 1991
L672, Jane Collins, 1992(added)(empty line here)
L322, Randy Green, 1992
H732, Justin ... | How to check a string for emptyness or length zero | I recently asked a question about converting list of values from txt file to dictionary list. You can see it from the link here: See my question here
P883, Michael Smith, 1991
L672, Jane Collins, 1992(added)(empty line here)
L322, Randy Green, 1992
H732, Justin Wood, 1995(/added)
^key ^name ^year of birth
... | [
"Check for empty lines inside your for-loop and skip them:\nfor line in infile:\n line = line.strip()\n if not line:\n continue\n parts = [p.strip() for p in line.split(\",\")]\n students[parts[0]] = (parts[1], parts[2])\n\n",
"Check for an empty line by either counting the elements of parts (i... | [
7,
0,
0,
0
] | [] | [] | [
"dictionary",
"python",
"split",
"strip"
] | stackoverflow_0005473154_dictionary_python_split_strip.txt |
Q:
Environment for quickly developing routing protocol prototype
I am doing research on routing protocols. Currently I perform simulations written in Python of a new protocol. The next step would be to build a real prototype which can really run on top of a Linux-based operating system (as a routing daemon such as ... | Environment for quickly developing routing protocol prototype | I am doing research on routing protocols. Currently I perform simulations written in Python of a new protocol. The next step would be to build a real prototype which can really run on top of a Linux-based operating system (as a routing daemon such as ospfd).
What would be a well-suited programming environment/languag... | [
"If you're primarily interested in how your protocol will interact with itself, and don't want to think about implementation details like what packets look like, you might have great luck with Erlang. Sending arbitrary messages across a (real or imaginary) network is an essential feature of the language. So if you... | [
3,
1,
1
] | [] | [] | [
"erlang",
"network_programming",
"protocols",
"python",
"routing"
] | stackoverflow_0005465010_erlang_network_programming_protocols_python_routing.txt |
Q:
how to write into XLS with python with format unchanged?
Is there a way to write something into an XLS file with python while keeping the initial format of this XLS file unchanged (such as font size, cell background color, etc)Thanks!
A:
Maybe have a look at xlrd, xlwt, xlutils:
http://www.python-excel.org/
I h... | how to write into XLS with python with format unchanged? | Is there a way to write something into an XLS file with python while keeping the initial format of this XLS file unchanged (such as font size, cell background color, etc)Thanks!
| [
"Maybe have a look at xlrd, xlwt, xlutils: \nhttp://www.python-excel.org/\nI have found it pretty useful in the past.\n",
"If you can go for XML serializations of Office documents. Also have a look at ... http://www.python-excel.org/\n",
"You could also use pywin32 if you are using Windows\n",
"If the availa... | [
2,
0,
0,
0
] | [] | [] | [
"format",
"python",
"xls"
] | stackoverflow_0005473301_format_python_xls.txt |
Q:
Ping a website address to return an IP
Hey, i'm new to python programing and i have problem that i can't decifer the answer to though a google search.
I need to ping a website address (eg www.google.com) and have python return me a IP address.
Cheers
A:
you want to do a "DNS lookup" :
import socket
print socket... | Ping a website address to return an IP | Hey, i'm new to python programing and i have problem that i can't decifer the answer to though a google search.
I need to ping a website address (eg www.google.com) and have python return me a IP address.
Cheers
| [
"you want to do a \"DNS lookup\" :\nimport socket\nprint socket.gethostbyname('www.google.com')\n\nOutput:\n74.125.230.112\n\nEDIT:\nFor IPv6 support, you can use getaddrinfo(). However, I'm not sure that is what you want ;)\n",
"You want to do an NS lookup?\n>>> import socket\n>>> print socket.getaddrinfo('www.... | [
12,
1
] | [] | [] | [
"python"
] | stackoverflow_0005473548_python.txt |
Q:
Query for items using filter for most recent entry in a related table
Hello I seem be having a problem with querying. I have a list of items. Any Item can have a status set to it (In, out, Collected, Destroyed, etc.). Here is my views.
def client_summary(request, client_id):
client = None
items = None
try... | Query for items using filter for most recent entry in a related table | Hello I seem be having a problem with querying. I have a list of items. Any Item can have a status set to it (In, out, Collected, Destroyed, etc.). Here is my views.
def client_summary(request, client_id):
client = None
items = None
try:
client = models.Client.objects.get(pk = client_id)
items = client... | [
"If you want a queryset of the items that belong to a client and are destroyed:\nclients_destroyed_items = StorageItem.objects.filter(client=client, \n itemstatushistory__status__description='destroyed')\n\n\nLookups that span relationships¶\nDjango offers a powerful and intuitive\n way to \"follow\" relationsh... | [
0,
0
] | [] | [] | [
"django",
"html",
"models",
"python"
] | stackoverflow_0005473130_django_html_models_python.txt |
Q:
How to validate person names? - Python/Django
I wish to create a validator for full names for one of my forms.
Unfortunately I am not sure the best way to go on about is, as it is not as trivial as:
if not char in string.letters + " .'":
raise ValidationError("...")
Thought a regex would work, but \w, [:alpha... | How to validate person names? - Python/Django | I wish to create a validator for full names for one of my forms.
Unfortunately I am not sure the best way to go on about is, as it is not as trivial as:
if not char in string.letters + " .'":
raise ValidationError("...")
Thought a regex would work, but \w, [:alpha:], [a-zA-Z] don't really capture special character... | [
"Don't.\nPlease, read this carefully: Falsehoods Programmers Believe About Names.\n",
"I don't think it is a good idea. \nWhat kind of names would you like to exclude? There is no international list of allowed characters for names and there is not much reason to disallow specific characters. \n",
"I personally ... | [
12,
2,
1,
0
] | [] | [] | [
"django",
"python",
"regex",
"validation"
] | stackoverflow_0005473480_django_python_regex_validation.txt |
Q:
How do I install pysvg using easy_install?
I am a hardcore C programmer and I want to learn python. I am trying to write a script to generate SVG files. If I can't get this to work then I will just kill a few kittens and write C program to perform this task.
I want to use the pysvg library. Actually, I'm not marri... | How do I install pysvg using easy_install? | I am a hardcore C programmer and I want to learn python. I am trying to write a script to generate SVG files. If I can't get this to work then I will just kill a few kittens and write C program to perform this task.
I want to use the pysvg library. Actually, I'm not married to that particular library. Is there a better... | [
"do me the favor and try it once more with easy_install. It should work now, as i uploaded the main binary zip file to PyPI.\nI must admit I neglected the installation procedure of pysvg quite a lot because:\n-Most users (so far) preferred to fetch the sources directly from the repository\n-I never have to install ... | [
5,
2,
2,
2
] | [] | [] | [
"easy_install",
"python",
"svg"
] | stackoverflow_0005454534_easy_install_python_svg.txt |
Q:
Type error problem with django, apache and mod_wsgi
I've this problem with my django code.
TypeError at /conto/partitario/cerca/
unsupported operand type(s) for +: 'Decimal' and 'Decimal'
Request Method: GET
Request URL: http://myurl.com/cerca/
Exception Type: TypeError
Exception Value:
unsuppor... | Type error problem with django, apache and mod_wsgi | I've this problem with my django code.
TypeError at /conto/partitario/cerca/
unsupported operand type(s) for +: 'Decimal' and 'Decimal'
Request Method: GET
Request URL: http://myurl.com/cerca/
Exception Type: TypeError
Exception Value:
unsupported operand type(s) for +: 'Decimal' and 'Decimal'
On my... | [
"After some research i find a tip on this ticket http://code.djangoproject.com/ticket/10933 and i apply this patch. For four days my software goes fine but yesterday the error come back!!!\nHere my code:\nmovim = \nconto.movimentocont_set.filter(testata__data_registrazione__lte=data2,testata__data_registrazione__gt... | [
0
] | [] | [] | [
"apache",
"decimal",
"django",
"mod_wsgi",
"python"
] | stackoverflow_0005433958_apache_decimal_django_mod_wsgi_python.txt |
Q:
scapy: UDP defragmentation timestamp problem
i use the following script (python + scapy) to create a defragmented version of a pcap file that contains fragmented UDP packets.
# Read pcap file
in=rdpcap("in.pcap")
# Defragment ...
out = defragment(in)
# Write defragmented pcap file
wrpcap ("out.pcap", out)
My pr... | scapy: UDP defragmentation timestamp problem | i use the following script (python + scapy) to create a defragmented version of a pcap file that contains fragmented UDP packets.
# Read pcap file
in=rdpcap("in.pcap")
# Defragment ...
out = defragment(in)
# Write defragmented pcap file
wrpcap ("out.pcap", out)
My problem is that the pcap timestamps of defragmented ... | [
"Here is a patch to inet.py that adds the capture date of the 1st fragment to the defragmented packet.\nThere is probably cleaner solutions, such as modifying Packet.copy() method and some others, but hey, it fits the bill ...\n*** inet.py 2011-03-29 14:01:19.000000000 +0000\n--- inet.py.orig 2011-03-29 ... | [
2
] | [] | [] | [
"pcap",
"python",
"scapy",
"udp"
] | stackoverflow_0005422432_pcap_python_scapy_udp.txt |
Q:
Including CAPTCHA on user registration page with Django
I am a Django newbie. I created an app which has a user login/registration page. Now I want to include CAPTCHA also in the registration page. Can somebody guide me how to implement this in Django as i am quite new to it. On googling I found there are many mod... | Including CAPTCHA on user registration page with Django | I am a Django newbie. I created an app which has a user login/registration page. Now I want to include CAPTCHA also in the registration page. Can somebody guide me how to implement this in Django as i am quite new to it. On googling I found there are many modules which do the function out of the box. If this is the way... | [
"Your question about which 3rd party solution is \"better\" is subjective, and stackoverflow doesn't generally like to answer subjective questions. Take some time and evaluate each in light of your needs.\nYou often don't need a fancy image captcha. Even a simple question like \"what color is an orange?\" will stop... | [
3,
2,
1,
1
] | [] | [] | [
"captcha",
"django",
"django_models",
"django_templates",
"python"
] | stackoverflow_0005473340_captcha_django_django_models_django_templates_python.txt |
Q:
program that finds results of two digits python
Write a program that finds two digit A and B (dont search the web,
and dont try 'manually') so that we get a two digit number AB (say
A = 8, B = 9 then the number is 89) and so that AB*AB = CAB for
some digit C. Thus if you square AB you get a 3 digit number. The
two... | program that finds results of two digits python | Write a program that finds two digit A and B (dont search the web,
and dont try 'manually') so that we get a two digit number AB (say
A = 8, B = 9 then the number is 89) and so that AB*AB = CAB for
some digit C. Thus if you square AB you get a 3 digit number. The
two last digits in AB^2 are AB but the first digit is so... | [
"In pseudo-code, you could simply do something like:\ndef findAB (c):\n c = c multiplied by 100\n for a in 0..9: # or possibly 1..9\n for b in 0..9:\n set ab to a multiplied by 10 plus b\n if (ab multiplied by ab) is equal to (c plus ab):\n return (a,b)\n return ... | [
2,
2,
0
] | [] | [] | [
"python",
"user_input"
] | stackoverflow_0005467471_python_user_input.txt |
Q:
simple question on dice poker in python
I'm following along a textbook example of building a dice poker game. Below is a snippet of code I don't quite understand but it does work. So in the while loop under the run method, the second condition is that the wantToPlay method in the TextInterface class must be true... | simple question on dice poker in python | I'm following along a textbook example of building a dice poker game. Below is a snippet of code I don't quite understand but it does work. So in the while loop under the run method, the second condition is that the wantToPlay method in the TextInterface class must be true, correct? But when I look at the wantToPlay... | [
"This returns a boolean:\nreturn ans[0] in \"yY\"\n\nThink of it as saying:\nif ans[0] in \"yY\":\n return True\nelse:\n return False\n\n",
"It does return a boolean, try this:\nans = 'Yes'\nans[0] in 'yY'\n\nThat resolves to True. It is evaluating whether the first character in string ans is Y or y.\n"
] | [
4,
1
] | [] | [] | [
"dice",
"poker",
"python"
] | stackoverflow_0005474624_dice_poker_python.txt |
Q:
What is the Image API of WordPress
I am writing a migrating script to move blog posts from an unknown blog to WordPress, and I want to host those images on WordPress. For the texts, I can write them into the ".wxr" file. I found some related topics saying importing pictures cannot be done automatically. Looking fo... | What is the Image API of WordPress | I am writing a migrating script to move blog posts from an unknown blog to WordPress, and I want to host those images on WordPress. For the texts, I can write them into the ".wxr" file. I found some related topics saying importing pictures cannot be done automatically. Looking forward to any clarification.
p.s. If ther... | [] | [] | [
"There are plugins that help the second stage of your import. The idea is to (1) import your blog posts via wxr. Doing so will leave hotlinked images in blog posts, pointing to the old location.\nAt that point, (2) run a image migration plugin and it will hopefully do what you want it to (physically move file, inse... | [
-1
] | [
"image",
"import",
"migration",
"python",
"wordpress"
] | stackoverflow_0005450013_image_import_migration_python_wordpress.txt |
Q:
Can't render data from GAE datastore with Jinja2
I can't realize what I do wrong. I have some entries in GAE datastore. I have Jinja2 imported. I want to show datastore entries on the page using Jinja2. I have created a shortcut function to call Jinja2 render function. It looks like this:
def render_template(respo... | Can't render data from GAE datastore with Jinja2 | I can't realize what I do wrong. I have some entries in GAE datastore. I have Jinja2 imported. I want to show datastore entries on the page using Jinja2. I have created a shortcut function to call Jinja2 render function. It looks like this:
def render_template(response, template_name, vars=dict()):
template_dirs = ... | [
"You're passing a list of entities to your render_template function instead of passing a dict. Try something like utils.render_template(self, 'persons.html', {'persons': persons})\n"
] | [
2
] | [] | [] | [
"google_app_engine",
"jinja2",
"python"
] | stackoverflow_0005474870_google_app_engine_jinja2_python.txt |
Q:
using result of a python script to invoke shutdown in terminal(ubuntu)
I've wrote a python script to check whether a condition has been fulfilled(in this case, the condition is a tweet).
Now, I want the computer to shutdown if the condition has been fulfilled. How do I use the result Python provides to invoke a s... | using result of a python script to invoke shutdown in terminal(ubuntu) | I've wrote a python script to check whether a condition has been fulfilled(in this case, the condition is a tweet).
Now, I want the computer to shutdown if the condition has been fulfilled. How do I use the result Python provides to invoke a shutdown command in Ubuntu?
| [
"os.system('shutdown -h now')\n\n?\n",
"import os\n\nif condition:\n os.system(\"shutdown -h now\")\n\nJust make sure the user running the script has privileges to call shutdown.\n",
"You can write a simple bash script that checks the result of your python program, and uses the terminal command \"shutdown -h n... | [
2,
0,
0
] | [] | [] | [
"python",
"shutdown",
"ubuntu"
] | stackoverflow_0005475186_python_shutdown_ubuntu.txt |
Q:
Some questions about python list element and list comprehensions
Come straight to the point. A list e.g. lst = [1, 1, 1, 0, 0, 0], now I want to change 1 into 0 as lst = [0, 0, 0, 0, 0, 0].
My original solution likes below:
for item in lst:
if item == 1:
item = 0
Actually, the result list is still ... | Some questions about python list element and list comprehensions | Come straight to the point. A list e.g. lst = [1, 1, 1, 0, 0, 0], now I want to change 1 into 0 as lst = [0, 0, 0, 0, 0, 0].
My original solution likes below:
for item in lst:
if item == 1:
item = 0
Actually, the result list is still lst = [1, 1, 1, 0, 0, 0].
Q1: Is there any other solutions to solve i... | [
"You could do:\nfor x, item in enumerate(lst):\n if item == 1:\n lst[x] = 0\n\nThis works because enumerate returns an iterator that yields a tuple of (index, item)\nThis way you can check the value of the item, but also know what index you are currently on so you can edit the reference.\nAnd to answer nu... | [
3,
3,
1,
1,
0,
0,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0005475384_python.txt |
Q:
Django: URLField model field exceptions
I've a model called urls (see below), how to handle some sort of link does not exists exception if I set verify_exists = True?
If the given link does not exist then this form is being invalid.
class Urls(models.Model):
title = models.CharField(max_length = 100)
link... | Django: URLField model field exceptions | I've a model called urls (see below), how to handle some sort of link does not exists exception if I set verify_exists = True?
If the given link does not exist then this form is being invalid.
class Urls(models.Model):
title = models.CharField(max_length = 100)
link = models.URLField(verify_exists = True, ver... | [
"You will probably need to overwrite the clean() method for that particular field in the form\nhttp://docs.djangoproject.com/en/dev/ref/forms/validation/\n"
] | [
1
] | [] | [] | [
"django",
"django_models",
"exception_handling",
"python"
] | stackoverflow_0005475353_django_django_models_exception_handling_python.txt |
Q:
How do I remove 2nd and rest digits after a period from column one of lines?
How do I remove 2nd and rest digit after the period from column one?
For example,
HP_000083.21423 N -1 NO 99.8951% 0.000524499999999983
NP_075561.1_1908 N -1 NO 99.9697% 0.000151499999999971
I would like to remove "_... | How do I remove 2nd and rest digits after a period from column one of lines? | How do I remove 2nd and rest digit after the period from column one?
For example,
HP_000083.21423 N -1 NO 99.8951% 0.000524499999999983
NP_075561.1_1908 N -1 NO 99.9697% 0.000151499999999971
I would like to remove "_1908" from "NP_075561.1_1908"
and "1423 from "HP_000083.21423"
without removing o... | [
"I'd avoid using regular expressions in this case. You can easily make do with standard string methods:\nfor line in infile:\n first_col, rest = line.split(\" \", 1)\n first_col = first_col[:first_col.index(\".\") + 2]\n output_line = str.join(\" \", (first_col, rest))\n outfile.write(output_line)\n\n"... | [
5,
0
] | [] | [] | [
"python"
] | stackoverflow_0005475923_python.txt |
Q:
What's an easy to use API for plotting latitude/longitude pairs on a world map?
I have a list of 50000 latitude/longitude pairs and want to plot them on a map. I tried http://gsl-nagoya-u.net/appendix/software/worldmap/. It works but it seems to ignore the data after a certain point (less than 100). What else can ... | What's an easy to use API for plotting latitude/longitude pairs on a world map? | I have a list of 50000 latitude/longitude pairs and want to plot them on a map. I tried http://gsl-nagoya-u.net/appendix/software/worldmap/. It works but it seems to ignore the data after a certain point (less than 100). What else can I use to generate a static image? I'd rather not use Javascript.
| [
"Perl has GD::Map in CPAN which looks about right. I haven't used it myself to say for sure, but its the closest thing I could find based on your requirements.\n",
"You can use the google maps static image api, it has a 1000 images/day limit, but you could get it in 5 50 days. Script the creation of the links an... | [
2,
1,
0,
0
] | [] | [] | [
"geolocation",
"gis",
"perl",
"python"
] | stackoverflow_0005199071_geolocation_gis_perl_python.txt |
Q:
Start a process in a different console window
How can I start a process to run in a different console window using Python in Linux, something similar to this in windows(using start):
import os
os.system('start dir c:\*.* /s')
A:
xterm -e should do the trick for you.
-e program [ arguments ... ]
This option sp... | Start a process in a different console window | How can I start a process to run in a different console window using Python in Linux, something similar to this in windows(using start):
import os
os.system('start dir c:\*.* /s')
| [
"xterm -e should do the trick for you.\n\n-e program [ arguments ... ]\nThis option specifies the program (and its command line arguments) to be\nrun in the xterm window. It also sets\nthe window title and icon name to be\nthe basename of the program being\nexecuted if neither -T nor -n are\ngiven on the command li... | [
2
] | [] | [] | [
"python"
] | stackoverflow_0005476239_python.txt |
Q:
Python and FeedParser question
I'm new to Python. I have this code using Feedparser:
import feedparser
d = feedparser.parse('http://pplware.sapo.pt/feed/')
i = range(10)
for i in range(10):
updates = [{"url": d.entries[i].link, "msg": d.entries[i].summary + ", "}]
My question.
How can I add to the variable... | Python and FeedParser question | I'm new to Python. I have this code using Feedparser:
import feedparser
d = feedparser.parse('http://pplware.sapo.pt/feed/')
i = range(10)
for i in range(10):
updates = [{"url": d.entries[i].link, "msg": d.entries[i].summary + ", "}]
My question.
How can I add to the variable "updates" the 10 entries?
Best Rega... | [
"import feedparser\n\nd = feedparser.parse('http://pplware.sapo.pt/feed/') \nupdates = []\nfor i in range(10):\n updates.append({\"url\": d.entries[i].link, \"msg\": d.entries[i].summary + \", \"})\n\nIn your for loop, you append the dictionnary result to the updates list. 'updates' contains 10 elements after... | [
1,
0
] | [] | [] | [
"feedparser",
"python"
] | stackoverflow_0005476212_feedparser_python.txt |
Q:
get information from web page
i want to make script to get information from web page the information first that is page http://whois.arin.net/rest/nets;q=74.125.232.147?showDetails=true&showARIN=false
so i want to get the NetRange and Name and CIDR ,so i made this code
import sys,urllib,re
J="http://whois.arin.net... | get information from web page | i want to make script to get information from web page the information first that is page http://whois.arin.net/rest/nets;q=74.125.232.147?showDetails=true&showARIN=false
so i want to get the NetRange and Name and CIDR ,so i made this code
import sys,urllib,re
J="http://whois.arin.net/rest/nets;q=74.125.232.147?showDet... | [
"B is a re match object. What you actually want is the value of the table cell next to the one that says \"NetRange\". For that, you can use an HTML/XML parser like Beautiful Soup.\nAlso, a note on style since the fact that this is homework suggests you're new to programming: Meaningful variable names are worth the... | [
4,
0,
0
] | [] | [] | [
"html",
"python",
"search"
] | stackoverflow_0005476401_html_python_search.txt |
Q:
Making a shopping cart in Python
I am learning Python, and I'm am trying to make a shopping cart (for practice). But I got kinda stuck here:
# Vars
budget = 200; # Budget
total = 0; # Total price
prices = { # Price list
"cola":22,
"chips":18,
"headset":800,
"pencil":5
}
cart = [] # Shopping cart
w... | Making a shopping cart in Python | I am learning Python, and I'm am trying to make a shopping cart (for practice). But I got kinda stuck here:
# Vars
budget = 200; # Budget
total = 0; # Total price
prices = { # Price list
"cola":22,
"chips":18,
"headset":800,
"pencil":5
}
cart = [] # Shopping cart
while True:
cmd = raw_input("Enter ... | [
"Homework?\nYour data structures are a little odd. You probably want the cart to be a list of tuples or something, with each tuple being item, quantity, or even item, quantity, subtotal. However.\nif cmd == \"additem\":\n item = raw_input(\"Enter item name: \")\n cart.append(item)\n\n#at the end\nfor item in ... | [
3,
1,
1
] | [] | [] | [
"dictionary",
"python",
"shopping_cart"
] | stackoverflow_0005476351_dictionary_python_shopping_cart.txt |
Q:
how to leave a computed field alone when writing to db using Elixir session.commit()
I am using Elixir to connect to MSSQL database. The database has a table with a computed column in it. However, when I update other columns in the object and commit the changes, python tells me I can't insert to the computed colu... | how to leave a computed field alone when writing to db using Elixir session.commit() | I am using Elixir to connect to MSSQL database. The database has a table with a computed column in it. However, when I update other columns in the object and commit the changes, python tells me I can't insert to the computed column.
I am using autoload so in my model:
class Slot(Entity):
using_options(tablename='t... | [
"Ehhh, I'm not a Python programmer, but it appears that this line:\nusing_options(tablename='tbScheduleSlots', autoload=True)\n\nwhich is using autoload is probably what is adding [EndDateTime] to the INSERT statement (as shown in your error message). Looks like that is the line that tells Python the metadata of th... | [
0
] | [] | [] | [
"python",
"python_elixir",
"sql_server"
] | stackoverflow_0005474642_python_python_elixir_sql_server.txt |
Q:
.startswith not working
In My program I have a file and then I read through all the lines in a for loop checking each line for what it begins with. Then adding each line as a variable. There are a little over 40 lines in this and they are all pretty much the same but one of the elif statements doesnt return true t... | .startswith not working | In My program I have a file and then I read through all the lines in a for loop checking each line for what it begins with. Then adding each line as a variable. There are a little over 40 lines in this and they are all pretty much the same but one of the elif statements doesnt return true the .startswith isnt working. ... | [
"You should think about how these two lines interact:\nelif line.startswith('c'):\n...\nelif line.startswith('cP'):\n\nAlso, you should look into using a dictionary to hold all your values, you could drastically shorten your program.\n",
"That's a pretty horrible chunk of code. Do you really need all those elemen... | [
8,
6,
4,
3,
0
] | [] | [] | [
"file_io",
"for_loop",
"if_statement",
"python"
] | stackoverflow_0005475472_file_io_for_loop_if_statement_python.txt |
Q:
where to download Hulahop module?
in this page Embedding XULRunner into a pyGTK application looks can embed a XULApp into a pyGTK application,but i can't find the hulahop module.and where can i find it thanks
A:
This is part of the http://www.sugarlabs.org project. You can find a link to the Git repository on th... | where to download Hulahop module? | in this page Embedding XULRunner into a pyGTK application looks can embed a XULApp into a pyGTK application,but i can't find the hulahop module.and where can i find it thanks
| [
"This is part of the http://www.sugarlabs.org project. You can find a link to the Git repository on the Dev. Modules page.\nRemember to check if your distro already has packages for this already if you're on Linux - quite a few do.\n"
] | [
1
] | [] | [] | [
"embed",
"pygtk",
"python",
"xulrunner"
] | stackoverflow_0005477240_embed_pygtk_python_xulrunner.txt |
Q:
wxpython disable Context Menu in TextCtrl
Hey. I am trying to disable the Context Menu in a TextCtrl widget under wxpython (prevent the context menu from coming up when right clicked). If I create my on Menu and bind it to the right mouse click it will always show my menu but if I dont create menu under right mous... | wxpython disable Context Menu in TextCtrl | Hey. I am trying to disable the Context Menu in a TextCtrl widget under wxpython (prevent the context menu from coming up when right clicked). If I create my on Menu and bind it to the right mouse click it will always show my menu but if I dont create menu under right mouse click event it automatically creates a standa... | [
"Try this (I'm on Python 2.7): \nimport wx\n\nclass Test(wx.Frame):\n def __init__(self, parent):\n wx.Frame.__init__(self, parent, title='Test', size = (700,500))\n\n self.screen = wx.TextCtrl(self, wx.ID_ANY, style = wx.TE_MULTILINE)\n self.screen.Bind(wx.EVT_CONTEXT_MENU, self.skip)\n\n ... | [
2
] | [] | [] | [
"python",
"wxpython"
] | stackoverflow_0004038858_python_wxpython.txt |
Q:
Invoke Lua/Python Scripts in Android App
I need to invoke Lua/Python Scripts from a String or a File with the possibility to bind Java objects, so I can use them directly inside the script.
Something like:
e.bind("varname", object);
e.call("object.toString()");
Unfortunately Jython, which is perfect for my purpos... | Invoke Lua/Python Scripts in Android App | I need to invoke Lua/Python Scripts from a String or a File with the possibility to bind Java objects, so I can use them directly inside the script.
Something like:
e.bind("varname", object);
e.call("object.toString()");
Unfortunately Jython, which is perfect for my purposes, does not work on the dalvik vm.
I also tri... | [
"Assuming SL4A does not meet your needs, you will need to turn Python into a library (Lua already is one) and attach it your your application via the NDK.\nAnd, as neither Lua nor Python know anything about Java, so you will have to write the glue code to connect your Java objects up to the Lua and Python scripts. ... | [
1,
0
] | [] | [] | [
"android",
"lua",
"python",
"scripting"
] | stackoverflow_0005476671_android_lua_python_scripting.txt |
Q:
sys.excepthook doesn't work in imported modules
I am trying to design a Python program that logs all uncaught exceptions using the logging module. I am doing this by using the sys.excepthook function to override the default exception handling. I noticed that if I run the program directly from the command line, it ... | sys.excepthook doesn't work in imported modules | I am trying to design a Python program that logs all uncaught exceptions using the logging module. I am doing this by using the sys.excepthook function to override the default exception handling. I noticed that if I run the program directly from the command line, it works fine, but if I try to import the file, it doesn... | [
"I reported this issue as a bug on the Python bug tracker. So far, someone responded that there is definitely a change between Python 2.7 and 2.7.1 and he thinks this is expected behavior. He suggested something like this to log all exceptions:\ndef handleException(excType, excValue, traceback, logger=logger):\n ... | [
4,
2
] | [] | [] | [
"exception",
"logging",
"python"
] | stackoverflow_0005451746_exception_logging_python.txt |
Q:
HTML/CSS/JS Syntax Highlighting in Eclipse
Hello How can I enable syntax highlighting for HTML/CSS/JS in Eclipse I am mainly developing in python using the PyDev package but right now I am creating Cheetah templates and they are very hard to read unhighlighted.
Any plugin/package suggestions related to Cheetah or ... | HTML/CSS/JS Syntax Highlighting in Eclipse | Hello How can I enable syntax highlighting for HTML/CSS/JS in Eclipse I am mainly developing in python using the PyDev package but right now I am creating Cheetah templates and they are very hard to read unhighlighted.
Any plugin/package suggestions related to Cheetah or just highlighting any file as html would be grea... | [
"\nCan I somehow trick Eclipse into treating .tmpl files as if they were .html?\n\nIt's not a trick.\nUnder Windows -> Preferences, General -> Editors -> File Associations, you can associate *.tmpl files with your HTML editor.\n"
] | [
5
] | [] | [] | [
"cheetah",
"eclipse",
"html",
"python",
"syntax"
] | stackoverflow_0005477078_cheetah_eclipse_html_python_syntax.txt |
Q:
getting files off ftp connection
I have been given a project where i need to write a program which runs on a server. This program needs to open an ftp connection to another server and pick up a file and place it in a given folder.
I dont know where to start although i think i need some sort of socket prgramming..... | getting files off ftp connection | I have been given a project where i need to write a program which runs on a server. This program needs to open an ftp connection to another server and pick up a file and place it in a given folder.
I dont know where to start although i think i need some sort of socket prgramming... can anyone help me with where to sta... | [
"\nWith Java, I would start from Apache Commons FTPClient.\nWith Python, I would start form ftplib.\nWith C++, you may find the answer here on SO.\n\n",
"If Java is available, ftp4j may be a good choice.\n\nhttp://www.sauronsoftware.it/projects/ftp4j/\n",
"This should help for Java: Apache commons net\n",
"Yo... | [
3,
2,
1,
0,
0
] | [] | [] | [
"c++",
"java",
"python",
"sockets"
] | stackoverflow_0005468889_c++_java_python_sockets.txt |
Q:
Python docstring parsing(and generally parsing languages in Python)
I would like to generate useful documentation for a REST API written in Python.
I imagine it should be something like this:
'''
/kittens/
This method creates kittens in the browser
HTTP Params:
format(default=json): The format in which kitt... | Python docstring parsing(and generally parsing languages in Python) | I would like to generate useful documentation for a REST API written in Python.
I imagine it should be something like this:
'''
/kittens/
This method creates kittens in the browser
HTTP Params:
format(default=json): The format in which kittens will be generated.
count(default=10): The number of kittens to ge... | [
"http://sphinx.pocoo.org/\nIts a online documentation tool. Its awesome and it will do exactly what you want.\n",
"I'm not sure I understand exactly what you want, but reStructuredText can be used to capture the information in your example:\n.. method:: kittens(format=\"json\", count=10)\n\n Creates kittens in ... | [
0,
0
] | [] | [] | [
"docstring",
"parsing",
"python"
] | stackoverflow_0005474375_docstring_parsing_python.txt |
Q:
Python selected libraries
I am running RHEL5 , and i have python 2.4 installed on it.Please dont ask why the native version?
My question is that in my home directory i want to install python2.6 with selected packages only and also most importantly i dont want any of the library os or any other which deals with sys... | Python selected libraries | I am running RHEL5 , and i have python 2.4 installed on it.Please dont ask why the native version?
My question is that in my home directory i want to install python2.6 with selected packages only and also most importantly i dont want any of the library os or any other which deals with system calls or mail box preferenc... | [
"This may not be quite what you're looking for... but the following steps will accomplish something similar to this (if you have root access). The below steps assume you are on i386 architecture.\n1) Install Python 2.6 in parallel on your system (requires root). It is available at the EPEL repository:\n$ rpm -i htt... | [
1,
1
] | [] | [] | [
"python",
"python_2.6",
"redhat",
"rhel5"
] | stackoverflow_0005477222_python_python_2.6_redhat_rhel5.txt |
Q:
Early Django Admin Logout
I'm working on a Django 1.2.3 project, and I'm finding that the admin session seems to timeout extremely early, after about a minute after logging in, even while I'm using it.
Initially, I had these settings:
SESSION_COOKIE_AGE=1800
SESSION_EXPIRE_AT_BROWSER_CLOSE=True
I thought the prob... | Early Django Admin Logout | I'm working on a Django 1.2.3 project, and I'm finding that the admin session seems to timeout extremely early, after about a minute after logging in, even while I'm using it.
Initially, I had these settings:
SESSION_COOKIE_AGE=1800
SESSION_EXPIRE_AT_BROWSER_CLOSE=True
I thought the problem might be my session storage... | [
"Caching sessions in locmem:// means that you lose the session whenever the python process restarts. If you're running under the dev server, that would be any time you save a file. In a production environment, that will vary based on your infrastructure - mod_wsgi in apache, for example, will restart python after... | [
3
] | [] | [] | [
"django",
"django_admin",
"python"
] | stackoverflow_0004648030_django_django_admin_python.txt |
Q:
Ignoring duplicate words in a python dictionary
I have a Python script that takes in '.html' files removes stop words and returns all other words in a python dictionary. But if the same word occurs in multiple files I want it to return only once. i.e. contain non-stop words, each only once.
def run():
filelist... | Ignoring duplicate words in a python dictionary | I have a Python script that takes in '.html' files removes stop words and returns all other words in a python dictionary. But if the same word occurs in multiple files I want it to return only once. i.e. contain non-stop words, each only once.
def run():
filelist = os.listdir(path)
regex = re.compile(r'.*<div class... | [
"Use a set. Simply add every word you find to the set; it ignores duplicates.\nAssuming you have an iterator that returns each word in a file (this is for plain text; HTML would be rather more complicated):\ndef words(filename):\n with open(filename) as wordfile:\n for line in wordfile:\n for w... | [
6
] | [] | [] | [
"dictionary",
"duplicates",
"python",
"regex",
"stop_words"
] | stackoverflow_0005478049_dictionary_duplicates_python_regex_stop_words.txt |
Q:
Google Code uploader script doesn't work out-of-the-box
I'm trying to run http://support.googlecode.com/svn/trunk/scripts/googlecode_upload.py .
It gives me this:
File "googlecode_upload.py", line 184
print 'Please enter your googlecode.com password.'
^
I'm qui... | Google Code uploader script doesn't work out-of-the-box | I'm trying to run http://support.googlecode.com/svn/trunk/scripts/googlecode_upload.py .
It gives me this:
File "googlecode_upload.py", line 184
print 'Please enter your googlecode.com password.'
^
I'm quite new to Python, but that line doesn't seem to have anything... | [
"At a guess: are you using Python 3? In Python 3, it would need to be:\nprint('Please enter your googlecode.com password.')\n\nThe script is written to be run in Python 2, so you may want to get 2.7. Python 3 is the up and coming thing in Python, but Python 2 is still more widely used.\n",
"Is this for Google App... | [
1,
1
] | [] | [] | [
"python"
] | stackoverflow_0005477777_python.txt |
Q:
django 1.3 UserProfile matching query does not exist
I have a small problem with User model, the model looks like this:
#! -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
class UserProfile(models.Model):
url = models.URLField(max_length = 70, blank = True, ver... | django 1.3 UserProfile matching query does not exist | I have a small problem with User model, the model looks like this:
#! -*- coding: utf-8 -*-
from django.db import models
from django.contrib.auth.models import User
class UserProfile(models.Model):
url = models.URLField(max_length = 70, blank = True, verbose_name = 'WWW')
home_address = models.TextField(b... | [
"Are you sure that UserProfile object for that user exists? Django doesn't automatically create it for you.\nWhat you probably want is this:\nu = User.objects.get(id=1)\nzm, created = UserProfile.objects.get_or_create(user = u)\n\nIf you're sure the profile exists (and you've properly set AUTH_PROFILE_MODULE), the... | [
8,
3
] | [] | [] | [
"authentication",
"django",
"python"
] | stackoverflow_0005477925_authentication_django_python.txt |
Q:
Use of OR as branch control in FP
I undertook an interview last week in which I learnt a few things about python I didn't know about (or rather realise how they could be used), first up and the content of this question is the use of or for the purposes of branch control.
So, for example, if we run:
def f():
#... | Use of OR as branch control in FP | I undertook an interview last week in which I learnt a few things about python I didn't know about (or rather realise how they could be used), first up and the content of this question is the use of or for the purposes of branch control.
So, for example, if we run:
def f():
# do something. I'd use ... but that's a... | [
"Your interviewers must have had a \"functional background\" way back. It used to be common to write\n(or (some-condition) (some-side-effect))\n\nbut in CL and in Scheme implementation that support it, it is much better written with unless. Same goes for and vs when.\nSo, to be more concrete -- it's not more func... | [
12,
6,
5,
2,
2,
0
] | [] | [] | [
"functional_programming",
"lisp",
"python",
"scheme"
] | stackoverflow_0005474514_functional_programming_lisp_python_scheme.txt |
Q:
returning data in python
I'm currently looking through the "Dive Into Python" to pick up the language and I was a bit confused about chapter 5's example 5.10. UserDict Normal Methods
Example 5.10. UserDict Normal Methods
def copy(self):
if self.__class__ is UserDict:
return UserDict(self.data)
impo... | returning data in python | I'm currently looking through the "Dive Into Python" to pick up the language and I was a bit confused about chapter 5's example 5.10. UserDict Normal Methods
Example 5.10. UserDict Normal Methods
def copy(self):
if self.__class__ is UserDict:
return UserDict(self.data)
import copy
return copy.copy(s... | [
"It returns a new UserDict object because .copy() is expected to return an object of the same type its copying.\n",
"In order to yield a copy, you should use UserDict(self.data).\nWhy we use UserDict(self.data) instead of self.data is that it returns new instance which is same class with self.\nIf you return only... | [
2,
1,
0
] | [] | [] | [
"python",
"return_type"
] | stackoverflow_0005478210_python_return_type.txt |
Q:
Python 2 or Python 3? Which should I begin with?
I found two "duplicate" questions, but considering they're about two years old, I figured it might be a good idea to see a more recent opinion.
I want to learn Python, but I don't know if I should start with Python 3 because it's newer, or if I should start with Pyt... | Python 2 or Python 3? Which should I begin with? | I found two "duplicate" questions, but considering they're about two years old, I figured it might be a good idea to see a more recent opinion.
I want to learn Python, but I don't know if I should start with Python 3 because it's newer, or if I should start with Python 2?
I come from a C#, Java, PHP, and HTML/CSS backg... | [
"There are few differences, but they are quite significant (strings vs bytes mostly).\nIf you wish to mess around, go for Python 3. If you wish to get something done, use Python 2.(7). There are few libraries that currently support Py3.\n",
"Really depends on what you want to do. Are the 3rd party libs you need ... | [
12,
5,
4,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0005478518_python.txt |
Q:
Python script hangs in loop
In one of my scripts I'm using the following infinite loop to check for an active internet connection:
def online_check():
try:
con = urllib2.urlopen("http://www.google.com/")
data = con.read()
logging.debug('{0} Reached the host. Exiting online_check'.format... | Python script hangs in loop | In one of my scripts I'm using the following infinite loop to check for an active internet connection:
def online_check():
try:
con = urllib2.urlopen("http://www.google.com/")
data = con.read()
logging.debug('{0} Reached the host. Exiting online_check'.format(time.strftime('[ %H:%M:%S ]')))
... | [
"You are running into infinite recursion, a method you can do to not have this happen is pass an argument into online_check for the maximum check.\nSuch as:\ndef online_check(max_checks=10, current_check=0):\n try:\n con = urllib2.urlopen(\"http://www.google.com/\")\n data = con.read()\n log... | [
4,
3,
2,
1
] | [] | [] | [
"freeze",
"loops",
"python"
] | stackoverflow_0005478699_freeze_loops_python.txt |
Q:
parsing out a second delimited data structure
I am reading in a .csv file similar to the following. Note that PhoneNumbers can contain multiple values delimited by the pipe character.
FirstName,LastName,PhoneNumbers
Bucky,Fuller,213.283.5555|714.345.5566
Stephen,Hawking,212.456.7897|312.345.6677|415.223.3423
Robe... | parsing out a second delimited data structure | I am reading in a .csv file similar to the following. Note that PhoneNumbers can contain multiple values delimited by the pipe character.
FirstName,LastName,PhoneNumbers
Bucky,Fuller,213.283.5555|714.345.5566
Stephen,Hawking,212.456.7897|312.345.6677|415.223.3423
Robert,Heinlein,562.457.8899
I am able to read in the... | [
"Why not split the phone number field?\nfor number in str(row.get('PhoneNumbers')).split('|'):\n file.write(\"\\t\\t\\t\\t<PHONENUM>\"+number+\"</PHONENUM>\\n\")\n\n",
"I haven't tested this, but I think it ought to take a string, chop it up into substrings based on the '|' delimiter, and return a list of such s... | [
1,
0
] | [] | [] | [
"python"
] | stackoverflow_0005478839_python.txt |
Q:
Why do I get TypeError in Threading in Python
I've got the following code which is based off an example i found here on SO, but when i run it i get an error. Please help, i'm sure its very simple:
def listener(port):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('',port))
sock.sett... | Why do I get TypeError in Threading in Python | I've got the following code which is based off an example i found here on SO, but when i run it i get an error. Please help, i'm sure its very simple:
def listener(port):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(('',port))
sock.settimeout(1) # n second(s) timeout
try:
wh... | [
"The error is coming from the following line:\nthreading.Thread(target=listener, args=(port)).start()\n\nThe args parameter needs to be a sequence, I think your intention is to use a tuple, but wrapping a single value in parentheses does not accomplish this. Here is what you need to change it to:\nthreading.Thread... | [
50,
8,
6,
3
] | [] | [] | [
"multithreading",
"python"
] | stackoverflow_0005479033_multithreading_python.txt |
Q:
Python: Imaplib error
import serial
import imaplib
from time import sleep
IMAP_SERVER='imap.gmail.com'
IMAP_PORT=993
ser= serial.Serial ('/dev/ttyACM0',9600)
while True:
M = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
rc, resp = M.login('user@gmail.com', 'Password')
print rc, resp
M.select()
f... | Python: Imaplib error | import serial
import imaplib
from time import sleep
IMAP_SERVER='imap.gmail.com'
IMAP_PORT=993
ser= serial.Serial ('/dev/ttyACM0',9600)
while True:
M = imaplib.IMAP4_SSL(IMAP_SERVER, IMAP_PORT)
rc, resp = M.login('user@gmail.com', 'Password')
print rc, resp
M.select()
for msg_num in M.search("INB... | [
"From the error message url (http://mail.google.com/support/bin/answer.py?answer=78754):\n\nMake sure your mail client isn't set\n to check for new mail too often. If\n your mail client checks for new\n messages more than once every 10\n minutes, your client might repeatedly\n request your username and passwor... | [
3
] | [] | [] | [
"gmail",
"gmail_imap",
"imaplib",
"python"
] | stackoverflow_0005479240_gmail_gmail_imap_imaplib_python.txt |
Q:
Longest Prefix Matches for URLs
I need information about any standard python package which can be used for "longest prefix match" on URLs. I have gone through the two standard packages http://packages.python.org/PyTrie/#pytrie.StringTrie & 'http://pypi.python.org/pypi/trie/0.1.1' but they don't seem to be useful f... | Longest Prefix Matches for URLs | I need information about any standard python package which can be used for "longest prefix match" on URLs. I have gone through the two standard packages http://packages.python.org/PyTrie/#pytrie.StringTrie & 'http://pypi.python.org/pypi/trie/0.1.1' but they don't seem to be useful for longest prefix match task on URLs.... | [
"Performance comparison\nsuffixtree vs. pytrie vs. trie vs. datrie vs. startswith -functions\nSetup\nThe recorded time is a minimum time among 3 repetitions of 1000 searches. A trie construction time is included and spread among all searches. The search is performed on collections of hostnames from 1 to 1000000 ite... | [
13,
12,
1,
1
] | [] | [] | [
"longest_prefix",
"python",
"trie",
"url"
] | stackoverflow_0005434813_longest_prefix_python_trie_url.txt |
Q:
bezier and matplotlib
Hi
I'm starting from http://matplotlib.sourceforge.net/users/path_tutorial.html . I'm looking a function to get all bezier points with a fixed sampling rate.
What I'm looking for is something like this:
interpolate(t, samplingrate)
where t is the curve parameter between 0 and 1, sampling ra... | bezier and matplotlib | Hi
I'm starting from http://matplotlib.sourceforge.net/users/path_tutorial.html . I'm looking a function to get all bezier points with a fixed sampling rate.
What I'm looking for is something like this:
interpolate(t, samplingrate)
where t is the curve parameter between 0 and 1, sampling rate is the length of the lis... | [
"The Path object does not store the points along a Bezier curve, just the minimum parameters it needs. Writing your own function shouldn't be hard. How about something like this, following the expressions from wikipedia.\ndef quadBrezPoints(P0, P2, P1, nSamples):\n ans = numpy.zeros((nSamples,2))\n for i in x... | [
3
] | [] | [] | [
"bezier",
"matplotlib",
"python"
] | stackoverflow_0005479134_bezier_matplotlib_python.txt |
Q:
Is there a Python module to "thaw" data frozen using Perl's Storable?
I have a legacy database which contains simple data structures (no CODE refs thank goodness) that have been written using the nfreeze method of the Storable module in Perl.
Now I have a need to load this data into a Python application. Does anyo... | Is there a Python module to "thaw" data frozen using Perl's Storable? | I have a legacy database which contains simple data structures (no CODE refs thank goodness) that have been written using the nfreeze method of the Storable module in Perl.
Now I have a need to load this data into a Python application. Does anyone know of a Python implementation of Storable's thaw? Google hasn't helped... | [
"It's not immediately clear to me how far along this project is, but it appears to aim to do what you want:\nhttps://pypi.org/project/storable/\n",
"If your first option doesn't work, another option would be to write a simple perl script to thaw the data, and then write it out in JSON or YAML or some format that ... | [
10,
6
] | [] | [] | [
"perl",
"python",
"serialization"
] | stackoverflow_0005479162_perl_python_serialization.txt |
Q:
Omitting values from certain keys in a dict
I am currently building a location-based service that calculates routes for users sharing cars to a specific event. In order to calculate the shortest distance, the driving distances between the users need to be known, because one of the constraints of the system is that... | Omitting values from certain keys in a dict | I am currently building a location-based service that calculates routes for users sharing cars to a specific event. In order to calculate the shortest distance, the driving distances between the users need to be known, because one of the constraints of the system is that each driver shouldn't go more than a certain dis... | [
"As this is Python, None is the null value. Compare to None using is None, not == None though.\n",
"Make your self.distances a dictionary mapping a (start_user, end_user) tuple to the info that you want. What you are doing involves O(N) accesses to list items just for a single lookup, instead just 1 dict lookup. ... | [
2,
2,
1
] | [] | [] | [
"dictionary",
"google_maps",
"python"
] | stackoverflow_0005479559_dictionary_google_maps_python.txt |
Q:
Python: How to do this string manipulation
Folks,
Might find this on searching, but need this rather quickly done:
I have the path like this: /mnt/path1/path2/path3/
I need to chown all the directories such as /mnt, /mnt/path1, /mnt/path1/path2, /mnt/path1/path2/path3, how to get this done in python?
I cannot do '... | Python: How to do this string manipulation | Folks,
Might find this on searching, but need this rather quickly done:
I have the path like this: /mnt/path1/path2/path3/
I need to chown all the directories such as /mnt, /mnt/path1, /mnt/path1/path2, /mnt/path1/path2/path3, how to get this done in python?
I cannot do 'chown -R /mnt/' since it tries to chown all the ... | [
"You could do something like this:\n>>> import os\n>>> path = \"abc/def/ghi\"\n>>> a = path.split(\"/\")\n>>> [os.path.join(*a[:i]) for i in range(1, len(a)+1)]\n['abc', 'abc/def', 'abc/def/ghi']\n\n",
"Quick 'n' dirty:\nstop = '/mnt/path1/path2/path3'\nfor (dir, subdirs, files) in os.walk('/mnt'):\n if dir[:l... | [
3,
2,
1
] | [] | [] | [
"python"
] | stackoverflow_0005479897_python.txt |
Q:
Symbol not found: _PEM_read_bio_EC_PUBKEY Importing M2Crypto-0.20.2 when compiled against openssl 0.9.8x or 1.0.0x
Importing M2Crypto version 0.20.2 on python 2.6.5 fails when M2Crypto was compiled against a recent openssl versions (0.9.8x or higher) on MAC OS X 10.4.11:
Even though the compilation works against t... | Symbol not found: _PEM_read_bio_EC_PUBKEY Importing M2Crypto-0.20.2 when compiled against openssl 0.9.8x or 1.0.0x | Importing M2Crypto version 0.20.2 on python 2.6.5 fails when M2Crypto was compiled against a recent openssl versions (0.9.8x or higher) on MAC OS X 10.4.11:
Even though the compilation works against these openssl version, M2Crypto fails to import, because a missing symbol: _PEM_read_bio_EC_PUBKEY
Python 2.6.5 (r265:79... | [
"I don't have 10.4.11, but I do have 10.5.8 with Python 2.6.5 and OpenSSL 0.9.8n and everything works without a problem. Please try with latest M2Crypto. If that does not work, try getting and compiling OpenSSL yourself and configuring M2Crypto to use that. Maybe something is wrong with your current OpenSSL.\n"
] | [
0
] | [] | [] | [
"m2crypto",
"openssl",
"python"
] | stackoverflow_0004280885_m2crypto_openssl_python.txt |
Q:
How to distinguish sender-generated carriage returns from word wrap auto-generated carriage returns in email body?
How can I distinguish sender-generated carriage returns from word wrap auto-generated carriage returns in an email body? I'm using Python imaplib to access Gmail and download message bodies like so:
u... | How to distinguish sender-generated carriage returns from word wrap auto-generated carriage returns in email body? | How can I distinguish sender-generated carriage returns from word wrap auto-generated carriage returns in an email body? I'm using Python imaplib to access Gmail and download message bodies like so:
user='whoever@gmail.com'
pwd='password'
m = imaplib.IMAP4_SSL("imap.gmail.com")
m.login(user,pwd)
m.select("INBOX")
resp,... | [
"Gmail sends messages in both the MIME multipart format, in both a text/plain version (what you are grabbing) and a text/html version. The latter version is what contains fancy formatting like bold, italic, links, etc., and is what Gmail displays. While the text/html version is also line-broken at 78 characters (a ... | [
1,
0
] | [] | [] | [
"email",
"gmail",
"python"
] | stackoverflow_0005475620_email_gmail_python.txt |
Q:
How to use a python package - shouldn't i be able to access anything listed in __all__?
I'm trying to use the pyupnp package (http://code.google.com/p/pyupnp/)
I've built and installed it and in my code I have:
import pyupnp
b = pyupnp.UpnpBase()
...
But I get this error: AttributeError: 'module' object has no at... | How to use a python package - shouldn't i be able to access anything listed in __all__? | I'm trying to use the pyupnp package (http://code.google.com/p/pyupnp/)
I've built and installed it and in my code I have:
import pyupnp
b = pyupnp.UpnpBase()
...
But I get this error: AttributeError: 'module' object has no attribute 'UpnpBase'
Now I had a look in the code for the package, and it has the following:
__... | [
"Looking at this package, you should import pyupnp.upnp, not pyupnp. The contents of __all__ are irrelevant here.\n"
] | [
3
] | [] | [] | [
"module",
"package",
"python",
"upnp"
] | stackoverflow_0005480354_module_package_python_upnp.txt |
Q:
apns-python-wrapper device token issues
To use the module apns-python-wrapper here: http://code.google.com/p/apns-python-wrapper/ you need to convert your iPhone's APNS device token, however, I'm not sure how to convert it.
Here is the fresh new token returned from the device: 8fa9c60685c158a3cf6f9c5de164b3817e68... | apns-python-wrapper device token issues | To use the module apns-python-wrapper here: http://code.google.com/p/apns-python-wrapper/ you need to convert your iPhone's APNS device token, however, I'm not sure how to convert it.
Here is the fresh new token returned from the device: 8fa9c60685c158a3cf6f9c5de164b3817e68a075fcfdafcd982aa4b3d2ca99c7
And this is what... | [
"Use the tokenHex(yourDeviceToken) method instead of token(yourDeviceToken) and it should work fine. I had the same problem and when I changed the method, it did the conversion inside this method. \n"
] | [
1
] | [] | [] | [
"apple_push_notifications",
"iphone",
"objective_c",
"python"
] | stackoverflow_0003150054_apple_push_notifications_iphone_objective_c_python.txt |
Q:
'Unexpected Section Title' with Sphinx -- is numpy the issue?
When running
sphinx-build . html/
in my doc/ directory, I get the following output:
$ sphinx-build . html/
Running Sphinx v0.6.4
No builder selected, using default: html
loading pickled environment... done
building [html]: targets for 0 source files th... | 'Unexpected Section Title' with Sphinx -- is numpy the issue? | When running
sphinx-build . html/
in my doc/ directory, I get the following output:
$ sphinx-build . html/
Running Sphinx v0.6.4
No builder selected, using default: html
loading pickled environment... done
building [html]: targets for 0 source files that are out of date
updating environment: 0 added, 1 changed, 0 remo... | [
"The subject is discussed in this thread: \nhttps://groups.google.com/d/msg/sphinx-users/MAFTlX8pAvk/B9hx7MuBVbIJ\nPierre GM says:\n\"fredrik, \nLooks like you're using thw numpy standard for your documentation. Consider \nthen using the numpydoc extensions that Pauli Virtanen implemented: it's \navailable here: ht... | [
5
] | [] | [] | [
"numpy",
"python",
"python_sphinx",
"restructuredtext"
] | stackoverflow_0003101281_numpy_python_python_sphinx_restructuredtext.txt |
Q:
How to go about creating a word count program?
The program should accept file names as input and then print three numbers showing:
the count of lines
count of words words
count of characters in the file.
Im really not sure where to start on this question. Please help.
A:
here's a pseudo-code to help you get st... | How to go about creating a word count program? | The program should accept file names as input and then print three numbers showing:
the count of lines
count of words words
count of characters in the file.
Im really not sure where to start on this question. Please help.
| [
"here's a pseudo-code to help you get started.\nopen file handle\nset counter_line=0\nset counter_word=0\nset counter_char=0\nwhile iterate file\n increment counter_line\n split line into array\n counter_word += length of split array\n counter_char += length of line\nend while\nclose file handle\n\n"
] | [
4
] | [] | [] | [
"python",
"python_3.x",
"word_count"
] | stackoverflow_0005480483_python_python_3.x_word_count.txt |
Q:
Sharing preferences between commandline and GUI programs
I am stymied by a seemingly simple problem. I have several preferences that I would like to access from a Cocoa app and a commandline python script. The preferences are mostly locations to things on disk. Since the locations build of each other ( $LOCA=$LO... | Sharing preferences between commandline and GUI programs | I am stymied by a seemingly simple problem. I have several preferences that I would like to access from a Cocoa app and a commandline python script. The preferences are mostly locations to things on disk. Since the locations build of each other ( $LOCA=$LOCB/stuff for example), using environment variables and somethi... | [
"As of Python 2.6, the plistlib module is available in standard Python. You can use this to read and write .plist files (and use NSPropertyListSerialization from Obj-C). Neither the NSPropertyListSerialization nor plistlib will perform the sorts of substitutions you want, so you will have to build this in to both t... | [
1
] | [] | [] | [
"cocoa",
"environment_variables",
"macos",
"python"
] | stackoverflow_0005480460_cocoa_environment_variables_macos_python.txt |
Q:
wxpython event handling between multiple classes
I have two classes in wxpython, a wx.Frame class and a wx.Dialog (calendar dialog) class
My calendar dialog looks like this:
class Calendar(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title)
vbox = wx.... | wxpython event handling between multiple classes | I have two classes in wxpython, a wx.Frame class and a wx.Dialog (calendar dialog) class
My calendar dialog looks like this:
class Calendar(wx.Dialog):
def __init__(self, parent, id, title):
wx.Dialog.__init__(self, parent, id, title)
vbox = wx.BoxSizer(wx.VERTICAL)
self.calend = cal.Calen... | [
"In calClick1 make instance of Calendar with self as parent:\ncalObj = Calendar(self, -1, 'test cal')\n\nIn Calendar class add something like:\nself.parent = parent after wx.Dialog.__init__(...).\nNow you can access attributes of frame in calendar. Example:\nIf you have in Frame class something like:\nself.txt = wx... | [
2,
1
] | [] | [] | [
"python",
"user_interface",
"wxpython"
] | stackoverflow_0005359384_python_user_interface_wxpython.txt |
Q:
Incorporating multiple login systems?
I have something simple right now, userdb schema is:
userid - autoincrement id email
email address
password
I want to incorporate Facebook and twitter, how would i deal with it on the DB side?
A:
You can do this many ways, either you store most of the data in a generic use... | Incorporating multiple login systems? | I have something simple right now, userdb schema is:
userid - autoincrement id email
email address
password
I want to incorporate Facebook and twitter, how would i deal with it on the DB side?
| [
"You can do this many ways, either you store most of the data in a generic usertable (as you are about to) and the provider details separated.\nOr you make a design where you can connect multiple logins to same user. This will end up with something like\n\nid user\nid facebookuser (nullable)\nid twitteruser (nullab... | [
3
] | [] | [] | [
"authentication",
"database",
"database_design",
"python"
] | stackoverflow_0005480742_authentication_database_database_design_python.txt |
Q:
writing an improved version of the Chaos Help
Here is the question proposed by the text.
Write an improved version of the Chaos program from Chapter 1 that allows a user to input two initial values and the number of iterations and then prints a nicely formatted table showing how the values change over time. for ex... | writing an improved version of the Chaos Help | Here is the question proposed by the text.
Write an improved version of the Chaos program from Chapter 1 that allows a user to input two initial values and the number of iterations and then prints a nicely formatted table showing how the values change over time. for example, if the starting values were .25 and .26 with... | [
"You really just have to duplicate the functionality you already have. Instead of just asking the user for an x value, also ask for a y value.\nx= float(input(\"enter a number between 0 and 1: \"))\ny= float(input(\"enter another number between 0 and 1: \"))\n\nThen in your loop you need to do the same thing you d... | [
0
] | [] | [] | [
"programming_languages",
"python",
"python_3.x"
] | stackoverflow_0005480284_programming_languages_python_python_3.x.txt |
Q:
How to parse shrink the web xml with ElementTree
I am trying to use the shrink the web service for site thumbnails. They have a API that returns XML telling you if the site thumbnail can be created. I am trying to use ElementTree to parse the xml, but not sure how to get to the information I need. Here is a exa... | How to parse shrink the web xml with ElementTree | I am trying to use the shrink the web service for site thumbnails. They have a API that returns XML telling you if the site thumbnail can be created. I am trying to use ElementTree to parse the xml, but not sure how to get to the information I need. Here is a example of the XML response:
<?xml version="1.0" encoding... | [
"Grrr namespaces ....try this:\nSTW_PREFIX = \"{http://www.shrinktheweb.com/doc/stwresponse.xsd}\"\n\n(see line 2 of your sample XML)\nThen when you want a tag like stw:StatusCode, use STW_PREFIX + \"StatusCode\"\nUpdate: That XML response isn't the most brilliant design. It's not possible to guess from your single... | [
1
] | [] | [] | [
"elementtree",
"python"
] | stackoverflow_0005480871_elementtree_python.txt |
Q:
How to hide the label for the hidden field
I have been trying to hide the label of the hidden field defined in a model class using Django api. The CRUD operations of the model are managed by Django admin.
My model is
class RackForm(django.forms.ModelForm):
def __init__(self, *args, **kwargs):
self.fields[... | How to hide the label for the hidden field | I have been trying to hide the label of the hidden field defined in a model class using Django api. The CRUD operations of the model are managed by Django admin.
My model is
class RackForm(django.forms.ModelForm):
def __init__(self, *args, **kwargs):
self.fields['racktypeid'].widget = \
forms.HiddenIn... | [] | [] | [
"Your problem stems from using {{ form.as_p }} or some other other shortcut function to render your form. Render the form yourself and you won't have this problem.\nAlso, in Django 1.3 there is an easier way to change the widget for a field, see http://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#overridi... | [
-1
] | [
"django",
"django_admin",
"javascript",
"python"
] | stackoverflow_0005480997_django_django_admin_javascript_python.txt |
Q:
What would be the best way to set limits on unknown code?
I'm using a Python library (SimpleParse) that I seem to be causing some runaway recursion with it. It's already crashed my computer once when I was just trying to debug it.
What would be the best way for me to set some limits on how much memory it's using?... | What would be the best way to set limits on unknown code? | I'm using a Python library (SimpleParse) that I seem to be causing some runaway recursion with it. It's already crashed my computer once when I was just trying to debug it.
What would be the best way for me to set some limits on how much memory it's using?
I was thinking I would write up a quick C program with setrlim... | [
"Python provides setrlimit(), so you can stay in Python. (Unless you're happier in C :)\nNote that the Linux kernel hasn't supported the RSS accounting in a long time; the address space accounting is probably your best bet, but it might be overly restrictive. (If the program mmap(2)s a few gigabytes but never bothe... | [
1,
0
] | [] | [] | [
"c",
"memory",
"python",
"resources",
"setrlimit"
] | stackoverflow_0005481010_c_memory_python_resources_setrlimit.txt |
Q:
Access user's OpenID info in templates on Google app engine (tipfy)
I'm using the OpenID authentication that's built into Google app engine and trying to make the currently signed in user's information automatically available in templates.
Doing it manually might be something like:
from google.appengine.api import... | Access user's OpenID info in templates on Google app engine (tipfy) | I'm using the OpenID authentication that's built into Google app engine and trying to make the currently signed in user's information automatically available in templates.
Doing it manually might be something like:
from google.appengine.api import users
from tipfy import RequestHandler
from tipfy.ext.jinja2 import rend... | [
"You can create a subclass of RequestHandler that retrieves the current user automatically on __init__. Also you can add methods to that subclass to customize template rendering. I don't think Middleware is the right solution for this problem.\nfrom google.appengine.api import users\nfrom tipfy import RequestHandl... | [
1
] | [] | [] | [
"google_app_engine",
"middleware",
"python",
"tipfy"
] | stackoverflow_0005481106_google_app_engine_middleware_python_tipfy.txt |
Q:
Cross-platform Python scanner interface
I'm looking for a library that can interface with scanners on both Windows and Linux, in Python. Is there such a thing?
Thanks in advance.
A:
There is a project on google code: imagescanner
The python-imagescanner (old
pyscanning) implements an abstraction
layers allo... | Cross-platform Python scanner interface | I'm looking for a library that can interface with scanners on both Windows and Linux, in Python. Is there such a thing?
Thanks in advance.
| [
"There is a project on google code: imagescanner\n\nThe python-imagescanner (old\n pyscanning) implements an abstraction\n layers allowing users to scan\n images/documents from Linux or Windows\n boxes without the need of write any\n specific Python code for each one of\n them.\n\n"
] | [
5
] | [] | [] | [
"cross_platform",
"image_scanner",
"python"
] | stackoverflow_0005480738_cross_platform_image_scanner_python.txt |
Q:
Custom jinja2 filter for iterator
How do I most efficiently write a custom filter for Jinja2 that applies to an iterable like the built-in 'sort' filter, for use in a for loop in the template?
For example:
{% for item in iterable|customsort(somearg) %}
...
{% endfor %}
See http://jinja.pocoo.org/docs/api/#writing... | Custom jinja2 filter for iterator | How do I most efficiently write a custom filter for Jinja2 that applies to an iterable like the built-in 'sort' filter, for use in a for loop in the template?
For example:
{% for item in iterable|customsort(somearg) %}
...
{% endfor %}
See http://jinja.pocoo.org/docs/api/#writing-filters for general documentation
| [
"The same way you'd write any other filter. Here's an example that should get you started:\nfrom jinja2 import Environment, Undefined\n\ndef custom_sort(iterable, somearg):\n if iterable is None or isinstance(iterable, Undefined):\n return iterable\n\n # Do custom sorting of iterable here\n\n return... | [
14
] | [] | [] | [
"customization",
"jinja2",
"python"
] | stackoverflow_0005481205_customization_jinja2_python.txt |
Q:
Generate a polygon of landmasses in python
Is anyone able to recommend a generator, algorithm or any other easy way of generating a bunch of random landmasses to make up a planet.
The idea is that i will be able to project this onto a circle (my game is 2d) and rotate it so it is a vectorish world map kind of thin... | Generate a polygon of landmasses in python | Is anyone able to recommend a generator, algorithm or any other easy way of generating a bunch of random landmasses to make up a planet.
The idea is that i will be able to project this onto a circle (my game is 2d) and rotate it so it is a vectorish world map kind of thing.
Also as this is a aesthetic part of the game ... | [
"Algorithm to generate natural looking terrains http://en.wikipedia.org/wiki/Perlin_noise\nGoogle will give you plenty of implementation for it. It gives you an heighfield, so a threshold to classify a point as either land or water gives you land masses. \nIf you need the land masses as polygons, you can run the ma... | [
1,
0,
0
] | [] | [] | [
"2d",
"polygon",
"python",
"vector"
] | stackoverflow_0005481087_2d_polygon_python_vector.txt |
Q:
Problem with routes.mapper package in python - generate is returning None for some reason?
I'm using the python Routes package (http://routes.groovie.org/modules/mapper.html#routes.mapper.Mapper.connect)
And i've simplified my code down to the following:
from routes import Mapper
m = Mapper()
m.connect('upnp/:udn/... | Problem with routes.mapper package in python - generate is returning None for some reason? | I'm using the python Routes package (http://routes.groovie.org/modules/mapper.html#routes.mapper.Mapper.connect)
And i've simplified my code down to the following:
from routes import Mapper
m = Mapper()
m.connect('upnp/:udn/:sid/:action', controller='upnp', action='desc', sid=None)
a = m.generate(controller='upnp', act... | [
"Figured out why: the sid=None in the generate line.\n"
] | [
0
] | [] | [] | [
"mapping",
"python",
"routes",
"routing"
] | stackoverflow_0005481291_mapping_python_routes_routing.txt |
Q:
python list __iter__ method called on every loop?
I am trying to make a class which inherits from a python list. I want the elements of the list to be initialized/finalized with every loop of the list. I thought this could be done by overriding the __iter__ method of the python list but I can't seem to get it to w... | python list __iter__ method called on every loop? | I am trying to make a class which inherits from a python list. I want the elements of the list to be initialized/finalized with every loop of the list. I thought this could be done by overriding the __iter__ method of the python list but I can't seem to get it to work. The __iter__ method appears to called only once ? ... | [
"You can simply return a generator expression from __iter__()\nclass MyList(list):\n def __iter__(self):\n return (self.do_something(x) for x in list.__iter__(self))\n\n def do_something(self, x):\n print 'do something', x\n return x\n\nmy_list = MyList(range(10))\nprint my_list\n\nfor it... | [
12,
4,
3,
0
] | [
"I don't understand exactly what you are trying to do, but what you've already been told is true. next() is the method called in every iteration.\nclass MyList(list):\n def next(self):\n print \"Do something\"\n return list.next(self)\n\n(I didn't tested it)\n"
] | [
-2
] | [
"iterator",
"loops",
"python",
"python_2.6"
] | stackoverflow_0005480898_iterator_loops_python_python_2.6.txt |
Q:
Is my EBNF logic wrong here?
I'm using SimpleParse in a Python program in order to parse some rather simple linguistics. It should be able to parse the following sample text (each line separately):
d6
(d4 + d8 + 5) + 6
{5d20}+12
[d10 + 6d6] + 9
(d10 + d12) + 8d8
I've written up the following EBNF for the above, ... | Is my EBNF logic wrong here? | I'm using SimpleParse in a Python program in order to parse some rather simple linguistics. It should be able to parse the following sample text (each line separately):
d6
(d4 + d8 + 5) + 6
{5d20}+12
[d10 + 6d6] + 9
(d10 + d12) + 8d8
I've written up the following EBNF for the above, but the parser keeps crashing on m... | [
"You haven't defined number, and I don't see it predefined in the docs.\n"
] | [
2
] | [] | [] | [
"ebnf",
"parsing",
"python"
] | stackoverflow_0005481315_ebnf_parsing_python.txt |
Q:
why aren't these floats evaluated as equal?
In the following code, if x0 == x1 and y0 == y1, then it should tell me so. In the example I'm using, they are. However, Python is only saying the x values are equal, not the y.
Here's the code:
print "arc2x0 = ", arc2x0, ", arc2x1 = ", arc2x1
print "arc2y0 = ", arc2... | why aren't these floats evaluated as equal? | In the following code, if x0 == x1 and y0 == y1, then it should tell me so. In the example I'm using, they are. However, Python is only saying the x values are equal, not the y.
Here's the code:
print "arc2x0 = ", arc2x0, ", arc2x1 = ", arc2x1
print "arc2y0 = ", arc2y0, ", arc2y1 = ", arc2y1
if arc2x0 == arc2x1:
... | [
"Yes there is more precision beyond what you're seeing. The problem is that the == operator should not usually be used with floats. Floating point numbers have limited precision and accumulate rounding error, and imprecision from not being able to store all decimal values precisely. e.g.\n>>> print '%.18f' % 0.1\n0... | [
5,
1,
1
] | [] | [] | [
"equivalent",
"printing",
"python"
] | stackoverflow_0005481339_equivalent_printing_python.txt |
Q:
Beaker caching performance guideline
I was implemented beaker with a cherrypy application, but after some requests, the beaker response time increases about 10-14 seconds.
i think after including 500 to 1000 items in cache, beaker goes down.
all cached types are simple(str,int,list,tuple,...)
A:
I Found the prob... | Beaker caching performance guideline | I was implemented beaker with a cherrypy application, but after some requests, the beaker response time increases about 10-14 seconds.
i think after including 500 to 1000 items in cache, beaker goes down.
all cached types are simple(str,int,list,tuple,...)
| [
"I Found the problem,\nThe beaker have some performance problems with file type back-end.\nsimply i changed the \n'cache.type' : 'file'\n\nto:\n'cache.type' : 'dbm'\n\nand everything is so good!!!\nwhen type is file beaker uses python pure pickle library to serialize the object. and pickle does not good for large o... | [
7
] | [] | [] | [
"beaker",
"cherrypy",
"python"
] | stackoverflow_0005465870_beaker_cherrypy_python.txt |
Q:
Using App Engine Task Queue Within Pyramid
Configuration of the Task Queue is done in the app.yaml file. There I have:
- url: /_ah/queue/default
script: task.py
Normally, task.py would be found when calling taskqueue.add()
Unfortunately, when using Pyramid I get a 404 in the log, and I'm guessing that has to do... | Using App Engine Task Queue Within Pyramid | Configuration of the Task Queue is done in the app.yaml file. There I have:
- url: /_ah/queue/default
script: task.py
Normally, task.py would be found when calling taskqueue.add()
Unfortunately, when using Pyramid I get a 404 in the log, and I'm guessing that has to do with the previous line:
- url: .*
script: run... | [
"Reverse the order of these two lines? The wildcard url should always be at the bottom of the list.\n"
] | [
4
] | [] | [] | [
"google_app_engine",
"pyramid",
"python"
] | stackoverflow_0005481279_google_app_engine_pyramid_python.txt |
Q:
how to remove multiple duplicates from a list?
I'm trying to write a program that plays a game of go fish between two players
and i currently stuck trying to remove the duplicates in the first hand dealt.
This is the code i have so far, and it only removes one dupe. I was wondering if anyone can help me enhance it... | how to remove multiple duplicates from a list? | I'm trying to write a program that plays a game of go fish between two players
and i currently stuck trying to remove the duplicates in the first hand dealt.
This is the code i have so far, and it only removes one dupe. I was wondering if anyone can help me enhance it by allowing to remove all dupes
#sorts player1 card... | [
"If the ordering does not matter: use a set() or dict() instead. Otherwise you have to iterate over the whole list and remove items from the list. Or you maintain the ordered list and keep track of the unique items in the list through a second dict. Before inserting a new item to the list you check first if the ite... | [
2,
1,
0,
0,
0
] | [] | [] | [
"list",
"python"
] | stackoverflow_0005481578_list_python.txt |
Q:
Implementing User Invalid Message with Django
I have created a django app. It has got a user login/registration on the same registrationForm.html. The login functionality is working fine now. Once the user gives the correct username (here email id) and password the user is redirected to another page(logedIn.html) ... | Implementing User Invalid Message with Django | I have created a django app. It has got a user login/registration on the same registrationForm.html. The login functionality is working fine now. Once the user gives the correct username (here email id) and password the user is redirected to another page(logedIn.html) showing a message 'User logged in', and when the us... | [
"There are massive problems with the way you are doing things - storing plaintext passwords for example -- look into the built in authentication backends available to django for how to properly log a user in. Added benefits include the user being available automatically in request.user\nhttp://docs.djangoproject.co... | [
3,
2
] | [] | [] | [
"django",
"django_admin",
"django_models",
"django_templates",
"python"
] | stackoverflow_0005481977_django_django_admin_django_models_django_templates_python.txt |
Q:
Python threading + socket IO lockup problem in Cygwin
I am having a weird concurrency issue with Python on Cygwin. I am running two threads:
A thread which sends UDP packets at regular intervals
A main thread which waits for KeyBoardInterrupt and when it receives one, it tells the UDP thread to stop sending via a... | Python threading + socket IO lockup problem in Cygwin | I am having a weird concurrency issue with Python on Cygwin. I am running two threads:
A thread which sends UDP packets at regular intervals
A main thread which waits for KeyBoardInterrupt and when it receives one, it tells the UDP thread to stop sending via a boolean flag
This works just fine under Linux (python 2.6... | [
"If you haven't updated your cygwin (cygwin 1.5.5-1+), there are some pthreads bugs I believe. You might want to try running the code with the latest snapshot to rule that out. \n"
] | [
0
] | [] | [] | [
"cygwin",
"multithreading",
"python",
"sockets"
] | stackoverflow_0003297028_cygwin_multithreading_python_sockets.txt |
Q:
Python py2exe all-in-one
I'm very new to python, and I wanted to compile my code into a .exe for everyone to be able to use. I create the .exe without a problem, but instead of it being in an "all-in-one" sort of file, I get a folder that looks like this:
http://i.stack.imgur.com/gi2kK.png
I tried pygame2.exe (pro... | Python py2exe all-in-one | I'm very new to python, and I wanted to compile my code into a .exe for everyone to be able to use. I create the .exe without a problem, but instead of it being in an "all-in-one" sort of file, I get a folder that looks like this:
http://i.stack.imgur.com/gi2kK.png
I tried pygame2.exe (provided courtesy of pygame, sinc... | [
"Instructions are available here:\nhttp://www.py2exe.org/index.cgi/SingleFileExecutable\nSee example of Bundle Files in the end.\n"
] | [
1
] | [] | [] | [
"py2exe",
"pygame",
"python"
] | stackoverflow_0005482155_py2exe_pygame_python.txt |
Q:
updating score in card game
I am a total beginner with python.
I need help updating the score of a card game.
The scoring works as follows:
Player A or B has a pair: score += 1
Player A asks Player B (vice versa) for a card and that player has it: score += 1
Player B doesn't have it, Player A has to draw a card... | updating score in card game | I am a total beginner with python.
I need help updating the score of a card game.
The scoring works as follows:
Player A or B has a pair: score += 1
Player A asks Player B (vice versa) for a card and that player has it: score += 1
Player B doesn't have it, Player A has to draw a card. If there is pair after draw: sc... | [
"Here is some code to get you started: \nclass Player:\n def hasPair(self):\n haveIt = False\n #write logic here to see if you have it\n return haveIt\n def hasCard(self,card):\n haveIt = False\n #write logic here to see if this player has the card\n return haveIt\n def drawCard(self):\n ... | [
1
] | [] | [] | [
"playing_cards",
"python"
] | stackoverflow_0005481603_playing_cards_python.txt |
Q:
C++: how to check whether an external program is running?
I run an external program with C++:
_wsystem(exec);
I want to kill the process if it runs for more than n seconds. I can do it in Python like this:
p = subprocess.Popen(self.temp_exec, shell=True)
cur_time = 0.0
while cur_time < self.time_limit:
... | C++: how to check whether an external program is running? | I run an external program with C++:
_wsystem(exec);
I want to kill the process if it runs for more than n seconds. I can do it in Python like this:
p = subprocess.Popen(self.temp_exec, shell=True)
cur_time = 0.0
while cur_time < self.time_limit:
if p.poll() != None:
# Kill the process
... | [
"There is a MS knowledge base entry describing how to cleanly terminate applications. Essentially if you just want to kill the process and don't care about potential side effects then you can just use TerminateProcess.\nThe Windows API way to check if a process is still running is GetExitCodeProcess.\n",
"If you ... | [
1,
0,
0
] | [] | [] | [
"c++",
"external_process",
"process_management",
"python",
"windows"
] | stackoverflow_0005482447_c++_external_process_process_management_python_windows.txt |
Q:
How do people usually implement jsonp in python?
I would like to learn how to use jsonp with python. I googled around for any useful tutorial. However, it seems that there are no so much resources up there.
Thus I would like to ask here if anybody knows any tutorial, API that I can use, or any best practices.
Than... | How do people usually implement jsonp in python? | I would like to learn how to use jsonp with python. I googled around for any useful tutorial. However, it seems that there are no so much resources up there.
Thus I would like to ask here if anybody knows any tutorial, API that I can use, or any best practices.
Thank you.
| [
"Do you mean supporting the generation of JSOP output with a Python-powered API or website?\nThat's pretty easy to support. Say your API at /some/resource.json already outputs some JSON encoded data (say, in the code it's a return json.dumps(dict(a='foo'))). \nTo support JSONP all you have to do is accept a callbac... | [
19
] | [] | [] | [
"api",
"jsonp",
"python"
] | stackoverflow_0005481926_api_jsonp_python.txt |
Q:
command execute directory
i have to execute a command use python subprocess .
by default , command is execute as working on the directory where the python script file is . such as
subprocess.Popen(shlex.split("ls -l"))
will list the file in the directory of the script file where is .
but i want this command to e... | command execute directory | i have to execute a command use python subprocess .
by default , command is execute as working on the directory where the python script file is . such as
subprocess.Popen(shlex.split("ls -l"))
will list the file in the directory of the script file where is .
but i want this command to execute in another directory ,sa... | [
"You can use os.chdir or you use the cwd parameter to Popen.\n",
"hi did u try changing the unix command\nls -l \n\nto \nsomething like\nls -l /usr/share;\n\n",
"ls -l list all items in current directory default. You could tell command ls -l which directory to list by using ls -l /your-path\n"
] | [
1,
0,
0
] | [] | [] | [
"python"
] | stackoverflow_0005482995_python.txt |
Q:
Protocol for retrieving and publishing messages (message queues without the pub/sub)
Is there a messaging solution out there (preferably supporting Python) that I can use like a mailbox, e.g. retrieve messages from any given queue without having to subscribe? I suppose message queues could work, but I would have t... | Protocol for retrieving and publishing messages (message queues without the pub/sub) | Is there a messaging solution out there (preferably supporting Python) that I can use like a mailbox, e.g. retrieve messages from any given queue without having to subscribe? I suppose message queues could work, but I would have to repeatedly subscribe, grab messages from the queue, then unsubscribe, which does not sou... | [
"There are quite a few options. Here are two:\n\nTake a look at Redis. There are two Python client libraries for it (see redis-py and txRedis). The operation you describe (mailbox-like operations on queues), can be simulated by performing a blpop on a list in Redis.\nAnother option is RabbitMQ. There are quite a fe... | [
0,
0,
0
] | [] | [] | [
"email",
"message_queue",
"messaging",
"python",
"scalability"
] | stackoverflow_0005482097_email_message_queue_messaging_python_scalability.txt |
Q:
python module like csv-DictReader with full utf8 support
I need import data from a csv in my project and i need a object like DictReader, but with full utf8 supports, anyone knows a module or app with this?
A:
Your data is NOT encoded in UTF-8. It is (mostly) encoded in cp1252. The data appears to include Spanis... | python module like csv-DictReader with full utf8 support | I need import data from a csv in my project and i need a object like DictReader, but with full utf8 supports, anyone knows a module or app with this?
| [
"Your data is NOT encoded in UTF-8. It is (mostly) encoded in cp1252. The data appears to include Spanish names. The most prevalent non-ASCII character is '\\xd1` (i.e. Latin capital letter N with tilde) -- this is the character that caused the exception.\nOne of the non-ASCII characters in the file is '\\x8d'. It ... | [
3,
0
] | [] | [] | [
"csv",
"python",
"utf_8"
] | stackoverflow_0005478659_csv_python_utf_8.txt |
Q:
Keeping Firefox profile persistent in multiple Selenium tests without specifying a profile
Trying to achieve:
same firefox profile throughout tests
Problem:
Tests are spread over 30 different files, instantiating a selenium object, and thus creating a firefox profile, in the first test won't persist to the foll... | Keeping Firefox profile persistent in multiple Selenium tests without specifying a profile | Trying to achieve:
same firefox profile throughout tests
Problem:
Tests are spread over 30 different files, instantiating a selenium object, and thus creating a firefox profile, in the first test won't persist to the following test because the objects die once script ends IIRC
Can't specify profile because I'm writi... | [
"I ran into this same problem and also noticed that persisting a single Firefox session across tests sped up the performance of the test suite considerably.\nWhat I did was to create a base class for my Selenium tests that would only activate Firefox if it wasn't already started. During tear-down, this class does ... | [
2,
0
] | [] | [] | [
"python",
"selenium"
] | stackoverflow_0004987773_python_selenium.txt |
Q:
What is the best way to write a Batch script in?
I am having around 20 scripts, each produce one output file as the output which is fed back as input to the next file. I want to now provide the user with an option to restart the batch script from any point in the script.
My friend suggested using make or ant havin... | What is the best way to write a Batch script in? | I am having around 20 scripts, each produce one output file as the output which is fed back as input to the next file. I want to now provide the user with an option to restart the batch script from any point in the script.
My friend suggested using make or ant having targets defined for each python script. I want to kn... | [
"Make works like this:\nTarget: dependencies\n commands\n\nBased on your scripts, you might try this type of Makefile:\nStep20: output19\n script20 #reads output19 and produces final output\n\nStep19: output18\n script19 # reads output18 and produces output19\n\n.. etc ..\n\nStep2: output1\n script2 # rea... | [
2
] | [] | [] | [
"ant",
"batch_file",
"batch_processing",
"makefile",
"python"
] | stackoverflow_0005483202_ant_batch_file_batch_processing_makefile_python.txt |
Q:
Parallelize my python program
I have a python program that reads a line from a input file, does some manipulation and writes it to output file. I have a quadcore machine, and I want to utilize all of them. I think there are two alternatives to do this,
Creating n multiple python processes each handling a total n... | Parallelize my python program | I have a python program that reads a line from a input file, does some manipulation and writes it to output file. I have a quadcore machine, and I want to utilize all of them. I think there are two alternatives to do this,
Creating n multiple python processes each handling a total number of records/n
Creating n threa... | [
"The reference implementation of the Python interpreter (CPython) holds the infamous \"Global Interpreter Lock\" (GIL), effectively allowing only one thread to execute Python code at a time. As a result, multithreading is very limited in Python -- unless your heavy lifting gets done in C extensions that release th... | [
4,
0,
0
] | [] | [] | [
"multicore",
"multiprocessing",
"python"
] | stackoverflow_0005483387_multicore_multiprocessing_python.txt |
Q:
What are the advantages of using metaclasses in django-like form implementations?
First a little background ... I was going over the Django source code for forms to understand the implementation of forms in Django (and to learn some Python along the way). Django implements forms using a DeclaredMetaFields MetaCla... | What are the advantages of using metaclasses in django-like form implementations? | First a little background ... I was going over the Django source code for forms to understand the implementation of forms in Django (and to learn some Python along the way). Django implements forms using a DeclaredMetaFields MetaClass.
Here is a very crude class diagram of a Django-like form implementation (link to s... | [
"Well syntactical benefits matters a lot. After all even classes in OOP languages is just a syntactical benefit of the language.\nIn your example of very crude implementation of meta-class-less form implementation you describe fields in Dict. Well you might have overlooked that it is actually SortedDict, because or... | [
2
] | [] | [] | [
"class",
"django",
"metaclass",
"oop",
"python"
] | stackoverflow_0005480716_class_django_metaclass_oop_python.txt |
Q:
how to "allow" firefox internet security automatically
I'm trying to figure out a way to "click" the "Allow" button in firefox internet security window by using pywin32 or windows API. I was able to get the "internet security" window by using FindWindow. I tried to send a button click event but no response and the... | how to "allow" firefox internet security automatically | I'm trying to figure out a way to "click" the "Allow" button in firefox internet security window by using pywin32 or windows API. I was able to get the "internet security" window by using FindWindow. I tried to send a button click event but no response and the button looks invisible from spyxx. Any ideas?
Thanks
| [
"It's probably not a real Windows button but a XUL widget, so only Firefox knows where it is and what it looks like.\nSince your question smells like \"I want to write a Trojan\", that's as much info I'm willing to give.\n[EDIT] Firefox is a very flexible browser, especially when it comes to packaging it. So what y... | [
2
] | [] | [] | [
"firefox",
"python",
"pywin32",
"security"
] | stackoverflow_0005483592_firefox_python_pywin32_security.txt |
Q:
Python - Suds0.4 - SOAP body complex arguments
I try to connect a python client - via SUDS0.4 - to a SOAP server.
Usually, to provide a complex argument to a SOAP function, I use a python dictionary:
Example, if the SOAP argument looks like:
<parameterDesignatorValuePair>
<parameterDesignator>Message</parameterDe... | Python - Suds0.4 - SOAP body complex arguments | I try to connect a python client - via SUDS0.4 - to a SOAP server.
Usually, to provide a complex argument to a SOAP function, I use a python dictionary:
Example, if the SOAP argument looks like:
<parameterDesignatorValuePair>
<parameterDesignator>Message</parameterDesignator>
<parameterValue>AAAABgBDAG8AdQBjAG8AdQ==</... | [
"Have you tried to just do this:\nparam = client.factory.create('ns1:parameterDesignatorValuePairNamespace')\nparam.parameterDesignator = val1\nparam.parameterValue = val2\n\nclient.service.FunctionName(param)\n\nNamespaces are available by printing the WSDL file after SUDS connection.\n"
] | [
1
] | [] | [] | [
"python",
"soap",
"suds",
"wsdl"
] | stackoverflow_0005409228_python_soap_suds_wsdl.txt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.