> 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
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
On Aug 18, 5:11 pm, "Jan Kaliszewski" wrote:
> 18-08-2009 o 22:27:41 Nat Williams wrote:
>
>
>
> > On Tue, Aug 18, 2009 at 2:44 PM, Pavel Panchekha
> > wrote:
>
> >> I want a dictionary that will transparently "inherit" from a pa
On Aug 18, 4:23 pm, "Jan Kaliszewski" wrote:
> 18-08-2009 o 21:44:55 Pavel Panchekha wrote:
>
>
>
> > I want a dictionary that will transparently "inherit" from a parent
> > dictionary. So, for example:
>
> > """
> > a = I
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
On Apr 18, 9:43 pm, Aaron Brady wrote:
> On Apr 17, 9:41 pm, Steven D'Aprano
> 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
> > >
On Apr 18, 4:01 pm, Piet van Oostrum 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", bases,
> 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
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
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 cl
10 matches
Mail list logo