[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:

[issue37997] Segfault when using pickle with exceptions and dynamic class inheritance

2021-09-07 Thread Irit Katriel
Irit Katriel added the comment: I am unable to reproduce the crash with either example on 3.9 or 3.11 on a Mac. Please create a new issue if you still see a problem on a current version (>= 3.9). -- nosy: +iritkatriel resolution: -> out of date stage: -> resolved status: open ->

[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread Tim Peters
Tim Peters added the comment: This wasn't written with subclassing in mind to begin with. A class was just an obvious way to allow advanced users to construct instances with their own states (e.g., so they could build pseudo-independent generators for parallel programming). When

[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread Raymond Hettinger
Raymond Hettinger added the comment: -1 I am opposed to this redesign. There is no problem being solved that warrants changing a long standing public API. It is irresponsible to just guess at whether anyone is using the API. To add randbytes() could have just been a simple two line

[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread STINNER Victor
STINNER Victor added the comment: > It may be time to start emitting a warning if a Random subclass overrides > random() but not getrandbits() or vice versa. Does someone know if there are users outside the stdlib of random subclass which only implements random()? I guess that a deprecation

[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It may be time to start emitting a warning if a Random subclass overrides random() but not getrandbits() or vice versa. If you only override random(), methods which rely on generating random integers will use worse algorithm (slightly less uniform). If

[issue40346] Redesign random.Random class inheritance

2020-04-21 Thread STINNER Victor
STINNER Victor added the comment: Example with Python 3.8: --- import random class MyRandom(random.Random): def getrandbits(self, n): return 0 my = MyRandom() print([my.randint(1, 6) for _ in range(3)]) print([my.random() for _ in range(3)]) --- Output: --- [1, 1, 1]

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: Having SystemRandom() use less memory is nice. The seed() logic is reusable (not MT specific) and should be kept. Historically, subclassers were supposed to supply random(), and the getrandbits() method was optional and just added greater range to

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread STINNER Victor
STINNER Victor added the comment: Attached PR 19631 adds random.BaseRandom. random.SystemRandom now inherits from BaseRandom and so no longer inherits from _random.Random: an instance now only takes 48 bytes of memory, rather than 2568 bytes (on x86-64). --

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +18958 pull_request: https://github.com/python/cpython/pull/19631 ___ Python tracker ___

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: The randbytes() method could have been added effortlessly as a one line pure python method. It only became complicated as a result of premature optimization into C code and as a result of ignoring the API promises. You really don't have to redesign the

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: -18957 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread Antoine Pitrou
Change by Antoine Pitrou : -- keywords: +patch nosy: +pitrou nosy_count: 1.0 -> 2.0 pull_requests: +18957 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19539 ___ Python tracker

[issue40346] Redesign random class inheritance

2020-04-20 Thread STINNER Victor
he implementation of bpo-40282 "Allow random.getrandbits(0)": https://github.com/python/cpython/pull/19539#pullrequestreview-393728231 It's maybe time to fix the class hierarchy. -- components: Library (Lib) messages: 366892 nosy: vstinner priority: normal severity: normal s

[issue40346] Redesign random.Random class inheritance

2020-04-20 Thread STINNER Victor
Change by STINNER Victor : -- title: Redesign random class inheritance -> Redesign random.Random class inheritance ___ Python tracker <https://bugs.python.org/issu

[issue37997] Segfault when using pickle with exceptions and dynamic class inheritance

2019-09-09 Thread Gabriel C
Gabriel C added the comment: Some further investigation suggests this may have nothing to do with pickle at all. Consider the following short example: ``` def CreateDynamicClass(basetype): class DynamicClassImpl(basetype): def __init__(self): super(DynamicClassImpl,

[issue37997] Segfault when using pickle with exceptions and dynamic class inheritance

2019-08-31 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +pitrou ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37997] Segfault when using pickle with exceptions and dynamic class inheritance

2019-08-31 Thread Gabriel C
mal severity: normal status: open title: Segfault when using pickle with exceptions and dynamic class inheritance type: crash versions: Python 3.5, Python 3.7 ___ Python tracker <https://bug

Re: class inheritance when not defined

2017-09-08 Thread Steve D'Aprano
On Fri, 8 Sep 2017 07:03 pm, Ben Finney wrote: >> Who is the father of ExampleClass1 ? > > No-one, since classes do not have gender. (The convention is to use the > gender-neutral “parent” to refer to that relationship.) Possibly not the case in Russia. Besides, words have gender in many

class inheritance when not defined

2017-09-08 Thread Andrej Viktorovich
Hello I found several class creation samples: class ExampleClass1: class ExampleClass2(object): What is difference between them? Who is the father of ExampleClass1 ? -- https://mail.python.org/mailman/listinfo/python-list

table class - inheritance, delegation?

2017-03-31 Thread duncan smith
Hello, I need to code up a table class, which will be based on numpy arrays. Essentially it needs to behave like a numpy array, but with a variable associated with each array dimension. It must (at least partially) satisfy the API of an existing class. The main reason for the new class is to

Re: Class Inheritance from different module

2014-09-22 Thread Jean-Michel Pichavant
class User(Inheritance from API): def __init__(self, ID): steamapi.core.APIConnection(api_key = KEY) super( Inheritance SteamUser (ID)) # creates the user using the API [...] So that in my code when I need to create a new user, I just call 'usr = User(XXX)' instead of calling

Re: Class Inheritance from different module

2014-09-22 Thread Jean-Michel Pichavant
- Original Message - From: Jean-Michel Pichavant jeanmic...@sequans.com To: Juan Christian juan0christ...@gmail.com Cc: Python python-list@python.org Sent: Monday, 22 September, 2014 1:37:41 PM Subject: Re: Class Inheritance from different module class User(Inheritance from API

Class Inheritance from different module

2014-09-20 Thread Juan Christian
I have the following structure: Third-party API installed via pip: steamapi / app.py consts.py core.py users.py [...] My script: test.py In the API, the module users.py has a class 'SteamUser' and I want to mimic it's usage on my code, like this: import steamapi [...] class User(Inheritance

Re: Class Inheritance from different module

2014-09-20 Thread Steven D'Aprano
Juan Christian wrote: [...] In the API, the module users.py has a class 'SteamUser' and I want to mimic it's usage on my code, like this: import steamapi [...] class User(Inheritance from API): What do you mean, Inheritance from API? You can't inherit from an API, only from classes.

Re: Class Inheritance from different module

2014-09-20 Thread Peter Otten
Juan Christian wrote: I have the following structure: Third-party API installed via pip: steamapi / app.py consts.py core.py users.py [...] My script: test.py In the API, the module users.py has a class 'SteamUser' and I want to mimic it's usage on my code, like this:

class inheritance python2.7 vs python3.3

2014-01-06 Thread jwe . van . dijk
I have problems with these two classes: class LPU1(): def __init__(self, formula): formula is a string that is parsed into a SymPy function and several derived functions self.formula = formula ... ... class LPU3(LPU1): def

Re: class inheritance python2.7 vs python3.3

2014-01-06 Thread Chris Angelico
On Tue, Jan 7, 2014 at 4:14 AM, jwe.van.d...@gmail.com wrote: class LPU3(LPU1): def __new__(self): the same functions as LPU1 but some added functions and some functions redefined You probably don't want to be using __new__ here. Try using __init__

Re: class inheritance python2.7 vs python3.3

2014-01-06 Thread Dave Angel
On Mon, 6 Jan 2014 09:14:08 -0800 (PST), jwe.van.d...@gmail.com wrote: I have problems with these two classes: class LPU1() : You forgot to derive from object. That's implied on 3.x, but you say you're also running on 2.7 Without naming your base class you're asking for an old style

Re: class inheritance python2.7 vs python3.3

2014-01-06 Thread Steven D'Aprano
jwe.van.d...@gmail.com wrote: I have problems with these two classes: class LPU1(): def __init__(self, formula): formula is a string that is parsed into a SymPy function and several derived functions self.formula = formula ... ...

Re: class inheritance python2.7 vs python3.3

2014-01-06 Thread jwe . van . dijk
On Monday, 6 January 2014 18:14:08 UTC+1, jwe.va...@gmail.com wrote: I have problems with these two classes: class LPU1(): def __init__(self, formula): formula is a string that is parsed into a SymPy function and several derived functions

I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread aaabbb16
my_function() ... Can anyone finish above code and let me try to understand Class inheritance? TIA. -david -- http://mail.python.org/mailman/listinfo/python-list

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Chris Rebert
, not a function, so please rename the class something less confusing. Can anyone finish above code and let me try to understand Class inheritance? TIA. Have you read any Python tutorial? There are several basic errors in your code which would suggest that you haven't. You really ought to; it's well worth

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Jason Swails
way of dealing with classes is to instantiate different classes. Can anyone finish above code and let me try to understand Class inheritance? You appear to be confusing functions and classes. Functions are chunks of code that you (optionally) pass variables to in order to perform a specific

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Chris Rebert
On Sat, Oct 15, 2011 at 12:09 AM, Jason Swails jason.swa...@gmail.com wrote: snip For instance, let's say you want to deal with shapes.  You can define a shape via a class class Shape(object):    Base shape class snip Now we get into inheritance.  Let's suppose that we want a specific type

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread aaabbb16
less confusing. sure. i like call it from my_lib Can anyone finish above code and let me try to understand Class inheritance? TIA. Have you read any Python tutorial? There are several basic errors in your code which would suggest that you haven't. You really ought to; it's well worth

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread Chris Rebert
   def test(self):       print this is a test If __name__ == '__main__':    my_class.main() --- my_lib.py class p_test() ... Can anyone finish it and give me a demo. Class inheritance? for this case, it inherit/change p_test

Re: I am a newbie for python and try to understand class Inheritance.

2011-10-15 Thread DevPlayer
On Oct 15, 2:20 am, aaabb...@hotmail.com wrote: Test.py --- #!/usr/bin/python from my_lib import my_function class MyClass(my_function): # usually class names start capital We know you're not forgetting to document.     def __init__(self, name): super(MyClass,

[issue10968] Timer class inheritance issue

2011-01-21 Thread Benjamin VENELLE
Benjamin VENELLE gu0su...@gmail.com added the comment: I've tested it with Python 3.1.2 under Windows 7 32 bits. It raises the following TypeError exception function() argument 1 must be code, not str -- ___ Python tracker rep...@bugs.python.org

[issue10968] Timer class inheritance issue

2011-01-21 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: I can't reproduce the error. Do you have a script that shows the issue? What is the complete traceback? -- nosy: +amaury.forgeotdarc ___ Python tracker rep...@bugs.python.org

[issue10968] Timer class inheritance issue

2011-01-21 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: Ah, got it. It's about threading.Timer, which looks like a class, but is actually a function. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10968

[issue10968] Timer class inheritance issue

2011-01-21 Thread Amaury Forgeot d'Arc
Amaury Forgeot d'Arc amaur...@gmail.com added the comment: It seems to be by design: from the documentation: http://docs.python.org/py3k/library/threading.html Timer is a subclass of Thread, and a Thread subclass should only override the __init__() and run() methods. What are you trying to do

[issue10968] Timer class inheritance issue

2011-01-21 Thread Benjamin VENELLE
Benjamin VENELLE gu0su...@gmail.com added the comment: Yes that's it. I Should precise it. I've taken a screenshot from my python's interpreter to spot it. -- Added file: http://bugs.python.org/file20479/issue10968.png ___ Python tracker

[issue10968] Timer class inheritance issue

2011-01-20 Thread Benjamin VENELLE
Changes by Benjamin VENELLE gu0su...@gmail.com: -- assignee: collinwinter components: Benchmarks nosy: Kain94, collinwinter priority: normal severity: normal status: open title: Timer class inheritance issue type: behavior ___ Python tracker rep

[issue10968] Timer class inheritance issue

2011-01-20 Thread Benjamin VENELLE
New submission from Benjamin VENELLE gu0su...@gmail.com: Hi, Due to Timer's object creation behavior, it is impossible to subclass it. This kind of declaration will result to an exception raising: class A(Timer): pass -- components: +Library (Lib) -Benchmarks versions: +Python 3.1

[issue10968] Timer class inheritance issue

2011-01-20 Thread Alexander Belopolsky
Alexander Belopolsky belopol...@users.sourceforge.net added the comment: Works for me: from timeit import Timer class A(Timer): pass ... (Tested with Python 3.1 and 3.2 on OSX.) -- nosy: +belopolsky ___ Python tracker rep...@bugs.python.org

Re: class inheritance

2010-12-23 Thread JLundell
That's nice, Ethan, especially in that it saves having to explicitly find and list all the methods being covered. It's perhaps not quite so critical for a Fraction-based class, since the set of methods to be covered is fairly well contained, but that's not always going to be the case. The

Re: class inheritance

2010-12-21 Thread Ethan Furman
JLundell wrote: On Saturday, March 13, 2010 9:03:36 AM UTC-8, Jonathan Lundell wrote: I've got a subclass of fractions.Fraction called Value; it's a mostly trivial class, except that it overrides __eq__ to mean 'nearly equal'. However, since Fraction's operations result in a Fraction, not a

Re: class inheritance

2010-12-17 Thread JLundell
On Saturday, March 13, 2010 9:03:36 AM UTC-8, Jonathan Lundell wrote: I've got a subclass of fractions.Fraction called Value; it's a mostly trivial class, except that it overrides __eq__ to mean 'nearly equal'. However, since Fraction's operations result in a Fraction, not a Value, I end up

Did class inheritance from dict work in early Python?

2010-07-21 Thread John Nagle
Did class inheritance from dict work in early Python? Or did that only start working when new objects came in? John Nagle -- http://mail.python.org/mailman/listinfo/python-list

Re: Did class inheritance from dict work in early Python?

2010-07-21 Thread Stephen Hansen
On 7/21/10 7:45 PM, John Nagle wrote: Did class inheritance from dict work in early Python? Or did that only start working when new objects came in? The latter, that's why UserDict (and UserList) was added. -- Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai

Re: Did class inheritance from dict work in early Python?

2010-07-21 Thread Steven D'Aprano
On Wed, 21 Jul 2010 19:45:24 -0700, John Nagle wrote: Did class inheritance from dict work in early Python? Or did that only start working when new objects came in? Only with the introduction of new-style classes and object in version 2.2. http://www.python.org/download/releases/2.2.3

Re: class inheritance

2010-03-18 Thread JLundell
On Mar 17, 5:12 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Mon, 15 Mar 2010 16:34:35 -0700,JLundellwrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for floating-point applications while preserving hash. If

Re: class inheritance

2010-03-17 Thread Steven D'Aprano
On Mon, 15 Mar 2010 16:34:35 -0700, JLundell wrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for floating-point applications while preserving hash. If only there were a ~= or ≈ operator I could overload. And ~ is unary, so no joy. Not

Re: class inheritance

2010-03-16 Thread Dave Angel
Carl Banks wrote: On Mar 15, 4:34 pm, JLundell jlund...@pobox.com wrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for floating-point applications while preserving hash. If only there were a ~=r ≈ operator I could overload. And ~ is

Re: class inheritance

2010-03-16 Thread Robert Kern
On 2010-03-16 07:35 AM, Dave Angel wrote: Carl Banks wrote: On Mar 15, 4:34 pm, JLundell jlund...@pobox.com wrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for floating-point applications while preserving hash. If only there were a

Re: class inheritance

2010-03-16 Thread JLundell
On Mar 16, 8:06 am, Robert Kern robert.k...@gmail.com wrote: On 2010-03-16 07:35 AM, Dave Angel wrote: Carl Banks wrote: On Mar 15, 4:34 pm, JLundell jlund...@pobox.com wrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for

Re: class inheritance

2010-03-16 Thread Robert Kern
On 2010-03-16 17:55 PM, JLundell wrote: On Mar 16, 8:06 am, Robert Kernrobert.k...@gmail.com wrote: On 2010-03-16 07:35 AM, Dave Angel wrote: Carl Banks wrote: On Mar 15, 4:34 pm, JLundelljlund...@pobox.com wrote: It's also unfortunate that Python doesn't have an approximately-equal

Re: class inheritance

2010-03-15 Thread Jean-Michel Pichavant
JLundell wrote: I've got a subclass of fractions.Fraction called Value; it's a mostly trivial class, except that it overrides __eq__ to mean 'nearly equal'. However, since Fraction's operations result in a Fraction, not a Value, I end up with stuff like this: x = Value(1) + Value(2) where x is

Re: class inheritance

2010-03-15 Thread JLundell
On Mar 13, 1:26 pm, Carl Banks pavlovevide...@gmail.com wrote: It's a tad unfortunately Python doesn't make this easier.  If I had to do it more than once I'd probably write a mixin to do it: class ArithmeticSelfCastMixin(object):     def __add__(self,other):         return

Re: class inheritance

2010-03-15 Thread Carl Banks
On Mar 15, 4:34 pm, JLundell jlund...@pobox.com wrote: It's also unfortunate that Python doesn't have an approximately-equal operator; it'd come in handy for floating-point applications while preserving hash. If only there were a ~= or ≈ operator I could overload. And ~ is unary, so no joy.

class inheritance

2010-03-13 Thread JLundell
I've got a subclass of fractions.Fraction called Value; it's a mostly trivial class, except that it overrides __eq__ to mean 'nearly equal'. However, since Fraction's operations result in a Fraction, not a Value, I end up with stuff like this: x = Value(1) + Value(2) where x is now a Fraction,

Re: class inheritance

2010-03-13 Thread Patrick Maupin
On Mar 13, 11:03 am, JLundell jlund...@pobox.com wrote: I've got a subclass of fractions.Fraction called Value; it's a mostly trivial class, except that it overrides __eq__ to mean 'nearly equal'. However, since Fraction's operations result in a Fraction, not a Value, I end up with stuff like

Re: class inheritance

2010-03-13 Thread Jack Diederich
On Sat, Mar 13, 2010 at 12:03 PM, JLundell jlund...@pobox.com wrote: I've got a subclass of fractions.Fraction called Value; it's a mostly trivial class, except that it overrides __eq__ to mean 'nearly equal'. However, since Fraction's operations result in a Fraction, not a Value, I end up

Re: class inheritance

2010-03-13 Thread Patrick Maupin
On Mar 13, 11:37 am, Jack Diederich jackd...@gmail.com wrote: If Fraction.__add__ returns a new object but the subclass Value is compatible (as I would except since it is a sublcass) then just change all references in Franction.__add__ to be more generic, ex/ class Franction():   def

Re: class inheritance

2010-03-13 Thread JLundell
On Mar 13, 9:37 am, Jack Diederich jackd...@gmail.com wrote: If Fraction.__add__ returns a new object but the subclass Value is compatible (as I would except since it is a sublcass) then just change all references in Franction.__add__ to be more generic, ex/ class Franction():   def

Re: class inheritance

2010-03-13 Thread Carl Banks
On Mar 13, 9:03 am, JLundell jlund...@pobox.com wrote: I've got a subclass of fractions.Fraction called Value; it's a mostly trivial class, except that it overrides __eq__ to mean 'nearly equal'. However, since Fraction's operations result in a Fraction, not a Value, I end up with stuff like

Re: Automatic Attribute Assignment during Class Inheritance

2009-09-10 Thread gizli
On Sep 9, 9:00 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Wed, 09 Sep 2009 20:14:33 -0700, gizli wrote: I do not want to force the consumers of this framework to write this obscure line of code. I was wondering if it is possible (at class definition time) to capture

Automatic Attribute Assignment during Class Inheritance

2009-09-09 Thread gizli
Hi all, I have been trying to do a programming trick with python and so far I failed. I am using sqlalchemy in my code and writing a framework with it. This framework uses something called polymorphic identity attribute to define the do single table inheritance. Here's roughly how it works: 1.

Re: Automatic Attribute Assignment during Class Inheritance

2009-09-09 Thread Steven D'Aprano
On Wed, 09 Sep 2009 20:14:33 -0700, gizli wrote: I do not want to force the consumers of this framework to write this obscure line of code. I was wondering if it is possible (at class definition time) to capture the fact that MyTask extends Task and automatically insert the

Re: Visualize class inheritance hierarchy

2008-09-24 Thread Rob Kirkpatrick
On Sep 23, 4:58 pm, Christian Heimes [EMAIL PROTECTED] wrote: Rob Kirkpatrick wrote: I'm assuming this has been discussed before, but I'm lacking any Google keywords that bring up the appropriate discussion. You are looking for mro aka method resolution order. The inspect module contains

Visualize class inheritance hierarchy

2008-09-23 Thread Rob Kirkpatrick
Hi All, I just finished debugging some code where I needed to determine why one subclass had a bound method and another did not. They had different pedigree's but I didn't know immediately what the differences were. I ended up walking the hierarchy, going back one class at a time through the

Re: Visualize class inheritance hierarchy

2008-09-23 Thread Christian Heimes
Rob Kirkpatrick wrote: I'm assuming this has been discussed before, but I'm lacking any Google keywords that bring up the appropriate discussion. You are looking for mro aka method resolution order. The inspect module contains several helper functions to inspect a class hierarchy. The

Re: Visualize class inheritance hierarchy

2008-09-23 Thread Aaron Castironpi Brady
On Sep 23, 5:53 pm, Rob Kirkpatrick [EMAIL PROTECTED] wrote: Hi All, I just finished debugging some code where I needed to determine why one subclass had a bound method and another did not.  They had different pedigree's but I didn't know immediately what the differences were. I ended up

Re: Visualize class inheritance hierarchy

2008-09-23 Thread Aaron Castironpi Brady
On Sep 23, 5:53 pm, Rob Kirkpatrick [EMAIL PROTECTED] wrote: Hi All, I just finished debugging some code where I needed to determine why one subclass had a bound method and another did not.  They had different pedigree's but I didn't know immediately what the differences were. I ended up

Re: Class Inheritance - What am I doing wrong?

2008-04-25 Thread Bruno Desthuilliers
Brian Munroe a écrit : Ok, so thanks everyone for the helpful hints. That *was* a typo on my part (should've been super(B...) not super(A..), but I digress) I'm building a public API. Along with the API I have a few custom types that I'm expecting API users to extend, if they need too. If I

Re: Class Inheritance - What am I doing wrong?

2008-04-25 Thread Brian Munroe
On Apr 24, 10:11 pm, Arnaud Delobelle [EMAIL PROTECTED] wrote: In python, use attributes starting with a single underscore (such as _name). It tells users that they shouldn't mess with them. By design, python doesn't include mechanisms equivalent to the Java / C++ 'private'. Arnaud,

Class Inheritance - What am I doing wrong?

2008-04-24 Thread Brian Munroe
My example: class A(object): def __init__(self, name): self.__name = name def getName(self): return self.__name class B(A): def __init__(self,name=None): super(A,self).__init__() def setName(self, name):

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Virgil Dupras
On Apr 24, 10:22 pm, Brian Munroe [EMAIL PROTECTED] wrote: My example: class A(object):         def __init__(self, name):                 self.__name = name         def getName(self):                 return self.__name class B(A):         def __init__(self,name=None):                

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Arnaud Delobelle
Brian Munroe [EMAIL PROTECTED] writes: My example: class A(object): def __init__(self, name): self.__name = name def getName(self): return self.__name class B(A): def __init__(self,name=None): super(A,self).__init__()

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Arnaud Delobelle
Arnaud Delobelle [EMAIL PROTECTED] writes: That is, if you also pass the name parameter to super(A,self).__init__ in B's __init__ method Oops. should be super(B, self).__init__(name), of course. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Gary Herron
Brian Munroe wrote: My example: class A(object): def __init__(self, name): self.__name = name def getName(self): return self.__name class B(A): def __init__(self,name=None): super(A,self).__init__() def

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Brian Munroe
Ok, so thanks everyone for the helpful hints. That *was* a typo on my part (should've been super(B...) not super(A..), but I digress) I'm building a public API. Along with the API I have a few custom types that I'm expecting API users to extend, if they need too. If I don't use name mangling,

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Gabriel Genellina
En Thu, 24 Apr 2008 18:18:01 -0300, Brian Munroe [EMAIL PROTECTED] escribió: Ok, so thanks everyone for the helpful hints. That *was* a typo on my part (should've been super(B...) not super(A..), but I digress) I'm building a public API. Along with the API I have a few custom types that

Re: Class Inheritance - What am I doing wrong?

2008-04-24 Thread Arnaud Delobelle
Brian Munroe [EMAIL PROTECTED] writes: Ok, so thanks everyone for the helpful hints. That *was* a typo on my part (should've been super(B...) not super(A..), but I digress) I'm building a public API. Along with the API I have a few custom types that I'm expecting API users to extend, if

Re: str class inheritance prob?

2008-04-18 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : so I’m trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: Others already gave you the technical solution (use __new__, not __init__). A couple remarks still: 1/ class Path(str):

str class inheritance prob?

2008-04-16 Thread jkazoo
so I’m trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while

str class inheritance prob?

2008-04-16 Thread Hamish McKenzie
so I'm trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean = str(path).replace('\\','/') while

Re: str class inheritance prob?

2008-04-16 Thread Jerry Hill
On Wed, Apr 16, 2008 at 2:35 PM, Hamish McKenzie [EMAIL PROTECTED] wrote: so I'm trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: You actually want to run your code when creating the new object, not when initializing

Re: str class inheritance prob?

2008-04-16 Thread s0suk3
On Apr 16, 1:43 pm, [EMAIL PROTECTED] wrote: so I’m trying to create a class that inherits from str, but I want to run some code on the value on object init. this is what I have: class Path(str): def __init__( self, path ): clean =

Re: Class Inheritance

2008-03-13 Thread Marc 'BlackJack' Rintsch
On Thu, 13 Mar 2008 00:06:52 -0500, Andrew Rekdal wrote: Problem is layout_ext and Layout code is dependant on a Class instance 'css'. Then pass that instance to the `Layout` class in the `__init__()` so both, the base class and the subclass use the same `CSS` instance. Ciao, Marc

Re: Class Inheritance

2008-03-13 Thread Bruno Desthuilliers
Andrew Rekdal a écrit : I am trying to bring functions to a class by inheritance... for instance in layout_ext I have.. --- layout_ext.py- class Layout() def...some function that rely on css in Layout.py It shouldn't, definitively. The Layout instance should have a

Class Inheritance

2008-03-12 Thread Andrew Rekdal
I am trying to bring functions to a class by inheritance... for instance in layout_ext I have.. --- layout_ext.py- class Layout() def...some function that rely on css in Layout.py def... ---EOF-- in the main application file I have... Layout.py--- from layout_ext import

Re: Case study: library class inheritance with property declarations

2007-08-08 Thread cdleary
On Aug 2, 7:05 am, Bruno Desthuilliers [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] a écrit : (snip) Last post -- I swear. I failed to realize that it's all part of an extremely well defined attribute resolution protocol, and handled via the descriptor specification. Discussing

Case study: library class inheritance with property declarations

2007-08-02 Thread cdleary
Hi all, It's possible that I'm missing the obvious -- I've been up for over 24 hours and I'm most likely dehydrated from mass coffee intake, but I figure many people in similar circumstances will be searching comp.lang.python one day, so here goes! class LibraryClass(object): A class

Re: Case study: library class inheritance with property declarations

2007-08-02 Thread cdleary
On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote: Hi all, It's possible that I'm missing the obvious -- I've been up for over 24 hours and I'm most likely dehydrated from mass coffee intake, but I figure many people in similar circumstances will be searching comp.lang.python one day, so here goes!

Re: Case study: library class inheritance with property declarations

2007-08-02 Thread cdleary
On Aug 2, 7:08 am, [EMAIL PROTECTED] wrote: On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote: Hi all, It's possible that I'm missing the obvious -- I've been up for over 24 hours and I'm most likely dehydrated from mass coffee intake, but I figure many people in similar circumstances will

Re: Case study: library class inheritance with property declarations

2007-08-02 Thread Steve Holden
[EMAIL PROTECTED] wrote: On Aug 2, 7:08 am, [EMAIL PROTECTED] wrote: On Aug 2, 6:49 am, [EMAIL PROTECTED] wrote: Hi all, It's possible that I'm missing the obvious -- I've been up for over 24 hours and I'm most likely dehydrated from mass coffee intake, but I figure many people in similar

Re: Case study: library class inheritance with property declarations

2007-08-02 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : (snip) Last post -- I swear. I failed to realize that it's all part of an extremely well defined attribute resolution protocol, and handled via the descriptor specification. Discussing descriptors was on the TODO list for the type/class unification document, but

  1   2   >