python

How to display outcoming and incoming SOAP message for ZSI.ServiceProxy in Python?

How to display a SOAP message generated by ZSI.ServiceProxy and a respond from a Web Service when a Web Service method is invoked? ...

question related to reverse function and kwargs

To reverse lookup an url by means of name or View_name we will use reverse function in the views like below reverse("calendarviewurl2", kwargs={"year":theyear,"month":themonth}) and reverse function signature is as follows http://code.djangoproject.com/browser/django/trunk/django/core/urlresolvers.py def reverse(self, lookup_view, ...

How to make unique short URL with Python?

How can I make unique URL in Python a la http://imgur.com/gM19g or http://tumblr.com/xzh3bi25y When using uuid from python I get a very large one. I want something shorter for URLs. ...

Can Python determine the class of a object accessing a method

Is there anyway to do something like this: class A: def foo(self): if isinstance(caller, B): print "B can't call methods in A" else: print "Foobar" class B: def foo(self, ref): ref.foo() class C: def foo(self, ref): ref.foo() a = A(); B().foo(a) # Outputs "B can't call methods in A...

Is it OK if objects from different classes interact with each other?

Hi, I just started to use the object oriented programming in Python. I wander if it is OK if I create a method of a class which use objects from another class. In other words, when I call a method of the first class I give an object from the second class as one of the arguments. And then, the considered methods (of the first class) can m...

Performance of Python worth the cost?

I'm looking at implementing a fuzzy logic controller based on either PyFuzzy (Python) or FFLL (C++) libraries. I'd prefer to work with python but am unsure if the performance will be acceptable in the embedded environment it will work in (either ARM or embedded x86 proc both ~64Mbs of RAM). The main concern is that response times are ...

book recommendations for perl type programming in python or ruby

My programming experience: I know Java, understand OOP and know some recursion. I would like to learn how to write "scripts" for text processing, file handling and stuff like that. I'm fine with learning either Ruby or Python for this. I want a book that focuses on what I've mentioned above but most books just teach more than that (OOP,...

Pymsn/Papyon contact memberships

Dear Stackoverflow, I'm having the following problem: I'm programming a bot for MSN Messenger in python with the pymsn/papyon library. I have everything running, except that I don't know how to accept new contacts already pending or new requests. Sadly the documentation of the library is very bad. I've achieved to retrieve all pending c...

Django: form values not updating when model updates

I am creating a form that uses MultipleChoiceField. The values for this field are derived from another model. This method works fine, however, I am noticing (on the production server) that when I add a new item to the model in question (NoticeType), the form does not dynamically update. I have to restart the server for the new item to...

How to get the path separator in Python?

When multiple directories need to be concatenated, as in an executable search path, there is an os-dependent separator character. For Windows it's ';', for Linux it's ':'. Is there a way in Python to get which character to split on? In the discussions to this question http://stackoverflow.com/questions/1489599/how-do-i-find-out-my-pyt...

Python - importing package classes into console global namespace

Hello all, I'm having a spot of trouble getting my python classes to work within the python console. I want to automatically import all of my classes into the global namespace so I can use them without any prefix.module.names. Here's what I've got so far... projectname/ |-__init__.py | |-main_stuff/ |-__init__.py |-main1.py |-ma...

Running python script as another user

On a Linux box I want to run a Python script as another user. I've already made a wrapper program in C++ that calls the script, since I've realized that the ownership of running the script is decided by the ownership of the python interpreter. After that I change the C++ program to a different user and run the C++ program. This setup d...

App Engine Python how to handle urls?

Hi all, I just want to ask a simple question, as I don't imagine how to do it. In the app.yaml, when I want to declare query string parameter, how do I do it? For example, to make a multi language site, I create the url in this format: mysite.com/english/aboutus mysite.com/italiano/aboutus and in app.yaml the script to handle them...

How do I define a SWIG typemap for a reference to pointer?

I have a Publisher class written in C++ with the following two methods: PublishField(char* name, double* address); GetFieldReference(char* name, double*& address); Python bindings for this class are being generated using SWIG. In my swig .i file I have the following: %pointer_class(double*, ptrDouble); This lets me publish a fiel...

With multiple Python installs, how does MacPorts know which one to install MySQLdb for?

I just upgraded the default Python 2.5 on Leopard to 2.6 via the installer on www.python.org. Upon doing so, the MySQLdb I had installed was no longer found. So I tried reinstalling it via port install py-mysql, and it succeeded, but MySQLdb was still not importable. So then I tried to python install python26 with python_select python26 ...

How to programmatically get SVN revision number?

Like this question, but without the need to actually query the SVN server. This is a web-based project, so I figure I'll just use the repository as the public view (unless someone can advise me why this is a bad idea). I assume this info is in a file in the .svn folder somewhere, but where, and how do I parse it? I want to do something l...

Python/WebApp Google App Engine - testing for user/pass in the headers

When you call a web service like this: username = 'test12' password = 'test34' client = httplib2.Http(".cache") client.add_credentials(username,password) URL = "http://localhost:8080/wyWebServiceTest" response, content = client.request(URL) How do you get the username/password into variables on the server side (i.e...

Django: How to set initial values for a field in an inline model formset?

I have what I think should be a simple problem. I have an inline model formset, and I'd like to make a select field have a default selected value of the currently logged in user. In the view, I'm using Django's Authentication middleware, so getting the user is a simple matter of accessing request.user. What I haven't been able to fi...

How to tell when nosetest is running programmatically

nosetest is the default test framework in Turbogeras 2.0. The application has a websetup.py module that initialise the database. I use mysql for my development and production environment and websetup works fine, but nosetest uses sqlite on memory and when it tries to initialise the DB sends an error: TypeError: SQLite Date, Time, a...

Programmatically determine maximum command line length with Python

Does anyone know a portable way for Python to determine a system's maximum command line length? The program I'm working on builds a command and feeds it to subprocess. For systems with smaller command line length maximums, it is possible that the command will be too long. If I can detect that, the command can be broken up to avoid exc...