Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread BartlebyScrivener
On Sep 7, 1:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > All you really need is to create your SplinterBorgs with appropriate > group names, you don't neef subclasses at all: oops, I tried this once and the link broke. I'll try tinyurl. Dang. With that subject heading I thought this was abou

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread BartlebyScrivener
On Sep 7, 1:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > All you really need is to create your SplinterBorgs with appropriate > group names, you don't neef subclasses at all: > Dang. With that subject heading I thought this was about some post- Singularity, Python-programmed cyborgs rising up

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 14:54 -0600, Steven Bethard wrote: > Carsten Haese wrote: > > [slightly convoluted example...] > > I think I would probably write that as:: > [concise example...] > > That is, I don't think there's really a need for __new__ if you're using > a metaclass. Just set the instan

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Steven Bethard
Carsten Haese wrote: > Indeed, if you have an __init__ method that shouldn't see the "group" > argument, you need a metaclass after all so you can yank the "group" > argument between __new__ and __init__. The following code seems to work, > but it's making my brain hurt: > > class SplinterBorgMeta

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread André
On Sep 7, 4:00 pm, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2007-09-07 at 15:54 +, André wrote: > > Unfortunately, it fails. Here's what I tried, followed by the > > traceback > > class SplinterBorg(object): > > _shared_states = {} > > def __new__(cls, *a, **k): > > g

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread André
On Sep 7, 3:53 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > André wrote: > > On Sep 7, 10:27 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > >> On Fri, 2007-09-07 at 12:31 +, André wrote: > >>> In my application, I make use of the Borg idiom, invented by Alex > >>> Martelli. > >>> class Borg(ob

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 15:54 +, André wrote: > Unfortunately, it fails. Here's what I tried, followed by the > traceback > class SplinterBorg(object): > _shared_states = {} > def __new__(cls, *a, **k): > group = k.pop("group","BORG") > obj = object.__new__(cls, *a, **k)

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Steve Holden
André wrote: > On Sep 7, 10:27 am, Carsten Haese <[EMAIL PROTECTED]> wrote: >> On Fri, 2007-09-07 at 12:31 +, André wrote: >>> In my application, I make use of the Borg idiom, invented by Alex >>> Martelli. >>> class Borg(object): >>> '''Borg Idiom, from the Python Cookbook, 2nd Edition, p:

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread André
On Sep 7, 10:27 am, Carsten Haese <[EMAIL PROTECTED]> wrote: > On Fri, 2007-09-07 at 12:31 +, André wrote: > > In my application, I make use of the Borg idiom, invented by Alex > > Martelli. > > > class Borg(object): > > '''Borg Idiom, from the Python Cookbook, 2nd Edition, p:273 > > >

Re: Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread Carsten Haese
On Fri, 2007-09-07 at 12:31 +, André wrote: > In my application, I make use of the Borg idiom, invented by Alex > Martelli. > > class Borg(object): > '''Borg Idiom, from the Python Cookbook, 2nd Edition, p:273 > > Derive a class form this; all instances of that class will share > the

Is a Borg rebellion possible? (a metaclass question)

2007-09-07 Thread André
In my application, I make use of the Borg idiom, invented by Alex Martelli. class Borg(object): '''Borg Idiom, from the Python Cookbook, 2nd Edition, p:273 Derive a class form this; all instances of that class will share the same state, provided that they don't override __new__; other