Overloaded Constructors?!?

Paul McGuire ptmcg at austin.rr.com
Sun Mar 20 21:49:06 EST 2005


>>Another way is to make two factory methods that
>>create instances of the class and do the correct initialization.

>I am sorry to be so tedious, but I am still quite a
>newbie in Python... could you please provide a very
>small example of your last sentence? Looks
>quite interesting...

See the recipe at this link.  It defines a basic constructor to create
Color objects using 3 integer args for red/green/blue, and a separate
staticmethod as a factory method to create a Color using a single
integer representing an RBG value.

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/223611

-- Paul
(This recipe was taken from a much larger sample for basic bitmap
drawing, which you will find at
http://www.geocities.com/ptmcg/python/index.html#bmp .)




More information about the Python-list mailing list