Re: Naming conventions for functions and methods

2014-07-08 Thread Ben Finney
pyt...@bdurham.com writes: > Looking for your opinions on how you name your functions and > methods. Example: I have a function that hashes a file. I could > name this function hash_file() or file_hash(). I'd prefer just ‘hash’. The function name can be considered an action verb, with its argumen

Re: Naming conventions for functions and methods

2014-07-08 Thread Arnaud Delobelle
On 8 July 2014 15:59, wrote: > > Looking for your opinions on how you name your functions and methods. > Example: I have a function that hashes a file. I could name this function > hash_file() or file_hash(). The 1st naming convention sounds more natural, > the 2nd naming convention allows one

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-15 Thread Aahz
In article <4c3a8087$0$28662$c3e8...@news.astraweb.com>, Steven D'Aprano 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 (a...@pythoncraft.com) <*> http://www.pythonc

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-13 Thread Neil Cerutti
On 2010-07-12, Steven D'Aprano wrote: > On Sun, 11 Jul 2010 01:30:36 -0700, rantingrick wrote: > >> On Jul 11, 3:03??am, "G??nther Dietrich" 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

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-12 Thread Jean-Michel Pichavant
rantingrick wrote: On Jul 11, 3:03 am, "Günther Dietrich" 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"

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-12 Thread Cameron Simpson
On 12Jul2010 02:43, Steven D'Aprano wrote: | On Mon, 12 Jul 2010 02:40:07 +, 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 "

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Terry Reedy
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, kno

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Steven D'Aprano
On Mon, 12 Jul 2010 02:40:07 +, 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

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Steven D'Aprano
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 -- http://mail.python.org/mailman/listinfo/python-list

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Mark Lawrence
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

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Steven D'Aprano
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. > >

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Steven D'Aprano
On Sun, 11 Jul 2010 01:30:36 -0700, rantingrick wrote: > On Jul 11, 3:03 am, "Günther Dietrich" 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. >

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread rantingrick
On Jul 11, 12:23 pm, MRAB 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"! ;-) -- http://mail.python.org/mailman/listinfo/python-list

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread MRAB
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

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread News123
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 -- http://mail.python.org/mailman/listinfo/python-list

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Andreas Waldenburger
On Sun, 11 Jul 2010 15:46:40 +0200 News123 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 fr

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread News123
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 stupi

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Marek Kubica
On Sun, 11 Jul 2010 00:26:36 -0700 (PDT) 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.

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Andre Alexander Bell
On 07/11/2010 10:30 AM, rantingrick wrote: > On Jul 11, 3:03 am, "Günther Dietrich" > 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" f

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread rantingrick
On Jul 11, 3:03 am, "Günther Dietrich" 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? "s

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Günther Dietrich
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 Ric

Re: Naming Conventions, Where's the Convention Waldo?

2010-07-11 Thread Alf P. Steinbach /Usenet
* 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

Re: Naming conventions for regular variables

2008-07-04 Thread Ben Finney
mk <[EMAIL PROTECTED]> writes: > http://www.python.org/dev/peps/pep-0008/ > > "Function Names > > Function names should be lowercase, with words separated by > underscores as necessary to improve readability." > > However, this PEP does not recommend any particular style for naming > regula

Re: *Naming Conventions*

2007-06-11 Thread [EMAIL PROTECTED]
On Jun 8, 2:06 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-06-08, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > Neil Cerutti a écrit : (snip) > > >> Certainly i and j are just as generic, but they have the > >> advantage over 'item' of being more terse. > > > I'm not sure this is rea

Re: *Naming Conventions*

2007-06-11 Thread Neil Cerutti
On 2007-06-11, Marius Gedminas <[EMAIL PROTECTED]> wrote: > On Jun 6, 3:18 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> > Since 'i' and 'j' are canonically loop indices, I find it >> > totally confusing to use them to name the iteration variable - >> > which is not an index. >> >> Certainly i and

Re: *Naming Conventions*

2007-06-11 Thread Marius Gedminas
On Jun 6, 3:18 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > > Since 'i' and 'j' are canonically loop indices, I find it > > totally confusing to use them to name the iteration variable - > > which is not an index. > > Certainly i and j are just as generic, but they have the > advantage over 'item'

Re: *Naming Conventions*

2007-06-08 Thread Neil Cerutti
On 2007-06-08, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Neil Cerutti a écrit : >> On 2007-06-06, Bruno Desthuilliers >> <[EMAIL PROTECTED]> wrote: >>> Neil Cerutti a écrit : On 2007-06-04, Michael Hoffman <[EMAIL PROTECTED]> wrote: > Wildemar Wildenburger wrote: > I agree with

Re: *Naming Conventions*

2007-06-08 Thread Bruno Desthuilliers
Neil Cerutti a écrit : > On 2007-06-06, Bruno Desthuilliers > <[EMAIL PROTECTED]> wrote: >> Neil Cerutti a écrit : >>> On 2007-06-04, Michael Hoffman <[EMAIL PROTECTED]> wrote: Wildemar Wildenburger wrote: I agree with Bruno that i and j should be used only for indices, but I'm usual

Re: *Naming Conventions*

2007-06-06 Thread Neil Cerutti
On 2007-06-06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > Neil Cerutti a écrit : >> On 2007-06-04, Michael Hoffman <[EMAIL PROTECTED]> wrote: >>> Wildemar Wildenburger wrote: >>> I agree with Bruno that i and j should be used only for >>> indices, but I'm usually less terse than that. >> >>

Re: *Naming Conventions*

2007-06-06 Thread Bruno Desthuilliers
Ninereeds a écrit : > Google Groups appears to have thrown away my original reply, so sorry > if this appears twice... > > On Jun 4, 9:51 pm, "[EMAIL PROTECTED]" > <[EMAIL PROTECTED]> wrote: > >> 'i' and 'j' are the canonical names for for loops indices in languages >> that don't support proper i

Re: *Naming Conventions*

2007-06-06 Thread Bruno Desthuilliers
Neil Cerutti a écrit : > On 2007-06-04, Michael Hoffman <[EMAIL PROTECTED]> wrote: >> Wildemar Wildenburger wrote: >>> While that is true, I guess it is commonplace to use i, j, k >>> and n (maybe others) in constructs like >>> >>> for i in range(len(data)): >>>do_stuff(data[i]) >>> >>> Or shou

Re: *Naming Conventions*

2007-06-05 Thread Ninereeds
Google Groups appears to have thrown away my original reply, so sorry if this appears twice... On Jun 4, 9:51 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > 'i' and 'j' are the canonical names for for loops indices in languages > that don't support proper iteration over a sequence. Using th

Re: *Naming Conventions*

2007-06-05 Thread Michael Hoffman
Neil Cerutti wrote: > I find i and j preferable to overly generic terms like "item." Well, I probably wouldn't use "item" in a real example, unless it were for a truly generic function designed to act on all sequences. -- Michael Hoffman -- http://mail.python.org/mailman/listinfo/python-list

Re: *Naming Conventions*

2007-06-05 Thread Neil Cerutti
On 2007-06-04, Michael Hoffman <[EMAIL PROTECTED]> wrote: > Wildemar Wildenburger wrote: >> While that is true, I guess it is commonplace to use i, j, k >> and n (maybe others) in constructs like >> >> for i in range(len(data)): >>do_stuff(data[i]) >> >> Or should the good python hacker do th

Re: *Naming Conventions*

2007-06-04 Thread Wildemar Wildenburger
Carsten Haese wrote: > On Mon, 2007-06-04 at 23:20 +0200, Wildemar Wildenburger wrote: > >> I guess it is commonplace to use i, j, k and n >> (maybe others) in constructs like >> >> for i in range(len(data)): >> do_stuff(data[i]) >> >> Or should the good python hacker do that differently?

Re: *Naming Conventions*

2007-06-04 Thread Michael Hoffman
Wildemar Wildenburger wrote: > [EMAIL PROTECTED] wrote: >> On Jun 4, 12:20 am, Ninereeds <[EMAIL PROTECTED]> wrote: >> >>> First, for small loops with loop variables whose meaning is obvious >>> from context, the most readable name is usually something like 'i' or >>> 'j'. >>> >> >> 'i' and

Re: *Naming Conventions*

2007-06-04 Thread Carsten Haese
On Mon, 2007-06-04 at 23:20 +0200, Wildemar Wildenburger wrote: > I guess it is commonplace to use i, j, k and n > (maybe others) in constructs like > > for i in range(len(data)): > do_stuff(data[i]) > > Or should the good python hacker do that differently? Hope not ;). That's a big, fat "

Re: *Naming Conventions*

2007-06-04 Thread Wildemar Wildenburger
[EMAIL PROTECTED] wrote: > On Jun 4, 12:20 am, Ninereeds <[EMAIL PROTECTED]> wrote: > >> First, for small loops with loop variables whose meaning is obvious >> from context, the most readable name is usually something like 'i' or >> 'j'. >> > > 'i' and 'j' are the canonical names for for lo

Re: *Naming Conventions*

2007-06-04 Thread [EMAIL PROTECTED]
On Jun 4, 12:20 am, Ninereeds <[EMAIL PROTECTED]> wrote: > On Jun 4, 5:03 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > > > for validanswer in validanswers: > > if myAnswers.myanswer in myAnswers.validAnswers[validanswer]: > > MyOptions['style'] = validanswer > > First, for small loop

Re: Dict naming, global vs local imports, etc. [was Re: *Naming Conventions*]

2007-06-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, George Sakkis wrote: > While we're at it, although it's not strictly a naming convention > issue I still waste brain cycles on where to put the import statements > that are used only once or twice in a module. Should > (1) all imports be at the global scope at the top of th

Re: *Naming Conventions*

2007-06-03 Thread Michael Hoffman
Michael Hoffman wrote: > Thorsten Kampe wrote: > >> for validanswer in validanswers: >> if myAnswers.myanswer in myAnswers.validAnswers[validanswer]: >> MyOptions['style'] = validanswer > > I usually try to avoid using "my" because I find it obscures a better > understanding of what

Re: *Naming Conventions*

2007-06-03 Thread Michael Hoffman
Thorsten Kampe wrote: > for validanswer in validanswers: > if myAnswers.myanswer in myAnswers.validAnswers[validanswer]: > MyOptions['style'] = validanswer I usually try to avoid using "my" because I find it obscures a better understanding of what is really going -- Michael Hoffman

Re: *Naming Conventions*

2007-06-03 Thread Steve Howell
--- Dan Bishop <[EMAIL PROTECTED]> wrote: > > * Loop indices often have single-letter names > (typically i/j/k or x/ > y), or names that are the singular form of the list > name (e.g., "for > ballot in self._ballots"). For iterating over > files, I use "line". > You are in good company with "i"

Re: *Naming Conventions*

2007-06-03 Thread Dan Bishop
On Jun 3, 11:03 pm, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > Okay, > > I hear you saying 'not another naming conventions thread'. I've read > through Google and the 'naming conventions' threads were rather > *spelling conventions* threads. > > I'm not interested in camelCase versus camel_case or

Dict naming, global vs local imports, etc. [was Re: *Naming Conventions*]

2007-06-03 Thread George Sakkis
On Jun 3, 4:32 pm, Steve Howell <[EMAIL PROTECTED]> wrote: > I also still waste brain cycles on naming > dictionaries. Sometimes I name the dictionary after > the values it stores, sometimes after the keys it > uses, and sometimes after both. I was in the same boat but now I've pretty much settl

Re: *Naming Conventions*

2007-06-03 Thread Ninereeds
On Jun 4, 5:03 am, Thorsten Kampe <[EMAIL PROTECTED]> wrote: > for validanswer in validanswers: > if myAnswers.myanswer in myAnswers.validAnswers[validanswer]: > MyOptions['style'] = validanswer First, for small loops with loop variables whose meaning is obvious from context, the most

Re: *Naming Conventions*

2007-06-03 Thread Steve Howell
--- Thorsten Kampe <[EMAIL PROTECTED]> wrote: > > for validanswer in validanswers: > if myAnswers.myanswer in > myAnswers.validAnswers[validanswer]: > MyOptions['style'] = validanswer > I can at least sympathize with your problem, although I don't have a great solution for you. I o

Re: *Naming Conventions*

2007-06-03 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Thorsten Kampe wrote: > Recently I wrote this code and noticed that I was completely lost in > giving these objects names to describe and distinguish them: > > for validanswer in validanswers: > if myAnswers.myanswer in myAnswers.validAnswers[validanswer]: > M

Re: Naming conventions

2006-08-30 Thread Neil Cerutti
On 2006-08-30, Chaz Ginger <[EMAIL PROTECTED]> wrote: > Neil Cerutti wrote: >> The first time I saw StudlyCaps I thought it was the ugliest >> thing I'd ever seen. Now I use it a lot. I still have trouble >> with GVR's preference for HTTPServer over HttpServer. The >> latter is, to me, easier to r

Re: Naming conventions

2006-08-30 Thread Chaz Ginger
Neil Cerutti wrote: > On 2006-08-30, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: >> On Wed, 30 Aug 2006 14:22:16 +1000, Ben Finney <[EMAIL PROTECTED]> wrote: >>> "glenn" <[EMAIL PROTECTED]> writes: >>> Bruno Desthuilliers wrote: > It might be better to use newstyle classes if you can. A

Re: Naming conventions (was: Re: refering to base classes)

2006-08-30 Thread Neil Cerutti
On 2006-08-30, Jean-Paul Calderone <[EMAIL PROTECTED]> wrote: > On Wed, 30 Aug 2006 14:22:16 +1000, Ben Finney <[EMAIL PROTECTED]> wrote: >>"glenn" <[EMAIL PROTECTED]> writes: >> >>> Bruno Desthuilliers wrote: >>> > It might be better to use newstyle classes if you can. Also, the >>> > convention i

Re: Naming conventions

2006-08-30 Thread Bruno Desthuilliers
Ben Finney wrote: > "glenn" <[EMAIL PROTECTED]> writes: > >> Bruno Desthuilliers wrote: >>> It might be better to use newstyle classes if you can. Also, the >>> convention is to use CamelCase for classes names (unless you have >>> a strong reason to do otherwise). > > Note that this style is more

Re: Naming conventions (was: Re: refering to base classes)

2006-08-29 Thread Jean-Paul Calderone
On Wed, 30 Aug 2006 14:22:16 +1000, Ben Finney <[EMAIL PROTECTED]> wrote: >"glenn" <[EMAIL PROTECTED]> writes: > >> Bruno Desthuilliers wrote: >> > It might be better to use newstyle classes if you can. Also, the >> > convention is to use CamelCase for classes names (unless you have >> > a strong r