diliup gabadamudalige <dili...@gmail.com> Wrote in message:
>
 there are many dictionaries and lists which are used in various functions. Is 
it better/pythonic/efficient to have these inside the function itself or 
declared at the beginning of the program in which case they will be global? 
They are all read only. I understand that global constants and variable have 
memory allocated to them but when declared inside a function are created on the 
fly, used and discarded. 
> 

(Please use text mail to post here, not html. Html messages can
 cause several kinds of problems in a text mailing list.
 )

If they are read-only, you don't want to waste time recreating
 them over and over.  Neither do you want to be repeating the code
 that initializes them. So make them either global or a class
 member, and be sure to name them all caps to signify they
 shouldn't be altered. 

-- 
DaveA

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to