Help with 'self' and 'set_usage'

Ethan Furman ethan at stoneleaf.us
Tue Jul 9 19:19:26 CEST 2013


On 07/09/2013 10:03 AM, L O'Shea wrote:
>
> Hi all,

Howdy!

> I'm interning and have been given the job of extending a program that has been written by someone else. I've never used Python before so it's a bit of a struggle but I've got to say I'm loving the language so far.

Excellent way to start a question!  :)


> In one of the scripts there is
>
> def set_usage(self,s):
>     self.usage_str = s

Careful of whitespace when posting (I fixed that one for you).


> Can you just create variables in that object by writing self.name = "david" self.hobby = "fishing"??

Yup, you sure can.

--
~Ethan~



More information about the Python-list mailing list