python

How do you send an Ethernet frame with a corrupt FCS?

I'm not sure if this is even possible since this might be handled in hardware, but I need to send some Ethernet frames with errors in them. I'd like to be able to create runts, jabber, misalignment, and bad FCS errors. I'm working in Python. ...

Python/Django pluggin for Dreamweaver

Does a plugin exists for Python/Django into Dreamweaver? Just wondering since Dreamweaver is a great web dev tool. ...

Is it possible to update a Google calendar from App Engine without logging in as the owner?

I'd like to be able to use the Google Data API from an AppEngine application to update a calendar while not logged in as the calendar's owner or the a user that the calendar is shared with. This is in contrast to the examples here: http://code.google.com/appengine/articles/more_google_data.html The login and password for the calendar'...

Import XML into SQL database

I'm working with a 20 gig XML file that I would like to import into a SQL database (preferably MySQL, since that is what I am familiar with). This seems like it would be a common task, but after Googling around a bit I haven't been able to figure out how to do it. What is the best way to do this? I know this ability is built into MySQL...

WSGI Authentication: Homegrown, Authkit, OpenID...?

I want basic authentication for a very minimal site, all I personally need is a single superuser. While hard-coding a password and username in one of my source files is awfully tempting, especially since I'm hosting the site on my own server, I feel I'm breaking the law of the internets and I should just use a database (I'm using sqlite ...

What's the best way to propagate information from my wx.Process back to my main thread?

I'm trying to subclass wx.Process such that I have a customized process launcher that fires events back to the main thread with data collected from the stdout stream. Is this a good way of doing things? class BuildProcess(wx.Process): def __init__(self, cmd, notify=None): wx.Process.__init__(self, notify) print "Const...

creating presentations with python

Hello! I am looking for a library that would allow me to create presentations as would ppt or latex would allow me to do, but using python! Does such a library exists? Thanks! [edit]:Well a simple precision: I don't know latex but from what I understand it's a scripting language with keywords etc that allows to create presentations. W...

How to handle unicode of an unknown encoding in Django?

I want to save some text to the database using the Django ORM wrappers. The problem is, this text is generated by scraping external websites and many times it seems they are listed with the wrong encoding. I would like to store the raw bytes so I can improve my encoding detection as time goes on without redoing the scrapes. But Django se...

What is your favorite python decorator?

Have you got a python decorator that you really love? Post it here! Here is my favorite, although since I have not known about the feature very long, it may change soon... def debug(f): """ Decorator. Function will enable debugging just for itself. Won't change anything if debugging is already enabled. """ def d...

Graphics module for python

Hi everybody, I'm pretty new on python and I'm looking for a good graphics module, especially to draw histograms, pie charts and stuff like that. What would you recommend to me ? ...

ctypes bindings for Subversion in windows

Is there a binary installer or a faq for the new ctypes bindings for Subversion 1.6 in Windows (32 and 64bit)? What library would you use to make an easy to deploy (both win32 and x64) svn client in python for svn version >= 1.5? ...

Python distutils, how to get a compiler that is going to be used?

For example, I may use "python setup.py build --compiler=msvc" or "python setup.py build --compiler=mingw32"or just "python setup.py build", in which case the default compiler (say, "bcpp") will be used. How can I get the compiler name inside my setup.py (e. g. "msvc", "mingw32" and "bcpp", respectively)? UPD.: I don't need the default ...

Picking out items from a python list which have specific indexes

I'm sure there's a nice way to do this in Python, but I'm pretty new to the language, so forgive me if this is an easy one! I have a list, and I'd like to pick out certain values from that list. The values I want to pick out are the ones whose indexes in the list are specified in another list. For example: indexes = [2, 4, 5] main_lis...

How to make pdb recognize that the source has changed between runs?

From what I can tell, pdb does not recognize when the source code has changed between "runs". That is, if I'm debugging, notice a bug, fix that bug, and rerun the program in pdb (i.e. without exiting pdb), pdb will not recompile the code. I'll still be debugging the old version of the code, even if pdb lists the new source code. So, doe...

String manipulation in Python

I am converting some code from another language to python. That code reads a rather large file into a string and then manipulates it by array indexing like: str[i] = 'e' This does not work directly in python due to the strings being immutable. What is the preferred way of doing this in python ? I have seen the string.replace() functi...

Finding all *rendered* images in a HTML file

Hi all, I need a way to find only rendered IMG tags in a HTML snippet. So, I can't just regex the HTML snippet to find all IMG tags because I'd also get IMG tags that are shown as text in the HTML (not rendered). I'm using Python on AppEngine. Any ideas? Thanks, Ivan ...

Dynamic use of a class method defined in a Cython extension module

I would like to use the C implementation of a class method (generated from Cython) if it is present, or use its Python equivalent if the C extension is not present. I first tried this: class A(object): try: import c_ext method = c_ext.optimized_method except ImportError: def method(self): retu...

Python: List concatenation. What is difference in "append" and "+= []"?

What is the difference in: some_list1 = [] some_list1.append("something") and some_list2 = [] some_list2 += ["something"] I hope this hasn't been already posted. If so just point me in that direction :) Thanks for your help. EDIT I've edited the title to reflect what I actually mean: "+ []" should have been "+= []". ...

Installing ipython with readline on the mac

I am using ipython on Mac OS 10.5 with python 2.5.1 (I would actually like to use ipython for 2.6.1, but it doesn't seem to be available?) I installed ipython via easy_install. It works but is missing gnu readline (needed for nice searching of command line history with ctrl-R, etc.) I found a blog post and other sources saying this cou...

Algorithm for Additive Color Mixing for RGB Values

I'm looking for an algorithm to do additive color mixing for RGB values. Is it as simple as adding the RGB values together to a max of 256? (r1, g1, b1) + (r2, g2, b2) = (min(r1+r2, 256), min(g1+g2, 256), min(b1+b2, 256)) ...