Prev: integer >= 1 == True and integer.0 == False is bad, bad, bad!!!
Next: getting the variable type
From: Steven D'Aprano on 11 Jul 2010 22:43 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
From: Terry Reedy on 12 Jul 2010 02:51 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
From: Cameron Simpson on 12 Jul 2010 03:08 On 12Jul2010 02:43, Steven D'Aprano <steve-REMOVE-THIS(a)cybersource.com.au> 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 <cs(a)zip.com.au> 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
From: Jean-Michel Pichavant on 12 Jul 2010 06:42 rantingrick wrote: > On Jul 11, 3:03 am, "G�nther Dietrich" <gd.use...(a)spamfence.net> > 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
From: Neil Cerutti on 13 Jul 2010 11:18 On 2010-07-12, Steven D'Aprano <steve(a)REMOVE-THIS-cybersource.com.au> wrote: > On Sun, 11 Jul 2010 01:30:36 -0700, rantingrick wrote: > >> On Jul 11, 3:03??am, "G??nther Dietrich" <gd.use...(a)spamfence.net> 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
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: integer >= 1 == True and integer.0 == False is bad, bad, bad!!! Next: getting the variable type |