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?

 
 
Steven D'Aprano
Guest
Posts: n/a
 
      07-12-2010
On Sun, 11 Jul 2010 01:30:36 -0700, rantingrick wrote:

> On Jul 11, 3:03¬*am, "G√ľnther 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?


If you're going to use generic names, why type three or four letters when
one will do?

i, j, k, m, n, p, q for ints.
L, a, b, x for lists
s, t, a, b for strings.

If you don't want to use generic names, then int, list, str are useless
because they don't mean anything. You need something like:

count_of_widgets
list_of_widgets
description




--
Steven
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      07-12-2010
On Sun, 11 Jul 2010 00:26:36 -0700, 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



Yes. So what? You can't wisely use variables like:

True = "rantingrick is an obnoxious loudmouth"
None = "the problem he is describing"

Nor can you wisely use variables like:

len = len("something")
chr = chr(4


[...]
> Just thoughts.


But not deep thoughts.



--
Steven
 
Reply With Quote
 
 
 
 
Mark Lawrence
Guest
Posts: n/a
 
      07-12-2010
On 12/07/2010 01:06, Steven D'Aprano wrote:
> On Sun, 11 Jul 2010 00:26:36 -0700, 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

>
>
> Yes. So what? You can't wisely use variables like:
>
> True = "rantingrick is an obnoxious loudmouth"

+1 QOTW
> None = "the problem he is describing"
>
> Nor can you wisely use variables like:
>
> len = len("something")
> chr = chr(4
>
>
> [...]
>> Just thoughts.

>
> But not deep thoughts.
>

Well said Steven, or is it Stephen, or Stephan, or Stefen, or what?
Kindest regards.

Mark Lawrence.


 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      07-12-2010
On Mon, 12 Jul 2010 01:31:14 +0100, Mark Lawrence wrote:

> Well said Steven, or is it Stephen, or Stephan, or Stefen, or what?


For some reason, when I answer the phone and say "Hello, Steven
speaking?" I often get called Peter.


--
Steven
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      07-12-2010
On Mon, 12 Jul 2010 02:40:07 +0000, Steven D'Aprano wrote:

> On Mon, 12 Jul 2010 01:31:14 +0100, Mark Lawrence wrote:
>
>> Well said Steven, or is it Stephen, or Stephan, or Stefen, or what?

>
> For some reason, when I answer the phone and say "Hello, Steven
> speaking?" I often get called Peter.


Er, without the question mark.

--
Steven
 
Reply With Quote
 
Terry Reedy
Guest
Posts: n/a
 
      07-12-2010
On 7/11/2010 3:26 AM, 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.


This is an anomaly, known to all long-time Pythoneers, due the the
history of Python. Before 2.2 and unification of types and classes as
new-style classes, those were all type constructor *functions*, not
class names. The idea of breaking most every serious Python program on
the planet by upper-casing them has been considered and so far rejected.

--
Terry Jan Reedy

 
Reply With Quote
 
Cameron Simpson
Guest
Posts: n/a
 
      07-12-2010
On 12Jul2010 02:43, Steven D'Aprano <(E-Mail Removed)> wrote:
| On Mon, 12 Jul 2010 02:40:07 +0000, Steven D'Aprano wrote:
| > On Mon, 12 Jul 2010 01:31:14 +0100, Mark Lawrence wrote:
| >> Well said Steven, or is it Stephen, or Stephan, or Stefen, or what?
| >
| > For some reason, when I answer the phone and say "Hello, Steven
| > speaking?" I often get called Peter.
|
| Er, without the question mark.

Ah, so you get differing results when you use the question mark?
Phonetic punctuation; Victor Borge would be proud.
--
Cameron Simpson <(E-Mail Removed)> DoD#743
http://www.cskk.ezoshosting.com/cs/

A lot of people don't know the difference between a violin and a viola, so
I'll tell you. A viola burns longer. - Victor Borge
 
Reply With Quote
 
Jean-Michel Pichavant
Guest
Posts: n/a
 
      07-12-2010
rantingrick wrote:
> On Jul 11, 3:03 am, "GŁnther 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?
>

def func154():
int32 = 24
list18 = [int32, 14]
str14 = ""
for int89 in list18:
if int89 == int32 or int89 == 88:
str14 = "I am missing everything"
if str14:
print str14

>>> func154()
>>> "I am missing everything"



JM
 
Reply With Quote
 
Neil Cerutti
Guest
Posts: n/a
 
      07-13-2010
On 2010-07-12, Steven D'Aprano <(E-Mail Removed)> wrote:
> On Sun, 11 Jul 2010 01:30:36 -0700, rantingrick wrote:
>
>> On Jul 11, 3:03??am, "G??nther 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?

>
> If you're going to use generic names, why type three or four letters when
> one will do?
>
> i, j, k, m, n, p, q for ints.
> L, a, b, x for lists
> s, t, a, b for strings.
>
> If you don't want to use generic names, then int, list, str are useless
> because they don't mean anything. You need something like:
>
> count_of_widgets
> list_of_widgets
> description


def map(function, list):
# etc.

It's a slight annoyance, nothing more.

In the data I deal with, I get annoyed at needing to write
student_id instead of id, but it's not a huge issue. The big
consolation is that Python really doesn't care if I happen to
shadow a builtin name that I've never heard of. I forget, and use
id as a variable all the time, and nothing bad happens to me,
because I don't need the builtin function.

To see a really odd example of a similar name clash, create a tab
separated values file with a header line starting with ID (I get
lots of them in my work), and then open it with Excel (I don't
know which version has the most bizarre error message).

--
Neil Cerutti
 
Reply With Quote
 
Aahz
Guest
Posts: n/a
 
      07-16-2010
In article <4c3a8087$0$28662$(E-Mail Removed)>,
Steven D'Aprano <(E-Mail Removed)> wrote:
>
>For some reason, when I answer the phone and say "Hello, Steven
>speaking?" I often get called Peter.


That's the Peter Principle in action.
--
Aahz ((E-Mail Removed)) <*> http://www.pythoncraft.com/

"....Normal is what cuts off your sixth finger and your tail..." --Siobhan
 
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