-Original Message-
From: Barry Scott
Sent: Tuesday, July 16, 2019 11:53 AM
To: Joseph L. Casale
Cc: [email protected]
Subject: Re: Class initialization with multiple inheritance
> And here is the MRO for LeftAndRight.
>
> >>> import m
> LeftAndRight.__ini
> On 16 Jul 2019, at 01:13, Joseph L. Casale wrote:
>
> I am trying to find explicit documentation on the initialization logic for a
> Base class when multiple exist. For the example in the documentation at
> https://docs.python.org/3/tutorial/classes.html#multiple-inheritance,
> if Base1 and
On 16/07/19 12:13 PM, Joseph L. Casale wrote:
I am trying to find explicit documentation on the initialization logic for a
Base class when multiple exist. For the example in the documentation at
https://docs.python.org/3/tutorial/classes.html#multiple-inheritance,
if Base1 and Base2 both themselv
On Sun, 08 Aug 2010 19:47:18 -0400, Mel wrote:
> Costin Gament wrote:
>
>> So you're saying I should just use __init__? Will that get me out of my
>> predicament?
>> No, I don't quite understand the difference between my exemple and
>> using __init__, but I will read the docs about it.
>
> Here'
Costin Gament wrote:
> So you're saying I should just use __init__? Will that get me out of
> my predicament?
> No, I don't quite understand the difference between my exemple and
> using __init__, but I will read the docs about it.
Here's the thing about class variables:
Python 2.6.2 (release26-
Thank you all for your answers and your patience. As soon as I can,
I'll update my code and read up on the subject. If I still can't get
it working, I'll bother you again.
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, Aug 8, 2010 at 6:32 AM, Costin Gament wrote:
>
> Hi there.
> I'm kind of a beginner with Python (and programming in general). My
> problem is with initializing a class. Let's say I've defined it like
> this:
>
> class foo:
> a = 0
> b = 0
>
> and later I'm trying to initialize two diff
On 2010-08-08, Tim Harig wrote:
> On 2010-08-08, Tim Harig wrote:
>> On 2010-08-08, Costin Gament wrote:
>>> So you're saying I should just use __init__? Will that get me out of
>>> my predicament?
>>> No, I don't quite understand the difference between my exemple and
>>> using __init__, but I w
On 2010-08-08, Tim Harig wrote:
> On 2010-08-08, Costin Gament wrote:
>> So you're saying I should just use __init__? Will that get me out of
>> my predicament?
>> No, I don't quite understand the difference between my exemple and
>> using __init__, but I will read the docs about it.
>
> It is no
Thanks a lot. I'll try give it a go and see if it helps.
On Sun, Aug 8, 2010 at 6:28 PM, Tim Harig wrote:
> It is not so much using __init__() that makes the difference as it what
> scope the variables are assigned to. If you define them as you where, then
> the variables are associated with the
On 2010-08-08, Costin Gament wrote:
> So you're saying I should just use __init__? Will that get me out of
> my predicament?
> No, I don't quite understand the difference between my exemple and
> using __init__, but I will read the docs about it.
It is not so much using __init__() that makes the
That looks just like my code. What's the problem?
On Sun, Aug 8, 2010 at 6:13 PM, Jesse Jaggars wrote:
>
> Is it possible that you are using a mutable class object? A common
> gotcha is to do something like this:
>
class foo(object):
> ... x = []
> ...
a = foo()
b = foo()
a.
So you're saying I should just use __init__? Will that get me out of
my predicament?
No, I don't quite understand the difference between my exemple and
using __init__, but I will read the docs about it.
On Sun, Aug 8, 2010 at 6:01 PM, Tim Harig wrote:
>
> Others have told you that at a and b belo
On Sun, Aug 8, 2010 at 10:01 AM, Tim Harig wrote:
> On 2010-08-08, Costin Gament wrote:
>> Thank you for your answer, but it seems I didn't make myself clear.
>> Take the code:
>> class foo:
>> a = 0
>> b = 0
>> c1 = foo()
>> c1.a = 5
>> c2 = foo()
>> print c2.a
>> 5
>>
>> Somehow, when I try
On 2010-08-08, Costin Gament wrote:
> Thank you for your answer, but it seems I didn't make myself clear.
> Take the code:
> class foo:
> a = 0
> b = 0
> c1 = foo()
> c1.a = 5
> c2 = foo()
> print c2.a
> 5
>
> Somehow, when I try to acces the 'a' variable in c2 it has the same
> value as the '
Apparently, the code I've given here does, in fact, work. Still, I am
encountering a similar problem in a much larger class (it is in a
separate module, if that is any help). Also, the variable I am having
trouble with is itself another class. I don't think it's appropriate
to paste so much code in
On Sun, 08 Aug 2010 17:14:08 +0300, Costin Gament wrote:
> Thank you for your answer, but it seems I didn't make myself clear. Take
> the code:
> class foo:
> a = 0
> b = 0
> c1 = foo()
> c1.a = 5
> c2 = foo()
> print c2.a
> 5
Incorrect.
>>> class foo:
... a = 0
... b = 0
...
>>> c1 = fo
On Aug 8, 2010, at 4:14 PM, Costin Gament wrote:
Thank you for your answer, but it seems I didn't make myself clear.
You could have been clearer in your first post, yeah.
Take the code:
class foo:
a = 0
b = 0
c1 = foo()
c1.a = 5
c2 = foo()
print c2.a
5
Somehow, when I try to acces the 'a'
Thank you for your answer, but it seems I didn't make myself clear.
Take the code:
class foo:
a = 0
b = 0
c1 = foo()
c1.a = 5
c2 = foo()
print c2.a
5
Somehow, when I try to acces the 'a' variable in c2 it has the same
value as the 'a' variable in c1. Am I missing something?
On Sun, Aug 8, 201
On Aug 8, 2010, at 3:32 PM, Costin Gament wrote:
Hi there.
I'm kind of a beginner with Python (and programming in general). My
problem is with initializing a class. Let's say I've defined it like
this:
class foo:
a = 0
b = 0
and later I'm trying to initialize two different classes like this
rantingrick wrote:
>
>WHY did i need do this you may ask?
>I am creating geometry with OpenGL. When you create a face you must
>specify a winding order (clockwise or counter clockwise) this winding
>order controls which side of the face will be visible (since only one
>side of a face is rendered).
rantingrick wrote:
On Sep 18, 12:24 am, "OKB (not okblacke)"
wrote:
Perhaps you want to cut off the recursion at the first step, so
that the nested instance itself does not have a nested instance. If so,
add another parameter to __init__ that flags whether you are creating a
"top-le
En Fri, 18 Sep 2009 03:12:46 -0300, rantingrick
escribió:
I am creating geometry with OpenGL. When you create a face you must
specify a winding order (clockwise or counter clockwise) this winding
order controls which side of the face will be visible (since only one
side of a face is rendered)
EDIT:
copy.copy did work in a simple python interactive session, but it
caused infinite recursion in my real world code? Anyway what ever is
going on (probably lack of sleep!) the cure all was using an arg in
the initial function. So now i am good as gold ;-)
WHY did i need do this you may ask?
I
On Sep 17, 10:08 pm, rantingrick wrote:
> On Sep 17, 11:54 pm, Carl Banks wrote:
>
>
>
>
>
> > On Sep 17, 8:27 pm, rantingrick wrote:
>
> > > ok i have a class and in it's constructor i want to create a copy of
> > > it as an attribute, i have tried super, __new__, and noting seems to
> > > work
On Sep 18, 3:31 pm, alex23 wrote:
> On Sep 18, 3:08 pm, rantingrick wrote:
>
> > ok here is some code. this will cause an infinite recursion.
>
> > class A():
> > def __init__(self, *args):
> > self.nestedA = A(*args) #NO GOOD!
>
> How about:
>
> class A(object):
> def __init_
On Sep 18, 3:08 pm, rantingrick wrote:
> ok here is some code. this will cause an infinite recursion.
>
> class A():
> def __init__(self, *args):
> self.nestedA = A(*args) #NO GOOD!
How about:
class A(object):
def __init__(self, first=True, *args):
if first:
On Sep 18, 12:24 am, "OKB (not okblacke)"
wrote:
> Perhaps you want to cut off the recursion at the first step, so
> that the nested instance itself does not have a nested instance. If so,
> add another parameter to __init__ that flags whether you are creating a
> "top-level" instance.
!SOLVED!
Thanks for the help guys!
copy.copy did it!
Why does me makes life so hard on me? ;-)
--
http://mail.python.org/mailman/listinfo/python-list
rantingrick wrote:
> ok here is some code. this will cause an infinite recursion.
>
> class A():
> def __init__(self, *args):
> self.nestedA = A(*args) #NO GOOD!
>
> there must be a way to create an instance of an object within the
> same objects constructor?
This is an inhe
On Sep 18, 3:08 pm, rantingrick wrote:
> ok here is some code. this will cause an infinite recursion.
>
> class A():
> def __init__(self, *args):
> self.nestedA = A(*args) #NO GOOD!
>
> there must be a way to create an instance of an object within the same
> objects constructor?
But i
On Sep 17, 11:54 pm, Carl Banks wrote:
> On Sep 17, 8:27 pm, rantingrick wrote:
>
> > ok i have a class and in it's constructor i want to create a copy of
> > it as an attribute, i have tried super, __new__, and noting seems to
> > work, please help!
>
> > class A(base):
> > def __init__(self
On Sep 17, 8:27 pm, rantingrick wrote:
> ok i have a class and in it's constructor i want to create a copy of
> it as an attribute, i have tried super, __new__, and noting seems to
> work, please help!
>
> class A(base):
> def __init__(self):
> super(A, self).__init__()
> self.
On Sep 17, 11:14 pm, alex23 wrote:
> On Sep 18, 1:27 pm, rantingrick wrote:
>
> > ok i have a class and in it's constructor i want to create a copy of
> > it as an attribute, i have tried super, __new__, and noting seems to
> > work, please help!
>
> > class A(base):
> > def __init__(self):
>
On Sep 18, 1:27 pm, rantingrick wrote:
> ok i have a class and in it's constructor i want to create a copy of
> it as an attribute, i have tried super, __new__, and noting seems to
> work, please help!
>
> class A(base):
> def __init__(self):
> super(A, self).__init__()
> self.
On 14 Jan 2005 07:32:06 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>Yes, my examle here is a tiny part of a larger more complex issue. My
>application is an DOM XML parser that is reading attributes one at a
you mean like blah blah and you are
grabbing things of interest out of a stream
Yes, my examle here is a tiny part of a larger more complex issue. My
application is an DOM XML parser that is reading attributes one at a
time. My class that I am creating is used elsewhere and must have
certain arguments for those uses to continue working. So, I seem to be
left with creating an i
On 13 Jan 2005 20:36:19 -0800, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>#
># My problem is that I want to create a
># class, but the variables aren't known
># all at once. So, I use a dictionary to
># store the values in temporarily.
Why?
># Then when I have a complete set, I want to
># ini
[EMAIL PROTECTED] wrote:
t2 = Test(dictionary.get('a'), dictionary.get('b'),
dictionary.get('c'))
print t2
Try this:
t2 = Test(**dictionary)
This performs keyword argument expansion on the dictionary, matching the
dictionary entries with the named arguments to the Test.__init__ function.
Cheers,
39 matches
Mail list logo