Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Naming Conventions, Where's the Convention Waldo?

Reply
Thread Tools

Naming Conventions, Where's the Convention Waldo?

 
 
rantingrick
Guest
Posts: n/a
 
      07-11-2010

Another source of asininity seems to be the naming conventions of the
Python language proper! True/False start with an upper case and i
applaud this. However str, list, tuple, int, float --need i go
on...?-- start with lowercase.

Q: Well what the hell is your problem Rick. Who cares right?

WRONG, I tell you what my problem is. Now i cannot "wisely" use
variables like...

str="this is a string"
list = [1,2,3]
def make_random_objs(range=10)
def show_message(str)
int = 12

If we would have adopted proper naming conventions from dios numero
uno all this nonsense would be rectified! Str, Float, List, Range,
etc, etc. You think Python 3000 was a hump to climb over just wait for
Python 4000.

Just thoughts.
 
Reply With Quote
 
 
 
 
Alf P. Steinbach /Usenet
Guest
Posts: n/a
 
      07-11-2010
* rantingrick, on 11.07.2010 09:26:
>
> Another source of asininity seems to be the naming conventions of the
> Python language proper! True/False start with an upper case and i
> applaud this. However str, list, tuple, int, float --need i go
> on...?-- start with lowercase.
>
> Q: Well what the hell is your problem Rick. Who cares right?
>
> WRONG, I tell you what my problem is. Now i cannot "wisely" use
> variables like...
>
> str="this is a string"
> list = [1,2,3]
> def make_random_objs(range=10)
> def show_message(str)
> int = 12
>
> If we would have adopted proper naming conventions from dios numero
> uno all this nonsense would be rectified! Str, Float, List, Range,
> etc, etc. You think Python 3000 was a hump to climb over just wait for
> Python 4000.
>
> Just thoughts.


Just do

Str = str
List = list
Float = float

and so on in module "myBasicTypes", and import that.



Cheers & hth.,

- Alf

--
blog at <url: http://alfps.wordpress.com>
 
Reply With Quote
 
 
 
 
Günther Dietrich
Guest
Posts: n/a
 
      07-11-2010
rantingrick <(E-Mail Removed)> wrote:

>Another source of asininity seems to be the naming conventions of the
>Python language proper! True/False start with an upper case and i
>applaud this. However str, list, tuple, int, float --need i go
>on...?-- start with lowercase.
>
>Q: Well what the hell is your problem Rick. Who cares right?
>
>WRONG, I tell you what my problem is. Now i cannot "wisely" use
>variables like...
>
>str="this is a string"
>list = [1,2,3]
>def make_random_objs(range=10)
>def show_message(str)
>int = 12


Someone who wants to write readable and maintainable code would
(practically) never want to use variables named in this way. Why?
Because these names don't tell anything about the purpose of the
variables.
So, it is not a disadvantage that the functions you listed above are
named in this way. In the contrary, it is an advantage, as it keeps
newcomers from using stupid variable names.


>If we would have adopted proper naming conventions from dios numero
>uno all this nonsense would be rectified! Str, Float, List, Range,
>etc, etc. You think Python 3000 was a hump to climb over just wait for
>Python 4000.


Additionally to what I mention above, there is PEP 0008. Read it, you
can learn from it. What you listed above, are functions, and their names
comply completely with PEP 0008.



Regards,

Günther




PS: Even though I suspect that you are simply an agitator rsp. troll
(based on what you posted in this group so far), and normally I refuse
to feed trolls, I make an exception in this case, so newcomers ar not
mislead by your half-baked ideas.
 
Reply With Quote
 
rantingrick
Guest
Posts: n/a
 
      07-11-2010
On Jul 11, 3:03*am, "Gnther Dietrich" <(E-Mail Removed)>
wrote:

> So, it is not a disadvantage that the functions you listed above are
> named in this way. In the contrary, it is an advantage, as it keeps
> newcomers from using stupid variable names.


"int" for an Integer is stupid?
"list" for a List is stupid?
"str" for a String is stupid?

What am i missing?
 
Reply With Quote
 
Andre Alexander Bell
Guest
Posts: n/a
 
      07-11-2010
On 07/11/2010 10:30 AM, rantingrick wrote:
> On Jul 11, 3:03 am, "Gnther Dietrich" <(E-Mail Removed)>
> wrote:
>
>> So, it is not a disadvantage that the functions you listed above are
>> named in this way. In the contrary, it is an advantage, as it keeps
>> newcomers from using stupid variable names.

>
> "int" for an Integer is stupid?
> "list" for a List is stupid?
> "str" for a String is stupid?
>
> What am i missing?


You are missing (from PEP :

--- 8< --- 8< ---
Class Names

Almost without exception, class names use the CapWords convention.
Classes for internal use have a leading underscore in addition.

--- 8< --- 8< ---

You may want to think of list, int, str, object, ... as classes that
don't follow this advice with their class name.

But besides that, shouldn't a variable name reflect it's purpose instead
of it's type? E.g.

name = 'rantingrick'
counter = 1
....

as compared to

str = 'rantingrick'
int = 1?

Regards


Andre
 
Reply With Quote
 
News123
Guest
Posts: n/a
 
      07-11-2010
Andre Alexander Bell wrote:
> On 07/11/2010 10:30 AM, rantingrick wrote:


>>> So, it is not a disadvantage that the functions you listed above are
>>> named in this way. In the contrary, it is an advantage, as it keeps
>>> newcomers from using stupid variable names.

>> "int" for an Integer is stupid?
>> "list" for a List is stupid?
>> "str" for a String is stupid?
>>
>> What am i missing?

>
> You are missing (from PEP :
>
> --- 8< --- 8< ---
> Class Names
>
> Almost without exception, class names use the CapWords convention.
> Classes for internal use have a leading underscore in addition.
>
> --- 8< --- 8< ---
>
> You may want to think of list, int, str, object, ... as classes that
> don't follow this advice with their class name.
>
> But besides that, shouldn't a variable name reflect it's purpose instead
> of it's type? E.g.


hm, well sometimes I do write generic functions, that do something with
a list or a string or an int.

However a simple way around this is to use following naming style.

to replace
def process_list(list):
dostuff_with(list)

with
def process_list(alist):
dostuff_with(alist)

or with
def process_list(a_list):
dostuff_with(a_list)

I must admit, that I have still problems
to not use the variables range or id




 
Reply With Quote
 
Andreas Waldenburger
Guest
Posts: n/a
 
      07-11-2010
On Sun, 11 Jul 2010 15:46:40 +0200 News123 <(E-Mail Removed)> wrote:

> Andre Alexander Bell wrote:
> > On 07/11/2010 10:30 AM, rantingrick wrote:

>
> >>> So, it is not a disadvantage that the functions you listed above
> >>> are named in this way. In the contrary, it is an advantage, as it
> >>> keeps newcomers from using stupid variable names.
> >> "int" for an Integer is stupid?
> >> "list" for a List is stupid?
> >> "str" for a String is stupid?
> >>
> >> What am i missing?

> >
> > [snip]

>
> hm, well sometimes I do write generic functions, that do something
> with a list or a string or an int.
>
> [snip]
>
> I must admit, that I have still problems
> to not use the variables range or id
>


There are several approaches:

- Use range_, id_, and so on. I think this is the proposed convention.
Slightly ugly, though.
- Use abbreviations, or misspellings like lst, Set, klass, ... Less
ugly, but can get weird.
- Prepend 'a' to a type name: alist, aset, astr. Similar weirdness
potential as above, but more consistent in terms of style. I
sometimes take this to the extreme and prepend 'some_'.

So really, this is a non issue, at least for me.

Having capitalized boolean values ... that is a bit odd, but as long as
children are starving in Africa, this isn't very high on my gripe-list.

/W

--
INVALID? DE!

 
Reply With Quote
 
News123
Guest
Posts: n/a
 
      07-11-2010
Andreas Waldenburger wrote:
>
> Having capitalized boolean values ... that is a bit odd, but as long as
> children are starving in Africa, this isn't very high on my gripe-list.
>

+1
 
Reply With Quote
 
MRAB
Guest
Posts: n/a
 
      07-11-2010
rantingrick wrote:
> Another source of asininity seems to be the naming conventions of the
> Python language proper! True/False start with an upper case and i
> applaud this. However str, list, tuple, int, float --need i go
> on...?-- start with lowercase.
>
> Q: Well what the hell is your problem Rick. Who cares right?
>
> WRONG, I tell you what my problem is. Now i cannot "wisely" use
> variables like...
>
> str="this is a string"
> list = [1,2,3]
> def make_random_objs(range=10)
> def show_message(str)
> int = 12
>
> If we would have adopted proper naming conventions from dios numero
> uno all this nonsense would be rectified! Str, Float, List, Range,
> etc, etc. You think Python 3000 was a hump to climb over just wait for
> Python 4000.
>
> Just thoughts.


If you're so unhappy with Python, why don't you create your own
language. I suggest the name "Rantthon".
 
Reply With Quote
 
rantingrick
Guest
Posts: n/a
 
      07-11-2010
On Jul 11, 12:23*pm, MRAB <(E-Mail Removed)> wrote:

> If you're so unhappy with Python, why don't you create your own
> language. I suggest the name "Rantthon".


Ah yes, then i can finally assume my worthy title of the "Ranting
Dictator For Life"!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
Naming Convention for ASP.NET BAL/DAL? dm1608 ASP .Net 6 02-24-2006 07:25 PM
WS C3550 naming convention question frishack@gmail.com Cisco 2 02-23-2005 07:29 PM
JSP Method Naming Convention Buck Turgidson Java 1 03-02-2004 04:43 PM
Which c# naming convention? Rick ASP .Net 1 01-19-2004 11:42 AM



Advertisments