python

copy files from IIs6.0 server to client machine without showing file dialog window on click of button in ASP.NET 3.5

Hi, File.VBS file should be copied from IIS6.0(File.VBS file will be deployed in IIS along the ASP.NET3.5 application) server to Client “TEMP” folder with out opening the file download dialog box. Thanks! ...

GTK+ Startup Notification Icon

In Gnome, whenever an application is started, the mouse cursor changes from normal to an activity indicator (a spinning wheel type thing on Ubuntu). Is there any way to inform Gnome (through some system call) when the application has finished launching so that the mouse cursor returns to normal without waiting for the usual timeout of 30...

Python: How much space does each element of a list take?

I need a very large list, and am trying to figure out how big I can make it so that it still fits in 1-2GB of RAM. I am using the CPython implementation, on 64 bit (x86_64). Edit: thanks to bua's answer, I have filled in some of the more concrete answers. What is the space (memory) usage of (in bytes): the list itself sys.getsizeof(...

How do I avoid having Python class data shared among instances?

What I want is this behavior: class a: list=[] y=a() x=a() x.list.append(1) y.list.append(2) x.list.append(3) y.list.append(4) print x.list [1,3] print y.list [2,4] of course, what really happens when I print is: print x.list [1,2,3,4] print y.list [1,2,3,4] clearly they are sharing the data in class a. how ...

Google Apps Engine mail fetch

How can I fetch mails from gmail account in Google Apps Engine Django application? ...

Detailed explanation about Python's "freeze"

Is there anywhere a detailed explanation about Python's "freeze" thing? I saw the PyPi page, but I don't think it's comprehensive enough. ...

Custom exception handling in Python

I have two modules, main and notmain. I declared my custom exception in main module and want to catch it. This exception is raised in notmain module. The problem is I can't catch my exception raised in notmain module. main.py: class MyException(Exception): pass m = __import__('notmain') try: m.func() except MyException as e: ...

how to get tz_info object corresponding to current timezone?

Is there a cross-platform function in python (or pytz) that returns a tzinfo object corresponding to the timezone currently set on the computer? environment variables cannot be counted on as they are not cross-platform ...

Python ClientForm Error

Hello, check this snippet: import ClientForm from urllib2 import urlopen page = urlopen('http://garciainteractive.com/blog/topic_view/topics/content/') form = ClientForm.ParseResponse(page, backwards_compat=False) print form[0] The problem is that ClientForm parses the first html form the following way: <POST http://garciainteractiv...

Python: Platform independent way to modify PATH environment variable

Is there a way to modify the PATH environment variable in a platform independent way using python? Something similar to os.path.join()? ...

how code a function similar to itertools.product in python 2.5

I have a list of tuples, e.g: A=[(1,2,3), (3,5,7,9), (7)] and want to generate all permutations with one item from each tuple. 1,3,7 1,5,7 1,7,7 ... 3,9,7 I can have any number of tuples and a tuple can have any number of elements. And I can't use itertools.product() because python 2.5. ...

Nested Python C Extensions/Modules?

How do I compile a C-Python module such that it is local to another? E.g. if I have a module named "bar" and another module named "mymodule", how do I compile "bar" so that it imported via "import mymodule.bar"? (Sorry if this is poorly phrased, I wasn't sure what the proper term for it was.) I tried the following in setup.py, but it d...

How do I find out where an icon was clicked (relative to itself) using python?

Essentially, what I want to do is have an icon that has different symbols for various programs at the bottom of it (for example, a python file might have a symbol for command prompt, a text editor, and a debugger, all little squares at the bottom of the icon), and when the user double clicks on one of these, that program is used to open ...

Google App Engine proxy

What would be the simplest implementation of a proxy written for GAE, which relays every URL (including POST, and header data) to a remote HTTP host, and return with it's result (with special consideration to error codes)? Please apply KISS principles! ...

How to debug a MemoryError in Python? Tools for tracking memory use?

I have a Python program that dies with a MemoryError when I feed it a large file. Are there any tools that I could use to figure out what's using the memory? This program ran fine on smaller input files. The program obviously needs some scalability improvements; I'm just trying to figure out where. "Benchmark before you optimize", as...

Django Formsets - form.is_valid() is False preventing formset validation

I'm am utilizing a formset to enable users subscribe to multiple feeds. I require a) Users chose a subscription by selecting a boolean field, and are also required to tag the subscription and b) a user must subscribe to an specified number of subscriptions. Currently the below code is capable of a) ensuring the users tags a subscription...

Cross-platform way to terminate a process in python...

When I try to kill a process in windows with the subprocess.Popen.terminate() or kill() commands, I get an access denied error. I really need a cross-platform way to terminate the process if the file no longer exists (Yes, I know it's not the most elegant way of doing what I'm doing), I don't want to have to use platform calls or import...

How to write a stub for a classmethod in Python

I have a method which calls for a classmethod of another class def get_interface_params_by_mac(self, host, mac_unified): lines = RemoteCommand.remote_command(host, cls.IFCONFIG) ... class RemoteCommand(object): @classmethod def remote_command(cls, host, cmd, sh = None): ... I'm going to write a unit test for *g...

Sorting Lists of List of Dictionaries

I've just read in a file that is something like: name: john, jane car: db9, m5 food: pizza, lasagne Each of these rows (names, car, food) are in order of who owns what. Therefore John owns the car 'DB9' and his favourite food is 'Pizza'. Likewise with Jane, her car is an 'M5' and her favourite food is 'Lasagne'. I effectively have: ...

How non blocking read/write throught remote FileSystem

Hi, Is there a way to write and read files on a remote filesystem (such as NFS, SSHFS, or sambafs) in a way that read or write or even open return immediately with an error code ? In fact i'm using twisted and i want to know whether there is a safe way to access remote files without block my reactor ? Regards Fab ...