Re: using classes

2020-03-13 Thread Pieter van Oostrum
joseph pareti wrote: > one more question. In the code below, there are 2 init() methods, one for > the class 'Fahrzeug' and > one for the class 'PKW'. > The program works when I instantiate the class as: > > fiat = PKW("Fiat Marea",50,0) > > but it fails if I say: > > fiat = PKW("Fia

Re: using classes

2020-03-13 Thread Peter J. Holzer
On 2020-03-13 09:46:29 +0100, joseph pareti wrote: > The program works when I instantiate the class as: > > fiat = PKW("Fiat Marea",50,0) > > but it fails if I say: > > *fiat = PKW("Fiat Marea",50,0,1)* The __init__ method of PKW has this signature: > def __init__(self, bez, ge, ins): You

Re: using classes

2020-03-13 Thread joseph pareti
one more question. In the code below, there are 2 init() methods, one for the class 'Fahrzeug' and one for the class 'PKW'. The program works when I instantiate the class as: fiat = PKW("Fiat Marea",50,0) but it fails if I say: *fiat = PKW("Fiat Marea",50,0,1)* *Traceback (most recent call l

Re: using classes

2020-03-12 Thread Pieter van Oostrum
joseph pareti writes: > thank you, that fixes it. I also noticed that both statements work: > > super(PKW, self).__init__(bez,ge) > > or > >super().__init__(bez,ge) The first is the required Python 2 calling (at least the first argument is required). The second way can be used

Re: using classes

2020-03-12 Thread Barry
> On 12 Mar 2020, at 14:28, joseph pareti wrote: > > thank you, that fixes it. I also noticed that both statements work: > > super(PKW, self).__init__(bez,ge) This form is for python 2 compatibility. > > or > > super().__init__(bez,ge) This is the python 3 way. If you do not

Re: using classes

2020-03-12 Thread joseph pareti
thank you, that fixes it. I also noticed that both statements work: super(PKW, self).__init__(bez,ge) or super().__init__(bez,ge) Am Do., 12. März 2020 um 12:58 Uhr schrieb MRAB : > On 2020-03-12 10:54, joseph pareti wrote: > > The following code that uses a class 'Fahrzeug' an

Re: using classes

2020-03-12 Thread MRAB
On 2020-03-12 10:54, joseph pareti wrote: The following code that uses a class 'Fahrzeug' and an inherited class 'PKW' runs correctly. However, if I use the 'super ' statement in in the PKW class, it ends with the following error message: *Traceback (most recent call last): File "erben_a.py",

using classes

2020-03-12 Thread joseph pareti
The following code that uses a class 'Fahrzeug' and an inherited class 'PKW' runs correctly. However, if I use the 'super ' statement in in the PKW class, it ends with the following error message: *Traceback (most recent call last): File "erben_a.py", line 19, in fiat = PKW("Fiat Marea",

Re: Using Classes

2010-06-26 Thread Mag Gam
Oh wow. You went beyond :-) Let me rewrite the example. I only want to calculate the wait time which is basically the depart time minus the arrival time for multiple days. This is all on 1 station. June 26, 2010: Trian A, Arrived at 6:00AM, Depart at 9:00AM Trian B, Arrived at 2:00AM, Depart at

Re: Using Classes

2010-06-25 Thread Mag Gam
uch as automatic code indenting :-), and making my programs >>> more modular by having functions. >>> >>> I know that Python is very OOP friendly, but I could not figure out >>> why and when to use Classes in it. I mostly use it for simple text >>> parsing

Re: Using Classes

2010-06-25 Thread geremy condra
ostly use it for simple text >> parsing  I suppose when a program gets "complicated" I should start >> using Classes. Are there any tips or tricks people use to "force" them >> into the OOP mentality? I would like to force myself to learn the >> Python wa

Re: Using Classes

2010-06-24 Thread Nathan Rice
ons. > > I know that Python is very OOP friendly, but I could not figure out > why and when to use Classes in it. I mostly use it for simple text > parsing I suppose when a program gets "complicated" I should start > using Classes. Are there any tips or tricks people us

Re: Using Classes

2010-06-24 Thread Alf P. Steinbach /Usenet
programs more modular by having functions. I know that Python is very OOP friendly, but I could not figure out why and when to use Classes in it. I mostly use it for simple text parsing I suppose when a program gets "complicated" I should start using Classes. Are there any tips or tri

Re: Using Classes

2010-06-24 Thread Neil Cerutti
On 2010-06-24, Bruno Desthuilliers wrote: > Not going into OO when you don't need it IS actually the > "Python way" !-) My most satisfying classes are the ones that gradually coalesce from a functional program. They take actual shape during refactoring. I find classes to be the most successful w

Re: Using Classes

2010-06-24 Thread Bruno Desthuilliers
ate_dp.pdf I mostly use it for simple text parsing I suppose when a program gets "complicated" I should start using Classes. Not necessarily. OO is one way to organize code and data, but there are other ways that work as well, depending on the problem at hand and how your brain is co

Using Classes

2010-06-24 Thread Mag Gam
functions. I know that Python is very OOP friendly, but I could not figure out why and when to use Classes in it. I mostly use it for simple text parsing I suppose when a program gets "complicated" I should start using Classes. Are there any tips or tricks people use to "force&quo

Re: binary search trees using classes

2007-05-26 Thread Steve Holden
Armağan Çelik wrote: >>/ Have a nice day. Have a nice day. > />/ Have a nice day. > />/ Have a nice day. > />/ > />/ the output is > />/ > />/ a 4 > />/ day 4 > / >>/ have 4 > />/ nice 4 > can you send c++ code of this output .This my homework/ > If it's your homework, shouldn't *you* be doing

binary search trees using classes

2007-05-26 Thread Armağan Çelik
* Have a nice day. Have a nice day. *>* Have a nice day. *>* Have a nice day. *>* *>* the output is *>* *>* a 4 *>* day 4 *>* have 4 *>* nice 4 can you send c++ code of this output .This my homework* -- http://mail.python.org/mailman/listinfo/python-list

Re: Using classes in python

2006-10-27 Thread Colin J. Williams
trevor lock wrote: > Hello, > > I've just started using python and have observed the following : > > class foo: > a=[] > def __init__(self, val): > self.a.append ( val ) > def getA(self): > print self.a > return self.a > > z = foo(5) > y = foo(4) >

Re: Using classes in python

2006-10-25 Thread Gabriel Genellina
At Wednesday 25/10/2006 16:19, trevor lock wrote: I've just started using python and have observed the following : class foo: a=[] def __init__(self, val): self.a.append ( val ) It's a common pitfall. As seen just a few days ago: http://groups.google.com/group/comp.lang.py

Re: Using classes in python

2006-10-25 Thread Éric Daigneault
trevor lock wrote: > Hello, > > I've just started using python and have observed the following : > > class foo: > a=[] > def __init__(self, val): > self.a.append ( val ) > def getA(self): > print self.a > return self.a > > z = foo(5) > y = foo(4) > z.

Using classes in python

2006-10-25 Thread trevor lock
Hello,I've just started using python and have observed the following :class foo:    a=[]    def __init__(self, val):    self.a.append ( val )    def getA(self):    print self.a    return self.az = foo(5)y = foo(4)z.getA()>> [5, 4]I was expecting that everytime I created an i