[Tutor] First OOP Attempt
Sean 'Shaleh' Perry
shaleh@valinux.com
Fri, 01 Sep 2000 11:56:26 -0700 (PDT)
On 01-Sep-2000 Perry, George W. wrote:
> The following appears to work, but I just now learning about OOP concepts,
> and I was wondering if there is anything that is obviously wrong or poor
> technique. Comments would be appreciated.
>
looks good for a first run
Now, to really use this, we modify it slighty.
>
> main()
>
becomes :
if __name__ == '__main__:
main()
What this does is check that the script is being run as a script by the
interpreter, if so, run main(). By adding this check you can now do:
import Apartment # or whatever you call the foo.py script
dog = Apartment.pet('fifi')
and use the classes in other code.