python

How can I get column types width MySQLdb?

Hello, how can I get text description for column types with MySQLdb? I know that cursor.description contains number which represents type of column and also there is module FIELD_TYPE.* with int constants like FIELD_TYPE.ENUM=247 For example how can I get name of column type if I know that it is '3'? ...

Why urllib2.urlopen can not open pages like "http://localhost/new-post#comment-29"?

I'm curious, how come I get 404 error running this line: urllib2.urlopen("http://localhost/new-post#comment-29") While everything works fine surfing http://localhost/new-post#comment-29 in any browser... urlopen method does not parse urls with "#" in it? Anybody knows? ...

Crosstab reports

Hi, I'm looking for a library/component/class to create synamic cross-tab reports that must be shown on a web page. One important requirement is that it must run on Linux and written in PHP, Python, FreePascal, Ruby, C or C++. I can't use Java or Mono here. ...

python mechanize javascript submit button problem!

Hello All im making some script with mechanize.browser module. one of problem is all other thing is ok, but when submit() form,it not working, so i was found some suspicion source part. in the html source i was found such like following. im thinking, loginCheck(this) making problem when submit form. but how to handle this kind of...

How to get windows user id in web2py for an intranet application?

I'm using web2py for an intranet site and need to get current login windows user id in my controller. Whether any function is available? ...

"Zero Iteration" - end to end acceptance test in simple contact-form feature

I was reading "Growing Object-Oriented Software, Guided by Tests" lately. Authors of this book sugested to always start developing a feature with an end-to-end acceptance test (before starting TDD cycle) to not loose a track of progress and to make sure that you're still on the same page while unit-testing. Ok, so I've start writing a v...

MongoDB for realtime ajax stuff?

Howdie stackoverflow people! So I've been doing some digging regarding these NoSQL databases, MongoDB, CouchDB etc. Though I am still not sure about real time-ish stuff therefore I thought i'd ask around to see if someone have any practical experience. Let's think about web stuff, let's say we've got a very dynamic super ajaxified weba...

Understanding __get__ and __set__ and Python descriptors.

I am trying to understand what Python's descriptors are and what they can useful for. However, I am failing at it. I understand how they work, but here are my doubts. Consider the following code: >>> class Celsius(object): def __init__(self, value=0.0): self.value = float(value) def __get__(self, instance, owner): ...

Appengine - Reportlab (Get Photo from Model)

I´m using Reportlab to generate a PDF. Can´t retrieve a photo from a model. #Personal Info p.drawImage('myPhoto.jpg', 40, 730) p.drawString(50, 670, 'Your name:' + '%s' % user.name) p.drawImage (50, 640, 'Photo: %s' % (user.photo)) When i create on generate PDF, i got this error: Traceback (most recent call last)...

Scraping Flash: accessing background files, perhaps in Mechanize?

Hi there I'm scraping a website in Flash, writing in Python. I can see in Firebug that the page loads its Flash file and then some background data in an .asmx file. The background data is what I'm interested in - so how can I get hold of the .asmx file? I already know what it's called. I can't get at the .asmx file directly, but can ...

Speeding up Django Testing

Im looking to learn more about your testing flows with Django. Background information http://docs.djangoproject.com/en/dev/topics/testing/ Im encountering difficulties when using test driven development. The test runner of Django constantly creates all db models in a test db when starting. For our current projects (between 40 and 240 m...

anti aliasing the lines

I used the pseudocode from wikipedia for wu's antialiasing algorithm, but when i run this code with draw function. i can draw a point when i click on next point everything disappears. It seems there is problem with color issue. Can you please tell what is going on, also this homework requires me to do manual antialiasing without using op...

How is possible to create a python shell script like top unix command?

Hi to all I'm need to create a Python shell script that refresh output every n seconds like top unix command. what 's the best way to do this? ...

Help interpreting code snippet

I am very new to python and beautifulsoup. In the for statement, what is incident? Is it a class, type, variable? The line following the for.. totally lost. Can someone please explain this code to me? for incident in soup('td', width="90%"): where, linebreak, what = incident.contents[:3] print where.strip() print what.str...

Python - Best way to compare two strings, record stats comparing serial position of particular item?

Hi all, I'm dealing with two files, both of which have lines that look like the following: This is || an example || line . In one of the files, the above line would appear, whereas the corresponding line in the other file would be identical BUT might have the '||' items in a different position: This || is an || example || line . I ...

Python: How to use os.spawnv with a lot of arguments ?

Im working in a Python plugin for XBMC (xbmc.org) and I want to execute a program (ffmpeg.exe) from my plugin without the cmd window appears. If I use os.system() to call ffmpeg.exe works fine but the xbmc minimizes because os.system open a cmd window a few seconds. So, I try to use os.spawnv() that I think its possible that allow me to ...

Dynamically importing Python module

I have a trusted remote server that stores many custom Python modules. I can fetch them via HTTP (e.g. using urllib2.urlopen) as text/plain, but I cannot save the fetched module code to the local hard disk. How can I import the code as a fully operable Python module, including its global variables and imports? I suppose I have to use som...

FFTW 2 to 3 in Python / Numpy

I am writing a Python program which should do some simulation. I have a working code example in C, which uses the FFTW library (version 2.1.5) to do Fourier transforms. A simplified version of the C code is as follows: #include <rfftw.h> #include <stdio.h> #include <math.h> int main(int argc, char** argv) { size_t i, n = 2; ff...

Python function help

Please help! cannot figure this out for the life of me Given the function f(x,n)= n**x(n-1) 5c. Using this function, calculate the rate of change of (((2^3 + 3^2)^4 -2^4)^2 + (3^4 – (6^2 + 3)^4)^3)^3 This is what I came up with in IDLE: def function(x, n): return (n*(x**(n-1))) assertEqual ( function (((( function ...

sqlalchemy polymorhic_identity not working

Hi, I'm trying to use polymorphic_on on a python class with several inheritances: engine = create_engine( 'mysql://xxx:yyy@localhost:3306/zzz?charset=utf8&use_unicode=0', pool_recycle=3600, echo=True) Base = declarative_base() class AbstractPersistent(object): version = Column('VERSION', Integer) last_modified_by = Co...