Request for help

Steven D'Aprano steve at pearwood.info
Tue Jul 19 12:31:52 EDT 2016


On Mon, 18 Jul 2016 07:50 pm, Eric kago wrote:

> Hi Pythoners
> 
> I need help in understanding hoe to put up the code to the following
> command

Hi Eric,

You might find that the "Tutor" mailing list is better for simple questions
like this:

https://mail.python.org/mailman/listinfo/tutor


Remember, for help with home work, show the code you already have.


>    - Create a constructor that takes in an integer and assigns this to a
>    `balance` property

Talking about a "constructor" means that you need to have a class. We define
a class with the "class" keyword:

class Myclass:
    pass



To give it a constructor method, you need to use the __init__ method, or
sometimes __new__. In this case, I think __init__ is what you want. Do you
know how to define methods inside a class?

Remember that __init__ is spelled with TWO underscores at the start and end.




-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list