A python script I need to run takes input only from an file passed as a command line argument, like so: $ markdown.py input_file Is there any way to get it to accept input from STDIN instead? I want to be able to do this through Bash, without significantly mod...
I'd like to know what is getting assigned to what in line 8. # Iterators class Fibs: def __init__(self): self.a = 0 self.b = 1 def next(self): self.a, self.b = self.b, self.a+self.b # <--- here return self.a def __iter__(self): ...
I'd like to build a graph showing which tags are used as children of which other tags in a given XML document. I've written this function to get the unique set of child tags for a given tag in an lxml.etree tree: def iter_unique_child_tags(root, tag): """Iterates th...
Hi there, I am wondering if anyone has any experience with Python and video processing. Essentially, I would like to know if there are any libraries that would allow me to do scene detection in a video? If not, are there any that can allow me to split the video up into a series of fra...
I have made a dictionary and I put the keys of the dict in a list. My list contains elements like this: s = [((5, 4), 'South', 1), ((4, 5), 'West', 1)] I made a dict from this: child = dict((t[0], t[1]) for t in s) keys = child.keys() print k...
s = [((5, 4), 'South', 1), ((4, 5), 'West', 1)] I want to put the (5,4) and (4,5) in to the stack. stack is already implemented in a file... so I am using : stack = search.Stack() Now I can use push and pop for stack. How to get the (5,4) and (4...
Hello, I've read through the FAQ for Jython and this post stackoverflow.com/questions/471000/jython-and-python-modules but am not sure how I can determine if a module is written purely in C or Pyth...
hey.. trying to figure out how to determine what version of XPath is supported by python 2.4.3/2.5.1 using libxml2dom. in looking through various docs, i must be missing something! basically, i'm considering how/if i can have an XPath function, and use regex within the ...
like one forum has many topic , ths specific is : forum and topic has the same model : class Geo(db.Model): #self = db.SelfReferenceProperty() title = db.StringProperty() link = db.StringProperty() updated = db.DateTimeProperty(auto_now =True) autho...
I have a list of patterns like list_patterns = [': error:', ': warning:', 'cc1plus:', 'undefine reference to'] what I want to do is to produce a union of all of them yielding a regular expression that matches every element in list_patterns [but pr...
How can I append the content of each of the following tuples (ie, elements within the list) to another list which already has 'something' in it? So, I want to append the following to a list (eg: result[]) which isn't empty: l = [('AAAA', 1.11), ('BBB', 2.22), ('CCCC', 3.33)]
output of n is in the form:- ((6,5),'north',1) I am making a dict child for it...in which (6,5) is the key and north and 1 are the values. I need to keep the (6,5) as the key and north as a direction....and I...
Hello, I've created a simple hexbin plot with matplotlib.pyplot. I haven't changed any default settings. My x-axis information ranges from 2003 to 2009, while the y values range from 15 to 35. Rather than writing out 2003, 2004, etc., matplotlib collapses it into 0, 1, 2, ... + 2.00...
I'm working on a twisted tutorial just to learn more python and it seems I've ran into a road block here. The doRead() function below is the "callback" of a reactor. What I can't understand is how the except part works. The way I read the code is that if bytes += self.sock.recv(...
The struct module is useful when you're trying to convert data to and from binary formats. However, recently I came across a file format specification that uses
I would like to invoke my chrome or firefox browser when a file that I specify is modified. How could I "watch" that file to do something when it gets modified? Programmatically it seems the steps are.. basically set a never ending interval every second or so ...
When doing an "from <> import *" in a package, the name <> is clobbered in the local namespace. Is this erroneous? Am I going about this all wrong? Here's the module contents: absolute_clobber_import/__init__.py from __future__ import absolute_import ...
i have self.some_field = [] in my class Im enquiring is there a way to make this list read-only like a property?
How to create a dictionary of 2 lists. I want to use the elements of 1 list as key and another as value. Like I have a dictionary in which keys are (6,4) and values are (north, 1) It means each key has values that has 2 elements in it. I need to have only one i.e north .So that when I ...
In my web application I have wizards with many next previous buttons and choices ( kind of flow chart with events and options ). Wizard do not run in one go, but may wait for external event, user come later or next day to carry on with that wizard. Currently I am manually writing code ( hard c...
how to simplify exponents in equations in sympy from sympy import symbols a,b,c,d,e,f=symbols('abcdef') j=(a**b**5)**(b**10) print j (a**(b**5))**(b**10) #ans even after using expand simplify # desired output a**(b**15) and if it is not possible with sym...
MYTable.objects.filter( where id = 42, 55, 65, and 55) and it returns a query set ?
I am building a dating site in Django / Python. I have birthday dates and need to show what the person's Zodiac sign is based on their birthday. Anybody done this before? What would be the most efficient way of accomplishing this?
This proxy server connects to another proxy server which is connected to the internet . The problem with this is that authentication etc works fine but the Server receives only the header from the remote server and not the HTML.How to fix this? please help USER='someUsername' ...
I made a dictionary, then split up the values and keys into lists and now its looks like this: keys = [(4,5),(5,6),(4,8)......so on]. values = [('west',1),('south',1).......] Then I made a new dictionary like in this way, final = dict((k,v[0]) ...
Hi, I'm playing with Python and Google App Engine for the first time but am unable to define a string within my function (mytest2), I get an indentation error on the line after the declaration. I can define one in the parameters that works (test) but can't see why I wouldn't be able to...
while stack.isEmpty() != 1: fin = stack.pop() print fin - output is (1,1) k = final.get(fin) return k def directionToVector(direction, speed = 1.0): dx, dy = Actions._directions[direction] return (dx * speed, dy * speed) di...
Hello, How do I create a twisted server that's also a client? I want the reactor to listen while at the same time it can also be use to connect to the same server instance which can also connect and listen.
In Python, the built-in functions all and any return True and False respectively for...
Let me start off by saying, I'm using the twisted.web framework. Twisted.web's file uploading didn't work like I wanted it to (it only included the file data, and not any other information), cgi.parse_multipart doesn't work like I want it to (same thing, ...
any c/c++ library out there that provides functions like getUrl, urlopen, post etc. ?
Hi all, i know that go language does not support windows yet, now, how can i compile .go file is windows ? and can python connect to go ? like connecting c++ or java to python ... lol
I have a Python program uses Qt (PyQt4 in fact) and when I launch it from its main.py, I get a console window and the GUI window (on Windows, of course). Then I compile my program with py2exe and main.exe is successfully created. However, if I run main.exe (this is what users of progra...
I have a string on which I try to create a regex mask that will show N number of words, given an offset. Let's say I have the following string: "The quick, brown fox jumps over the lazy dog." I want to show 3 words at the time: offset 0
Hi, Is there pyTTS or some kind of speech module for python 3.0? I can't seem to find it anywhere and I'd really like to try it out.
hi. using python 2.4/2.5, with libxm2dom. trying to get my haead around a question/issue that i'm considering. i have a doc i import the doc, and can build the dom (libxml2dom) i'm trying to figure out if there's a way to programatically "search" for a given te...
I am trying to get a value out of a HTML page using the python HTMLParser library. The value I want to get hold of is within this html element: ... <div id="remository">20</div> ... This is my HTMLParser class so far: class LinksPar...
Using the argparse module, is it possible to perform multiple actions for a given argument? Specifically, I'd like to provide a -l/--list option with nargs='?' that will change the behaviour of the program from its main function to on...
How can I extract the date from a string like "monkey 2010-07-10 love banana"? Thanks!
I know there are tons of blogging platforms out there (Wordpress,Drupal,etc) but I want to make my own blog engine or blog platform from scratch using python as a learning tool. The idea of using Google App Engine solves the issues in hosting. Blogs relatively consumes less amount of disk spac...
I need to store basic data of customer's and cars that they bought and payment schedule of these cars. These data come from GUI, written in Python. I don't have enough experience to use a database system like sql, so I want to store my data in a file as plain text. And it doesn't have to be on...
Hi, In the subprocess documentation, I haven't found any hint if the pipes created by PIPE are blocking or non-blocking. I.e., if I call p.stdout.read(), will it block in certa...
In a previous question of mine i get this answer: Subclass twisted.conch.recvline.HistoricRecvLine instead of twisted.protocols.basic.LineReceiver. keystrokeReceived is one of the several additional protocol callbacks available when you are using a terminal instead of a TCP connection....
Hi, Can I simply execute Python program using PHP like this? (in a browser) exec("python myProgram /Applications/MAMP/htdocs/somefile.xml"); or like this: exec("/path/to/python path/to/myProgram /Applications/MAMP/htdocs/somefile.xml"); ...
Why Hidden features of Python has been closed and ... Hidden Features of JavaScript
I have a for loop that checks a series of conditions. On each iteration, it should yield output for only one of the conditions. The final yield is a default, in case none of the conditions are true. Do I have to put a continue after each block of yields? def functio...
if i use this : class A(db.Model): a=db.StringProperty() class demo(BaseRequestHandler): def get(self): a=A() a.a='sss' a.put() raise Exception(a.key().id()) i can get the a.key().id() is 961 but if i add key_na...
hi! i have a example who should show what i'd like to do queue = 2 def function(): print 'abcd' time.sleep(3) def exec_times(times): #do something function() def exec_queue(queue): #do something function() exec_times(3) #things need be working while ...
I need to programmatically get the number of arguments that a function requires. With functions declared in modules this is trivial: myfunc.func_code.co_argcount But built-in functions don't have the func_code attribute. Is there another way to do...
Hi, I have a string I need to encrypt using AES in CBC mode with zero padding, before finally encoding it to base64. I've got my initialisation vector. What would be the fastest (and easiest) way to do this on Google App Engine in Python? Thanks, Denis
this is my code: class A(db.Model): a=db.StringProperty() class demo(BaseRequestHandler): def get(self): a='' def fn(): global a a=A(a='www') a.put() db.run_in_transaction(fn) raise Exception(a.key()) ...
I have a Django model: class Customer(models.Model): first_name=models.CharField(max_length=20,null=True, blank=True) last_name=models.CharField(max_length=25,null=True, blank=True) address=models.CharField(max_length=60,null=True, blank=True) address2=models.CharField(...
I have a names table in my database and I would wish to conduct a fuzzy search on it for example my database contains: Name ID John Smith 1 Edward Smith 2 Gabriel Gray 3 Paul Roberts 4 Sorry I dont know how to mak...
Is there a way to make the something like the following code work? add = lambda n: (yield n) or add(n+1) (answers don't need to be in functional style)
Relevant question: stackoverflow.com/questions/2339735/fabric-password I configured Putty to login with private-public keys (no password) using this guide:
I'd like to have some data descriptors as part of a class. Meaning that I'd like class attributes to actually be properties, whose access is handled by class methods. It seems that Python doesn't directly support this, but that it can be implemented by subclassing the type
Django version 1.1.1 I have a custom dashboard view set up to override the django admin default like: (r'^admin/$', 'dashboard.views.dashboard'), (r'^admin/', include(admin.site.urls)), dashboard view authenticates with the @staff_member_required decorator...
my code is : class demo(BaseRequestHandler): def get(self): a=[[1,2,3],[3,6,9]] self.render_template('map/a.html',{'geo':a}) and the html is : {% for i in geo %} <p><a href="{{ i[0] }}">{{ i[0]}}</a&g...
I would like to either extend or append a list to the content of another list: I've got the following: l = (('AA', 1.11), ('BB', 2.22), ('CC', 3.33)) ls = [('XX', 7.77), ('YY', 8.88), ('ZZ', 9.99)] m = ['first', 'second', 'third'] for i in range(len(l)): result = [] for...
I need to quickly extract text from HTML files. I am using the following regular expressions instead of a full-fledged parser since I need to be fast rather than accurate (I have more than a terabyte of text). The profiler shows that most of the time in my script is spent in the re.sub procedu...
Is it possible to pass more than 1 argument to a context processor in Django? In other words, in addition to the HttpRequest object, I would like to pass 1 or more additional argument?
Hi I'm pretty much new in python object oriented programming and I have troubles understanding the super() function (new style classes) especially when it comes to multiple inheritance. For example if you have something like: class First(object): def __init__(self): ...
I'm working on a plugin for some software that I'm planning on selling someday. The software I'm making it for has both a C++ SDK and a Python SDK. The C++ SDK documentation appears incomplete in certain areas and isn't documented that well. The Python SDK docs appear more comp...
I'm trying to add the comments framework to a weblog I'm creating in Django. Adding the comments system appears to be working fine until I attempt to enable comment moderation. I add the ...
How do I read every line of a file in python and store each line as an element in an array? I want to read the file line by line and each line is appended to the end of the array. I could not find how to do this anywhere and I couldn't find how to create an array of strings in python.
I am looking for a good framework for building web apps in python (could also be python + php). The apps will make http requests (GET/POST) and process data, so I'd like to have threading support to make it faster.
Anybody know how to deploy a simple Flask application on Webfaction? I know Webfaction support mod_wsgi and I read the guide on the Flask site but still I can't make my app working. Anybody have a working configuration? Thanks.
« first day (3 days earlier) ← previous day next day → last day (31 days later) »