osdir.com


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

Not Defined error in basic code


>>> Just getting started with tutorials and such, and don't understand 
>>> this -
>> Did you answer the post asking which tutorial you were following/copying?
> Sorry - it is this -
> https://www.learnpython.org/en/ ..
> The section is on classes and objects - 
> https://www.learnpython.org/en/Classes_and_Objects


Wanted to check: Someone publishing the 'first code' in this thread as 
training material, would have been 'unhelpful'.

Those guys have a good reputation - if the code camp approach suits the 
learner, rapid progress can be made.

The examples they provide illustrate attributes being 'defined' with a 
value. (unlike the first code 'here' which only listed attributes)

This feature of Python's dynamic nature often confuses folk who come 
from other, more rigidly defined, languages - there is no need to 
declare "id" as an integer per-se, passing it an integer constant as its 
value performs two tasks for the price of one!

Advice (if I may): don't be too literal in attempting to write Python 
the way you currently write xyz-language code.

You may find it helpful to combine those tutorials with similar 
information from additional sources, eg the Python docs site's tutorial, 
other on-line books, 'dead-tree' sources, other on-line training, etc. 
Whilst it seems like more work (it's certainly more reading/scanning), 
two non-identical statements of 'the same thing', will express things 
differently. Often something from one source that is initially puzzling, 
when compared with another presentation of the 'same', helps learners' 
minds go 'click' or to enjoy that 'ahah moment'.

All the best...
-- 
Regards =dn