Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109687
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | MAthematical formula terms make for terrible names in a program (was: What's good for mathematical formulas can be bad for program code (was: how to extract a variable as parameter which has index using by a for loop?)) |
| Date | 2016-06-09 06:26 +1000 |
| Message-ID | <mailman.84.1465417626.2306.python-list@python.org> (permalink) |
| References | <dc4d4599-05e1-4156-8ce6-66ff955d9851@googlegroups.com> <5757ddcd$0$1520$c3e8da3$5496439d@news.astraweb.com> <85eg871l65.fsf_-_@benfinney.id.au> |
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: > On Wednesday 08 June 2016 17:31, meInvent bbird wrote: > > > H2 = [MM[mmm][b[i][0:1]+b[i][1:2]] for i in range(len(b))] > > This is a mess. I don't understand what you are trying to do. You have > these variable names that don't mean anything, like "b" and "H2", and > others which aren't defined, like MM. I don't understand what you are > trying to accomplish, or the purpose of your code. The nice thing about mathematical formulas is that one has latitude, in the accompanying academic paper, to define at length the single-character names. This means the formulas are briefer to write by hand on the blackboard, and the reader can refer to the author's extensive explanation of what the character means. Mathematicians (and other scientists), please don't attempt to cram meaning into single-letter names in your program code. None of the above advantages apply, and we get only the disadvantages Steven describes. Instead, choose meaningful names that someone who knows that meaning has at least a better-than-random chance of remembering. -- \ “The fundamental principle of science, the definition almost, | `\ is this: the sole test of the validity of any idea is | _o__) experiment.” —Richard P. Feynman | Ben Finney
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
how to extract a variable as parameter which has index using by a for loop? meInvent bbird <jobmattcon@gmail.com> - 2016-06-08 00:31 -0700
Re: how to extract a variable as parameter which has index using by a for loop? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-06-08 18:56 +1000
Re: how to extract a variable as parameter which has index using by a for loop? meInvent bbird <jobmattcon@gmail.com> - 2016-06-08 02:20 -0700
Re: how to extract a variable as parameter which has index using by a for loop? Joonas Liik <liik.joonas@gmail.com> - 2016-06-08 12:48 +0300
Re: how to extract a variable as parameter which has index using by a for loop? Ben Finney <ben+python@benfinney.id.au> - 2016-06-09 06:28 +1000
MAthematical formula terms make for terrible names in a program (was: What's good for mathematical formulas can be bad for program code (was: how to extract a variable as parameter which has index using by a for loop?)) Ben Finney <ben+python@benfinney.id.au> - 2016-06-09 06:26 +1000
csiph-web