I've been hacking visual basic for several years and understand the basic
concepts of OOP. That said, I'm stumped here with the Python Class.
Here is the Class...
[color=blue]
>class Test:
> def __init__(self, something):
> self.something = something
>
> def getSomething(se lf):
> return self.something[/color]
This is what I get when I test it. Why does <getSomething > not return the
value of <something>? is obvious that <something> has a value. I fear this
is a simple oversight but I've racked my brain for hours looking at online
doc's and examples. Thanks for any help!!
[color=blue]
>Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on[/color]
win32[color=blue]
>Type "copyright" , "credits" or "license()" for more information.
>************** *************** *************** *************** *****
>IDLE 1.0 ==== No Subprocess ====[color=green][color=darkred]
>>>>
>>>> x = Test("Microsoft Sucks")
>>>> x.getSomething[/color][/color]
><bound method Test.getSomethi ng of <__main__.Tes t instance at 0x00C01940>>[color=green][color=darkred]
>>>> x.something[/color][/color]
>'Microsoft Sucks'[color=green][color=darkred]
>>>>[/color][/color][/color]
concepts of OOP. That said, I'm stumped here with the Python Class.
Here is the Class...
[color=blue]
>class Test:
> def __init__(self, something):
> self.something = something
>
> def getSomething(se lf):
> return self.something[/color]
This is what I get when I test it. Why does <getSomething > not return the
value of <something>? is obvious that <something> has a value. I fear this
is a simple oversight but I've racked my brain for hours looking at online
doc's and examples. Thanks for any help!!
[color=blue]
>Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 32 bit (Intel)] on[/color]
win32[color=blue]
>Type "copyright" , "credits" or "license()" for more information.
>************** *************** *************** *************** *****
>IDLE 1.0 ==== No Subprocess ====[color=green][color=darkred]
>>>>
>>>> x = Test("Microsoft Sucks")
>>>> x.getSomething[/color][/color]
><bound method Test.getSomethi ng of <__main__.Tes t instance at 0x00C01940>>[color=green][color=darkred]
>>>> x.something[/color][/color]
>'Microsoft Sucks'[color=green][color=darkred]
>>>>[/color][/color][/color]
Comment