Newbie: Functions and class

Shu-Hsien Sheu sheu at bu.edu
Thu Oct 30 15:49:31 EST 2003


Hi Alex,

Great thanks! What u've suggested was exactly what I was looking for. 
Too bad it's such a trivial question:((

I have another trivial question though. Why won't the following work?

class hittable(object):
    def __init__(self):
       self = [[], [], [], []]

-shuhsien

>Just forget that wanton assignment in method search!  Why would you
>want to assign anything new to self.table[i], when self.build(i) has
>just modified self.table[i] appropriately?!  I.e., change search to:
>
>    def search(self, i):
>        self.build(i)
>
>this doesn't have anything special to do with classes -- rather,
>with the care and feeding of dictionaries, I'd say:-).
>  
>






More information about the Python-list mailing list