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 -
On Mon, Sep 24, 2012 at 11:43 AM, Chris Withers ch...@simplistix.co.uk 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
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__;
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
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
Derive a class
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:273
Derive
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)
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(object):
'''Borg
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):
group =
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(type):
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 instance's
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 to
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 about
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:
code
class autosuper(type):
def __init__(cls,name,bases,dict):
super(autosuper,cls).__init__(name,bases,dict)
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
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:
code
class autosuper(type):
def __init__(cls,name,bases,dict):
16 matches
Mail list logo