Chris Angelico writes:
> On Tue, Nov 5, 2019 at 5:43 PM dieter wrote:
>> I suppose that "isinstance" (at least under Python 2) does not
>> behave exactly as stated in PEP 3119. Instead, "isinstance"
>> first directly checks for the instance to be an instance of the
>> class *AND ONLY IF THIS FAI
On 04/11/2019 22:23, Peter J. Holzer wrote:
On 2019-11-04 14:54:23 +, Rhodri James wrote:
On 04/11/2019 14:33, Veek M wrote:
__metaclass__ = whatever; # is python2.x syntax
But not Python3: see PEP 3115
Doesn't "X is python2.x syntax" imply "X is not python3 syntax"?
Not necessarily,
On Tue, Nov 5, 2019 at 5:43 PM dieter wrote:
> I suppose that "isinstance" (at least under Python 2) does not
> behave exactly as stated in PEP 3119. Instead, "isinstance"
> first directly checks for the instance to be an instance of the
> class *AND ONLY IF THIS FAILS* calls the class' "__instanc
in
"True" also for other cases.
> 1. Why do I get True whenever i tuple the
> isinstance(f, (Bar, Foo))
> (and why don't the print's run)
>
> The docs say that you can feed it a tuple and that the results are OR'd
>
>
> The form using a tupl
On 2019-11-04 14:54:23 +, Rhodri James wrote:
> On 04/11/2019 14:33, Veek M wrote:
> > __metaclass__ = whatever; # is python2.x syntax
>
> But not Python3: see PEP 3115
Doesn't "X is python2.x syntax" imply "X is not python3 syntax"?
hp
--
_ | Peter J. Holzer| Story must ma
On 04/11/2019 14:33, Veek M wrote:
Aha. You're trying to fix up the metaclass after the fact, which is not
the right way to do it. If you change the class definitions to:
__metaclass__ = whatever; # is python2.x syntax
But not Python3: see PEP 3115
then you get the prints from MyMeta.__i
>
> Aha. You're trying to fix up the metaclass after the fact, which is not
> the right way to do it. If you change the class definitions to:
>
__metaclass__ = whatever; # is python2.x syntax
> then you get the prints from MyMeta.__instancecheck__(). The
> isinstance() still returns True, tho
On 04/11/2019 11:30, Veek M wrote:
1. Why do I get True whenever i tuple the
isinstance(f, (Bar, Foo))
(and why don't the print's run)
I'm not very familiar with metaclasses, but I can answer the second part
of your question.
The docs say that you can feed it a tuple and t
B) or ... (etc.).
-
which implies that the metaclasses are called for each class?
class MyzMeta(type):
def __instancecheck__(cls, other):
print('MyzzMeta', other)
return 0
class MyMeta(MyzMeta, object):
def __instancecheck__(cls, other):
prin
Thank you for your thoughts.
I'm trying to migrating en existing python2 api,
which has been build using boost::python with pure python3 code.
All of the py2 classes do have these additional properties names and values.
You are right, using dict(Ordinal.__members__) for names
could have been used
Eko palypse wrote:
> I'm fairly new when it comes to metaclass programming and therefore the
> question whether the following makes sense or not.
>
> The goal is to have two additional class properties which return a
> dictionary name:class_attribute and value:class_attribute for an IntEnum
> cla
I'm fairly new when it comes to metaclass programming and therefore the
question whether the following makes sense or not.
The goal is to have two additional class properties which return a
dictionary name:class_attribute and value:class_attribute for an IntEnum class
and after reading about it I
W dniu 23.12.2016 o 15:14, Ian Kelly pisze:
(...)
cls.added_in_init = 'test'
Man, you are awsome genius! Finally somebody was able to explain me what
is the power of __new__ and difference between __init__ !!!
So what I wanted to achieve was adding some new attributes to the class
ins
On Fri, Dec 23, 2016 at 5:14 AM, Mr. Wrobel wrote:
> Hi,thanx for answers, let's imagine that we want to add one class attribute
> for newly created classess with using __init__ in metaclass, here's an
> example:
>
> #!/usr/bin/env python
>
> class MetaClass(type):
> # __init__ manipulation:
>
wise I use `__init__`. Likewise, if I'm using
`__new__` then I do all my configuration in `__new__` unless I have a
really good reason not to (such as making it easier for subclasses to
modify/skip `__init__`).
As far as metaclasses go... the only time I recall writing an `__init__`
for a metac
g
`__new__` then I do all my configuration in `__new__` unless I have a
really good reason not to (such as making it easier for subclasses to
modify/skip `__init__`).
As far as metaclasses go... the only time I recall writing an `__init__`
for a metaclass was to strip off the extra arguments so
On 12/20/2016 03:26 PM, Ian Kelly wrote:
... The latter is interesting mostly because it allows you to set the
__slots__ or do something interesting with the __prepare__ hook
(although the only interesting thing I've ever seen done with
__prepare__ is to use an OrderedDict to preserve the the de
"Mr. Wrobel" writes:
> Quick question, can anybody tell me when to use __init__ instead of
> __new__ in meta programming?
Use ‘__new__’ to do the work of *creating* one instance from nothing;
allocating the storage, determining the type, etc. — anything that will
be *the same* for every instance
On Tue, Dec 20, 2016 at 2:04 PM, Mr. Wrobel wrote:
> Hi,
>
> Quick question, can anybody tell me when to use __init__ instead of __new__
> in meta programming?
>
> I see that __new__ can be used mostly when I want to manipulate with class
> variables that are stored into dictionary.
>
> But when t
Hi,
Quick question, can anybody tell me when to use __init__ instead of
__new__ in meta programming?
I see that __new__ can be used mostly when I want to manipulate with
class variables that are stored into dictionary.
But when to use __init__? Any example?
Thanx,
M
--
https://mail.python.
to post-process the class, it seems
that metaclasses are simply not the right tool.
Using a post-processing object as a metaclass or decorator necessarily
requires predefinition. Such objects are usually used more than once.
For one-off postprocessing, I probably would not bother.
At the moment, t
it can be instantiated when you
> define the class.
I don't like the approach to define the code to post-process a class
before defining the class. It's a bit like top-posting, it messes up the
reading order. Since I really intend to post-process the class, it seems
that metaclasses
On 11 April 2013 07:43, Ulrich Eckhardt wrote:
> The second question that came up was if there is a way to keep a metaclass
> defined inside the class or if the only way is to provide it externally.
Yes, using metaclasses! I wouldn't recommend it though. Here's a
proof of
ng back, I have a hack in mind that involves
> creating a baseclass which in turn provides a metaclass that invokes a
> specific function to post-initialize the class, similar to the way
> Python 2 does it automatically, but I'm wondering if there isn't
> anything better.
See
Am 10.04.2013 11:52, schrieb Peter Otten:
It looks like this particular invocation relies on class attribute and
function __name__ being identical.
Please file a bug report.
http://bugs.python.org/issue17696
Uli
--
http://mail.python.org/mailman/listinfo/python-list
Python 3, it fails to detect any test case at all! My
guess is that the unittest library was changed to use metaclasses itself
in order to detect classes derived from unittest.TestCase. Therefore,
overriding the metaclass breaks test case discovery. My question in that
context is how do I extend
)])
File "/usr/lib/python2.7/unittest/case.py", line 191, in __init__
(self.__class__, methodName))
ValueError: no such test method in : test_2
It looks like this particular invocation relies on class attribute and
function __name__ being identical.
Please file a bug report.
&g
whether I discovered a bug.
Now, concerning Python 3, it fails to detect any test case at all! My
guess is that the unittest library was changed to use metaclasses itself
in order to detect classes derived from unittest.TestCase. Therefore,
overriding the metaclass breaks test case discovery
like 1+1 has very little power (it just adds two numbers),
classes have more power, metaclasses more again, and exec even more still.
Power can be used for good things, but it can also be used for bad. I
consider metaclasses to be about equal in power to decorators, but more
obscure and l
On 25 juil, 17:36, "Steven W. Orr" wrote:
> I have been doing a lot of reading. I'm starting to get it. I think it's
> really cool as well as dangerous,
Dangerous ??? Why so ? Is there anything "dangerous" in a constructor
or an initialiser ??? A metaclass is just a class, and a class is just
an
On 26/07/11 04:44, Victor Khangulov wrote:
> Hi Steven,
>
> I too am just learning about metaclasses in Python and I found the
> example you posted to be excellent.
>
> I played around with it and noticed that the issue seems to be the
> double-underscore in front of the
Hi Steven,
I too am just learning about metaclasses in Python and I found the
example you posted to be excellent.
I played around with it and noticed that the issue seems to be the
double-underscore in front of the fields (cls.__fields = {}). If you
change this parameter to use the single
or key, value in ns.items():
>if isinstance(value, Field):
>cls._fields[key] = value
>
> class Enforcer(object):
># attach the metaclass
>__metaclass__ = EnforcerMeta
>
>def __setattr__(self, key, value):
>if key in self._fields:
>
Very good.
Karim
On 07/25/2011 05:46 PM, jfine wrote:
Hi
I gave a tutorial at this year's EuroPython that covered metaclasses.
You can get the tutorial materials from a link on:
http://ep2011.europython.eu/conference/talks/objects-and-classes-in-python-and-javascript
Jonathan
--
Steven W. Orr wrote:
> I have been doing a lot of reading. I'm starting to get it. I think it's
> really cool as well as dangerous, but I plan on being respectful of the
> construct. I found a web page that I found quite readable.
>
> http://cleverdevil.org/computing/78/
>
> So, I tried to run t
Hi
I gave a tutorial at this year's EuroPython that covered metaclasses.
You can get the tutorial materials from a link on:
http://ep2011.europython.eu/conference/talks/objects-and-classes-in-python-and-javascript
Jonathan
--
http://mail.python.org/mailman/listinfo/python-list
I have been doing a lot of reading. I'm starting to get it. I think it's
really cool as well as dangerous, but I plan on being respectful of the
construct. I found a web page that I found quite readable.
http://cleverdevil.org/computing/78/
So, I tried to run the example code (below), and I ge
Hi there,
We are currently looking for someone who has ideally several years coding
experience, and who is familar with
Network coding and the Python language.
The project revolves around emulation and a chat based system, altough the vast
majority of the project is focused
on the chat based
Falcolas writes:
> On Jan 21, 12:10 pm, Arnaud Delobelle wrote:
[...]
>> Or you could override __getattr__
>>
>> --
>> Arnaud
>
> I tried overriding __getattr__ and got an error at runtime (the
> instance did not have xyz key, etc), and the Tag dict is not
> modifiable (granted, I tried Tag.__di
On Jan 21, 1:55 pm, Peter Otten <__pete...@web.de> wrote:
> Falcolas wrote:
> > I tried overriding __getattr__ and got an error at runtime (the
>
> You can either move __getattr__() into the metaclass or instantiate the
> class. I prefer the latter.
>
> Both approaches in one example:
>
> >>> class
Falcolas wrote:
> I tried overriding __getattr__ and got an error at runtime (the
You can either move __getattr__() into the metaclass or instantiate the
class. I prefer the latter.
Both approaches in one example:
>>> class Tag:
... class __metaclass__(type):
... def __getattr_
On Jan 21, 12:10 pm, Arnaud Delobelle wrote:
> On Jan 21, 6:37 pm, Falcolas wrote:
>
> > On Jan 21, 11:24 am, Arnaud Delobelle wrote:
>
> > It was the easiest way I found to add a lot of static methods to the
> > Tag class without writing each one out. __getattr__ was not working
> > for this ap
On Jan 21, 6:37 pm, Falcolas wrote:
> On Jan 21, 11:24 am, Arnaud Delobelle wrote:
>
>
>
>
>
> > Falcolas writes:
> > > I'm running into an issue with closures in metaclasses - that is, if I
> > > create a function with a closure in a metacla
On Jan 21, 11:24 am, Arnaud Delobelle wrote:
> Falcolas writes:
> > I'm running into an issue with closures in metaclasses - that is, if I
> > create a function with a closure in a metaclass, the closure appears
> > to be lost when I access the final class. I end up g
Falcolas writes:
> I'm running into an issue with closures in metaclasses - that is, if I
> create a function with a closure in a metaclass, the closure appears
> to be lost when I access the final class. I end up getting the text
> 'param' instead of the actual tags I
I'm running into an issue with closures in metaclasses - that is, if I
create a function with a closure in a metaclass, the closure appears
to be lost when I access the final class. I end up getting the text
'param' instead of the actual tags I am expecting:
ALL_TAGS = ['
Hi,
I have been studying python metaclasses for a few days now and I believe that
slowly but surely I am grasping the subject. The best article I have found on
this is "Metaclass Demystified", by J. LaCour, Python Magazine, July 2008
(http://cleverdevil.org/computing/78/).
I repl
p = Base.DerivedGroup(format2.Group) # useful
>>>
>>> Could anyone please offer a comment, is this an appropriate use of
>>> metaclassing, or is there maybe an easier/better alternative?
>DD> I don't fully understand metaclasses, but I think I have convince
On Apr 12, 4:53 pm, Darren Dale wrote:
> On Apr 12, 4:50 pm, Kay Schluehr wrote:
>
>
>
> > On 11 Apr., 20:15, Darren Dale wrote:
>
> > > I am working on a project that provides a high level interface to hdf5
> > > files by implementing a thin wrapper around h5py.
> > > I would like to
> > > gene
On Apr 12, 4:50 pm, Kay Schluehr wrote:
> On 11 Apr., 20:15, Darren Dale wrote:
>
> > I am working on a project that provides a high level interface to hdf5
> > files by implementing a thin wrapper around h5py.
> > I would like to
> > generalize the project so the same API can be used with other
On 11 Apr., 20:15, Darren Dale wrote:
> I am working on a project that provides a high level interface to hdf5
> files by implementing a thin wrapper around h5py.
> I would like to
> generalize the project so the same API can be used with other formats,
> like netcdf or ascii files. The format sp
On Apr 12, 3:23 pm, Aaron Brady wrote:
> On Apr 12, 1:30 pm, Darren Dale wrote:
>
>
>
> > On Apr 11, 2:15 pm, Darren Dale wrote:
>
> _
>
> > > format1.Group # implementation of group in format1
> > > format2.Group # ...
> > > Base.DerivedGroup # base implementation of DerivedGroup, not directly
On Apr 12, 1:30 pm, Darren Dale wrote:
> On Apr 11, 2:15 pm, Darren Dale wrote:
>
>
_
>
> > format1.Group # implementation of group in format1
> > format2.Group # ...
> > Base.DerivedGroup # base implementation of DerivedGroup, not directly
> > useful
> > format1.DerivedGroup = Base.DerivedGroup(
t directly
> useful
> format1.DerivedGroup = Base.DerivedGroup(format1.Group) # useful
> format2.DerivedGroup = Base.DerivedGroup(format2.Group) # useful
>
> Could anyone please offer a comment, is this an appropriate use of
> metaclassing, or is there maybe an easier/better alternative?
I don&
I am working on a project that provides a high level interface to hdf5
files by implementing a thin wrapper around h5py. I would like to
generalize the project so the same API can be used with other formats,
like netcdf or ascii files. The format specific code exists in File,
Group and Dataset clas
Barak, Ron wrote:
When I try the following (to see the types of the classes involved):
#!/usr/bin/env python
import wx
from Debug import _line as line
class CopyAndPaste(object):
def __init__(self, *args, **kwargs):
super(CopyAndPaste, self).__init__(*args, **kwargs)
pr
mo09.py Traceback (most recent call
> last):
> File "./failover_pickle_demo09.py", line 321, in
> class ListControlMeta(wx.Frame, CopyAndPaste):
> TypeError: Error when calling the metaclass bases
> metaclass conflict: the metaclass of a derived class must be a
> (
> -Original Message-
> From: ch...@rebertia.com [mailto:ch...@rebertia.com] On
> Behalf Of Chris Rebert
> Sent: Sunday, February 22, 2009 22:12
> To: Barak, Ron
> Cc: python-list@python.org
> Subject: Re: Is there a way to ask a class what its metaclasses are ?
>
On Sun, Feb 22, 2009 at 5:14 AM, Barak, Ron wrote:
> Hi Chris,
Is there a way to ask a class what its metaclasses are ?
> (e.g., how to ask wx.Frame what it's metaclass is)
Of course. A metaclass is the type of a class, so it's just type(wx.Frame).
Cheers,
Chris
--
Follow
e it's listing below).
> > Could you have a look at the CopyAndPaste class, and see if
> something in its construction strikes you as susspicious ?
> >
> > Thanks,
> > Ron.
> >
> > $ cat ./CopyAndPaste.py
> > #!/usr/bin/env python
> >
> &g
On Nov 12, 3:01 pm, sandro <[EMAIL PROTECTED]> wrote:
> Aaron Brady wrote:
> > On Nov 12, 9:38 am, sandro <[EMAIL PROTECTED] wrote:
> >> Hi,
> >> Is there a way to solve this? I'd like ro force a reload of the
> >> metaclass after 'debug' has been loaded and debug.DBG set to True,
> >> but that do
Aaron Brady wrote:
> On Nov 12, 9:38 am, sandro <[EMAIL PROTECTED] wrote:
>> Hi,
>> Is there a way to solve this? I'd like ro force a reload of the
>> metaclass after 'debug' has been loaded and debug.DBG set to True,
>> but that doesn't seem to happen...
>>
>> Any hints?
>>
>> sandro
>> *:-)
>>
On Nov 12, 9:38 am, sandro <[EMAIL PROTECTED]> wrote:
> Hi,
> Is there a way to solve this? I'd like ro force a reload of the
> metaclass after 'debug' has been loaded and debug.DBG set to True,
> but that doesn't seem to happen...
>
> Any hints?
>
> sandro
> *:-)
>
> sqlkit: http://sqlkit.argoli
Hi,
I had two packages working fine toghether: debug and sqlkit. Debug
provides a metaclass just for debuggging purposes to sqlkit (to log
methods following a recipe on ASPN. It worked very well, just logging
depending on the value of a module variable in debug module. That
means module debug a
On Mar 4, 12:51 am, Gerard Flanagan <[EMAIL PROTECTED]> wrote:
> On Mar 4, 6:31 am, [EMAIL PROTECTED] wrote:
>
>
>
>
>
> > On Mar 3, 10:01 pm, Benjamin <[EMAIL PROTECTED]> wrote:
>
> > > On Mar 3, 7:12 pm, [EMAIL PROTECTED] wrote:
>
> > >
On Mar 4, 6:31 am, [EMAIL PROTECTED] wrote:
> On Mar 3, 10:01 pm, Benjamin <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Mar 3, 7:12 pm, [EMAIL PROTECTED] wrote:
>
> > > What are metaclasses?
>
> > Depends on whether you want to be confused or not. If you do,
On Mar 3, 10:01 pm, Benjamin <[EMAIL PROTECTED]> wrote:
> On Mar 3, 7:12 pm, [EMAIL PROTECTED] wrote:
>
> > What are metaclasses?
>
> Depends on whether you want to be confused or not. If you do, look at
> this old but still head bursting
> essay:http://www.pyt
On Mar 3, 7:12 pm, [EMAIL PROTECTED] wrote:
> What are metaclasses?
Depends on whether you want to be confused or not. If you do, look at
this old but still head bursting essay:
http://www.python.org/doc/essays/metaclasses/.
Basically, the metaclass of a (new-style) class is responsible
On Mar 3, 8:22 pm, "Daniel Fetchinson" <[EMAIL PROTECTED]>
wrote:
> > What are metaclasses?
>
> http://www.google.com/search?q=python+metaclass
>
> HTH,
> Daniel
Not satisfied.
http://en.wikipedia.org/wiki/Metaclass#Python_example
That's a limitation
> What are metaclasses?
http://www.google.com/search?q=python+metaclass
HTH,
Daniel
--
http://mail.python.org/mailman/listinfo/python-list
What are metaclasses?
--
http://mail.python.org/mailman/listinfo/python-list
En Mon, 03 Sep 2007 07:39:05 -0300, km <[EMAIL PROTECTED]>
escribi�:
> But why does it show varied difference in the time between a and b
> instance creations when __metaclass__ hook is used and when not used in
> class Y ? I dont understand that point !
What do you expect from a._created, b.
Hi,
But why does it show varied difference in the time between a and b
instance creations when __metaclass__ hook is used and when not used in
class Y ? I dont understand that point !
KM
On 9/1/07, Michele Simionato <[EMAIL PROTECTED]> wrote:
>
> On Sep 1, 6:07 pm, Steve Holden <[EMAIL PROTECTE
On Sep 1, 6:07 pm, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> Debugging with Wing IDE and examining the classes at a breakpoint shows
> this to be true (even after Y's __metaclass__ assignment is commented out):
>
> >>> X.__metaclass__
>
> >>> Y.__metaclass__
>
> >>>
For the benefit of the
km wrote:
> Hi all,
>
> I have extended a prototype idea from Alex Martelli's resource on
> metaclasses regarding time stamping of instances.
>
>
> import time
> class Meta(type):
> start = time.time()
> def __call__(cls, *args, **kw):
>
Hi all,
I have extended a prototype idea from Alex Martelli's resource on
metaclasses regarding time stamping of instances.
import time
class Meta(type):
start = time.time()
def __call__(cls, *args, **kw):
print 'Meta start time %e'%cls.start
x =
Lenard Lindstrom <[EMAIL PROTECTED]> wrote:
> I don't know if C asserts are active in release Python, but for
> new-style classes one thing that happens during attribute lookup is that
> an object's class is asserted to be an instance of type.
Thank's for the explanation. My Linux distribution
Mirko Dziadzka wrote:
> Hi all
>
> I'm playing around with metaclasses and noticed, that there is small
> but mesurable a performance difference in the code shown below. With a
> more complex example I get a 5 percent performance penalty for using a
> metaclass. Until
Hi all
I'm playing around with metaclasses and noticed, that there is small
but mesurable a performance difference in the code shown below. With a
more complex example I get a 5 percent performance penalty for using a
metaclass. Until today I assumed, that a metaclass has no performance
i
class M
-- execute:
ic = M("ic", bases, D)
the body always creates a dictionary -- you can't override that with
metaclasses. Maybe some deep bytecode hacks might work, but I have some
doubts in the matter (not given it much thought, tho).
Alex
--
http://mail.python.org/mailman/listinfo/python-list
Adam Atlas wrote:
> Suppose I want to create a type (i.e. a new-style class via the usual
> `class blah(...)` mechanism) but, during the process of creating the
> type, I want to replace its __dict__
If I understand you right, what you want is something like::
class MyDict(object):
On May 2, 5:24 pm, Larry Bates <[EMAIL PROTECTED]> wrote:
> I think that most people accomplish this by:
>
> class blah:
> __initial_values={'a': 123, 'b': 456}
>
> def __init__(self):
> self.__dict__.update(self.__initialvalues)
That's not really what I'm talking about... I'm talk
t is, I have `class
> blah(...): a = 123; b = 456; ...`, and I want to substitute my own
> dict subclass which will thus receive __setitem__(a, 123),
> __setitem__(b, 456), and so on.
>
> Is this possible? Maybe with metaclasses? I've experimented with them
> a bit, but I
; b = 456; ...`, and I want to substitute my own
dict subclass which will thus receive __setitem__(a, 123),
__setitem__(b, 456), and so on.
Is this possible? Maybe with metaclasses? I've experimented with them
a bit, but I haven't found any setup that works.
--
http://mail.python.o
On Mar 11, 7:31 pm, "Alan Isaac" <[EMAIL PROTECTED]> wrote:
> Forman's book is out of print.
> Is there a good substitute?
>
> Thanks,
> Alan Isaac
The book is about a non-standard implementation of C++ featuring
metaclasses.
It it not that relevant if you are
Forman's book is out of print.
Is there a good substitute?
Thanks,
Alan Isaac
--
http://mail.python.org/mailman/listinfo/python-list
On Feb 27, 6:47 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote:
> Andrew Felch wrote:
> > Thanks for checking. I think I narrowed the problem down to
> > inheritance. I inherit from list or some other container first:
>
> > class PointList( list, AutoReloader ):
> > def PrintHi1(self):
> >
On Feb 27, 3:47 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote:
> Andrew Felch wrote:
> > Thanks for checking. I think I narrowed the problem down to
> > inheritance. I inherit from list or some other container first:
>
> > class PointList( list, AutoReloader ):
> > def PrintHi1(self):
> >
Andrew Felch wrote:
> Thanks for checking. I think I narrowed the problem down to
> inheritance. I inherit from list or some other container first:
>
> class PointList( list, AutoReloader ):
> def PrintHi1(self):
> print "Hi2"
>
> class MyPrintingClass( AutoReloader ):
> def Prin
On Feb 27, 3:23 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote:
> Andrew Felch wrote:
> > I pasted the code into mine and replaced the old. It seems not to
> > work for either unpickled objects or new objects. I add methods to a
> > class that inherits from AutoReloader and reload the module, but
Andrew Felch wrote:
> I pasted the code into mine and replaced the old. It seems not to
> work for either unpickled objects or new objects. I add methods to a
> class that inherits from AutoReloader and reload the module, but the
> new methods are not callable on the old objects. Man! It seems
On Feb 27, 5:30 pm, "Ziga Seilnacht" <[EMAIL PROTECTED]> wrote:
> Andrew Felch wrote:
>
> > Thanks Ziga. I use pickle protocol 2 and binary file types with the
> > command: "cPickle.dump(obj, file, 2)"
>
> > I did your suggestion, i commented out the "__call__" function of
> > MetaInstanceTracker
Andrew Felch wrote:
>
> Thanks Ziga. I use pickle protocol 2 and binary file types with the
> command: "cPickle.dump(obj, file, 2)"
>
> I did your suggestion, i commented out the "__call__" function of
> MetaInstanceTracker and copied the text to the __new__ function of
> AutoReloader (code append
ss
>
> > ... then the changes don't affect the unpickled object. If I unpickle
> > the object again, of course the changes take effect.
>
> > My friend that loves Smalltalk is laughing at me. I thought I had the
> > upperhand when I discovered the metaclasses
es take effect.
>
> My friend that loves Smalltalk is laughing at me. I thought I had the
> upperhand when I discovered the metaclasses but now I am not sure what
> to do. I really don't want to have to unpickle again, I'm processing
> video and it can take a long time.
>
pperhand when I discovered the metaclasses but now I am not sure what
to do. I really don't want to have to unpickle again, I'm processing
video and it can take a long time.
By the way, I used to avoid all of these problems by never making
classes, and always building complex structures
Peter Otten wrote:
> You determine the factory Python uses to
> make a class by adding
>
> __metaclass__ = factory
>
> to the class body, so you'll probably end with something like
>
> class ProducerHandlerType(type):
> # your code
>
> class A:
> __metaclass__ = ProducerHandlerType
>
> Without looking into the details -- the (subclass of) type is meant to be
> the class of the class, or the other way round, your normal classes are
> instances of (a subclass of) type. You determine the factory Python uses to
> make a class by adding
>
> __metaclass__ = factory
>
> to the class
Laszlo Nagy wrote:
> I would like to create a hierarchy classes, where the leaves have a
> special attribute called "producer_id". In addition, I would like to
> have a function that can give me back the class assigned to any
> producer_id value. I tried to implement this with a metaclass, but I
>
Hello,
I would like to create a hierarchy classes, where the leaves have a
special attribute called "producer_id". In addition, I would like to
have a function that can give me back the class assigned to any
producer_id value. I tried to implement this with a metaclass, but I
failed. Pleas
1 - 100 of 189 matches
Mail list logo