Stef Mientki a écrit :
> Marc 'BlackJack' Rintsch wrote:
>
>> In <[EMAIL PROTECTED]>, Stef Mientki wrote:
>>
>>> What's the difference between using __init__ and using nothing,
>>> as the examples below.
>>>
>>> class cpu:
>>> PC = 4
>>
>>
>> This is a *class attribute*. It's the same for all instances of `cpu`.
>>
>>> class cpu:
>>> def __init__:
def __init__(self):
>>> self.PC = 4
By convention, ALL_UPPER names have a 'symbolic constant' semantic.
Since Python is a very 'free' language (no attribute access restriction,
no symbolic constants etc), it *strongly* relies on conventions.
>>
>> This is an *instance attribute* which is set in every instance of `cpu`.
>>
> thanks Marc,
>
> Oh so obvious, why didn't I discovered that myself ;-)
Perhaps because it may not be that obvious at first sight ?-)
(that is, until you really understand Python's object model, which is
really different from most mainstream OOPLs object models...)
--
http://mail.python.org/mailman/listinfo/python-list