[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: Polymorphism using constructors

Diez B. Roggisch

3/3/2008 8:09:00 PM

K Viltersten schrieb:
> I'm writing a class for rational numbers
> and besides the most obvious constructor
>
> def __init__ (self, nomin, denom):
>
> i also wish to have two supporting ones
>
> def __init__ (self, integ):
> self.__init__ (integ, 1)
> def __init__ (self):
> self.__init__ (0, 1)
>
> but for some reason (not known to me at
> this point) i get errors. My suspicion is that it's a syntax issue.
>
> Suggestions?

"errors" is not much of an error-description. That's what stacktraces
are for.

Apart from that, you won't succeed with the above. Python has no
signature-based polymorphism. Instead, you use default arguments, like this:


def __init__(nomin=0, denom=1):
...

That should suffice.

Diez
10 Answers

K Viltersten

3/4/2008 8:05:00 PM

0

"Diez B. Roggisch" <deets@nospam.web.de> skrev i meddelandet
news:63346uF25gigqU1@mid.uni-berlin.de...
>K Viltersten schrieb:
>> I'm writing a class for rational numbers
>> and besides the most obvious constructor
>>
>> def __init__ (self, nomin, denom):
>>
>> i also wish to have two supporting ones
>>
>> def __init__ (self, integ):
>> self.__init__ (integ, 1)
>> def __init__ (self):
>> self.__init__ (0, 1)
>>
>> but for some reason (not known to me at
>> this point) i get errors. My suspicion is that it's a syntax issue.
>
> "errors" is not much of an error-description. That's what stacktraces are
> for.

I assumed that the error was so obvious to a
seasoned Pytonist (Pythoner?) that a trace
didn't matter. Your help below proves it. :)

Nevertheless, i'll be careful in the future
and make sure to post the traces too. Sorry.

> Apart from that, you won't succeed with the above. Python has no
> signature-based polymorphism. Instead, you use default arguments, like
> this:
>
> def __init__(nomin=0, denom=1):
> ...

Thank you.

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

Jeff Schwab

3/4/2008 9:53:00 PM

0

What does "SV" in the subject mean?

Tommy Grav

3/5/2008 1:07:00 AM

0


On Mar 4, 2008, at 4:53 PM, Jeff Schwab wrote:

> What does "SV" in the subject mean?

SV = "Svar" is the Norwegian word for Reply.

Cheers
Tommy

Aaron Brady

3/5/2008 2:31:00 AM

0

On Mar 4, 7:06 pm, Tommy Grav <tg...@mac.com> wrote:
> On Mar 4, 2008, at 4:53 PM, Jeff Schwab wrote:
>
> > What does "SV" in the subject mean?
>
> SV = "Svar" is the Norwegian word for Reply.
>
> Cheers
>    Tommy

It is also the name of my lockermate in grade school. "So, Svar, how
'bout them posters?"

Jeff Schwab

3/5/2008 4:05:00 AM

0

Tommy Grav wrote:
>
> On Mar 4, 2008, at 4:53 PM, Jeff Schwab wrote:
>
>> What does "SV" in the subject mean?
>
> SV = "Svar" is the Norwegian word for Reply.

Thanks. Serves me right for not speaking Norwegian.

K Viltersten

3/5/2008 4:26:00 AM

0

> What does "SV" in the subject mean?


Probably, it's an abbreviation of
"svar", which means "reply".

--
Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor
ambition - lack of sense to be lazy

Dennis Lee Bieber

3/5/2008 5:18:00 AM

0

On Tue, 4 Mar 2008 20:06:38 -0500, Tommy Grav <tgrav@mac.com> declaimed
the following in comp.lang.python:

>
> SV = "Svar" is the Norwegian word for Reply.
>
Ah, good... In my working life, "SV" => "Space Vehicle", often used
to differentiate between the base satellite and "PL" Payload (the part
that earns the money)

--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/

Jeff Schwab

3/5/2008 4:26:00 PM

0

Dennis Lee Bieber wrote:
> On Tue, 4 Mar 2008 20:06:38 -0500, Tommy Grav <tgrav@mac.com> declaimed
> the following in comp.lang.python:
>
>> SV = "Svar" is the Norwegian word for Reply.
>>
> Ah, good... In my working life, "SV" => "Space Vehicle", often used
> to differentiate between the base satellite and "PL" Payload (the part
> that earns the money)

Which is which? Aren't those both part of the space vehicle? Btw, do
you work for government or industry? Do you enjoy working with the
space program? I've heard only indirect reviews, and they've been mixed.

[1] "Av Emne," according to the free online translater.
http://www.tranexp.com:2000/Translate/re...

Dennis Lee Bieber

3/6/2008 5:06:00 AM

0

On Wed, 05 Mar 2008 08:26:04 -0800, Jeff Schwab <jeff@schwabcenter.com>
declaimed the following in comp.lang.python:

>
> Which is which? Aren't those both part of the space vehicle? Btw, do
> you work for government or industry? Do you enjoy working with the
> space program? I've heard only indirect reviews, and they've been mixed.
>
Lockheed... I don't really work with the sat's themselves.

When it comes to division of responsibility, the "payload" is the
part the customer wants in orbit. The "space vehicle" is the part that
carries it around in that orbit -- the SV has the station-keeping
thrusters (I'm presuming a geosynchronous orbit), the power supply and
solar panels... The payload may just consist of a wide-band transponder
(for direct TV, say) and maybe an independent commanding system (its own
receive transmit gear on a different frequency from the satellite
control -- though I wouldn't really expect this type of split)
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/

Jeff Schwab

3/6/2008 5:17:00 AM

0

Dennis Lee Bieber wrote:
> On Wed, 05 Mar 2008 08:26:04 -0800, Jeff Schwab <jeff@schwabcenter.com>
> declaimed the following in comp.lang.python:
>
>> Which is which? Aren't those both part of the space vehicle? Btw, do
>> you work for government or industry? Do you enjoy working with the
>> space program? I've heard only indirect reviews, and they've been mixed.
>>
> Lockheed... I don't really work with the sat's themselves.
>
> When it comes to division of responsibility, the "payload" is the
> part the customer wants in orbit. The "space vehicle" is the part that
> carries it around in that orbit -- the SV has the station-keeping
> thrusters (I'm presuming a geosynchronous orbit), the power supply and
> solar panels... The payload may just consist of a wide-band transponder
> (for direct TV, say) and maybe an independent commanding system (its own
> receive transmit gear on a different frequency from the satellite
> control -- though I wouldn't really expect this type of split)

Interesting. Thanks.