newbie python question : FunctionCapitalizedWords = function_lower_case_with_underscores

0 views
Skip to first unread message

Sylvain

unread,
May 5, 2008, 7:30:54 AM5/5/08
to Google App Engine
I'm a newbie to python and i've checked different codes (i.e.
users.py,...) with this :

def function_lower_case_with_underscores()
....
...
FunctionCapitalizedWords = function_lower_case_with_underscores
#<------- ???

We can find the same thing with classes.
I really wonder why it is usefull to assign the same function/class
with 2 different cases ?

Thank you.

Regards

example in users.py :
----------------------------------------------------------------------------
def get_current_user():
try:
return User()
except UserNotFoundError:
return None

GetCurrentUser = get_current_user <------------- ???
----------------------------------------------------------------------------



Duncan

unread,
May 5, 2008, 8:32:15 AM5/5/08
to Google App Engine
On May 5, 12:30 pm, Sylvain <sylvain.viv...@gmail.com> wrote:
> I'm a newbie to python and i've checked different codes (i.e.
> users.py,...) with this :
>
> def function_lower_case_with_underscores()
> ....
> ...
> FunctionCapitalizedWords = function_lower_case_with_underscores
> #<------- ???
>
> We can find the same thing with classes.
> I really wonder why it is usefull to assign the same function/class
> with 2 different cases ?
>
It isn't useful. My guess would be that whoever first wrote that code
defined functions with names such as GetCurrentUser, but then someone
else later came along and decided that the app engine should follow
normal Python naming conventions (initial capitals are usually
reserved for class names), so you'll find the documented function is
get_current_user. They seem to have kept the other name for backwards
compatibility, but you should use the documented form.

See http://www.python.org/dev/peps/pep-0008/ for the naming
conventions applied to core Python code, but remember these
conventions are only prescriptive for Python itself, if you prefer you
are of course free to adopt any other conventions for your own code.

Ronald Lew

unread,
May 5, 2008, 12:47:57 PM5/5/08
to Google App Engine
Spaces vs Tabs is my biggest pet-peeve. I usually set my editor to
use 4-spaces per indent and insert spaces for tabs. Occasionally, I
find others use 2-spaces per indent which throws off my eyesight (I
find it easier to view code when the indents are larger).

On May 5, 5:32 am, Duncan <kupu...@googlemail.com> wrote:
> On May 5, 12:30 pm, Sylvain <sylvain.viv...@gmail.com> wrote:> I'm a newbie to python and i've checked different codes (i.e.
> > users.py,...) with this :
>
> > def function_lower_case_with_underscores()
> > ....
> > ...
> > FunctionCapitalizedWords = function_lower_case_with_underscores
> > #<------- ???
>
> > We can find the same thing with classes.
> > I really wonder why it is usefull to assign the same function/class
> > with 2 different cases ?
>
> It isn't useful. My guess would be that whoever first wrote that code
> defined functions with names such as GetCurrentUser, but then someone
> else later came along and decided that the app engine should follow
> normal Python naming conventions (initial capitals are usually
> reserved for class names), so you'll find the documented function is
> get_current_user. They seem to have kept the other name for backwards
> compatibility, but you should use the documented form.
>
> Seehttp://www.python.org/dev/peps/pep-0008/for the naming
Reply all
Reply to author
Forward
0 new messages