Hans,

Python does not possess a constant as part of the syntax. So something
like CONST is nothing but a variable in uppercase. One could define a
hidden class that acts as an immutable once defined as this example
shows -- http://code.activestate.com/recipes/65207/ .  In Python would
in most cases  define a var  as part of the constructor and that var
is only referenced in the associated methods. But it is all the
programmers responsibility as to the handling of the var for the
methods.

JohnMc

On Jun 5, 3:46 pm, Hans Donner <hans.don...@pobox.com> wrote:
> what is it you do not understand? perhaps I can exaplin it better.
>
> Examples of 'strings'
> - in PasswordWidget (sqlhtml.py) there is the default display for a
> password, in FORM.accepts this is also re-used
> - In the top of sql.py, when loading the drivers 'Postgre' is used as
> a key, while later it looks like it is referred to as 'Postgres'
>
> On Fri, Jun 5, 2009 at 10:29 PM, mdipierro<mdipie...@cs.depaul.edu> wrote:
>
> > I do not understand. I am sure it is because of lack of sleep and
> > headache due to broken glasses (waiting for a replament).
>
> > Massimo
>
> > On Jun 5, 3:09 pm, Hans Donner <hans.don...@pobox.com> wrote:
> >> could be my upbringing and my fat fingers/reliance on autocompletion,
> >> but I see a lot of repetitive code and strings, eg
> >> table_field = re.compile('[\w_]+\.[\w_]+') and 'keyname' etc.
>
> >> like the table_field being present in multiple files, why not move
> >> them to some shared globals and import from there?
>
> >> any reason why frequently reused keynames are not provided as CONST?
> >> Esp when used in different parts of web2py.
> >> This might also prevent the 'Postgre' (missing s?) in sql.py
>
> >> I've only been using python for a short time, so this might be the
> >> python way to do it.
>
> >> Hans
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to