python

C# Web Server: Implementing a Dynamic Language

I've just finished writing a web server in C#. Its pretty basic and only serves static content like html, xml, and images at the moment. I would like to implement a dynamic language, however. I'm trying to choose between one of the following: ASP.NET PHP Python I'd prefer to implement PHP or Python because I am much more familiar wit...

How to use subversion Ctypes Python Bindings?

Hello. Subversion 1.6 introduce something that is called 'Ctypes Python Binding', but it is not documented. Is it any information available what this bindings are and how to use it? For example, i have a fresh windows XP and want to control SVN repository using subversiion 1.6 and this mysterious python bindings. What exactly i need to ...

How do you remove html tags using Universal Feed Parser?

The documentation lists the tags that are allowed/removed by default: http://www.feedparser.org/docs/html-sanitization.html But it doesn't say anything about how you can specify which additional tags you want removed. Is there a way to do this using Universal Feed Parser or do you have to do further processing using your own regex and...

callable as instancemethod?

Let's say we've got a metaclass CallableWrappingMeta which walks the body of a new class, wrapping its methods with a class, InstanceMethodWrapper: import types class CallableWrappingMeta(type): def __new__(mcls, name, bases, cls_dict): for k, v in cls_dict.iteritems(): if isinstance(v, types.FunctionType): ...

Python, SimPy: How to generate a value from a triangular probability distribution?

I want to run a simulation that uses as parameter a value generated from a triangular probability distribution with lower limit A, mode B and and upper limit C. How can I generate this value in Python? Is there something as simple as expovariate(lambda) (from random) for this distribution or do I have to code this thing? ...

Scientific Plotting in Python

I have a large data set of tuples containing (time of event, latitude, longitude) that I need to visualize. I was hoping to generate a 'movie'-like xy-plot, but was wondering if anyone has a better idea or if there is an easy way to do this in Python? Thanks in advance for the help, --Leo ...

What's a good way to mix RSS feeds using Python?

SimplePie lets you merge feeds together: http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date Is there anything like this in the Python world? The Universal Feed Parser documentation doesn't say anything about merging multiple feeds together. ...

What is wrong with this SimPy installation?

Alright, I have tried a bunch of times the python setup.py install command from my command prompt, and this is what I'm getting: SCREEN And when trying this: from SimPy.Simulation import * on Idle, I get this: Traceback (most recent call last): File "C:/Python30/pruebas/prueba1", line 1, in <module> from SimPy.Simulation ...

Python/Ruby as mobile OS

I was wondering why smartphone/mobile device OSs are not written to allow dynamic languages as the language of choice? iPhone uses Objective-C, Google Android uses Java, Windows Mobile uses any manner of .NET language. What would be the reasoning behind a mobile OS being written in Python, Ruby, or any other dynamic language? I unders...

How to unescape apostrophes and such in Python?

I have a string with symbols like this: &#39; That's an apostrophe apparently. I tried saxutils.unescape() without any luck and tried urllib.unquote() How can I decode this? Thanks! ...

Where is Python's "best ASCII for this Unicode" database?

I have some text that uses Unicode punctuation, like left double quote, right single quote for apostrophe, and so on, and I need it in ASCII. Does Python have a database of these characters with obvious ASCII substitutes so I can do better than turning them all into "?" ? ...

Python: avoiding pylint warnings about too many arguments

I want to refactor a big Python function into smaller ones. For example, consider this following code snippet: x = x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 Of course, this is a trivial example. In practice, the code is more complex. My point is that it contains many local-scope variables that would have to be passed to the extracted...

how to get the url of the current page in a GAE template

In Google App Engine, is there a tag or other mechanism to get the URL of the current page in a template or is it necessary to pass the url as a variable to the template from the python code? ...

save an image with selenium & firefox

i'm trying to save an image from a website using selenium server & python client. i know the image's URL, but i can't find the code to save it, either when it's the the document itself, or when it's embedded in the current browser session. the workaround i found so far is to save the page's screenshot (there are 2 selenium methods for ...

Dynamically change range in Python?

So say I'm using BeautifulSoup to parse pages and my code figures out that there are at least 7 pages to a query. The pagination looks like 1 2 3 4 5 6 7 Next If I paginate all the way to 7, sometimes there are more than 7 pages, so that if I am on page 7, the pagination looks like 1 2 3 7 8 9 10 Next So now, I know there are...

wxPython: A foldable panel widget

I have my main program window, and I would like to make a foldable panel. What I mean is, a panel which is aligned to one of the sides of the window, with a fold/unfold button. It's important that when the panel gets folded/unfolded, the other widgets change their size accordingly to take advantage of the space they have. How do I do th...

Call a function with argument list in python

I'm trying to call a function inside another function in python, but can't find the right syntax. What I want to do is something like this: def wrapper(func, args): func(args) def func1(x): print(x) def func2(x, y, z): return x+y+z wrapper(func1, [x]) wrapper(func2, [x, y, z]) In this case first call will work, and seco...

Delete digits in Python (Regex)

I'm trying to delete all digits from a string. However the next code deletes as well digits contained in any word, and obviously I don't want that. I've been trying many regular expressions with no success. Thanks! s = "This must not b3 delet3d, but the number at the end yes 134411" s = re.sub("\d+", "", s) print s Result: This...

NetBeans debugging of Python (GAE)

dev_appserver works normal when run it. But if i try o debug, i found an error caused by __file__ that is changed on jpydaemon.py. Has anyone successfully debugged apps on NetBeans? ...

Update Facebooks Status using Python

Is there an easy way to update my Facebook status ("What's on your mind?" box) using Python code ? ...