python

List attributes of an object

Is there a way to grab a list of attributes that exist on instances of a class? (This class is just an bland example, it is not my task at hand.) class new_class(): def __init__(self, number): self.multi = int(number) * 2 self.str = str(number) a = new_class(2) print(', '.join(a.SOMETHING)) The desired result is ...

Problem bounding name to a class in Django

Hello! I've got a view function that has to decide which form to use depending on some conditions. The two forms look like that: class OpenExtraForm(forms.ModelForm): class Meta: model = Extra def __init__(self, *args, **kwargs): super(OpenExtraForm, self).__init__(*args, **kwargs) self.fields['opening...

video tutorial for learning python?

Anyone knows video tutorial resource for learning Python (the one that is similar to learnvisualstudio.net for learning .NET)? ...

Generating a List Class in Python

I am having some problems generating a list for a class in Python. I know there is something simple I'm overlooking, but I just can't figure it out. My basic code so far: class Test: def __init__(self,test): self.__test = test My problem is that if I enter t = Test([1,3,5]) things will work just fine, but if I add t...

What is Ruby's analog to Python Metaclasses?

Python has the idea of metaclasses that, if I understand correctly, allow you to modify an object of a class at the moment of construction. You are not modifying the class, but instead the object that is to be created then initialized. Python (at least as of 3.0 I believe) also has the idea of class decorators. Again if I understand cor...

Long running, polling, queueing process for Python. What's the best stuff to use?

Feel free to close and/or redirect if this has been asked, but here's my situation: I've got an application that will require doing a bunch of small units of work (polling a web service until something is done, then parsing about 1MB worth of XML and putting it in a database). I want to have a simple async queueing mechanism that'll po...

Best way to do enum in Sqlalchemy?

im reading sqlalchemy and i see the code employees_table = Table('employees', metadata, Column('employee_id', Integer, primary_key=True), Column('name', String(50)), Column('manager_data', String(50)), Column('engineer_info', String(50)), Column('type', String(20), nullable=False) ) employee_mapper = mapper(Employee...

In which scenario it is useful to use Disassembly on python?

The dis module can be effectively used to disassemble Python methods, functions and classes into low-level interpreter instructions. I know that dis information can be used for: 1. Find race condition in programs that use threads 2. Find possible optimizations From your experience, do you know any other scenarios where Disassembly Pyth...

Need some help with PyQt and QGridLayout

I'm having an annoyingly stubborn problem here, and I would appreciate it if anyone could give me some insight into what I'm doing wrong. I have a PyQt app that is supposed to display a table of numbers. So, naturally, I am using QTableWidget. Right now, it's extremely simple: all I do is create a window with a Table Widget and a button...

X11 - How to raise another application's window using Python

I'd like to be able to raise another application's Window using Python. I did see this, which I suppose I could try: http://stackoverflow.com/questions/1028972/x11-raise-an-existing-window-via-command-line However, I'd prefer to do it in Python if at all possible. ...

Swig - wrapping C struct

Hello everyone, I am trying to write Python wrap for C code which uses struct. modules.c: struct foo { int a; }; struct foo bar; modulues.i %module nepal %{ struct foo { int a; } %} extern struct foo bar; But during compiling I am given error: In function ‘Swig_var_bar_set’: error: ‘bar’ undeclared (fi...

Stealing Cookies with no user input?

I'm creating a static site generator with a dynamic admin backend for one user. The site accepts no user input. Does this mean that I am safe from attackers who are trying to steal my admin cookie? (there is no user input, so XSS and other methods don't work, right?) ...

What version of Visual Studio is this python compiled with?

I am trying to find out the version of Visual Study that is used to compile the python on my computer It says Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32 What I do not understand is that MSC V.1500. Does it mean it is compiled with 2005? I cannot find this information on `python.org' neither...

google-app-engine: json module

Hey i'm using JSON with appengine. I'm using json for comunication, so in the python side i have import json the error i'm getting is this: <class 'django.core.exceptions.ViewDoesNotExist'>: Could not import views.ganttapp. Error was: No module named json In my stand alone this works great, is there any problem with json on the ap...

How to parse malformed HTML in python, using standard libraries

There are so many html and xml libraries built into python, that it's hard to believe there's no support for real-world HTML parsing. I've found plenty of great third-party libraries for this task, but this question is about the python standard library. Requirements: Use only Python standard library components (any 2.x version) DOM s...

python gio waiting for async operations to be done

I have to mount a WebDav location and wait for the operation to be finished before to proceed (it's a script). So I'm using the library in this way: location = gio.File("dav://server.bb") location.mount_enclosing_volume(*args,**kw) # The setup is not much relevant location.get_path() # Returns None because it's not yet mounted since the...

jQuery as a replacement for Django or Web2Py

Hi all, I was planning to write a new webapp, I figured out two options for my backend - web2py or django. I recently came across jQuery and found it to be very cool. Could I just use jQuery as a replacement for django and web2py and finish this webapp. Some features that I'm going to implement - user profiles, users can add content...

How read method signature?

From method name I would like know its signature i.e. def myMethod(firt, second, third='something'): pass from myMethod name is possible have samenthig like that myMethod(firt, second, third='something') ...

Reading a client's header from Python CGI script?

I'm writing a very simple web service, written in Python and run as CGI on an Apache server. According to Python docs (somewhere... I forgot where), I can use sys.stdin to read the data POSTed by a random client, and this has been working fine. However, I would like to be able to read the HTTP header information as well - incoming IP, u...

Any 'pretty' data visualization libraries for Python?

There are plenty of 'pretty-printing' visualization libraries for Javascript. E.g. those listed here. Googling for 'python visualization libraries' only turns up stuff like VTK and mayavi, which are primarily more for no-nonsense scientific use. So, do you know of any Python libraries similar to those Javascript ones in the above link?...