Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48840
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-06-20 19:18 -0700 |
| References | <7e6361d5-6619-4aaa-adda-8b5f01bde57f@googlegroups.com> <b3d90d37-896c-4c80-8f94-9e046453927c@googlegroups.com> <447dd1c6-1bb2-4276-a109-78d7a067b442@d8g2000pbe.googlegroups.com> <2e92b4c7-31be-40d2-a906-ab19f3630dfa@googlegroups.com> <09cfa648-ab87-4261-b8f0-bf493de00553@4g2000pbf.googlegroups.com> |
| Message-ID | <2ad7d32b-90de-4516-9a4c-88f2dd454c4c@googlegroups.com> (permalink) |
| Subject | Re: Default Value |
| From | 88888 Dihedral <dihedral88888@gmail.com> |
rusi於 2013年6月21日星期五UTC+8上午1時12分01秒寫道: > You know Rick, you are good at python, you are better at polemics. > > If only you would cut the crap I would (be able to) agree with you. > > See below > > > > On Jun 20, 7:49 pm, Rick Johnson <rantingrickjohn...@gmail.com> wrote: > > > On Thursday, June 20, 2013 7:57:06 AM UTC-5, rusi wrote: > > > > Every language has gotchas. This is one of python's. > > > > > > So are we purposely injecting illogic into our language just > > > to be part of some "cool crowd" of programming languages with > > > gotchas. > > > > > > "You thought intuitiveness was a virtue? Haha, we gotcha!" > > > > > > Python (and all the other 'cool' languages) dont have gotchas because > > someone malevolently put them there. > > In most cases, the problem is seen too late and the cost of changing > > entrenched code too great. > > Or the problem is clear, the solution is not etc etc. > > > > > > > > Or maybe this is reminiscent of the fraternity hazing rituals > > > of days gone by: > > > > > > *POP* > > > "Thank you Sir, may i have another?" > > > > > > > If you are a beginning python programmer, really the best > > > > answer is: Just dont do it! Dont do what? Dont use > > > > mutable arguments as function defaults. Once you cross the > > > > noob stage you can check that its a standard gotcha: Just > > > > run a search for 'python gotcha default []' > > > > > > > And when you feel that you need to, use Steven's trick: > > > > use a immutable indicator 'None' for the mutable []. Once > > > > you cross the noob stage you can check that its a standard > > > > gotcha: Just run a search for 'python gotcha default []' > > > > Its even been discussed repeatedly on the python-ideas > > > > list > > > > > > Your attempting to excuse an inexcusable language flaw by > > > pointing out that the effects of the flaw can be avoided by > > > using a workaround. And, to add insult to injury, you > > > provide no good reason for the flaw to exist: > > > > > > "Just do x, y, and z and shut up. Yes we made a mistake > > > but we are not about to admit our mistake and the onerous > > > will be on all the noobs to re-invent the workaround each > > > time" > > > > > > To me that is unacceptable. > > > > > > > Heres a correction suggestion: [...] Here's Terry Reedy's > > > > nicely explaining the 'why-of-the-how' : [...] FWIW here > > > > is a conceptual/philosophical explanation of your > > > > confusion: There are 2 fundamental ways for approaching > > > > the programming task -- functional and imperative. > > > > > > All these "explanations" ignore a fundamental fact about > > > subroutines[1]. > > > > > > > > A call to a subroutine should exists as a unique transaction > > > within the entire program. It is expected to optionally take > > > inputs, and optionally return an output (depending on the > > > definition). > > > > > > When the subroutine is completed, all inputs and local > > > variables are expected to be destroyed. If the programmer > > > wants a return value, he need simply ask. Data persistence > > > is not a function of subroutines! Finally, a subroutine > > > should never have side effects UNLESS the programmer > > > explicitly ask for a side effect. > > > > > > However, the Python flaw of allowing mutable sequence > > > arguments to persist between successive calls of a > > > subroutine is breaking the entire definition of a > > > subroutine, and for what noble purpose i ask? What purpose > > > is SO important that you change a well established interface > > > in a totally unintuitive manner? > > > > > > If your answer is that recursion is easier, then i say that > > > is foolish because a programmer can keep a reference > > > to a mutable sequence OUTSIDE the subroutine and you can > > > save the "gotchas" for Guido's next birthday party. > > > > > > [1]:http://en.wikipedia.org/wiki/Subroutine > > > > > > You are saying in different language what I said: Functional > > programming is a good idea, imperative programming is a bad idea. > > From the invention of subroutines (ie 50 years) PL designers are > > hearing this truth but somehow or other fail to listen; for more > > details see http://blog.languager.org/2012/11/imperative-programming-lessons-not.html Well, that was the story of the expensive memory era.the In 198X -2000 the auto GC of LISP was beaten by practical engineers using C, C++, PASCAL, and object pascal. But now it is different in 201X.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Default Value Ahmed Abdulshafy <abdulshafy@gmail.com> - 2013-06-19 12:17 -0700
Re: Default Value Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-06-19 22:35 +0300
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-19 12:38 -0700
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-20 05:57 -0700
Re: Default Value Roy Smith <roy@panix.com> - 2013-06-20 09:19 -0400
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-20 06:31 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-21 00:17 +0000
Re: Default Value Roy Smith <roy@panix.com> - 2013-06-20 20:25 -0400
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-20 07:49 -0700
Re: Default Value Chris Angelico <rosuav@gmail.com> - 2013-06-21 01:38 +1000
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-20 11:05 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-21 00:57 +0000
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-20 20:16 -0700
Re: Default Value Chris Angelico <rosuav@gmail.com> - 2013-06-21 17:10 +1000
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 07:32 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-21 16:22 +0000
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-21 15:57 +0000
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 10:01 -0700
Re: Default Value Rotwang <sg552@hotmail.co.uk> - 2013-06-21 18:47 +0100
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 11:26 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-21 18:37 +0000
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 12:18 -0700
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 12:35 -0700
Re: Default Value Chris Angelico <rosuav@gmail.com> - 2013-06-22 05:07 +1000
Re: Default Value Neil Cerutti <neilc@norwich.edu> - 2013-06-21 19:20 +0000
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 13:27 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-22 01:31 +0000
Re: Default Value Chris Angelico <rosuav@gmail.com> - 2013-06-22 11:40 +1000
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 18:42 -0700
Re: Default Value MRAB <python@mrabarnett.plus.com> - 2013-06-22 03:04 +0100
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 19:32 -0700
Re: Default Value MRAB <python@mrabarnett.plus.com> - 2013-06-22 20:36 +0100
Re: Default Value Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-22 18:51 -0400
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-21 19:43 -0700
Re: Default Value Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-22 09:26 +0100
Re: Default Value MRAB <python@mrabarnett.plus.com> - 2013-06-21 20:25 +0100
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 13:44 -0700
Re: Default Value MRAB <python@mrabarnett.plus.com> - 2013-06-21 23:49 +0100
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 16:51 -0700
Re: Default Value MRAB <python@mrabarnett.plus.com> - 2013-06-22 02:54 +0100
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-22 01:15 +0000
Re: Default Value Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-21 19:27 -0600
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-21 19:32 -0700
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 19:55 -0700
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-21 23:23 -0700
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-22 08:07 -0700
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-22 08:31 -0700
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-22 09:11 -0700
Re: Default Value Grant Edwards <invalid@invalid.invalid> - 2013-06-24 14:22 +0000
Re: [SPAM] Re: Default Value MRAB <python@mrabarnett.plus.com> - 2013-06-24 16:22 +0100
Re: Default Value Chris Angelico <rosuav@gmail.com> - 2013-06-22 11:41 +1000
Re: Default Value Michael Torrie <torriem@gmail.com> - 2013-06-21 20:46 -0600
Re: Default Value Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-06-22 16:40 +0200
Re: Default Value Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-22 12:49 -0400
Re: Default Value Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-22 12:57 -0600
Re: Default Value Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-22 18:48 -0400
Re: Default Value Rotwang <sg552@hotmail.co.uk> - 2013-06-22 00:40 +0100
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 18:15 -0700
Re: Default Value Chris Angelico <rosuav@gmail.com> - 2013-06-22 11:37 +1000
Re: Default Value Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-21 19:42 -0600
Re: Default Value Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-21 19:38 -0600
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 19:40 -0700
Re: Default Value Rotwang <sg552@hotmail.co.uk> - 2013-06-22 03:01 +0100
Re: Default Value Chris Angelico <rosuav@gmail.com> - 2013-06-22 12:18 +1000
Re: Default Value Rotwang <sg552@hotmail.co.uk> - 2013-06-22 03:25 +0100
Re: Default Value Rotwang <sg552@hotmail.co.uk> - 2013-06-22 18:19 +0100
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-22 11:49 -0700
Re: Default Value Rotwang <sg552@hotmail.co.uk> - 2013-06-23 01:49 +0100
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-20 10:12 -0700
Re: Default Value Chris Angelico <rosuav@gmail.com> - 2013-06-21 03:19 +1000
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-20 10:30 -0700
Re: Default Value Ian Kelly <ian.g.kelly@gmail.com> - 2013-06-20 11:57 -0600
Re: Default Value rusi <rustompmody@gmail.com> - 2013-06-20 11:15 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-21 01:08 +0000
Re: Default Value Tim Chase <python.list@tim.thechases.com> - 2013-06-20 20:26 -0500
Re: Default Value Roy Smith <roy@panix.com> - 2013-06-20 21:40 -0400
Re: Default Value Tim Chase <python.list@tim.thechases.com> - 2013-06-20 21:02 -0500
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-20 11:07 -0700
Re: Default Value alex23 <wuwei23@gmail.com> - 2013-06-21 10:55 +1000
Re: Default Value 88888 Dihedral <dihedral88888@gmail.com> - 2013-06-20 19:18 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-21 02:26 +0000
Re: Default Value "Lefavor, Matthew (GSFC-582.0)[MICROTEL LLC]" <matthew.lefavor@nasa.gov> - 2013-06-20 17:28 -0500
Re: Default Value Rick Johnson <rantingrickjohnson@gmail.com> - 2013-06-21 08:17 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-21 01:28 +0000
Re: Default Value Gary Herron <gherron@digipen.edu> - 2013-06-19 12:57 -0700
Re: Default Value Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-20 01:17 +0000
csiph-web