Java way... if you don't want to do it,
put both classes in the same file.
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
with a different behavior. It's better for you to override
__contains__() too.
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
tom _init method for
each one of them.
You can use the subclass __new__, but that's definitely 'unpythonic'.
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
easonable thing to do, exactly for
what you mentioned on your code... someone could easily break a lot of
stuff doing it the wrong way, instead if not using __dict__.
I mailed the list because someone else thought it might be a bug and I
was in doubt... now it's clear it was the right thing to do.
Regards,
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
;>> class C(object):
... __metaclass__ = M
...
>>> C.y = 'bar'
>>> C.x
'foo'
>>> C.y
'bar'
>>> o = C()
>>> o.x
...
AttributeError: 'C' object has no attribute 'x'
>>> o.y
'bar'
>>>
So... both 'x' and 'y' are class attributes, but 'x' is a virtual
attribute implemented with M.__getattr__. From the instance I have
access to 'y' but not to 'x'.
Regards,
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
>>> x is y
True
But __init__ will be called once for each time you call A, even if it's
always the same instance returned. If this is a problem, you'll need
another method to use for initialization and call it only once.
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
oid some problems with method and descriptors creation,
since someone using metaclasses and custom __getattribute__ at the same
time is asking for trouble, but... I googled for it and tried to find
something on the list but, nothing. From the source it seems like a
generic wrapper is used. What's the real case here ?
Regards,
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
27;initialized')
>except AttributeError: # should raise
> print 'not initialized'
>else:
> raise
>try:
> a.initialized #every look up would do ,even a print
>except AttributeError:
> raise
>else:
> print 'initialized'
>
>
> Have fun Paolino
>
>
>
>
>
> ___
> Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
> http://mail.yahoo.it
> --
> http://mail.python.org/mailman/listinfo/python-list
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
;n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
>>> [chr(x) for x in xrange(ord('d'), ord('p') + 1)]
['d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']
>>> [chr(x) for x in xrange(ord('A'), ord('Z') + 1)]
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
etc...
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
is really just a documentation problem.
Check the comments on the bug report here:
http://sourceforge.net/tracker/index.php?func=detail&aid=1294232&group_id=5470&atid=105470
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
taclass I set explicitly.
I will change the bug report and add some of the suggested
documentation.
Thanks
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
and "explicit is better
than implicit". If it's just a documentation issue, the first rule in
search order is much more complex than documented. If I am completely
wrong in all of this, maybe it's better stop wasting our time. :)
Thank you
--
Pedro Werneck
http://sourceforge.net/tracker/index.php?func=detail&aid=1294232&group_id=5470&atid=105470
--
http://mail.python.org/mailman/listinfo/python-list
must be a
(non-strict) subclass of the metaclasses of all its bases
>>> class C(B): __metaclass__ = M_A
...
>>> C.__metaclass__
>>> C.__class__
> You are free to post the bug report and look at the opinions of the
> developers.
I posted a few hours ago.
Thank you.
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
.net/tracker/index.php?func=detail&aid=1294232&group_id=5470&atid=105470
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
class conflict error. But with M_A, the error is ignored, probably
because PyType_IsSubtype is returning 1 for M_A being a subtype of M_B
and the winner and metatype are exchanged later, so we end with M_B as
C's real type.
> I suggest you to file a documentation bug. Unfortunately the basic
> d
7:47)
[GCC 3.3.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class M_A(type): pass
...
>>> class A: __metaclass__ = M_A
...
>>> class B(A): __metaclass__ = type
...
>>> B.__class__
>>> B.__metaclass__
Regards,
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
_class__ to M_B!
>>> class C(B): __metaclass__ = type
...
>>> C.__metaclass__
>>> C.__class__
>>> type(C)
Since the explicit __metaclass__ attribute has priority over parent
classes, a case like this is an error and should raise an exception like
the metaclass conflict, right ?
Regards,
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
aryfunc)Pin_and, /*nb_and*/
(binaryfunc)Pin_xor, /*nb_xor*/
(binaryfunc)Pin_or, /*nb_or*/
0, /*nb_coerce*/
...
};
Thanks for any help...
--
Pedro Werneck
--
http://mail.python.org/mailman/listinfo/python-list
Hi
The problem is that '\x00' is a escape sequence...
Try something like this:
>>> x = '\x00'
>>> int(repr(x)[3:-1], 16)
0
>>> x = '\x15'
>>> int(repr(x)[3:-1], 16)
21
>>>
On Sat, 05 Feb 2005 06:51:32 -0700
Earl Eiland <[EMAIL PROTECTED]> wrote:
> I'm trying to process the IP packet lengt
What about this ?
#
if sys.version_info >= (2,4):
def sorted(iterable, *args, **kwds):
seq = list(iterable)
seq.sort(*args, **kwds)
return seq
#
It worked against the TestSorted in lib/test/test_builtins.py
On Sun, 30 Jan 2005 08:30:17 +0100
"Fredrik Lundh" <[EM
Hi,
If you need direct access to some atribute, use object.__getattribute__.
>>> class DefaultAttr(object):
... def __init__(self, default):
... self.default = default
... def __getattribute__(self, name):
... try:
... value = object.__getattribute__(self, na
Hi,
Up to Python 2.2, type() was just a function to return an object type.
>From 2.2 on, type have this behavior when called with only one argument
and is used to create a new type when called with 3 arguments.
>From http://www.python.org/2.2/descrintro.html :
"The signature of type() requires
On Tue, 25 Jan 2005 13:44:32 +
Martin Franklin <[EMAIL PROTECTED]> wrote:
> > thanks for this info - I had to abandon the createfilehandler() method
> > as it is not supported in windows and the GUI "might" be used there at
> > some time ...
Take a look here:
http://www.pythonbrasil.com.br/m
On Mon, 24 Jan 2005 18:45:46 +0100
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
>
> > Why does slicing a tuple returns a new tuple instead of a view of
> > the existing one, given that tuples are immutable ?
>
> really?
Well... seems like this case (slicing the whole tuple
On Mon, 24 Jan 2005 18:45:46 +0100
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
> George Sakkis wrote:
>
> > Why does slicing a tuple returns a new tuple instead of a view of
> > the existing one, given that tuples are immutable ?
>
> really?
Well... seems like this case is optimized to return th
A quick example for you:
###
import SocketServer
class EchoRequestHandler(SocketServer.BaseRequestHandler):
def setup(self):
print self.client_address, 'connected!'
self.request.send('hi ' + str(self.client_address) + '\n')
def handle(self):
while 1:
Hi,
Maybe something like this...
from Tkinter import *
import itertools
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.createWidgets()
def createWidgets(self):
self.stop = Button(self,text='Emerge
can
send it to you in pvt, if you want.
Pedro Werneck
On Fri, 21 Jan 2005 10:27:20 +0100
David <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm getting the following error:
>
>
> Traceback (most recent call last):
> File "..\kk.py", line 37,
28 matches
Mail list logo