Re: Customizing class attribute access in classic classes

2011-10-30 Thread Geoff Bache
On Oct 30, 4:16 am, Ben Finney wrote: > Geoff Bache writes: > > I'm wondering if there is any way to customize class attribute access > > on classic classes? > > Why do that? What is it you're hoping to achieve, and why limit it to > classic classes only? > I'm building a mocking tool, CaptureMo

Re: Customizing class attribute access in classic classes

2011-10-30 Thread Steven D'Aprano
On Sat, 29 Oct 2011 14:06:12 -0700, Geoff Bache wrote: > Hi, > > I'm wondering if there is any way to customize class attribute access on > classic classes? > > So this works: > > class Meta(type): > def __getattr__(cls, name): > return "Customized " + name > > class A: > __met

Re: Customizing class attribute access in classic classes

2011-10-30 Thread Geoff Bache
Thanks for this Steven. I'm however gettings some pretty odd effects, both on method access and inheritance. I expanded your example a bit... class Meta: def __init__(self, name, bases, namespace): self.__name__ = name self.__bases__ = bases self.__dict__ = namespace

Re: Need Windows user / developer to help with Pynguin

2011-10-30 Thread Mark Hammond
On 30/10/2011 1:43 AM, Lee Harr wrote: For Windows users who want to just run Pyguin (not modify or tinker with the source code), it would be best to bundle Pynguin up with Py2exe I considered that, but I agree that licensing issues would make it problematic. What licensing issues concern you

Re: Dynamically creating properties?

2011-10-30 Thread DevPlayer
To be honest, I was hoping someone would have posted a link to a well known and tested recipe. You'd think this function would be in the standard library or a specific Exception tied directly with setattr() and getattr() (and possibly __getattr__(), __getattribute__(), __setattr__()) The main thin

[Help] python ctypes to process C pointer!

2011-10-30 Thread Korobase
A c code snippet,the c file compiled to a dll file named libxxx.dll: typedef void* HND; typedef unsigned char UCHAR; typedef short int SWORD; ... int Connect( HND* hnd, UCHAR* ipaddr, SWORD port){ .. return 1; } then How to handle function Connect using python and ct

__init__ with multiple list values

2011-10-30 Thread Gnarlodious
Initializing a list of objects with one value: class Order: def __init__(self, ratio): self.ratio=ratio def __call__(self): return self.ratio ratio=[1, 2, 3, 4, 5] Orders=[Order(x) for x in ratio] But now I want to __init__ with 3 values: class Order: def __init__(self, ratio, bias, loc

Re: Review Python site with useful code snippets

2011-10-30 Thread Mehrzad Irani
Considering that the site is going to grow over time, putting the snippets in a drop-down menu isn't a wise idea in my opinion. Snippets on a separate page like activestate python would make it more convenient. Nice initiative, and would be very helpful when it grows over time. -- http://mail.

Re: __init__ with multiple list values

2011-10-30 Thread Chris Angelico
On Mon, Oct 31, 2011 at 2:02 AM, Gnarlodious wrote: > Orders=[Order(x,y,z) for x,y,z in [ratio, bias, locus]] > Assuming that you intend to take the first element of each list, then the second, and so on, you'll want to use zip(): Orders=[Order(x,y,z) for x,y,z in zip(ratio, bias, locus)] With

[ANN] Pyrolite 1.3 - native Pyro and Pickle library for Java and .NET

2011-10-30 Thread Irmen de Jong
Hello, I'd like to announce Pyrolite 1.3, a tiny (~50k) Pyro client library for Java and .NET. Q: "what is a java/.net library doing in this newsgroup?" A.1: This library is meant to connect a Java or .NET program to Python in a very simple way, using the Pyro protocol. Pyro is my remote object

Re: __init__ with multiple list values

2011-10-30 Thread Gnarlodious
On Oct 30, 9:15 am, Chris Angelico wrote: > Orders=[Order(x,y,z) for x,y,z in zip(ratio, bias, locus)] Brilliant, thanks! -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

RE: Need Windows user / developer to help with Pynguin

2011-10-30 Thread Lee Harr
>>> Py2exe >> >> I considered that, but I agree that licensing issues would make it >> problematic. > > What licensing issues concern you? The py2exe license shouldn't be a > problem and py2exe or something like it is good advice. I think PyQt 4 would be the biggest issue. It is GPL 2 / 3. I th

Re: Need Windows user / developer to help with Pynguin

2011-10-30 Thread Alec Taylor
Maybe push something onto pip or easy_install? On Fri, Oct 28, 2011 at 6:38 AM, Lee Harr wrote: > > I develop the free python-based turtle graphics application pynguin. > > http://pynguin.googlecode.com/ > > > Lately I have been getting a lot of positive comments from people > who use the program

Re: __init__ with multiple list values

2011-10-30 Thread MRAB
On 30/10/2011 15:02, Gnarlodious wrote: Initializing a list of objects with one value: class Order: def __init__(self, ratio): self.ratio=ratio def __call__(self): return self.ratio ratio=[1, 2, 3, 4, 5] Orders=[Order(x) for x in ratio] But now I want to __init__ with 3 values: cla

Calling JavaScript inside the webbrowser module

2011-10-30 Thread Anders Gunnarsson
Hi! Is there anyway to communicate with JavaScript inside a website opened via the webbrowser module? | import webbrowser | webbrowser.open('http://python.org') Here I'd like to do something like webbrowser.call('alert(1)') and I'd like to be able to call the python app from javascript too. I'

Appending to sys.path during module install with distutils

2011-10-30 Thread Darren Hart
I'm trying to use distutils to install a collection of modules in /usr/local/lib/python2.7/site-packages. My distribution (Fedora 15) doesn't include any /usr/local paths in sys.path, so the import fails when running the program. The distutils documentation suggests adding a $NAME.pth file to an ex

SSE4a with ctypes in python? (gcc __builtin_popcount)

2011-10-30 Thread est
Hi guys, Here is the sample code http://stackoverflow.com/questions/6389841/efficiently-find-binary-strings-with-low-hamming-distance-in-large-set/6390606#6390606 static inline int distance(unsigned x, unsigned y) { return __builtin_popcount(x^y); } Is it possible to rewrite the above gcc c

ttk Listbox

2011-10-30 Thread Ric
What would be an equivalent widget in ttk like a Listbox and if possible a small example? I tried to look here http://docs.python.org/library/ttk.html but did not see anything. Maybe I did not look in the right place? tia -- http://mail.python.org/mailman/listinfo/python-list