Re: Distutils evil voodoo: install into a package

2009-08-28 Thread Pavel Panchekha
This is what whe world has created namespace-packages for. At least if you can live with the namespace pya being otherwise empty. That seems like a good solution. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Distutils evil voodoo: install into a package

2009-08-24 Thread Pavel Panchekha
Before you flame me, I know that what I'm trying to do is beyond evil. But I nonetheless want to do it. Feel free to rant if you must. :) I have a package that I want to install into another package. For example, I have the packages pya and pyb. pya is guaranteed to be installed before pyb is, so

Inheriting dictionary

2009-08-18 Thread Pavel Panchekha
I want a dictionary that will transparently inherit from a parent dictionary. So, for example: a = InheritDict({1: one, 2: two, 4: four}) b = InheritDict({3: three, 4: foobar}, inherit_from=a) a[1] # one a[4] # four b[1] # one b[3] # three b[4] # foobar I've written something like this in

Re: Inheriting dictionary

2009-08-18 Thread Pavel Panchekha
On Aug 18, 4:23 pm, Jan Kaliszewski z...@chopin.edu.pl wrote: 18-08-2009 o 21:44:55 Pavel Panchekha pavpanche...@gmail.com wrote: I want a dictionary that will transparently inherit from a parent dictionary. So, for example: a = InheritDict({1: one, 2: two, 4: four}) b

Re: Inheriting dictionary

2009-08-18 Thread Pavel Panchekha
On Aug 18, 5:11 pm, Jan Kaliszewski z...@chopin.edu.pl wrote: 18-08-2009 o 22:27:41 Nat Williams nat.willi...@gmail.com wrote: On Tue, Aug 18, 2009 at 2:44 PM, Pavel Panchekha   pavpanche...@gmail.comwrote: I want a dictionary that will transparently inherit from a parent dictionary

Re: Overriding methods per-object

2009-04-19 Thread Pavel Panchekha
On Apr 18, 9:43 pm, Aaron Brady castiro...@gmail.com wrote: On Apr 17, 9:41 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Fri, 17 Apr 2009 18:22:49 -0700, Pavel Panchekha wrote: I've got an object which has a method, __nonzero__ The problem is, that method

Re: Overriding methods per-object

2009-04-18 Thread Pavel Panchekha
On Apr 18, 4:01 pm, Piet van Oostrum p...@cs.uu.nl wrote: But you can give each object its own class and then put the special methods in that class: def create_special_object(bases, *args): ...   if not isinstance(bases, tuple): ...      bases = bases, ...   cls = type(SpecialClass,

Overriding methods per-object

2009-04-17 Thread Pavel Panchekha
I've got an object which has a method, __nonzero__ The problem is, that method is attached to that object not that class a = GeneralTypeOfObject() a.__nonzero__ = lambda: False a.__nonzero__() False But: bool(a) True What to do? -- http://mail.python.org/mailman/listinfo/python-list

Re: Overriding methods per-object

2009-04-17 Thread Pavel Panchekha
The docs don't say you can do that: Thanks, hadn't noticed that. Should you be able to? I'd say so. In my case, I need a class that can encapsulate any object, add a few methods to it, and spit something back that works just like the object, but also has those extra methods. I can't just add

Re: How to comment code?

2007-01-19 Thread Pavel Panchekha
I think that doc strings are the most important way in which you should be commenting on your code. Once the code works, you can elimainate most inline comments, leaving only doc string for everything and a few comments on some particularly confusing parts. Other than that, comments usually only