On Mon, Sep 24, 2012 at 11:43 AM, Chris Withers wrote:
> Hi All,
>
> Is there a metaclass-y way I could cause the following:
>
> class TheParser(Parser):
> def handle_ARecord(self):
> pass
> def handle_ARecord(self):
> pass
>
> ...to raise an exception as a result of the 'h
Hi All,
Is there a metaclass-y way I could cause the following:
class TheParser(Parser):
def handle_ARecord(self):
pass
def handle_ARecord(self):
pass
...to raise an exception as a result of the 'handle_ARecord' name being
reused?
cheers,
Chris
--
Simplistix - Conte
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
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
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
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
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
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
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)
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:
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
>
> >
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
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
could ildg wrote:
> When I try to learn metaclass of python by article at this place:
> http://www.python.org/2.2/descrintro.html#metaclasses,
> I changed the autosuper example a little as below:
>
> class autosuper(type):
> def __init__(cls,name,bases,dict):
> super(autosuper,cls).__i
could ildg wrote:
> When I try to learn metaclass of python by article at this place:
> http://www.python.org/2.2/descrintro.html#metaclasses,
> I changed the autosuper example a little as below:
>
> class autosuper(type):
> def __init__(cls,name,bases,dict):
> super(autosuper,cls).__
There are many resources for metaclasses on the Net.
There was a Wiki page on www.python.org about them,
but I don't find it now. So, I will refer you to the links
I have handy:
http://www-106.ibm.com/developerworks/linux/library/l-pymeta.html
http://www-128.ibm.com/developerworks/linux/library/l-
When I try to learn metaclass of python by article at this place:
http://www.python.org/2.2/descrintro.html#metaclasses,
I changed the autosuper example a little as below:
class autosuper(type):
def __init__(cls,name,bases,dict):
super(autosuper,cls).__init__(name,bases,dict)
s
17 matches
Mail list logo