[issue409355] Meta-class inheritance problem

2022-04-10 Thread admin
Change by admin : -- github: None -> 34177 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue409354] Meta-class inheritance problem

2022-04-10 Thread admin
Change by admin : -- github: None -> 34176 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

Re: Unexpected Inheritance Problem

2021-05-21 Thread Grant Edwards
On 2021-05-20, Terry Reedy wrote: > On 5/20/2021 2:53 PM, Grant Edwards wrote: >> On 2021-05-20, Mats Wichmann wrote: >> >>> many fonts squish together repeated underscores in the display so it's >>> hard to see this visually, >> >> Is it just me, or does it seem foolish to use such fonts for

Re: Unexpected Inheritance Problem

2021-05-20 Thread Terry Reedy
On 5/20/2021 2:53 PM, Grant Edwards wrote: On 2021-05-20, Mats Wichmann wrote: On 5/20/21 4:54 AM, Richard Damon wrote: On 5/20/21 3:24 AM, Peter Otten wrote: On 20/05/2021 06:00, Richard Damon wrote: class GedcomHead(Gedcom0Tag): """GEDCOM 0 HEAD tag""" def ___init___(self,

Re: Unexpected Inheritance Problem

2021-05-20 Thread Grant Edwards
On 2021-05-20, Mats Wichmann wrote: > On 5/20/21 4:54 AM, Richard Damon wrote: >> On 5/20/21 3:24 AM, Peter Otten wrote: >>> On 20/05/2021 06:00, Richard Damon wrote: >>> class GedcomHead(Gedcom0Tag): """GEDCOM 0 HEAD tag""" def ___init___(self, *, parent): >>> >>> An

Re: Unexpected Inheritance Problem

2021-05-20 Thread Mats Wichmann
On 5/20/21 4:54 AM, Richard Damon wrote: On 5/20/21 3:24 AM, Peter Otten wrote: On 20/05/2021 06:00, Richard Damon wrote: class GedcomHead(Gedcom0Tag): """GEDCOM 0 HEAD tag""" def ___init___(self, *, parent): An __init__ with three underscores; you must me joking ;) Yes, that

Re: Unexpected Inheritance Problem

2021-05-20 Thread Richard Damon
On 5/20/21 1:58 AM, Chris Angelico wrote: > On Thu, May 20, 2021 at 2:02 PM Richard Damon > wrote: >> Given the following definition of classes, I am getting an unexpected >> error of : >> >> TypeError: __init__() missing 2 required keyword-only arguments: >> 'idcode' and 'tag' >> >> On the

Re: Unexpected Inheritance Problem

2021-05-20 Thread Richard Damon
On 5/20/21 3:24 AM, Peter Otten wrote: > On 20/05/2021 06:00, Richard Damon wrote: > >> class GedcomHead(Gedcom0Tag): >> """GEDCOM 0 HEAD tag""" >> def ___init___(self, *, parent): > > An __init__ with three underscores; you must me joking ;) > Yes, that is what I was missing, too many

Re: Unexpected Inheritance Problem

2021-05-20 Thread Peter Otten
On 20/05/2021 06:00, Richard Damon wrote: class GedcomHead(Gedcom0Tag):     """GEDCOM 0 HEAD tag"""     def ___init___(self, *, parent): An __init__ with three underscores; you must me joking ;) -- https://mail.python.org/mailman/listinfo/python-list

Re: Unexpected Inheritance Problem

2021-05-20 Thread Chris Angelico
On Thu, May 20, 2021 at 2:02 PM Richard Damon wrote: > > Given the following definition of classes, I am getting an unexpected > error of : > > TypeError: __init__() missing 2 required keyword-only arguments: > 'idcode' and 'tag' > > On the call to create a GedcomHead in the call to GedcomHead()

Unexpected Inheritance Problem

2021-05-19 Thread Richard Damon
Given the following definition of classes, I am getting an unexpected error of : TypeError:  __init__() missing 2 required keyword-only arguments: 'idcode' and 'tag' On the call to create a GedcomHead in the call to GedcomHead() in Gedcom0Tag.add() Code: class GedcomTag:     """Represents a

Re: mutlifile inheritance problem

2013-09-20 Thread Peter Cacioppi
On Thursday, March 21, 2002 2:03:23 PM UTC-7, Marc wrote: I have classes defined in different files and would like to inherit from a class in file A.py for a class in file B.py but am running into problems. I'm using Python 1.5.2 on Windows NT Here's a specific example:

Re: mutlifile inheritance problem

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 10:17 AM, Peter Cacioppi peter.cacio...@gmail.com wrote: It's too bad, I really lean on reload(). It appears to be incompatible with inheritance more than one level deep. Python's really not designed for reload of this nature. You can easily make a nasty mess of things.

Re: mutlifile inheritance problem

2013-09-18 Thread Peter Cacioppi
This is a very old topic, but here is a trick for single inheritance. (The problem you allude to isn't restricted to multiple inheritance). Any class with a single parent simply defines this function. def mySuper(self) : return super(self.__class__, self) And then any

Re: mutlifile inheritance problem

2013-09-18 Thread Peter Cacioppi
One more comment - my trick has some utility with multiple inheritance, but you really need to understand super() to and method resolution ordering in that case (as, I suppose, you ought to whenever you cross the Rubicon beyond single inheritance). So it's a nice trick but YMMV On Wednesday,

Re: mutlifile inheritance problem

2013-09-18 Thread Ned Batchelder
On 9/18/13 7:54 PM, Peter Cacioppi wrote: This is a very old topic, but here is a trick for single inheritance. (The problem you allude to isn't restricted to multiple inheritance). Any class with a single parent simply defines this function. def mySuper(self) : return

Re: mutlifile inheritance problem

2013-09-18 Thread Steven D'Aprano
On Wed, 18 Sep 2013 20:38:10 -0400, Ned Batchelder wrote: super() takes a class and an instance for a reason. If you could use self.__class__ for the class, then it would only take the instance. Super() needs to know the instance, but also needs to know the class it's being called from.

Inheritance problem

2008-11-05 Thread Mr . SpOOn
Hi, I have a problem with this piece of code: class NoteSet(OrderedSet): def has_pitch(self): pass def has_note(self): pass class Scale(NoteSet): def __init__(self, root, type): self.append(root) self.type = type ScaleType(scale=self)

Re: Inheritance problem

2008-11-05 Thread Diez B. Roggisch
Mr.SpOOn wrote: Hi, I have a problem with this piece of code: class NoteSet(OrderedSet): def has_pitch(self): pass def has_note(self): pass class Scale(NoteSet): def __init__(self, root, type): self.append(root) self.type = type

Re: Inheritance problem

2008-11-05 Thread Mr . SpOOn
On Wed, Nov 5, 2008 at 6:59 PM, Diez B. Roggisch [EMAIL PROTECTED] wrote: You need to call the __init__ of NoteSet inside Scale, as otherwise the instance isn't properly initialized. Thanks, solved. -- http://mail.python.org/mailman/listinfo/python-list

module organization/inheritance problem

2007-12-07 Thread km
Hi all, I have a python module (M) with the following structure M (directory) | __init__.py (class Base(object) ...) | - a.py (class A(Base) ...) | - b.py (class B(Base) ...) | - c.py (class C(Base) ...) The __init_.py has a class which all the

Inheritance problem

2007-05-09 Thread amidzic . branko
I'm trying to solve a problem using inheritance and polymorphism in python 2.4.2 I think it's easier to explain the problem using simple example: class shortList: def __init__(self): self.setList() def setList(self): a = [1,2,3] print a class

Re: Inheritance problem

2007-05-09 Thread Neil Cerutti
On 2007-05-09, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm trying to solve a problem using inheritance and polymorphism in python 2.4.2 It's not an inheritance problem, it's a notation problem. Python uses explicit 'self', saving you the trouble of devising a naming convention for data

Re: Inheritance problem

2007-05-09 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: class longList(shortList): def __init__(self): shortList.setList() self.setList() Addition: Always call the base class __init__ in your constructor if there exists one, i. e. class longList(shortList) def __init__(self):

Re: Inheritance problem

2007-05-09 Thread attn . steven . kuo
On May 9, 11:33 am, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: class longList(shortList): def __init__(self): shortList.setList() self.setList() Addition: Always call the base class __init__ in your constructor if there exists

Re: Inheritance problem

2007-05-09 Thread Jason
On May 9, 12:09 pm, [EMAIL PROTECTED] wrote: I'm trying to solve a problem using inheritance and polymorphism in python 2.4.2 I think it's easier to explain the problem using simple example: class shortList: def __init__(self): self.setList() def setList(self):

Inheritance problem. Creating an instance.

2006-12-05 Thread .nu
#!/usr/bin/env python # -*- coding: utf-8 -*- # Name: Sleepy Hollow # Author: .nu import wx import os import sys NEW_ID = 1; OPEN_ID = 2; SAVE_ID = 3; SAVE_AS_ID = 4; QUIT_ID = 5; UNDO_ID = 6; REDO_ID = 7; HELPME_ID = 8; ABOUT_ID = 9; OPTIONS_ID = 10 APP_NAME = 'Sleepy Hollow' class

Inheritance problem?

2006-01-06 Thread KraftDiner
I have a class class MyClass(MyBaseClass) def __init__(self) super(self.__class__, self).__init__() self.type = MyClassType return self It has a few methods... I have another class and the only difference is the __init__ method.. I tried this: class MySpecialClass(MyClass)

Re: Inheritance problem?

2006-01-06 Thread Simon Percivall
Don't use self.__class__, use the name of the class. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
Well, I would even add : don't use super ! Just call the superclass method : MyClass.__init__(self) Simon Percivall a écrit : Don't use self.__class__, use the name of the class. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem?

2006-01-06 Thread Xavier Morel
Pierre Barbier de Reuille wrote: Well, I would even add : don't use super ! Just call the superclass method : MyClass.__init__(self) Simon Percivall a écrit : Don't use self.__class__, use the name of the class. Bad idea if you're using new-style classes with a complex inheritance

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
Xavier Morel a écrit : Pierre Barbier de Reuille wrote: Well, I would even add : don't use super ! Just call the superclass method : MyClass.__init__(self) Simon Percivall a écrit : Don't use self.__class__, use the name of the class. Bad idea if you're using new-style classes with

Re: Inheritance problem?

2006-01-06 Thread Xavier Morel
Pierre Barbier de Reuille wrote: Xavier Morel a écrit : Pierre Barbier de Reuille wrote: Well, I would even add : don't use super ! Just call the superclass method : MyClass.__init__(self) Simon Percivall a écrit : Don't use self.__class__, use the name of the class. Bad idea if

Re: Inheritance problem?

2006-01-06 Thread Mike Meyer
Xavier Morel [EMAIL PROTECTED] writes: Pierre Barbier de Reuille wrote: Well, I would even add : don't use super ! Just call the superclass method : MyClass.__init__(self) Simon Percivall a écrit : Don't use self.__class__, use the name of the class. Bad idea if you're using new-style

Re: Inheritance problem?

2006-01-06 Thread KraftDiner
So ok I've written a piece of code that demonstrates the problem. Can you suggest how I change the Square class init? class Shape(object): def __init__(self): print 'MyBaseClass __init__' class Rectangle(Shape): def __init__(self):

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
KraftDiner a écrit : So ok I've written a piece of code that demonstrates the problem. Can you suggest how I change the Square class init? class Shape(object): def __init__(self): print 'MyBaseClass __init__' class Rectangle(Shape): def __init__(self):

Re: Inheritance problem?

2006-01-06 Thread Scott David Daniels
KraftDiner wrote: So ok I've written a piece of code that demonstrates the problem. Can you suggest how I change the Square class init? class Shape(object): def __init__(self): print 'MyBaseClass __init__' class Rectangle(Shape): def __init__(self): #

Inheritance problem ?

2005-08-24 Thread tooper
Hello all, I'm trying to implement a common behavior for some object that can be read from a DB or (when out of network) from an XML extract of this DB. I've then wrote 2 classes, one reading from XML the other from the DB, both inheritating from a common one where I want to implement several

Re: Inheritance problem ?

2005-08-24 Thread db
On Wed, 24 Aug 2005 03:34:36 -0700, tooper wrote: Hello all, I'm trying to implement a common behavior for some object that can be read from a DB or (when out of network) from an XML extract of this DB. I've then wrote 2 classes, one reading from XML the other from the DB, both

Re: Inheritance problem ?

2005-08-24 Thread jitya
tooper wrote: Hello all, I'm trying to implement a common behavior for some object that can be read from a DB or (when out of network) from an XML extract of this DB. I've then wrote 2 classes, one reading from XML the other from the DB, both inheritating from a common one where I want to

Re: Inheritance problem ?

2005-08-24 Thread tooper
Thanks, at least makes it running ! I'll have to teach myself to move to this new style classes by default anyway... -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem ?

2005-08-24 Thread jitya
The stuff on Descriptor.htm was really good . Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem ?

2005-08-24 Thread tooper
Not always easy to follow but great ! Using __str__ instead of __repr__ makes it work also with old style (thanks to Simon Brunning for suggesting it, and with your link I even now understand why !) -- http://mail.python.org/mailman/listinfo/python-list

object oriented inheritance problem

2005-05-10 Thread Matthew Thorley
I am trying to inherit from ElementTree so I can add some methods. This is the code I am trying to make work, and the following is the error I am getting. from elementtree import ElementTree class AcidTree(ElementTree): def write_string(self): File

Re: object oriented inheritance problem

2005-05-10 Thread Michele Simionato
It looks like ElementTree is a module and not a class. The same error message was posted here few weeks ago. Actually, I discuss it in my Oxford lectures, page 30: see http://www.reportlab.org/~andy/accu2005/pyuk2005_simionato_wondersofpython.zip (there also everything you want to know about

Re: object oriented inheritance problem

2005-05-10 Thread Fredrik Lundh
Matthew Thorley wrote: I am trying to inherit from ElementTree so I can add some methods. This is the code I am trying to make work, and the following is the error I am getting. from elementtree import ElementTree class AcidTree(ElementTree): def write_string(self):

Re: object oriented inheritance problem

2005-05-10 Thread Matthew Thorley
So is elementtree a module of modules? I didn't know you could do that. I just assumed that from elementtree import ElementTree imported a class from the module elementtree. It works now. Thanks guys. Fredrik Lundh wrote: Matthew Thorley wrote: I am trying to inherit from ElementTree so I

Re: object oriented inheritance problem

2005-05-10 Thread Fredrik Lundh
Matthew Thorley wrote: So is elementtree a module of modules? I didn't know you could do that. elementtree is a package. see: http://docs.python.org/tut/node8.html#SECTION00840 for a bit more information. /F -- http://mail.python.org/mailman/listinfo/python-list

Re: inheritance problem with 2 cooperative methods

2004-12-03 Thread Dan Perl
This is almost the same code as Greg's with the only difference being that test for configuration having been done. But the test is unnecessary. I don't see how setConfig could be invoked in the super of the base class (A), so such a test would be relevant only in subclasses, if they DO

Re: inheritance problem with 2 cooperative methods

2004-12-02 Thread Greg Ewing
Dan Perl wrote: So far, so good! But let's assume that I want to change the __init__ methods so that they take a configuration as an argument so the objects are created and configured in one step, like this: alpha = A(config) One way would be to make the setConfig call only in the root class,

Re: inheritance problem with 2 cooperative methods

2004-12-02 Thread Dan Perl
Thank you very much, Greg, that does the job! Somehow I couldn't see it and I needed someone to point out to me. Dan Greg Ewing [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dan Perl wrote: So far, so good! But let's assume that I want to change the __init__ methods so that