osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Design: method in class or general function?


OOP newbie on Python 2.6.

I create instances of Character class with an attribute dict of 
'skills'. The 'skills' dict has the name of a skill as the key and an 
int as a value. The code adds or modifies skills before outputting the 
Character.

Is it better design to have a Character.method that takes a 'skill' key 
and optional value or to have a general function that takes an instance, 
a dict, a key, and an optional value?