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: Specified edge lengths on networkx/igraph (Python) I wanted to visualize a network with the data I have and would like to graph them with specific edge lengths. I use Python, and I've tried networkx and igraph to plot but all seem to assign fixed edge lengths. a.) I wonder if I did the codes wrong or the packages...
Specified edge lengths on networkx/igraph (Python)
I wanted to visualize a network with the data I have and would like to graph them with specific edge lengths. I use Python, and I've tried networkx and igraph to plot but all seem to assign fixed edge lengths. a.) I wonder if I did the codes wrong or the packages aren't really capable. How do you properly implement sp...
[ "This should work:\nimport networkx as NX\nimport pygraphviz as PG\n\nG = PG.AGraph()\nnlist = \"A B C D E\".split()\na, b = \"A A B\", \"B C D\"\nelist = zip(a.split(), b.split())\n\nG.add_nodes_from(nlist)\nG.add_edges_from(elist)\nG.node_attr.update(color=\"red\", style=\"filled\")\nG.edge_attr.update(color=\"bl...
[ 8 ]
[]
[]
[ "graphviz", "igraph", "networkx", "python" ]
stackoverflow_0001851296_graphviz_igraph_networkx_python.txt
Q: Twisted ignoring data sent from MUD Clients? I have the following code (almost an exact copy of the Chat server example listed here: import twisted.scripts.twistd from twisted.protocols import basic from twisted.internet import protocol, reactor from twisted.application import service, internet class MyChat(basic....
Twisted ignoring data sent from MUD Clients?
I have the following code (almost an exact copy of the Chat server example listed here: import twisted.scripts.twistd from twisted.protocols import basic from twisted.internet import protocol, reactor from twisted.application import service, internet class MyChat(basic.LineReceiver): def connectionMade(self): ...
[ "In case anyone stumbles across this question with similar problems, I'm leaving my findings as the accepted answer so that people don't have to hunt the way I did.\nI fixed the issue by changing the delimiter value from in my Twisted protocol from \"\\r\\n\" (default), to just \"\\n\" (which is what my MUD clients...
[ 3, 1 ]
[]
[]
[ "networking", "python", "sockets", "tcp", "twisted" ]
stackoverflow_0001898411_networking_python_sockets_tcp_twisted.txt
Q: Problem opening registry key on Windows 7 This code used to work on Vista (and Windows XP) but after an upgrade to Windows 7 it now fails with the error shown: Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 >>> import _winreg >>> h1 = _winreg.ConnectRegistry(None, _winreg.HKE...
Problem opening registry key on Windows 7
This code used to work on Vista (and Windows XP) but after an upgrade to Windows 7 it now fails with the error shown: Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 >>> import _winreg >>> h1 = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE) >>> key = r'SOFTWARE\P...
[ "This was a user mistake, compounded or triggered by changes in Windows 7 to how the UAC feature is implemented. \nIn Vista, the much-detested User Access Control feature was binary, either on or off. On Windows 7 that has been changed to provide four levels of granularity:\n\nAlways Notify (when either programs ...
[ 2, 1 ]
[]
[]
[ "python", "registry", "windows_7" ]
stackoverflow_0001897324_python_registry_windows_7.txt
Q: Using Python Yacc\Lex as a formula parser At the moment i'm working on using the python implementation of Yacc/Lex to build a formula parser for converting strings of formulae into a set of class defined operands. So far i've been mostly successful but i've come to an empasse in defining the parsing rules due to a...
Using Python Yacc\Lex as a formula parser
At the moment i'm working on using the python implementation of Yacc/Lex to build a formula parser for converting strings of formulae into a set of class defined operands. So far i've been mostly successful but i've come to an empasse in defining the parsing rules due to ambiguity with parentheses and several shift/red...
[ "START SMALL!!! Regardless of the parser library you end up using, try doing just a simple binary operation like expr & expr, and get that working. Then add support for '|'. Now you have two different operators, and you have enough to represent precedence of operations, and parentheses actually play a part. Thi...
[ 2, 2 ]
[]
[]
[ "python", "yacc" ]
stackoverflow_0001863824_python_yacc.txt
Q: Simple DB query on Google App Engine taking a lot of CPU time I'm fairly new to Google App Engine and Python, but I did just release my first real-world site with it. But now I'm getting problems with one path that is using significantly more CPU (and API CPU) time than the other paths. I've narrowed it down to a ...
Simple DB query on Google App Engine taking a lot of CPU time
I'm fairly new to Google App Engine and Python, but I did just release my first real-world site with it. But now I'm getting problems with one path that is using significantly more CPU (and API CPU) time than the other paths. I've narrowed it down to a single datastore fetch that's causing the problem: Carvings.all().f...
[ "\nMemcache, if you haven't already, and especially if the same carvings are going to be fetched again and again. If you only have 90 total, I would imagine they would all be in the cache pretty quickly, and then you should be golden.\nDo you need all the properties of the Carvings? For example, if you're just di...
[ 2, 0, 0, 0 ]
[]
[]
[ "cpu_usage", "google_app_engine", "google_cloud_datastore", "python" ]
stackoverflow_0001892325_cpu_usage_google_app_engine_google_cloud_datastore_python.txt
Q: Python login script I have the following script to logon to a url,but on submit in the webpage i call <input type=button value="go" onclick="Search()";> How to do the same in the following script instead of submit...... import urllib, urllib2, time username = "sumname" password = "test" interval = 10 data = {"us...
Python login script
I have the following script to logon to a url,but on submit in the webpage i call <input type=button value="go" onclick="Search()";> How to do the same in the following script instead of submit...... import urllib, urllib2, time username = "sumname" password = "test" interval = 10 data = {"username":username,"passwor...
[ "urllib and urllib2 are not the best ways to simulate browser interaction! You should rather be looking at mechanize (which does plug into urllib2). It's possible to simulate such interaction on \"bare\" urllib2, but it's just too much work and fragility to bother;-).\n" ]
[ 2 ]
[]
[]
[ "python", "scripting" ]
stackoverflow_0001899174_python_scripting.txt
Q: How should I store state for a long-running process invoked from Django? I am working on a Django application which allows a user to upload files. I need to perform some server-side processing on these files before sending them on to Amazon S3. After reading the responses to this question and this blog post I de...
How should I store state for a long-running process invoked from Django?
I am working on a Django application which allows a user to upload files. I need to perform some server-side processing on these files before sending them on to Amazon S3. After reading the responses to this question and this blog post I decided that the best manner in which to handle this is to have my view handler ...
[ "We do this by having a \"Request\" table in the database.\nWhen the upload arrives, we create the uploaded File object, and create a Request.\nWe start the background batch processor.\nWe return a 200 \"we're working on it\" page -- it shows the Requests and their status.\nOur batch processor uses the Django ORM. ...
[ 6, 5, 1 ]
[]
[]
[ "amazon_s3", "asynchronous", "django", "pyro", "python" ]
stackoverflow_0000853421_amazon_s3_asynchronous_django_pyro_python.txt
Q: How can I pass my ID and my password to a website in Python using Google App Engine? Here is a piece of code that I use to fetch a web page HTML source (code) by its URL using Google App Engine: from google.appengine.api import urlfetch url = "http://www.google.com/" result = urlfetch.fetch(url) if result.status_c...
How can I pass my ID and my password to a website in Python using Google App Engine?
Here is a piece of code that I use to fetch a web page HTML source (code) by its URL using Google App Engine: from google.appengine.api import urlfetch url = "http://www.google.com/" result = urlfetch.fetch(url) if result.status_code == 200: print "content-type: text/plain" print print result.content Everythi...
[ "You can check for an HTTP status code of 401, \"authorization required\", and provide the kind of HTTP authorization (basic, digest, whatever) that the site is asking for -- see e.g. here for more details (there's not much that's GAE specific here -- it's a matter of learning HTTP details and obeying them!-).\n", ...
[ 3, 1 ]
[]
[]
[ "google_app_engine", "passwords", "python" ]
stackoverflow_0001899259_google_app_engine_passwords_python.txt
Q: Why program functionally in Python? At work we used to program our Python in a pretty standard OO way. Lately, a couple guys got on the functional bandwagon. And their code now contains lots more lambdas, maps and reduces. I understand that functional languages are good for concurrency but does programming Pytho...
Why program functionally in Python?
At work we used to program our Python in a pretty standard OO way. Lately, a couple guys got on the functional bandwagon. And their code now contains lots more lambdas, maps and reduces. I understand that functional languages are good for concurrency but does programming Python functionally really help with concurren...
[ "Edit: I've been taken to task in the comments (in part, it seems, by fanatics of FP in Python, but not exclusively) for not providing more explanations/examples, so, expanding the answer to supply some.\nlambda, even more so map (and filter), and most especially reduce, are hardly ever the right tool for the job i...
[ 72, 25, 19, 16, 9, 7, 2, 1 ]
[]
[]
[ "functional_programming", "python" ]
stackoverflow_0001892324_functional_programming_python.txt
Q: wxPython - How to get the ID of a widget when you passed in -1? I'm doing a little wxPython work today and I've got this piece of code (I've stripped out the irrelevant parts): def CreateRowOne(self, pan): hbox1 = wx.BoxSizer(wx.HORIZONTAL) hbox1.Add(wx.Button(pan, -1, "250 Words"),...
wxPython - How to get the ID of a widget when you passed in -1?
I'm doing a little wxPython work today and I've got this piece of code (I've stripped out the irrelevant parts): def CreateRowOne(self, pan): hbox1 = wx.BoxSizer(wx.HORIZONTAL) hbox1.Add(wx.Button(pan, -1, "250 Words"), 1, wx.EXPAND | wx.ALL) hbox1.Add(wx.Button(pan, -1, "500...
[ "\n\nAm I going to have to manually assign the ID numbers?\n\n\nNo, putting -1 or using wx.NewId() will give you autogenerated ID.\nand You can always get id with button1.GetID() or button1.Id back anytime.\n--\nUPDATE:\nID_BUTTON1 = wx.NewId()\n\nhbox1.Add(wx.Button(pan, ID_BUTTON1, \"250 Words\"), 1, wx.EXPAND | ...
[ 3, 3, 1 ]
[]
[]
[ "python", "wxpython" ]
stackoverflow_0001879694_python_wxpython.txt
Q: Python: Amount of wall time a process has been running I want to do something like this: try: pid = int(file(lock_file, "r").read()) print "%s exists with pid: %s" % (lock_file, pid) if not check_pid(pid): print "%s not running. Phantom lock file? Continuing anyways" % pid elif wall_time(pi...
Python: Amount of wall time a process has been running
I want to do something like this: try: pid = int(file(lock_file, "r").read()) print "%s exists with pid: %s" % (lock_file, pid) if not check_pid(pid): print "%s not running. Phantom lock file? Continuing anyways" % pid elif wall_time(pid) > 60 * 5: print "%s has been running for more tha...
[ "Perhaps you could look at the creation time of the lock file. This wouldn't be guaranteed correct, but it would be correct in most cases (and the consequences of getting it wrong are minimal).\n", "If you do not want to use the modify time of the lockfile for some reason, you could just write it down in the file...
[ 1, 1 ]
[]
[]
[ "process", "python" ]
stackoverflow_0001899922_process_python.txt
Q: Getting every odd variable in a list? If I make a list in Python and want to write a function that would return only odd numbers from a range 1 to x how would I do that? For example, if I have list [1, 2, 3, 4] from 1 to 4 (4 ix my x), I want to return [1, 3]. A: If you want to start with an arbitrary list: [ite...
Getting every odd variable in a list?
If I make a list in Python and want to write a function that would return only odd numbers from a range 1 to x how would I do that? For example, if I have list [1, 2, 3, 4] from 1 to 4 (4 ix my x), I want to return [1, 3].
[ "If you want to start with an arbitrary list:\n[item for item in yourlist if item % 2]\n\nbut if you're always starting with range, range(1, x, 2) is better!-)\nFor example:\n$ python -mtimeit -s'x=99' 'filter(lambda(t): t % 2 == 1, range(1, x))'\n10000 loops, best of 3: 38.5 usec per loop\n$ python -mtimeit -s'x=9...
[ 14, 3, 0 ]
[]
[]
[ "python" ]
stackoverflow_0001780763_python.txt
Q: Remove whitespace in Python using string.whitespace Python's string.whitespace is great: >>> string.whitespace '\t\n\x0b\x0c\r ' How do I use this with a string without resorting to manually typing in '\t|\n|... etc for regex? For example, it should be able to turn: "Please \n don't \t hurt \x0b me." into "Pleas...
Remove whitespace in Python using string.whitespace
Python's string.whitespace is great: >>> string.whitespace '\t\n\x0b\x0c\r ' How do I use this with a string without resorting to manually typing in '\t|\n|... etc for regex? For example, it should be able to turn: "Please \n don't \t hurt \x0b me." into "Please don't hurt me." I'd probably want to keep the single sp...
[ "There is a special-case shortcut for exactly this use case!\nIf you call str.split without an argument, it splits on runs of whitespace instead of single characters. So:\n>>> ' '.join(\"Please \\n don't \\t hurt \\x0b me.\".split())\n\"Please don't hurt me.\"\n\n", "What's wrong with the \\s character class?\n>>...
[ 146, 14, 9, 2, 1 ]
[]
[]
[ "python", "string", "whitespace" ]
stackoverflow_0001898656_python_string_whitespace.txt
Q: Tree Transformations Using Visitor Pattern (Disclaimer: these examples are given in the context of building a compiler, but this question is all about the Visitor pattern and does not require any knowledge of compiler theory.) I'm going through Andrew Appel's Modern Compiler Implementation in Java to try to teac...
Tree Transformations Using Visitor Pattern
(Disclaimer: these examples are given in the context of building a compiler, but this question is all about the Visitor pattern and does not require any knowledge of compiler theory.) I'm going through Andrew Appel's Modern Compiler Implementation in Java to try to teach myself compiler theory (so no, this isn't home...
[ "A SAX parser is a kind of visitor. To avoid adding a return value to the method, you can use a stack:\nclass Visitor {\n Stack<Node> stack = new Stack<Node>();\n\n// . . .\n\n void visitPlus(PlusExp pe) {\n pe.left.accept(this);\n pe.right.accept(this);\n Node b = stack.pop();\n ...
[ 11, 1, 0 ]
[]
[]
[ "abstract_syntax_tree", "java", "python", "tree", "visitor_pattern" ]
stackoverflow_0001898967_abstract_syntax_tree_java_python_tree_visitor_pattern.txt
Q: How can I get the target platform info of a dll with Python 3.1.1? I have many dll files and I would like to select them into two different folders (PC and PPC). For this I need to know the target platform of the dll file or any other details about its platform. I use Python 3.1.1. I have tried the win32api which ...
How can I get the target platform info of a dll with Python 3.1.1?
I have many dll files and I would like to select them into two different folders (PC and PPC). For this I need to know the target platform of the dll file or any other details about its platform. I use Python 3.1.1. I have tried the win32api which does not compatible with this Python version. So, I tried to use the cty...
[ "I found a solution based on the dll file structure. Here is the part of my code:\ndef DLLIdentifier( self ):\n '''\n Microsoft Portable Executable and Common Object File Format Specification\n http://www.microsoft.com/whdc/system/platform/firmware/PECOFF.mspx \n\n After the MS DOS stub, at the file ...
[ 1 ]
[]
[]
[ "api", "dll", "platform", "python", "winapi" ]
stackoverflow_0001889694_api_dll_platform_python_winapi.txt
Q: Why is SQLAlchemy/associationproxy duplicating my tags? I'm trying to use association proxy for tags, in a very similar scenario to the example in the docs. Here is a subset of my schema (it's a blog), using declarative: class Tag(Base): __tablename__ = 'tags' id = Column(Integer, primary_key=Tr...
Why is SQLAlchemy/associationproxy duplicating my tags?
I'm trying to use association proxy for tags, in a very similar scenario to the example in the docs. Here is a subset of my schema (it's a blog), using declarative: class Tag(Base): __tablename__ = 'tags' id = Column(Integer, primary_key=True) tag = Column(Unicode(255), unique=True, nul...
[ "Disclaimer: it's been ages since I used SQLAlchemy so this is more of a guess than anything.\nIt looks like you're expecting SQLAlchemy to magically take the string 'bar' and look up the relevant Tag for it when performing the insert on the many-to-many table. I expect this is invalid, because the field in questio...
[ 3, 0 ]
[]
[]
[ "declarative", "orm", "python", "sqlalchemy", "tags" ]
stackoverflow_0001899984_declarative_orm_python_sqlalchemy_tags.txt
Q: Is there a function that gives me a file name without path? I want to turn C:\abc.bmp into abc.bmp, or even better, if possible, in abc. That is easy to do with .NET as there are functions for both goals. Is there anything similar in python? A: >>> os.path.basename(r'C:\abc.txt') 'abc.txt' for basename only: >>...
Is there a function that gives me a file name without path?
I want to turn C:\abc.bmp into abc.bmp, or even better, if possible, in abc. That is easy to do with .NET as there are functions for both goals. Is there anything similar in python?
[ ">>> os.path.basename(r'C:\\abc.txt')\n'abc.txt'\n\nfor basename only:\n>>> base, ext = os.path.splitext(os.path.basename(r'C:\\abc.txt'))\n>>> base\n'abc'\n\n", "Try os.path.basename().\n" ]
[ 11, 3 ]
[]
[]
[ "path", "python" ]
stackoverflow_0001900216_path_python.txt
Q: Django Model returning NoneType I have a model Product it has two fields size & colours among others colours = models.CharField(blank=True, null=True, max_length=500) size = models.CharField(blank=True, null=True, max_length=500) In my view I have current_product = Product.objects.get(slug=title) if len(current...
Django Model returning NoneType
I have a model Product it has two fields size & colours among others colours = models.CharField(blank=True, null=True, max_length=500) size = models.CharField(blank=True, null=True, max_length=500) In my view I have current_product = Product.objects.get(slug=title) if len(current_product.size) != 0 : current_pro...
[ "NoneType is the type that the None value has. You want to change the second snippet to\nif current_product.size: # This will evaluate as false if size is None or len(size) == 0.\n blah blah\n\n", "NoneType is Pythons NULL-Type, meaning \"nothing\", \"undefined\". It has only one value: \"None\". When creating a...
[ 8, 1, 0 ]
[ "I don't know Django, but I assume that some kind of ORM is involved when you do this:\ncurrent_product = Product.objects.get(slug=title)\n\nAt that point you should always check whether you get None back ('None' is the same as 'null' in Java or 'nil' in Lisp with the subtle difference that 'None' is an object in P...
[ -1 ]
[ "django", "django_views", "python" ]
stackoverflow_0000552521_django_django_views_python.txt
Q: Need example/help with GtkTextBuffer (of GtkTextView) serialize/deserialize I am trying to save user's bold/italic/font/etc tags in a GtkTextView. Using GtkTextBuffer.get_text() does not return the tags. The best documentation I have found on this is: http://www.pygtk.org/docs/pygtk/class-gtktextbuffer.html#method...
Need example/help with GtkTextBuffer (of GtkTextView) serialize/deserialize
I am trying to save user's bold/italic/font/etc tags in a GtkTextView. Using GtkTextBuffer.get_text() does not return the tags. The best documentation I have found on this is: http://www.pygtk.org/docs/pygtk/class-gtktextbuffer.html#method-gtktextbuffer--register-serialize-format However, I do not understand the functi...
[ "If you need to save the tags because you just want to copy the text into another text buffer, you can use gtk.TextBuffer.insert_range().\nIf you need to save the text with tags into another format readable by other programs, I once wrote a library with a GTK text buffer serializer to and from RTF. It doesn't have ...
[ 3, 1 ]
[]
[]
[ "gtk", "gtk2", "pygtk", "python" ]
stackoverflow_0001885552_gtk_gtk2_pygtk_python.txt
Q: How to access a standard-library module in Python when there is a local module with the same name? How can a standard-library module (say math) be accessed when a file prog.py is placed in the same directory as a local module with the same name (math.py)? I'm asking this question because I would like to create a p...
How to access a standard-library module in Python when there is a local module with the same name?
How can a standard-library module (say math) be accessed when a file prog.py is placed in the same directory as a local module with the same name (math.py)? I'm asking this question because I would like to create a package uncertainties that one can use as import uncertainties from uncertainties.math import * Thus, th...
[ "You are looking for Absolute/Relative imports from PEP 328, available with 2.5 and upward.\nIn Python 2.5, you can switch import‘s behaviour to absolute imports using a from __future__ import absolute_import directive. This absolute- import behaviour will become the default in a future version (probably Python 2.7...
[ 22, 4 ]
[]
[]
[ "import", "module", "python", "standard_library" ]
stackoverflow_0001900189_import_module_python_standard_library.txt
Q: ORM library for automatically mapping foreign keys in Python or Ruby A frequent task I run into at work is writing scripts against pre-existing databases. Sometimes I'm connecting to Oracle, other times it might be MySql or even sql server. What I would like is a tool which would reverse-engineer the database's ta...
ORM library for automatically mapping foreign keys in Python or Ruby
A frequent task I run into at work is writing scripts against pre-existing databases. Sometimes I'm connecting to Oracle, other times it might be MySql or even sql server. What I would like is a tool which would reverse-engineer the database's tables and foreign keys and allow me to write OO-style scripts against the d...
[ "You should take a look at the SQLSoup extension in SQLAlchemy. It claims to do all this for you (including foreign keys). I haven't tested it myself.\n", "Serious Ruby ORMs don't do this for a reason: it's inflexible, not explicit enough and too much magic.\nIf you really want this in your project, try coding it...
[ 4, 3, 0 ]
[ "In Ruby there are several ORMs like ActiveRecord, DataMapper or even Sequel.\nFor example using ActiveRecord you would do:\n##################################\n#mysql conection\n##################################\nbegin\n ActiveRecord::Base.establish_connection(\n :adapter => DBAdapter,\n :host => DBHo...
[ -2 ]
[ "database", "orm", "python", "ruby" ]
stackoverflow_0001897465_database_orm_python_ruby.txt
Q: Compile a string to Ruby bytecode for better performance -- like compile() in Python I have a string (authenticated, trusted, etc.) containing source code intended to run within a Ruby loop, quickly. In Python, I would compile the string into an abstract syntax tree and eval() or exec() it later: # Python 3 examp...
Compile a string to Ruby bytecode for better performance -- like compile() in Python
I have a string (authenticated, trusted, etc.) containing source code intended to run within a Ruby loop, quickly. In Python, I would compile the string into an abstract syntax tree and eval() or exec() it later: # Python 3 example given_code = 'n % 2 == 1' pred = compile(given_code, '<given>', 'eval') print("Passed:"...
[ "Based on the solution of jhs, but directly using the lambda as the loop body (the & calls to_proc on the lambda and passes it as block to the select function).\ngiven_code = 'n % 2 == 1'\npred = eval \"lambda { |n| #{given_code} }\"\np all = (1..10).select(&pred)\n\n", "I wrap the whole string in a lambda (still...
[ 7, 1 ]
[]
[]
[ "compilation", "eval", "python", "ruby" ]
stackoverflow_0001900327_compilation_eval_python_ruby.txt
Q: can NLTK/pyNLTK work "per language" (i.e. non-english), and how? How can I tell NLTK to treat the text in a particular language? Once in a while I write a specialized NLP routine to do POS tagging, tokenizing and etc. on a non-english (but still hindo-European) text domain. This question seem to address only diffe...
can NLTK/pyNLTK work "per language" (i.e. non-english), and how?
How can I tell NLTK to treat the text in a particular language? Once in a while I write a specialized NLP routine to do POS tagging, tokenizing and etc. on a non-english (but still hindo-European) text domain. This question seem to address only different corpora, not the change in code/settings: POS tagging in German A...
[ "I'm not sure what you're referring to as the changes in code/settings. NLTK mostly relies on machine learning and the \"settings\" are usually extracted from the training data.\nWhen it comes to POS tagging the results and tagging will be dependant on the tagger you use/train. Should you train your own you'll of c...
[ 9 ]
[]
[]
[ "nlp", "nltk", "python" ]
stackoverflow_0001795410_nlp_nltk_python.txt
Q: [GAE]How to set `inline` if in template Coming from PHP world, I used to create select box like this: <select> <?php foreach($arrField as $idx=>$val){?> <option <?php echo ($fieldVal == $idx ? "selected='selected'" : ''); ?>><?php echo $val; ?></option> <?php } ?> </select> However, I can't do that in python. ...
[GAE]How to set `inline` if in template
Coming from PHP world, I used to create select box like this: <select> <?php foreach($arrField as $idx=>$val){?> <option <?php echo ($fieldVal == $idx ? "selected='selected'" : ''); ?>><?php echo $val; ?></option> <?php } ?> </select> However, I can't do that in python. Here's my snippet: <select name='type'> <o...
[ "You will need to use (if you are using Django):\n{% ifequal id \"something\"%}selected='selected'{% endifequal %}\n\nYou will also need to make sure \"id\" is a variable you pass into templates.Render()\nP\n" ]
[ 2 ]
[]
[]
[ "google_app_engine", "python", "templates", "web_applications" ]
stackoverflow_0001900175_google_app_engine_python_templates_web_applications.txt
Q: django urlencode filter I have a problem with encoding urls using build-in django urlencode filter. When I use it on default django server everything is fine. But on apache2 it doesn`t work, ie. i have a tag called C#. On localhost my url is encoded to ...tags/C%23/ but on apache2 it is tags/C/ What should I do? ...
django urlencode filter
I have a problem with encoding urls using build-in django urlencode filter. When I use it on default django server everything is fine. But on apache2 it doesn`t work, ie. i have a tag called C#. On localhost my url is encoded to ...tags/C%23/ but on apache2 it is tags/C/ What should I do?
[ "I guess this is a bug with apache, simplest solution would be do url encoding twice or do a base64 encoding. \n" ]
[ 0 ]
[]
[]
[ "django", "python", "urlencode" ]
stackoverflow_0001899407_django_python_urlencode.txt
Q: How to avoid multiple instances of a program? I need to find a right way to prevent two running instances of my (Python) program. I am currently using the following method. On Windows, os.popen('wmic process get caption,processid | findstr `programname.exe`') On Linux, os.popen('ps x | grep `programname`') It se...
How to avoid multiple instances of a program?
I need to find a right way to prevent two running instances of my (Python) program. I am currently using the following method. On Windows, os.popen('wmic process get caption,processid | findstr `programname.exe`') On Linux, os.popen('ps x | grep `programname`') It seems to work fine for now. Is this method correct? C...
[ "There are numerous ways:\n\nhave an \"instance file\" in /var/run or similar (cross-platform)\nuse a fixed socket (cross-platform)\nuse DBus to register a name (linux)\n\nWhat you need is a service (external to your application) that manages a namespace where unique ids are available & enforced.\n", "on Linux, ...
[ 5, 2, 1 ]
[]
[]
[ "instance", "python" ]
stackoverflow_0001900979_instance_python.txt
Q: What's a neater, more pythonic way to do the following enumeration? for row, instrument in enumerate(instruments): for col, value in enumerate(instrument): self.table.SetValue(row, col, value) A: What you are calling row is not a row, it is a row index. instrument is a row. Apart from that: If the o...
What's a neater, more pythonic way to do the following enumeration?
for row, instrument in enumerate(instruments): for col, value in enumerate(instrument): self.table.SetValue(row, col, value)
[ "What you are calling row is not a row, it is a row index. instrument is a row. Apart from that:\nIf the only tool that you have is a SetValue(row_index, column_index, value) method and that method does more than help replicate the structure of instruments laboriously, and the instruments collection is as your code...
[ 4, 2, 2 ]
[ "One option is using a list comprehension:\n[self.table.setValue(row, col, value) \n for row, instrument in enumerate(instruments) \n for col, value in enumerate(instrument)]\n\nNot sure if it is any neater or more pythonic... But it is another way of expressing the loop.\nOne could argue that the list co...
[ -3 ]
[ "enumeration", "python" ]
stackoverflow_0001900195_enumeration_python.txt
Q: Get the executing file's path from an installed package? If one installs a python package using setuptools, then executes a method in that package from a standard python script, is it possible to get the file path of the calling/executing file? For instance, the file I'm executing is /usr/foo/bar.py, which looks l...
Get the executing file's path from an installed package?
If one installs a python package using setuptools, then executes a method in that package from a standard python script, is it possible to get the file path of the calling/executing file? For instance, the file I'm executing is /usr/foo/bar.py, which looks like this: import baz baz.get_current_path() # should print /us...
[ "Use inspect.getouterframes() or inspect.stack(), then get the filename from the calling frame.\n" ]
[ 1 ]
[]
[]
[ "python" ]
stackoverflow_0001901407_python.txt
Q: Emacs Python-Mode: Sending statements to a subprocess does not lead to REPL-style evaluation After selecting 1 + 1 and issuing python-send-region, my subprocess buffer shows no results. I have to evaluate print 1 + 1, instead. How can I force the python-send-* commands to print the value of the respective statemen...
Emacs Python-Mode: Sending statements to a subprocess does not lead to REPL-style evaluation
After selecting 1 + 1 and issuing python-send-region, my subprocess buffer shows no results. I have to evaluate print 1 + 1, instead. How can I force the python-send-* commands to print the value of the respective statements rather than echoing their stdout?
[ "It sounds like you need print; use print.\nemacs is launching a python process and getting text from its standard output, not a python value.\n" ]
[ 2 ]
[]
[]
[ "emacs", "python" ]
stackoverflow_0001901354_emacs_python.txt
Q: The following code in python (and why) I am learning python because it looks very nice and i know a bit of ruby and perl. The following is a C program to plot 3d points onto the screen. I used this as an example because it uses arrays, structures and function calls. I left out classes because i believe that sort o...
The following code in python (and why)
I am learning python because it looks very nice and i know a bit of ruby and perl. The following is a C program to plot 3d points onto the screen. I used this as an example because it uses arrays, structures and function calls. I left out classes because i believe that sort of (OOP) thing is used simularly in all langu...
[ "Here's a direct port, only works in python3 due to the print thing combined with x-if-a-else-y\nscreenWidth = 10\nscreenHeight = 10\n\nbuf = [False] * screenWidth * screenHeight\ndef draw3dpoint(x,y,z):\n pt = int((((y / z) + (screenHeight/2)) * screenWidth) + (x / z) + (screenWidth/2))\n buf[pt] = True\n\nd...
[ 2, 1, 0 ]
[]
[]
[ "c", "python" ]
stackoverflow_0001901518_c_python.txt
Q: Overlapping partially transparent shapes If I draw any shape onto a surface (with SRCALPHA flag on) in a partially transparent colour it completely replaces what was underneath it, instead of overlapping like you would expect in image editors. How can I make the shapes overlap properly? A: You could use blit wit...
Overlapping partially transparent shapes
If I draw any shape onto a surface (with SRCALPHA flag on) in a partially transparent colour it completely replaces what was underneath it, instead of overlapping like you would expect in image editors. How can I make the shapes overlap properly?
[ "You could use blit with appropriate BLEND_* values (keeping the shapes as separate surfaces, for integrity and editing, and only blitting them for display purposes).\n", "As noted, the draw functions in PyGame don't actually do blending the way you might expect. From the PyGame documentation:\n\nMost of the argu...
[ 1, 1, 0 ]
[]
[]
[ "alpha", "pygame", "python" ]
stackoverflow_0001894564_alpha_pygame_python.txt
Q: What is the standard sort order for Python release/version numbers? Python's pip and easy_install follow some rules to sort packages by their release numbers. What are the rules for numbering beta/release/bugfix releases so these tools will know which is the newest? A: This is a sore point for many folks. setupt...
What is the standard sort order for Python release/version numbers?
Python's pip and easy_install follow some rules to sort packages by their release numbers. What are the rules for numbering beta/release/bugfix releases so these tools will know which is the newest?
[ "This is a sore point for many folks. setuptools and easy_install have some rather bizarre rules in an attempt to play nice with everybody. You can read the full rules in setuptools's parse_version method, but here's the summary:\n\nVersion numbers are broken up by dots into a tuple of that many segments. 4.5.6.7 i...
[ 9, 2, 2 ]
[]
[]
[ "easy_install", "pip", "python" ]
stackoverflow_0001901612_easy_install_pip_python.txt
Q: A function callback every time a key is pressed (regardless of which window has focus)? I want to write a programme (in python) on Linux (Ubuntu Linux 9.10) that will keep track of how many key presses per second/minute I make. This includes normal letter keys, and control/shift/space/etc. Is there some way to hoo...
A function callback every time a key is pressed (regardless of which window has focus)?
I want to write a programme (in python) on Linux (Ubuntu Linux 9.10) that will keep track of how many key presses per second/minute I make. This includes normal letter keys, and control/shift/space/etc. Is there some way to hook into X so that I can say "when a key is pressed call this function?". Since I want to have ...
[ "Take a look at what others have done already. You can take a look on how this pykeylogger code handles Linux in its backend, and see if that works for you.\n", "I'd recommend that you look at the StackOverflow question: Is there a cross-platform python low-level API to capture or generate keyboard events?\nYou c...
[ 5, 5 ]
[]
[]
[ "keylogger", "keypress", "linux", "python", "xorg" ]
stackoverflow_0001901850_keylogger_keypress_linux_python_xorg.txt
Q: How to disable screen update in matplotlib I have a loop that is adding a line to a plot on each iteration. Right now this is horribly slow as it seems to redraw the the whole graph each time. Is it possible to disable screen updates for a graph while it is being set up then re-enable them afterwards. Here's the c...
How to disable screen update in matplotlib
I have a loop that is adding a line to a plot on each iteration. Right now this is horribly slow as it seems to redraw the the whole graph each time. Is it possible to disable screen updates for a graph while it is being set up then re-enable them afterwards. Here's the code: for rr,dd in zip(angles,dists): ...
[ "It sounds like you have the interactive mode on, so you should just set it to off using the command\nioff()\n\nNote that when interactive mode is off, you'll need to use the command show() to display the plots.\n" ]
[ 3 ]
[]
[]
[ "matplotlib", "python", "scipy" ]
stackoverflow_0001901461_matplotlib_python_scipy.txt
Q: For Loop, os.listdir() not working correctly I am creating a script to create new folder hierarchies for a friend of mine. There are around a thousand clients, so a script would save a ton of time. I have everything almost working, the part I don't have is this. yearList = os.listdir(driveLetter + clientName) fo...
For Loop, os.listdir() not working correctly
I am creating a script to create new folder hierarchies for a friend of mine. There are around a thousand clients, so a script would save a ton of time. I have everything almost working, the part I don't have is this. yearList = os.listdir(driveLetter + clientName) for year in yearList: os.chdir(year) os.mkdi...
[ "In the for year in yearList loop you change to the year's subdirectory, but probably never leave it again. So in the first iteration you enter the \"2005\" subdirectory and in the second iteration you are still in that subdirectory. Then you get the error that there is no \"2006\" directory (in the current \"2005\...
[ 1, 0, 0, 0 ]
[]
[]
[ "directory", "python" ]
stackoverflow_0001895538_directory_python.txt
Q: How do I disable Nagle's algorithm for sockets? I'm writing some python and are stuck at the moment. I think this "Nagle algoritm" is the problem since my packages are delayed some time for some reason to the client. I've tried this on both client and server but it doesn't seems to work (or there's another problem...
How do I disable Nagle's algorithm for sockets?
I'm writing some python and are stuck at the moment. I think this "Nagle algoritm" is the problem since my packages are delayed some time for some reason to the client. I've tried this on both client and server but it doesn't seems to work (or there's another problem causing it): socketobj.setsockopt(socket.IPPROTO_TCP...
[ "I'm not familiar with Python's sockets, but does it have a flush method? Even with Nagle's disabled, most socket implementations will buffer if you don't write X number of bytes. However, if you call flush, the bytes should be sent immediately.\n" ]
[ 0 ]
[]
[]
[ "networking", "python", "sockets" ]
stackoverflow_0001902325_networking_python_sockets.txt
Q: How do i make Pydev + jython to startup faster when running a script? i'm working with pydev + jython.great ide , but quite slow when i try to run a jython program. this is probably something due to libraries load time. What can i do to speed it up ? Thanks , yaniv A: Jython startup time is slow ... there's a lo...
How do i make Pydev + jython to startup faster when running a script?
i'm working with pydev + jython.great ide , but quite slow when i try to run a jython program. this is probably something due to libraries load time. What can i do to speed it up ? Thanks , yaniv
[ "Jython startup time is slow ... there's a lot to bootup!\nEverytime you run a Jython script from scratch, it will incur the same Jython startup time cost.\nHence, the reason Jython, Java, and Python are not great for CGI invocations. Hence, the reason for mod_python in Apache.\nThe key is to start-up Jython once a...
[ 2, 1 ]
[]
[]
[ "jython", "pydev", "python" ]
stackoverflow_0001467827_jython_pydev_python.txt
Q: Javascript communication with Selenium (RC) My Application has a lot of calculation being done in JavaScript according to how and when the user acts on the application. The project prints out valuable information (through console calls) as to how this calculation is going on, and so we can easily spot any NaNs cre...
Javascript communication with Selenium (RC)
My Application has a lot of calculation being done in JavaScript according to how and when the user acts on the application. The project prints out valuable information (through console calls) as to how this calculation is going on, and so we can easily spot any NaNs creeping in. We are planning to integrate Selenium (...
[ "There is GetEval() call that returns the result of a JavaScript call to the page. If you have the JavaScript on the page then you can do something like \nself.assertEqual(selenium.GetEval(\"this.browserbot.getUserWindow().functionUnderTest().isNaN();\"),\"false\",\"There was a NaN detected\")\n\nThe browserbot acc...
[ 4, 1 ]
[]
[]
[ "javascript", "python", "selenium", "selenium_rc", "testing" ]
stackoverflow_0001819903_javascript_python_selenium_selenium_rc_testing.txt
Q: python url fetch help - regex I have a web site where there are links like <a href="http://www.example.com?read.php=123"> Can anybody show me how to get all the numbers (123, in this case) in such links using python? I don't know how to construct a regex. Thanks in advance. A: import re re.findall("\?read\.php=(...
python url fetch help - regex
I have a web site where there are links like <a href="http://www.example.com?read.php=123"> Can anybody show me how to get all the numbers (123, in this case) in such links using python? I don't know how to construct a regex. Thanks in advance.
[ "import re\nre.findall(\"\\?read\\.php=(\\d+)\",data)\n\n", "\"If you have a problem, and decide to use regex, now you have two problems...\" \nIf you are reading one particular web page and you know how it is formatted, then regex is fine - you can use S. Mark's answer. To parse a particular link, you can use Ki...
[ 3, 2, 1, 1 ]
[ "/[0-9]/\nthats the regex sytax you want\nfor reference see\nhttp://gnosis.cx/publish/programming/regular_expressions.html\n", "One without the need for regex\n>>> s='<a href=\"http://www.example.com?read.php=123\">'\n>>> for item in s.split(\">\"):\n... if \"href\" in item:\n... print item[item.index...
[ -1, -1 ]
[ "python", "regex" ]
stackoverflow_0001899412_python_regex.txt
Q: How to properly remove a specific ManyToMany relationship? I have a ManyToMany relationship with one of my Models. On deleting a child, I want to remove the relationship but leave the record as it might be being used by other objects. On calling the delete view, I get an AttributeError error: Exception Value: '...
How to properly remove a specific ManyToMany relationship?
I have a ManyToMany relationship with one of my Models. On deleting a child, I want to remove the relationship but leave the record as it might be being used by other objects. On calling the delete view, I get an AttributeError error: Exception Value: 'QuerySet' object has no attribute 'clear' This is my models.p...
[ "Clear the fields on a Digest isntance\ndigest = get_object_or_404(Digest, id=id)\nif digest.user == request.user:\n digest.feeds.clear()\n #do your processing\n\nIn response to your comment.\ndigest = get_object_or_404(Digest, id=id)\nif digest.user == request.user:\n feed=digest.feeds.get(id=2)#get an instance...
[ 6 ]
[]
[]
[ "django", "django_models", "many_to_many", "python" ]
stackoverflow_0001902487_django_django_models_many_to_many_python.txt
Q: Running Django Tests with a Precommit Hook I would like to run all my django tests using mercurial's precommit hook. Whenever a test fails the commit will be aborted. The goal is to block build-breaking commits as often as possible. edit: Ended up using the external script route. Here is the reletant portion of my...
Running Django Tests with a Precommit Hook
I would like to run all my django tests using mercurial's precommit hook. Whenever a test fails the commit will be aborted. The goal is to block build-breaking commits as often as possible. edit: Ended up using the external script route. Here is the reletant portion of my hgrc: [hooks] precommit = python ./pinax/projec...
[ "It looks like Mercurial's way of importing modules is clashing with Django's somehow.\nBefore trying to dive in and sort that out, is there any reason to not just run the tests with the normal command?\n[hooks]\nprecommit.runtests = python manage.py test\n\n" ]
[ 7 ]
[]
[]
[ "django", "mercurial", "pre_commit", "python", "version_control" ]
stackoverflow_0001902817_django_mercurial_pre_commit_python_version_control.txt
Q: How do I chain object instantiation with its methods? For example this chunk of code: new_log = ActivityLog(user=self.user, activity=activity) new_log.save() Can I chain it to be like new_log = ActivityLog(...).save() ? I believe I tried the above, but it doesn't work. Is there a way to make...
How do I chain object instantiation with its methods?
For example this chunk of code: new_log = ActivityLog(user=self.user, activity=activity) new_log.save() Can I chain it to be like new_log = ActivityLog(...).save() ? I believe I tried the above, but it doesn't work. Is there a way to make it a 1 liner?
[ "Let save() return self, such as:\nclass ActivityLog (object): # EDIT: OR INHERIT FROM WHATEVER OTHER CLASS, I DONT CARE\n ...\n\n def save(self):\n ...\n return self\n\nNOTE: This is a generic coding pattern called method chaining.\n", "Django provides a convenience method on the model manage...
[ 6, 2 ]
[]
[]
[ "python" ]
stackoverflow_0001902836_python.txt
Q: Django Admin app: building a dynamic list of admin actions I am trying to dynamically build a list of admin actions using the get_actions() method on a ModelAdmin. Each action relates to a particular instance of another model, and as new instances may be added or removed, I want to make sure the list of actions re...
Django Admin app: building a dynamic list of admin actions
I am trying to dynamically build a list of admin actions using the get_actions() method on a ModelAdmin. Each action relates to a particular instance of another model, and as new instances may be added or removed, I want to make sure the list of actions reflects that. Here's the ModelAdmin: class PackageAdmin(admin.Mod...
[ "try \n def make_action(quality):\n return lambda modeladmin, req, qset: qset.update(quality=quality)\n\n for q in models.Quality.objects.all():\n action = make_action(q)\n name = \"mark_%s\" % (q,)\n yield (name, (action, name, \"Mark selected as %s quality\" % (q,)))\n\nif that doesn'...
[ 7, 5, 0 ]
[]
[]
[ "closures", "django", "python" ]
stackoverflow_0001902332_closures_django_python.txt
Q: How to implement time event scheduler in python? In python how to implement a thread which runs in the background (may be when the module loads) and calls the function every minute Monday to Friday 10 AM to 3 PM. For example the function should be called at: 10:01 AM 10:02 AM 10:03 AM . . 2:59 PM Any pointers? Env...
How to implement time event scheduler in python?
In python how to implement a thread which runs in the background (may be when the module loads) and calls the function every minute Monday to Friday 10 AM to 3 PM. For example the function should be called at: 10:01 AM 10:02 AM 10:03 AM . . 2:59 PM Any pointers? Environment: Django Thanks
[ "Django is a server application, which only reacts to external events.\nYou should use a scheduler like cron to create events that call your django application, either calling a management subcommand or doing an HTTP request on some special page.\n", "The threading.Timer class is convenient to do such tasks. But ...
[ 4, 2, 1 ]
[ "Note sure how django affects threads (unless you're using App Engine where you can't do low level such), but once your thread is running you can continuously check timestamps:\nfrom datetime import time\nfrom datetime import date\ntime_delta = 60\nwhile True:\n end_time = time.time() + time_delta\n while tim...
[ -1, -1 ]
[ "django", "multithreading", "python", "scheduling" ]
stackoverflow_0001902338_django_multithreading_python_scheduling.txt
Q: Validate that atleast one modelfield has value in Django admin Given the following model, how do I require that atleast one of the two fields has been given a value? class ZipUpload(models.Model): zip_file = models.FileField(upload_to="/tmp", blank=True, help_text='Select a file...
Validate that atleast one modelfield has value in Django admin
Given the following model, how do I require that atleast one of the two fields has been given a value? class ZipUpload(models.Model): zip_file = models.FileField(upload_to="/tmp", blank=True, help_text='Select a file to upload.') zip_file_path = models.FilePathField(path="/tmp", ...
[ "This kind of validation is what a customized Form is for. Define a Form, write validation methods in the Form. Bind the Form to the Model to create the Admin interface.\n" ]
[ 3 ]
[]
[]
[ "django", "django_admin", "django_models", "python" ]
stackoverflow_0001903158_django_django_admin_django_models_python.txt
Q: Are there any matrix math modules compatible with Python 3.x? When I began this project, I thought it would be easy to get libraries for common stuff like matrix math, so I chose to work in Python 3.1- it being the most recent, updated version of the language. Unfortunately, NumPy is only compatible with 2.5 and ...
Are there any matrix math modules compatible with Python 3.x?
When I began this project, I thought it would be easy to get libraries for common stuff like matrix math, so I chose to work in Python 3.1- it being the most recent, updated version of the language. Unfortunately, NumPy is only compatible with 2.5 and 2.6 and seems to be the only game in town! Even other stuff that I...
[ "Given that a large portion of those interested in this sort of development are involved in NumPy, and given their schedule for migrating I think the answer is \"no, there is nothing yet\".\nI would advise treating Python 3.x as \"still experimental\" and start with Python 2.6 instead. Make some small effort to wri...
[ 5, 1 ]
[]
[]
[ "math", "matrix", "python" ]
stackoverflow_0001903209_math_matrix_python.txt
Q: python libraries for programatic email access: mime, smtp, pop3 Does python have built in libraries for accessing email including: smtp, pop3, mime parsers etc? A: Absolutely: smtplib — SMTP protocol client poplib — POP3 protocol client imaplib — IMAP4 protocol client email — An email and MIME handling package ...
python libraries for programatic email access: mime, smtp, pop3
Does python have built in libraries for accessing email including: smtp, pop3, mime parsers etc?
[ "Absolutely:\n\nsmtplib — SMTP protocol client\npoplib — POP3 protocol client\nimaplib — IMAP4 protocol client\nemail — An email and MIME handling package\n\nThey are all included in the Python standard library.\n" ]
[ 3 ]
[]
[]
[ "email", "pop3", "python" ]
stackoverflow_0001904108_email_pop3_python.txt
Q: Python Windows Service Problems - Works when using debug argument but not while started as a service? hopefully someone here can shed some light on my issue :D I've been creating a Windows XP service in python that is designed to monitor/repair selected Windows/Application/Service settings, atm I have been focusin...
Python Windows Service Problems - Works when using debug argument but not while started as a service?
hopefully someone here can shed some light on my issue :D I've been creating a Windows XP service in python that is designed to monitor/repair selected Windows/Application/Service settings, atm I have been focusing on default DCOM settings. The idea is to backup our default configuration within another registry key for...
[ "So I guess it's time to admit my stupidity.... :P\nIt turns out this was not a python issue, py2exe issue, nor a WMI issue. :(\nThis was more or less a simple permission issue. So simple I overlooked it for the better part of a month. :(\nRule of thumb, if you want to create a service that calls to specific regist...
[ 1, 0 ]
[]
[]
[ "py2exe", "python", "pywin32", "windows_services", "wmi" ]
stackoverflow_0001780066_py2exe_python_pywin32_windows_services_wmi.txt
Q: Alter namespace prefixing with ElementTree in Python By default, when you call ElementTree.parse(someXMLfile) the Python ElementTree library prefixes every parsed node with it's namespace URI in Clark's Notation: {http://example.org/namespace/spec}mynode This makes accessing specific nodes by name a huge pai...
Alter namespace prefixing with ElementTree in Python
By default, when you call ElementTree.parse(someXMLfile) the Python ElementTree library prefixes every parsed node with it's namespace URI in Clark's Notation: {http://example.org/namespace/spec}mynode This makes accessing specific nodes by name a huge pain later in the code. I've read through the docs on Element...
[ "You don't specifically need to use iterparse. Instead, the following script:\nfrom cStringIO import StringIO\nimport xml.etree.ElementTree as ET\n\nNS_MAP = {\n 'http://www.red-dove.com/ns/abc' : 'rdc',\n 'http://www.adobe.com/2006/mxml' : 'mx',\n 'http://www.red-dove.com/ns/def' : 'oth',\n}\n\nDATA = '''...
[ 6, 2 ]
[]
[]
[ "elementtree", "namespaces", "python", "xml" ]
stackoverflow_0001249876_elementtree_namespaces_python_xml.txt
Q: Getting a list of all churches in a certain state using Python I am pretty good with Python, so pseudo-code will suffice when details are trivial. Please get me started on the task - how do go about crawling the net for the snail mail addresses of churches in my state. Once I have a one liner such as "123 Old West...
Getting a list of all churches in a certain state using Python
I am pretty good with Python, so pseudo-code will suffice when details are trivial. Please get me started on the task - how do go about crawling the net for the snail mail addresses of churches in my state. Once I have a one liner such as "123 Old West Road #3 Old Lyme City MD 01234", I can probably parse it into City,...
[ "Try lynx --dump <url> to download the web pages. All the troublesome HTML tags will be stripped from the output, and all the links from the page will appear together.\n", "You could use mechanize. It's a python library that simulates a browser, so you could crawl through the white pages (similarly to what you do...
[ 2, 2, 2, 2, 1 ]
[]
[]
[ "automation", "pseudocode", "python", "street_address", "web_crawler" ]
stackoverflow_0001903966_automation_pseudocode_python_street_address_web_crawler.txt
Q: Does Reddit use any type of ORM? Sorry I want to learn Python, and was curious if Reddit's codebase uses any sort of ORM? A: Have a look: http://code.reddit.com/browser/r2/r2/lib/db/ A: Yes. Reddit uses the Pylons framework, and relies on the SQLAlchemy framework for its own ORM layer. However, SQLAlchemy is a...
Does Reddit use any type of ORM?
Sorry I want to learn Python, and was curious if Reddit's codebase uses any sort of ORM?
[ "Have a look: http://code.reddit.com/browser/r2/r2/lib/db/\n", "Yes. Reddit uses the Pylons framework, and relies on the SQLAlchemy framework for its own ORM layer. However, SQLAlchemy is a fairly low-level ORM library as far as ORMs go, and so Reddit has a fair amount of custom code that makes the ORM stuff work...
[ 4, 3 ]
[]
[]
[ "python", "reddit" ]
stackoverflow_0001904319_python_reddit.txt
Q: Run a remote python script from ASP.Net I have a python script on a linux server that I can SSH into and I want to run the script on the linux server( and pass it parameters entered by the user) and get the output on an ASP.net webpage running on IIS. How would I be able to do that? Would it be easier if I was ru...
Run a remote python script from ASP.Net
I have a python script on a linux server that I can SSH into and I want to run the script on the linux server( and pass it parameters entered by the user) and get the output on an ASP.net webpage running on IIS. How would I be able to do that? Would it be easier if I was running a wamp server? Edit: The servers are in...
[ "Probably the best approach is the least coupled one. If you can determine a protocol that you're comfortable with the two (asp/python) talking in, it will go a long way to reducing headaches.\nLet's say you pick XML.\nSetup the python script to run as a WSGI application with either cherrypy or apache (or whatever...
[ 0 ]
[]
[]
[ "asp.net", "python", "remote_execution" ]
stackoverflow_0001904320_asp.net_python_remote_execution.txt
Q: Python tempfile module and threads aren't playing nice; what am I doing wrong? I'm having an interesting problem with threads and the tempfile module in Python. Something doesn't appear to be getting cleaned up until the threads exit, and I'm running against an open file limit. (This is on OS X 10.5.8, Python 2.5....
Python tempfile module and threads aren't playing nice; what am I doing wrong?
I'm having an interesting problem with threads and the tempfile module in Python. Something doesn't appear to be getting cleaned up until the threads exit, and I'm running against an open file limit. (This is on OS X 10.5.8, Python 2.5.1.) Yet if I sort of replicate what the tempfile module is doing (not all the securi...
[ "I am unable to reproduce the problem with (Apple's own build of) Python 2.5.1 on Mac OS X 10.5.9 -- runs to completion just fine!\nI've tried both on a Macbook Pro, i.e., an Intel processor, and an old PowerMac, i.e., a PPC processor.\nSo I can only imagine there must have been a bug in 10.5.8 which I never notice...
[ 4, 3, 1, 1, 0 ]
[]
[]
[ "multithreading", "python", "temporary_files" ]
stackoverflow_0001895350_multithreading_python_temporary_files.txt
Q: Synchronizing time between simple python-socket-based server and clients I have the beginnings of a small multiplayer game that I'm writing in python as a learning exercise. Currently the server runs at 10 fps, while the clients run at whatever rate they like. This works well to conserve bandwidth, but unless the ...
Synchronizing time between simple python-socket-based server and clients
I have the beginnings of a small multiplayer game that I'm writing in python as a learning exercise. Currently the server runs at 10 fps, while the clients run at whatever rate they like. This works well to conserve bandwidth, but unless the client tells the server when its input happened, all input gets quantized to 1...
[ "I accidentally came across an excruciatingly fine blog post on how to do distributed network physics in general (without traditional client prediction). I highly recommend it, along with the GDC slides Fiedler presented a couple of years ago. Good luck!\n", "This is a very interesting question. Unfortunately th...
[ 1, 0 ]
[]
[]
[ "multiplayer", "networking", "python", "udp" ]
stackoverflow_0001893987_multiplayer_networking_python_udp.txt
Q: How to have `pip install --editable` to run sdist instead of develop? This Python package install using pip or easy_install from repos points out a very interesting features of pip. However, sometimes you just want it to install the source distribution; this is particularly true when you are running in a virtuale...
How to have `pip install --editable` to run sdist instead of develop?
This Python package install using pip or easy_install from repos points out a very interesting features of pip. However, sometimes you just want it to install the source distribution; this is particularly true when you are running in a virtualenv (so you don't care about messing up the python path, since you are delib...
[ "Have you tried just omitting the --editable? If I run\npip install hg+http://bitbucket.org/carljm/django-markitup/\n\nit clones the repo to a temporary build directory and installs normally (via setup.py install rather than setup.py develop).\nOf course, if you then freeze this environment, the generated requireme...
[ 3 ]
[]
[]
[ "build_automation", "installation", "pip", "python" ]
stackoverflow_0001900775_build_automation_installation_pip_python.txt
Q: How to add a variable to the module I import from? What I want to do is something like this: template.py def dummy_func(): print(VAR) # more functions like this to follow fabfile.py # this gets called by fabric (fabfile.org) # safe to think of it as ant build.xml import template template.VAR = 'some_val' fr...
How to add a variable to the module I import from?
What I want to do is something like this: template.py def dummy_func(): print(VAR) # more functions like this to follow fabfile.py # this gets called by fabric (fabfile.org) # safe to think of it as ant build.xml import template template.VAR = 'some_val' from template import * Namely I have a template module ot...
[ "I'm not sure what you mean by \"a functional manner\" -- do you mean, as in functional programming? That's not going to happen (since you're intrinsically trying to modify an object, which is the reverse of FP). Or do you mean something like \"a way that works\"?\nFor the latter interpretation, the big problem i...
[ 4, 0, 0 ]
[]
[]
[ "fabric", "python" ]
stackoverflow_0001902656_fabric_python.txt
Q: PyObjc and Cocoa on Snow Leopard I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I w...
PyObjc and Cocoa on Snow Leopard
I am about to start my A-Level Computing project (High School Level) which will hopefully be a point-of-sale application for Mac OS. Unfortunately, Objective-C is a little out of my league at the moment and should I get stuck with it in the project I have no one to help out so I would fail the section of the course an...
[ "Allow me to echo what has already been said. I too am a student who just started a Cocoa development project, and at the beginning I thought \"Well, I already know Python, I'll just use PyObjC and save myself from having to learn Objective-C, which looks beyond my grasp.\" I learned quickly that it can't be done. ...
[ 18, 7, 4, 3, 3, 3 ]
[]
[]
[ "cocoa", "osx_snow_leopard", "pyobjc", "python", "xcode" ]
stackoverflow_0001359227_cocoa_osx_snow_leopard_pyobjc_python_xcode.txt
Q: PyQt: Call a TrayMinimized application I have an application wich is minimized to the tray (showing an icon) when the user close it. What I need to know is how can I call it back with a combination of keys, like Ctrl+Alt+Something. Actually I call it back when I double-click it, but it will be nice to do the same ...
PyQt: Call a TrayMinimized application
I have an application wich is minimized to the tray (showing an icon) when the user close it. What I need to know is how can I call it back with a combination of keys, like Ctrl+Alt+Something. Actually I call it back when I double-click it, but it will be nice to do the same on a keystroke. Here is a portion of the cod...
[ "For a keystroke to be handled by your application when it does not have keyboard focus, you need to install a global shortcut. Qt doesn't support this, but Qxt, a Qt extension library, does. See \nhttp://doc.libqxt.org/0.5.0/classQxtGlobalShortcut.html. I don't know if PyQt bindings exist for Qxt.\n" ]
[ 1 ]
[]
[]
[ "pyqt", "python", "qt" ]
stackoverflow_0001904557_pyqt_python_qt.txt
Q: Literals in django template language? If I want some text to appear literally in a Django template, e.g. {{Image.jpg|title}} and I want that text to be output (not interpretated) in the HTML, how do I do so? A: Try the {% templatetag %} template tag {% templatetag openvariable %}Image.jpg|title{% templatetag cl...
Literals in django template language?
If I want some text to appear literally in a Django template, e.g. {{Image.jpg|title}} and I want that text to be output (not interpretated) in the HTML, how do I do so?
[ "Try the {% templatetag %} template tag\n{% templatetag openvariable %}Image.jpg|title{% templatetag closevariable %}\n\nhttp://docs.djangoproject.com/en/dev/ref/templates/builtins/#templatetag\n", "You could start it with an HTML entity. e.g.:\n&#123;{Image.jpg|title}}\n\nHowever, I can only imagine this means y...
[ 5, 1 ]
[]
[]
[ "django", "django_templates", "literals", "python", "templates" ]
stackoverflow_0001905396_django_django_templates_literals_python_templates.txt
Q: Python QPushButton setIcon: put icon on button I want to put an in ICON into a push button.. the code should work like that: self.printButton = QtGui.QPushButton(self.tab_name) self.printButton.setIcon(QtGui.QPixmap('printer.tif')) self.printButton.setGeometry(QtCore.QRect(1030, 500, 161, 61)) But ins...
Python QPushButton setIcon: put icon on button
I want to put an in ICON into a push button.. the code should work like that: self.printButton = QtGui.QPushButton(self.tab_name) self.printButton.setIcon(QtGui.QPixmap('printer.tif')) self.printButton.setGeometry(QtCore.QRect(1030, 500, 161, 61)) But instead, it gives the error message: TypeError: arg...
[ "This is strange, I quickly tested the code on my C++ application and it seems to be working...\nMaybe by using this you could correct your problem :\nrMyIcon = QtGui.QPixmap(\"printer.tif\");\nself.printButton.setIcon(QtGui.QIcon(rMyIcon))\n\nHope this helps a bit...\n", "Create a QIcon rather than a QPixmap for...
[ 18, 7, 5 ]
[]
[]
[ "button", "icons", "python", "qt", "user_interface" ]
stackoverflow_0001905402_button_icons_python_qt_user_interface.txt
Q: dict keys with spaces in Django templates I am trying to present a dictionary from my view.py at the HTML template such as: test = { 'works': True, 'this fails':False } and in the template: This works without a problem: {{ test.works }} But a dictionary key that is having an empty space between words such as 'th...
dict keys with spaces in Django templates
I am trying to present a dictionary from my view.py at the HTML template such as: test = { 'works': True, 'this fails':False } and in the template: This works without a problem: {{ test.works }} But a dictionary key that is having an empty space between words such as 'this fails' doesn't work: {{ test.this fails }} ...
[ "The filter you want is something like \n@register.filter(name='getkey')\ndef getkey(value, arg):\n return value[arg]\n\nAnd used with \n{{test|getkey:'this works'}}\n\nsource: http://www.bhphp.com/blog4.php/2009/08/17/django-templates-and-dictionaries\n", "I don't know any standard solution in Django. I think...
[ 18, 2 ]
[ "That doesn't look right to me. Can you do the following?\n{{ test['works'] }} \n{{ test['this fails'] }}\n\nThis is how dictionary access in python typically works.\n" ]
[ -4 ]
[ "django", "django_templates", "python", "whitespace" ]
stackoverflow_0001906129_django_django_templates_python_whitespace.txt
Q: pyExcelerator has problems reading some files I've got a problem using pyExcelerator when reading some xls-files. There're some python scripts i wrote, that use this library to parse XLS-files and populate database with info. The templates for the files these scripts parse may vary and i sometimes reconfigure the...
pyExcelerator has problems reading some files
I've got a problem using pyExcelerator when reading some xls-files. There're some python scripts i wrote, that use this library to parse XLS-files and populate database with info. The templates for the files these scripts parse may vary and i sometimes reconfigure the script to handle them. With the one of the templat...
[ "I'm the author of xlrd. It reads XLS files and is not a fork of anything. I maintain a package called xlwt which writes XLS files and is a fork of pyExcelerator. The parse_xls functionality in pyExcelerator was deprecated to the point of removal from xlwt. Use xlrd instead.\nGiven the traceback that you reproduced...
[ 2, 1 ]
[]
[]
[ "excel", "pyexcelerator", "python", "xls" ]
stackoverflow_0001881253_excel_pyexcelerator_python_xls.txt
Q: Keyword Matching in Pyparsing: non-greedy slurping of tokens Pythonistas: Suppose you want to parse the following string using Pyparsing: 'ABC_123_SPEED_X 123' were ABC_123 is an identifier; SPEED_X is a parameter, and 123 is a value. I thought of the following BNF using Pyparsing: Identifier = Word( alphanums + ...
Keyword Matching in Pyparsing: non-greedy slurping of tokens
Pythonistas: Suppose you want to parse the following string using Pyparsing: 'ABC_123_SPEED_X 123' were ABC_123 is an identifier; SPEED_X is a parameter, and 123 is a value. I thought of the following BNF using Pyparsing: Identifier = Word( alphanums + '_' ) Parameter = Keyword('SPEED_X') or Keyword('SPEED_Y') or Keyw...
[ "I based my answer off of this one, since what you're trying to do is get a non-greedy match. It seems like this is difficult to make happen in pyparsing, but not impossible with some cleverness and compromise. The following seems to work:\nfrom pyparsing import *\nParameter = Literal('SPEED_X') | Literal('SPEED_Y'...
[ 7, 1, 1 ]
[ "This answers a question that you probably have also asked yourself: \"What's a real-world application for reduce?):\n>>> keys = ['CAT', 'DOG', 'HORSE', 'DEER', 'RHINOCEROS']\n>>> p = reduce(lambda x, y: x | y, [Keyword(x) for x in keys])\n>>> p\n{{{{\"CAT\" | \"DOG\"} | \"HORSE\"} | \"DEER\"} | \"RHINOCEROS\"}\n\...
[ -1 ]
[ "grammar", "parsing", "pyparsing", "python" ]
stackoverflow_0001905278_grammar_parsing_pyparsing_python.txt
Q: split svnversion output in bash I have this function, works fine, but I would like to rewrite it in bash. the problem is, I have too little knowledge of what's available in bash. #!/usr/bin/python def parse_svnversion(value): """split the output of svnversion into its three components given a string tha...
split svnversion output in bash
I have this function, works fine, but I would like to rewrite it in bash. the problem is, I have too little knowledge of what's available in bash. #!/usr/bin/python def parse_svnversion(value): """split the output of svnversion into its three components given a string that looks like the output of the comman...
[ "This creates an array called \"tuple\" with three elements:\n[[ $(svnversion .) =~ ([0-9]+):*([0-9]*)([A-Z]*) ]]\ntuple[0]=${BASH_REMATCH[1]}\ntuple[1]=${BASH_REMATCH[2]:-${tuple[0]}}\ntuple[2]=${BASH_REMATCH[3]:-''}\n\nRequires Bash 3.2 or greater. It may work in Bash >= 3 and < 3.2. Not portable to the Bourne sh...
[ 4, 1, 0 ]
[]
[]
[ "bash", "parsing", "python" ]
stackoverflow_0001905980_bash_parsing_python.txt
Q: Django general template controled by which variables? I have been developing some Django app and there's some duplicated code for different Models. I'd like to create a generic table template and pass the Model class, a list of model instances, and Form classes to it so it can render the page and generate the form...
Django general template controled by which variables?
I have been developing some Django app and there's some duplicated code for different Models. I'd like to create a generic table template and pass the Model class, a list of model instances, and Form classes to it so it can render the page and generate the forms to add/delete elements. Then create some generic add/dele...
[ "I'm not exaclty sure about your question and your code, but here is a short story about _meta ...\nTo access the column name of a class, you can inspect the _meta attribute of the class.\nExample. A sample model, which defines three fields and a helper methods whats_inside, which just iterates over _meta.fields an...
[ 0, 0 ]
[]
[]
[ "django", "django_forms", "django_templates", "python" ]
stackoverflow_0001906350_django_django_forms_django_templates_python.txt
Q: In python, is there a setdefault() equivalent for getting object attributes? Python's setdefault allows you to get a value from a dictionary, but if the key doesn't exist, then you assign the based on parameter default. You then fetch whatever is at the key in the dictionary. Without manipulating an object's __di...
In python, is there a setdefault() equivalent for getting object attributes?
Python's setdefault allows you to get a value from a dictionary, but if the key doesn't exist, then you assign the based on parameter default. You then fetch whatever is at the key in the dictionary. Without manipulating an object's __dict__Is there a similar function for objects? e.g. I have an object foo which may ...
[ "Note that the currently accepted answer will, if the attribute doesn't exist already, have called hasattr(), setattr() and getattr(). This would be necessary only if the OP had done something like overriding setattr and/or getattr -- in which case the OP is not the innocent enquirer we took him for. Otherwise call...
[ 26, 9, 4 ]
[ "Don't Do This.\nPlease use __init__ to provide default values. That's the Pythonic way.\nclass Foo( object ):\n def __init__( self ):\n self.bar = 'bah'\n\nThis is the normal, standard, typical approach. There's no compelling reason to do otherwise.\n" ]
[ -2 ]
[ "python" ]
stackoverflow_0001904723_python.txt
Q: python unbound method again This gets me into difficult time (sorry, i am still very new to python) Thank you for any kind of help. The error print Student.MostFrequent() TypeError: unbound method MostFrequent() must be called with Student instance as first argument (got nothing instead) This Student.MostFr...
python unbound method again
This gets me into difficult time (sorry, i am still very new to python) Thank you for any kind of help. The error print Student.MostFrequent() TypeError: unbound method MostFrequent() must be called with Student instance as first argument (got nothing instead) This Student.MostFrequent() is called all the way in...
[ "use Student().MostFrequent()\nedit:\nbeware that you use class attributes and this is dangerous. here an example:\n>>> class Person:\n... name = None\n... hobbies = []\n... def __init__(self, name):\n... self.name = name\n... \n>>> a = Person('marco')\n>>> b = Person('francesco')\n>>> a.hobbies.append('footba...
[ 7, 7, 2, 1, 0, 0 ]
[ "in your class def, the method definition \ndef MostFrequent(self,mostFrequent):\n\nhas the extra variable mostFrequent that you probably don't want there. Try changing to :\ndef MostFrequent(self):\n\n" ]
[ -1 ]
[ "class", "python" ]
stackoverflow_0001906926_class_python.txt
Q: How to connect an application with Facebook? The topic may be a bit ambiguous. I am writing a Python application. I want to upload it on Facebook as a Facebook application (NOT Facebook Connect). But I am having the hardest time figuring out how to implement the features of my application with Facebook. My applic...
How to connect an application with Facebook?
The topic may be a bit ambiguous. I am writing a Python application. I want to upload it on Facebook as a Facebook application (NOT Facebook Connect). But I am having the hardest time figuring out how to implement the features of my application with Facebook. My application currently uses a MySQL database. Now I want ...
[ "There is a good Facebook library that supports Django, pyfacebook. There are some examples in that package of how to use it.\nAnd there's no substitute for the actual Facebook developer documentation - it's written with PHP in mind, but you can use the same API calls via the Python library.\nHowever we can't reall...
[ 2, 0 ]
[]
[]
[ "django", "facebook", "facebook_fql", "python" ]
stackoverflow_0001906184_django_facebook_facebook_fql_python.txt
Q: How can I express base class method calling derived virtual? what's the way to do in python the following in C++? B* b = new D(); b->virtual_fn(); Which would call virtual_fn in D. Are there a form of references to do this? A: Effectively, all instance methods in Python are virtual and types are inferred. For e...
How can I express base class method calling derived virtual?
what's the way to do in python the following in C++? B* b = new D(); b->virtual_fn(); Which would call virtual_fn in D. Are there a form of references to do this?
[ "Effectively, all instance methods in Python are virtual and types are inferred. For example, this works:\nclass Vehicle:\n def __init__(self, lp):\n self.license_plate = lp\n def alert(self):\n raise NotImplementedError(\"Must implement this!\")\n\nclass Boat(Vehicle):\n def alert(self):\n print \"honk...
[ 2, 2 ]
[]
[]
[ "oop", "python" ]
stackoverflow_0001907182_oop_python.txt
Q: nested looping in python in a string suppose 12345 , i want to take nested loops , so that i would be able to iterate through the string in this following way :- 1, 2, 3, 4, 5 would be taken as integers 12, 3, 4,5 as integers 1, 23, 4, 5 as integers 1, 2, 34, 5 as integers ... And so on. I know what's the logi...
nested looping in python
in a string suppose 12345 , i want to take nested loops , so that i would be able to iterate through the string in this following way :- 1, 2, 3, 4, 5 would be taken as integers 12, 3, 4,5 as integers 1, 23, 4, 5 as integers 1, 2, 34, 5 as integers ... And so on. I know what's the logic but being a noob in Python, ...
[ "This smells a bit like homework.\nTry writing down the successive outputs, one per line, and look for a pattern. See if you can explain that pattern with slices of the input string. Then look for a numeric pattern to the slicing.\nAlso, please edit your question to put quotes around your strings. What you've wr...
[ 1, 0, 0 ]
[]
[]
[ "python" ]
stackoverflow_0001907519_python.txt
Q: python http handler I want something like BaseHTTPRequestHandler, except that I don't want it to bind to any sockets; I want to handle the raw HTTP data to and from it myself. Is there a good way that I can do this in Python? To Clarify, I want a class that receives raw TCP data from Python (NOT a socket), proces...
python http handler
I want something like BaseHTTPRequestHandler, except that I don't want it to bind to any sockets; I want to handle the raw HTTP data to and from it myself. Is there a good way that I can do this in Python? To Clarify, I want a class that receives raw TCP data from Python (NOT a socket), processes it and returns TCP da...
[ "BaseHTTPRequestHandler derives from StreamRequestHandler, which basically reads from file self.rfile and writes to self.wfile, so you can derive a class from BaseHTTPRequestHandler and supply your own rfile and wfile e.g.\nimport StringIO\nfrom BaseHTTPServer import BaseHTTPRequestHandler\n\nclass MyHandler(BaseH...
[ 3 ]
[]
[]
[ "handler", "http", "python", "request" ]
stackoverflow_0001907071_handler_http_python_request.txt
Q: python raw_input def input problem I am only going to post the portion where the problem is at, the program has no error (all the codes are valid except for this raw_input problem) I tested with search_function(1) and etc and it worked. But if I do this while loop, it doesn't print anything. Example output: Ente...
python raw_input def input problem
I am only going to post the portion where the problem is at, the program has no error (all the codes are valid except for this raw_input problem) I tested with search_function(1) and etc and it worked. But if I do this while loop, it doesn't print anything. Example output: Enter a number to print specific table, or...
[ "raw_input() returns string, while your code expects integer. Use search_function(int(x)) or change conditions to compare with strings.\n", "Test for x == 'STOP' first and break if True, else cast to int and call search_function:\nwhile True:\n x = raw_input(\"Enter a number to print specific table, or STOP to...
[ 2, 1 ]
[]
[]
[ "input", "python" ]
stackoverflow_0001907647_input_python.txt
Q: Framework for building visually rich desktop applications? I've started building an app with Flex/Air but am getting sick of it's clunkyness. The app that I'm building has similar behaviour to Prezi (www.prezi.com) but in a completely different field. I'm looking for something on the desktop which has flex like ca...
Framework for building visually rich desktop applications?
I've started building an app with Flex/Air but am getting sick of it's clunkyness. The app that I'm building has similar behaviour to Prezi (www.prezi.com) but in a completely different field. I'm looking for something on the desktop which has flex like capabilities, such as drawing vectors then zooming in/out, rotatin...
[ "Qt (Python bindings: PyQt) is a flexible and mature framework that can certainly do that (take a look at QGraphicsView and QGraphicsScene for example). \nYou'll have to code most of it 'by hand' though (the designer is good for standard GUI widgets but is lacking functionality in this particular area).\n", "If ...
[ 3, 0 ]
[]
[]
[ "python", "svg", "vector" ]
stackoverflow_0001907736_python_svg_vector.txt
Q: Whether to simplify two stage regular expression? I'm newbie in Python, but this question is not a homework (actually this code helps to generate RSS on my Subversion server). I have an array of strings in the info_lines variable. And I want to replace each occurrence of the bug ID. My current code looks like the ...
Whether to simplify two stage regular expression?
I'm newbie in Python, but this question is not a homework (actually this code helps to generate RSS on my Subversion server). I have an array of strings in the info_lines variable. And I want to replace each occurrence of the bug ID. My current code looks like the following: for ln in range(3, len(info_lines)): # skip ...
[ "No, there's not much of a better way to do it. The replacement code messes up the case where there are bug numbers and other numbers on the same line, but even so, you're not getting away from two res because you want support for a comma-separated bug list.\nimport re\n\ninfo_lines = [\n \"Me\",\n \"now\",\...
[ 2, 0 ]
[]
[]
[ "python", "regex" ]
stackoverflow_0001907137_python_regex.txt
Q: Problems installing MySQL-python-1.2.3c1 on Mac Snow Leopard I am having a problem installing the Python MySQL connector (MySQL-python-1.2.3c1) on my Mac OSX Snow Leopard. System State I have manually compiled an installed: mysql-5.1.41 This seems to work fine, as I can create and query a database from the command...
Problems installing MySQL-python-1.2.3c1 on Mac Snow Leopard
I am having a problem installing the Python MySQL connector (MySQL-python-1.2.3c1) on my Mac OSX Snow Leopard. System State I have manually compiled an installed: mysql-5.1.41 This seems to work fine, as I can create and query a database from the commandline. I have compiled: MySQL-python-1.2.3c1 I first set the follow...
[ "What does \notool -L /Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so\n\nreport?\n", "First, I would suggest using the MySQL binaries for MacOS X 10.5 64-bit (x86_64). The tar ball works on MacOS X 10.6.\nYou said you used ARCHFLAGS.. however, try it again like th...
[ 1, 1 ]
[]
[]
[ "compilation", "macos", "mysql", "osx_snow_leopard", "python" ]
stackoverflow_0001907540_compilation_macos_mysql_osx_snow_leopard_python.txt
Q: context within a query filter? I have a very basic contact model. The model has the following fields: class Entry(models.Model): name = models.CharField(max_length=64, unique=False) organization = models.CharField(max_length=100, unique=False, blank=True, null=True) team = models.CharField(max_length=...
context within a query filter?
I have a very basic contact model. The model has the following fields: class Entry(models.Model): name = models.CharField(max_length=64, unique=False) organization = models.CharField(max_length=100, unique=False, blank=True, null=True) team = models.CharField(max_length=64, unique=False, blank=True, null=T...
[ "You probably want the display_organization URL map to include a parameter for the organization:\n('^organization/(?P<org_name>.+)$', 'myapp.views.display_organization'),\n\nWith that, your display_organization function must accept the org_name parameter too:\ndef display_organization(request, org_name):\n recor...
[ 3, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0001902813_django_python.txt
Q: how can I make 'between' query with web2py.DAL? I'm trying to make a query function that accepts two datetime.date object(start_date and end_date), and return all records with a related field that's between start_date and end_date. However, I found nothing like a between function in the web2py manual, so I impleme...
how can I make 'between' query with web2py.DAL?
I'm trying to make a query function that accepts two datetime.date object(start_date and end_date), and return all records with a related field that's between start_date and end_date. However, I found nothing like a between function in the web2py manual, so I implement it this way: for o in objects: ...
[ "db((db.mytable.create_date>=query_dict['create_date1'])&(db.mytable.create_date<=query_dict['create_date2'])).select()\n" ]
[ 3 ]
[]
[]
[ "python", "web2py" ]
stackoverflow_0001907088_python_web2py.txt
Q: Encoding utf-8 to base64 with accents I have some data like this: data1 = ['Agos', '30490349304'] data2 = ['Desir\xc3\xa9','9839483948'] I'm using an API that expects the data encoded in base64, so what I do is: data = data1 string = base64.b64encode("Hi, %s! Your code is %s" % (data[0], data[0])) myXMLRPCCall(st...
Encoding utf-8 to base64 with accents
I have some data like this: data1 = ['Agos', '30490349304'] data2 = ['Desir\xc3\xa9','9839483948'] I'm using an API that expects the data encoded in base64, so what I do is: data = data1 string = base64.b64encode("Hi, %s! Your code is %s" % (data[0], data[0])) myXMLRPCCall(string) Which works fine with data1. With da...
[ "First make sure you're not confused about encodings, etc. Read, for example, this.\nThen notice that the main problem isn't with the base64 encoding, but with the fact that you're trying to put byte string (normal string in Python 2.x) inside a Unicode string. I believe you can fix this by removing the \"u\" from ...
[ 1, 1, 0 ]
[]
[]
[ "ascii", "base64", "encoding", "python", "utf_8" ]
stackoverflow_0001908035_ascii_base64_encoding_python_utf_8.txt
Q: turbogears request/user object in templates and request context I am currently making the switch from Django to Turbogears 2.1 and am running into some problems that I could not find the answers to in the Turbogears docs. If tg developers read this, let me tell you that one of the best features Django has over TG ...
turbogears request/user object in templates and request context
I am currently making the switch from Django to Turbogears 2.1 and am running into some problems that I could not find the answers to in the Turbogears docs. If tg developers read this, let me tell you that one of the best features Django has over TG is its documentation! 1) How do I access the request (user?) object w...
[ "I've moved from Turbogears 1.0 to Django. Might not be able to answer all of these, but I believe in general TG2 tries to keep things fairly similar to TG1. Hopefully pointing out how it works in TG 1, might help...\n1) In Turbogears 1.0 you would use tg.identity.anonymous to see if the user was logged in or not...
[ 1 ]
[]
[]
[ "django", "mako", "python", "requestcontext", "turbogears" ]
stackoverflow_0001905885_django_mako_python_requestcontext_turbogears.txt
Q: From Sax to Dom with DTD (python) I need a validated DomTree with DTD (to use getElementById). Validating and Parsing works, but the dom does't work properly: from xml.dom import minidom from xml.dom.pulldom import SAX2DOM from lxml import etree import lxml.sax from StringIO import StringIO data_string = """\ <?...
From Sax to Dom with DTD (python)
I need a validated DomTree with DTD (to use getElementById). Validating and Parsing works, but the dom does't work properly: from xml.dom import minidom from xml.dom.pulldom import SAX2DOM from lxml import etree import lxml.sax from StringIO import StringIO data_string = """\ <?xml version="1.0" encoding="utf-8"?> <!...
[ "As far as I know: SAX DTD events are not handled by the ContentHandler, but by the DTDHandler, which is a property you can set on the sax parser (XMLReader). This means that you cannot do this without serializing and reparsing the document.\nvalidated_string = etree.tostring(tree)\ndomDocument = minidom.parseStrin...
[ 1 ]
[]
[]
[ "dom", "dtd", "python", "sax" ]
stackoverflow_0001907740_dom_dtd_python_sax.txt
Q: How to combine multiple images fast for page views counter How can I combine multiple images, such as base image with logo and number of digits images to display graphical counter with pageviews count, updated dynamically? It should be very fast, with thousands of renders per second. User should see counter image ...
How to combine multiple images fast for page views counter
How can I combine multiple images, such as base image with logo and number of digits images to display graphical counter with pageviews count, updated dynamically? It should be very fast, with thousands of renders per second. User should see counter image without Javascript and with single img tag. I prefer to implemen...
[ "Precompute for the given background the image of a single digit (for each digit 0 ... 10) at each digit position.\nThen to create arbitrary number you only have to paste the correct images next to eachother, but you won't have to do any alpha blending. Therefore this must be more efficient.\nAlso, if certain page ...
[ 2, 0, 0 ]
[]
[]
[ "counter", "python", "python_imaging_library" ]
stackoverflow_0001908334_counter_python_python_imaging_library.txt
Q: Best way to add python scripting into QT application? I have a QT 4.6 application (C++ language) and i need to add python scripting to it on windows platform. Unfortunately, i never embed python before, and it seems to be a lot of different ways to do so. Can anyone share his wisdom and point me into some articles...
Best way to add python scripting into QT application?
I have a QT 4.6 application (C++ language) and i need to add python scripting to it on windows platform. Unfortunately, i never embed python before, and it seems to be a lot of different ways to do so. Can anyone share his wisdom and point me into some articles/documentation i can read to perform a specified task in le...
[ "Edit:\nYou can use PythonQt (not PyQt) that allow you to use Python with Qt. I think this is what you are searching for.\nHere a documentation on the official website: http://doc.qt.digia.com/qq/qq23-pythonqt.html.\n", "You should take a look at PythonQt. From the homepage:\n\nPythonQt is a dynamic Python\n bin...
[ 6, 6 ]
[]
[]
[ "c++", "python", "qt" ]
stackoverflow_0001908269_c++_python_qt.txt
Q: Blocking behavior of PyGTK's main loop My intention was to use pyGTK's main loop to create a function that blocks while it waits for the user's input. The problem I've encountered is best explained in code: #! /usr/bin/python import gtk def test(): retval = True def cb(widget): retval = False ...
Blocking behavior of PyGTK's main loop
My intention was to use pyGTK's main loop to create a function that blocks while it waits for the user's input. The problem I've encountered is best explained in code: #! /usr/bin/python import gtk def test(): retval = True def cb(widget): retval = False gtk.main_quit() window = gtk.Windo...
[ "This is the dialog pattern. Use a gtk.Dialog. Dialog.run() blocks exactly how you need it to, and returns the dialog's return code.\n", "What is happening is that when python sees foo = bar as the first reference to foo in a function it assumes that it is a local variable. In python3k you can get around this by ...
[ 3, 2 ]
[]
[]
[ "callback", "pygtk", "python" ]
stackoverflow_0001890715_callback_pygtk_python.txt
Q: Improve code: test for key in dict and store in datastore Hey, I'm fairly new to python I have this piece of code which stores the birth info to the datastore in Google App Engine. The code works but is it the correct way to do it? Is there a simpler way to do it, to make sure that the key exists before storing it...
Improve code: test for key in dict and store in datastore
Hey, I'm fairly new to python I have this piece of code which stores the birth info to the datastore in Google App Engine. The code works but is it the correct way to do it? Is there a simpler way to do it, to make sure that the key exists before storing it in datastore? def store_birthinfo(self, user, birthday): """...
[ "def store_birthinfo(self, user, birthday):\n \"\"\"\n Store birthinfo\n \"\"\"\n\n birthinfo = BirthInfo(user=user, **birthday)\n birthinfo.put()\n\nsee the docs on unpacking argument lists.\n", "ʞɔıu's answer is the shortest, though it has slightly different semantics than yours, in that yours will pro...
[ 2, 1, 1, 0, 0 ]
[]
[]
[ "google_app_engine", "python" ]
stackoverflow_0001908104_google_app_engine_python.txt
Q: buildbot: run svn with --trust-server-cert I am trying to install buildbot for my project. I always run my svn commands with trust-server-cert option. How can I pass that to SVN thru buildbot? I don't see there is a way for doing that. What is the shortest workaround? A: Use the extra_args argument to the buildb...
buildbot: run svn with --trust-server-cert
I am trying to install buildbot for my project. I always run my svn commands with trust-server-cert option. How can I pass that to SVN thru buildbot? I don't see there is a way for doing that. What is the shortest workaround?
[ "Use the extra_args argument to the buildbot.steps.source.SVN constructor.\n" ]
[ 2 ]
[]
[]
[ "build_process", "buildbot", "project_management", "python", "svn" ]
stackoverflow_0001908856_build_process_buildbot_project_management_python_svn.txt
Q: Python: list problems I've read in a text file and converted each line into a list. using this script: l = [s.strip().split() for s in open("cluster2.wcnf").readlines()] How would i go about : the file it opens is dynamic rather than static? i.e. the user chooses the file to open. Select specific lines to read a...
Python: list problems
I've read in a text file and converted each line into a list. using this script: l = [s.strip().split() for s in open("cluster2.wcnf").readlines()] How would i go about : the file it opens is dynamic rather than static? i.e. the user chooses the file to open. Select specific lines to read after it has been converted ...
[ "First of all, you must drop .readlines() from your list comprehension.\nSecond, l is a list of lists, to access first line just do: l[0]. First element of the first line would then be l[0][0].\nThe problem with the growing file I believe cannot be solved with such approach, though. If by dynamic you mean file name...
[ 1, 0, 0, 0, 0 ]
[]
[]
[ "line", "list", "python", "select" ]
stackoverflow_0001908961_line_list_python_select.txt
Q: Starting Python script without explicitly having X11 open I had Python v2.3 on my system. When I wanted to run a Tkinter script I could just use python myscript.py I recently upgraded to Python 2.5 and now I need to have X11 running and the "DISPLAY" environment variable set before I can run any of my scripts. Th...
Starting Python script without explicitly having X11 open
I had Python v2.3 on my system. When I wanted to run a Tkinter script I could just use python myscript.py I recently upgraded to Python 2.5 and now I need to have X11 running and the "DISPLAY" environment variable set before I can run any of my scripts. This is bad for me, because I can't distribute any scripts withou...
[ "Install python2.5 or python2.6 for OS X from python.org. They use the native Aqua Tk and thus do not require X11 for IDLE or python scripts that use Tkinter.\n", "I have installed Python 2.6.4 and I haven't any problem at all running it without a $DISPLAY variable ...\nI'm on linux ...\n", "If I had to guess ...
[ 1, 0, 0 ]
[]
[]
[ "macos", "python", "tkinter", "x11" ]
stackoverflow_0001905382_macos_python_tkinter_x11.txt
Q: Integrate Python app into PHP site This might sound really crazy, but still... For our revamped project site, we want to integrate Trac (as code browser, developer wiki and issue tracker) into the site design. That is, of course, difficult, since Trac is written in Python and our site in PHP. Does anybody here kno...
Integrate Python app into PHP site
This might sound really crazy, but still... For our revamped project site, we want to integrate Trac (as code browser, developer wiki and issue tracker) into the site design. That is, of course, difficult, since Trac is written in Python and our site in PHP. Does anybody here know a way how to integrate a header and fo...
[ "The best option probably is to (re)write the header and footer using python.\nIf the header and footer are relatively static you can also generate them once using php (or once every x minutes) and include them from the filesystem. (You probably already thought about this and dismissed the idea because your sites a...
[ 1, 1, 0 ]
[]
[]
[ "integration", "php", "python", "trac" ]
stackoverflow_0001907782_integration_php_python_trac.txt
Q: Django date filter to output "am" or "A.M." The Django date template filter takes the format character "a" for "a.m." and "A" for "AM". How do you get lower case without periods or upper case with the periods? You can use lower and upper filters, but they will mess with month and day of the week formatting. A: ...
Django date filter to output "am" or "A.M."
The Django date template filter takes the format character "a" for "a.m." and "A" for "AM". How do you get lower case without periods or upper case with the periods? You can use lower and upper filters, but they will mess with month and day of the week formatting.
[ "Alternately you could inherit the base functionality and simply add the output you're looking for. (again with a custom filter).\nHere's a custom template fitler which adds a new argument 'c' that will change (get it, c... change) the functional of a/A. It basically serves as a switch to toggle the functionality ...
[ 4, 1, 0 ]
[]
[]
[ "django", "python" ]
stackoverflow_0001905721_django_python.txt
Q: C/Python Socket Performance? my question simply relates to the difference in performance between a socket in C and in Python. Since my Python build is CPython, I assume it's similar, but I'm curious if someone actually has "real" benchmarks, or at least an opinion that's evidence based. My logics is as such: C s...
C/Python Socket Performance?
my question simply relates to the difference in performance between a socket in C and in Python. Since my Python build is CPython, I assume it's similar, but I'm curious if someone actually has "real" benchmarks, or at least an opinion that's evidence based. My logics is as such: C socket much faster? then write a C ...
[ "In general, sockets in Python perform just fine. For example, the reference implementation of the BitTorrent tracker server is written in Python.\nWhen doing networking operations, the speed of the network is usually the limiting factor. That is, any possible tiny difference in speed between C and Python's socket ...
[ 13, 1 ]
[]
[]
[ "c", "python", "scapy", "sockets" ]
stackoverflow_0001909471_c_python_scapy_sockets.txt
Q: Combine lxml XSLT pretty_print with strip-space I'm cleaning up some gross XML, and so I've had pretty_print = True set in the call to etree.tostring() on my lxml output of the XSL transform. However, that left me with a few junk whitespace nodes from the original input, so I added <xsl:strip-space elements="*"/> ...
Combine lxml XSLT pretty_print with strip-space
I'm cleaning up some gross XML, and so I've had pretty_print = True set in the call to etree.tostring() on my lxml output of the XSL transform. However, that left me with a few junk whitespace nodes from the original input, so I added <xsl:strip-space elements="*"/> ...but that completely collapses all whitespace, ign...
[ "Do it in two steps? First strip the spaces, then pretty-print?\nJust a thought.\n" ]
[ 1 ]
[]
[]
[ "lxml", "pretty_print", "python", "xml", "xslt" ]
stackoverflow_0001909401_lxml_pretty_print_python_xml_xslt.txt
Q: Higher-performance method do this type of insert from python? Given two arrays hashes and table, for each value in hashes I want to store the position of the element at the element's value's offset in the array table. Here is the naïve algorithm: def insert_n(table,hashes): for x in xrange(len(hashes)): ...
Higher-performance method do this type of insert from python?
Given two arrays hashes and table, for each value in hashes I want to store the position of the element at the element's value's offset in the array table. Here is the naïve algorithm: def insert_n(table,hashes): for x in xrange(len(hashes)): table[hashes[x]]=x This is extremely slow. Psyco helps some her...
[ "This is fast and simple (assuming table and hashes are numpy.uint32 arrays):\ntable[hashes] = numpy.arange(len(hashes), dtype=numpy.uint32)\n\nYou may want to compare the speed with this:\ntable[hashes] = xrange(len(hashes))\n\nBy the way, numpy.insert does not do the same thing as the for-loop you posted.\n" ]
[ 2 ]
[]
[]
[ "algorithm", "benchmarking", "performance", "python" ]
stackoverflow_0001907911_algorithm_benchmarking_performance_python.txt
Q: How does one feed a list of files into an app with appscript and Python? Get your newb-shields up, I'm about to sprinkle you with some. I'm trying to get Photoshop CS4 to open a folderful of JPEG images with AppScript+Python, which could be described like so in BASH: #!/bin/bash for F in `ls ~/Desktop/test`; do ...
How does one feed a list of files into an app with appscript and Python?
Get your newb-shields up, I'm about to sprinkle you with some. I'm trying to get Photoshop CS4 to open a folderful of JPEG images with AppScript+Python, which could be described like so in BASH: #!/bin/bash for F in `ls ~/Desktop/test`; do open -a "Adobe Photoshop CS4" $F # proceed to mutilate the image appea...
[ "Photoshop's open command requires an alias object (or list of alias objects).\nfrom appscript import *\n\nfolder = '/path/to/folder'\n\nps = app('Adobe Photoshop CS4')\n\nfor f in app('Finder').items[mactypes.Alias(folder)].files.get(resulttype=k.alias):\n ps.open(f)\n # do stuff here...\n\n" ]
[ 3 ]
[]
[]
[ "applescript", "finder", "macos", "python", "sourceforge_appscript" ]
stackoverflow_0001909282_applescript_finder_macos_python_sourceforge_appscript.txt
Q: Read https url from Python with basic access authentication How do you open https url in Python? import urllib2 url = "https://user:password@domain.com/path/ f = urllib2.urlopen(url) print f.read() gives: httplib.InvalidURL: nonnumeric port: 'password@domain.com' A: This has never failed me import urllib2, bas...
Read https url from Python with basic access authentication
How do you open https url in Python? import urllib2 url = "https://user:password@domain.com/path/ f = urllib2.urlopen(url) print f.read() gives: httplib.InvalidURL: nonnumeric port: 'password@domain.com'
[ "This has never failed me\nimport urllib2, base64\nusername = 'foo'\npassword = 'bar'\nauth_encoded = base64.encodestring('%s:%s' % (username, password))[:-1]\n\nreq = urllib2.Request('https://somewebsite.com')\nreq.add_header('Authorization', 'Basic %s' % auth_encoded)\ntry:\n response = urllib2.urlopen(req)\ne...
[ 11, 5, 3, 2 ]
[]
[]
[ "authentication", "https", "passwords", "python" ]
stackoverflow_0001906977_authentication_https_passwords_python.txt
Q: Python: List to integers I have read a file in and converted each line into a list. A sample of the list looks like: ['15', '2', '0'], ['63', '3', '445', '456' '0'], ['23', '4', '0'] i want to retrieve the first number from each list and convert it to and integer so when i carry out the type function i.e. type(x) ...
Python: List to integers
I have read a file in and converted each line into a list. A sample of the list looks like: ['15', '2', '0'], ['63', '3', '445', '456' '0'], ['23', '4', '0'] i want to retrieve the first number from each list and convert it to and integer so when i carry out the type function i.e. type(x) <type 'int'> is returned Als...
[ "To cast your ints:\nmy_ints = [int(l[0]) for l in your_list]\n\nTo print them out:\nprint \"\".join(map(str, my_ints))\n\n", "If you want a list with the first number of each list, [int(L[0]) for L in lines] (assuming the list of lists is called lines); if you want the first two numbers of each list (it's hard t...
[ 11, 3, 1, 0, 0 ]
[]
[]
[ "integer", "list", "python" ]
stackoverflow_0001909619_integer_list_python.txt
Q: ISO public Django apps developed Agile / BDD style with Doctest, Unitests and Selenium I've found several blog posts where TDD/BDD is explained, but the examples are usually really basic. Usually they are just for Models. I want to see how people are really using BDD in Real Life. I'd love be pointed towards some...
ISO public Django apps developed Agile / BDD style with Doctest, Unitests and Selenium
I've found several blog posts where TDD/BDD is explained, but the examples are usually really basic. Usually they are just for Models. I want to see how people are really using BDD in Real Life. I'd love be pointed towards some Django apps that were built test first style so I can learn from them. I know that Rails ha...
[ "Your likely doing it right already. For the moment, there's an ample amount of blog posts from Django developers where they talk about doing Django development right and how they solved issues with testing some heavy-duty stuff, but not a single resource that covers it all, especially not with employing TDD exclus...
[ 3 ]
[]
[]
[ "agile", "bdd", "django", "python", "tdd" ]
stackoverflow_0001909674_agile_bdd_django_python_tdd.txt
Q: Is it possible to use functions before declaring their body in python? Is there any way to make possible to use functions in your file before you actually declare their body? The following code doesn't seem to work: abc = myFunction def myFunction(): print "123" Thanks A: You can't use the myFunction varia...
Is it possible to use functions before declaring their body in python?
Is there any way to make possible to use functions in your file before you actually declare their body? The following code doesn't seem to work: abc = myFunction def myFunction(): print "123" Thanks
[ "You can't use the myFunction variable before it's assigned. Your example code is similar to:\ndef myFunction():\n print abc\n abc = 123\n\nTo do what you want, either re-arrange the order:\ndef myFunction():\n print \"123\"\n\nabc = myFunction\n\nOr declare abc as just a proxy:\n# Style 1\nabc = lambda: m...
[ 21, 13, 1, 1, 1 ]
[]
[]
[ "python" ]
stackoverflow_0001909325_python.txt
Q: Dynamically build and return a Python list in a C Python extension I'm writing a Python extension in C, and I'm trying to figure out how to dynamically build and return a Python list using my extension. I know how to build a list of predetermined size using Py_BuildValue. Is there a way to create a list with Py_...
Dynamically build and return a Python list in a C Python extension
I'm writing a Python extension in C, and I'm trying to figure out how to dynamically build and return a Python list using my extension. I know how to build a list of predetermined size using Py_BuildValue. Is there a way to create a list with Py_BuildValue then append items to that list? Is there a different, and bet...
[ "How about using PyList_Append, just like (modulo reference management and whatnot) you'd use .append in Python?\nLooking at the list API docs may help as well.\n" ]
[ 4 ]
[]
[]
[ "cextension", "cpython", "python" ]
stackoverflow_0001910258_cextension_cpython_python.txt
Q: facebook app in python showing file list i am making a facebook app in python with django. now i have successfully resolved the callback url to my localhost account. but the app is not displaying on facebook. when i navigate to apps.facebook.com/'myappname', it authenticates and then displays the file list on proj...
facebook app in python showing file list
i am making a facebook app in python with django. now i have successfully resolved the callback url to my localhost account. but the app is not displaying on facebook. when i navigate to apps.facebook.com/'myappname', it authenticates and then displays the file list on project folder?
[ "Based on your comments, I think I see what's going on. 192.168.2.2 is not a valid URL. That is a local network IP, and cannot be accessed from outside your network.\nYou need to set your Canvas Callback URL to the external IP address of your modem.\n" ]
[ 3 ]
[]
[]
[ "django", "facebook", "python" ]
stackoverflow_0001910131_django_facebook_python.txt
Q: Parsing XML to a hash table I have an XML file in the following format: <doc> <id name="X"> <type name="A"> <min val="100" id="80"/> <max val="200" id="90"/> </type> <type name="B"> <min val="100" id="20"/> <max val="20" id="90"/> </type> </id> <type...> </type> </doc> I would like to pa...
Parsing XML to a hash table
I have an XML file in the following format: <doc> <id name="X"> <type name="A"> <min val="100" id="80"/> <max val="200" id="90"/> </type> <type name="B"> <min val="100" id="20"/> <max val="20" id="90"/> </type> </id> <type...> </type> </doc> I would like to parse this document and build a has...
[ "I disagree with the suggestion in other answers to use minidom -- that's a so-so Python adaptation of a standard originally conceived for other languages, usable but not a great fit. The recommended approach in modern Python is ElementTree.\nThe same interface is also implemented, faster, in third party module lxm...
[ 12, 3, 2, 2, 1, 0 ]
[]
[]
[ "dom", "python", "xml" ]
stackoverflow_0001908410_dom_python_xml.txt