Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6521 > unrolled thread
| Started by | Henry Olders <henry.olders@mcgill.ca> |
|---|---|
| First post | 2011-05-29 04:30 -0400 |
| Last post | 2011-05-31 10:33 -0700 |
| Articles | 7 on this page of 27 — 14 participants |
Back to article view | Back to comp.lang.python
scope of function parameters Henry Olders <henry.olders@mcgill.ca> - 2011-05-29 04:30 -0400
Re: scope of function parameters Mel <mwilson@the-wire.com> - 2011-05-29 07:59 -0400
Re: scope of function parameters Terry Reedy <tjreedy@udel.edu> - 2011-05-29 16:27 -0400
Re: scope of function parameters Peter Pearson <ppearson@nowhere.invalid> - 2011-05-29 17:21 +0000
Re: scope of function parameters Ben Finney <ben+python@benfinney.id.au> - 2011-05-30 07:42 +1000
Re: scope of function parameters Laurent Claessens <moky.math@gmail.com> - 2011-05-30 09:12 +0200
Re: scope of function parameters Chris Rebert <clp2@rebertia.com> - 2011-05-30 00:27 -0700
Re: scope of function parameters Laurent <moky.math@gmail.com> - 2011-05-30 09:38 +0200
Re: scope of function parameters Daniel Kluev <dan.kluev@gmail.com> - 2011-05-30 19:10 +1100
Re: scope of function parameters Terry Reedy <tjreedy@udel.edu> - 2011-05-30 05:02 -0400
Re: scope of function parameters Laurent Claessens <moky.math@gmail.com> - 2011-05-30 11:08 +0200
Re: scope of function parameters Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-30 09:14 +0000
Re: scope of function parameters Ben Finney <ben+python@benfinney.id.au> - 2011-05-30 19:17 +1000
Re: scope of function parameters Peter Otten <__peter__@web.de> - 2011-05-30 11:41 +0200
Re: scope of function parameters Laurent Claessens <moky.math@gmail.com> - 2011-05-30 12:10 +0200
Re: scope of function parameters Laurent Claessens <moky.math@gmail.com> - 2011-05-30 12:10 +0200
Re: scope of function parameters Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2011-05-30 13:40 +0300
Re: scope of function parameters Terry Reedy <tjreedy@udel.edu> - 2011-05-30 12:49 -0400
Re: scope of function parameters Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-30 09:16 +0000
Re: scope of function parameters Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-29 23:46 +0000
Re: scope of function parameters Ben Finney <ben+python@benfinney.id.au> - 2011-05-30 11:31 +1000
Re: scope of function parameters Chris Angelico <rosuav@gmail.com> - 2011-05-30 11:56 +1000
Re: scope of function parameters Ben Finney <ben+python@benfinney.id.au> - 2011-05-30 12:08 +1000
Re: scope of function parameters Chris Angelico <rosuav@gmail.com> - 2011-05-30 12:37 +1000
Re: scope of function parameters Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-05-30 04:23 +0000
Re: scope of function parameters rusi <rustompmody@gmail.com> - 2011-05-31 09:46 -0700
Re: scope of function parameters rusi <rustompmody@gmail.com> - 2011-05-31 10:33 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2011-05-30 11:31 +1000 |
| Message-ID | <87pqn17z4a.fsf@benfinney.id.au> |
| In reply to | #6598 |
Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes:
> http://mail.python.org/pipermail/tutor/2010-December/080505.html
>
>
> Constructive criticism welcome.
Informative, but it “buries the lead” as our friends in the press corps
would say.
Instead you should write as though you have no idea where the reader
will stop reading, and still give them the most useful part. Write the
most important information first, and don't bury it at the end.
In this case, I'd judge the most important information to be “what is
the Python passing model?” Give it a short name; the effbot's “pass by
object” sounds good to me.
Then explain what that means.
Then, only after giving the actual information you want the reader to go
away with, you can spend the rest of the essay giving a history behind
the craziness.
More on this style:
<URL:http://www.computerworld.com/s/article/print/93903/I_m_OK_The_Bull_Is_Dead>
--
\ Moriarty: “Forty thousand million billion dollars? That money |
`\ must be worth a fortune!” —The Goon Show, _The Sale of |
_o__) Manhattan_ |
Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-05-30 11:56 +1000 |
| Message-ID | <mailman.2246.1306720590.9059.python-list@python.org> |
| In reply to | #6606 |
On Mon, May 30, 2011 at 11:31 AM, Ben Finney <ben+python@benfinney.id.au> wrote: > <URL:http://www.computerworld.com/s/article/print/93903/I_m_OK_The_Bull_Is_Dead> I agree with the gist of that. My take on this is: When I'm talking to my boss, I always assume that the phone will ring ten seconds into my explanation. Ten seconds is enough for "Dad, I'm OK; the bull is dead", it's enough for "I've solved Problem X, we can move on now"; it's enough for "Foo is crashing, can't ship till I debug it". If fortune is smiling on me and the phone isn't ringing, I can explain that Problem X was the reason Joe was unable to demo his new module, or that the crash in Foo is something that I know I'll be able to pin down in a one-day debugging session, but even if I don't, my boss knows enough to keep going with. Of course, there's a significant difference between a mailing list post and a detailed and well copyedited article. Quite frequently I'll ramble on list, in a way quite inappropriate to a publication that would be linked to as a "hey guys, here's how it is" page. Different media, different standards. Chris Angelico "Forty thousand million billion THEGS quotes? That must be worth a fortune!" -- definitely a fan of THEGS --
[toc] | [prev] | [next] | [standalone]
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2011-05-30 12:08 +1000 |
| Message-ID | <87lixp7xe9.fsf@benfinney.id.au> |
| In reply to | #6608 |
Chris Angelico <rosuav@gmail.com> writes: > Of course, there's a significant difference between a mailing list > post and a detailed and well copyedited article. Quite frequently I'll > ramble on list, in a way quite inappropriate to a publication that > would be linked to as a "hey guys, here's how it is" page. Different > media, different standards. Right. But Steven specifically asked for constructive criticism, which I took as permission to treat the referenced post as an article in need of copy editing :-) -- \ “The truth is the most valuable thing we have. Let us economize | `\ it.” —Mark Twain, _Following the Equator_ | _o__) | Ben Finney
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2011-05-30 12:37 +1000 |
| Message-ID | <mailman.2248.1306723057.9059.python-list@python.org> |
| In reply to | #6610 |
On Mon, May 30, 2011 at 12:08 PM, Ben Finney <ben+python@benfinney.id.au> wrote: > Chris Angelico <rosuav@gmail.com> writes: > >> Of course, there's a significant difference between a mailing list >> post and a detailed and well copyedited article. Quite frequently I'll >> ramble on list, in a way quite inappropriate to a publication that >> would be linked to as a "hey guys, here's how it is" page. Different >> media, different standards. > > Right. But Steven specifically asked for constructive criticism, which I > took as permission to treat the referenced post as an article in need of > copy editing :-) Indeed. Was just saying that there are times when you need to get the slug out first, and times when it's okay to be a little less impactual (if that's a word). Although it's still important to deliver your message promptly. Of course, there are other contexts where you specifically do NOT want to give everything away at the beginning. Certain styles of rhetoric demand that you set the scene, build your situation, and only at the climax reveal what it is you are trying to say. Ahh! wordsmithing, how we love thee. Chris Angelico
[toc] | [prev] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2011-05-30 04:23 +0000 |
| Message-ID | <4de31bd0$0$29990$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #6606 |
On Mon, 30 May 2011 11:31:33 +1000, Ben Finney wrote: > Steven D'Aprano <steve+comp.lang.python@pearwood.info> writes: > >> http://mail.python.org/pipermail/tutor/2010-December/080505.html >> >> >> Constructive criticism welcome. > > Informative, but it “buries the lead” as our friends in the press corps > would say. Thank you, that's a good point. [...] > More on this style: > > <URL:http://www.computerworld.com/s/article/print/93903/ I_m_OK_The_Bull_Is_Dead> Or as they say in the fiction-writing trade, "shoot the sheriff on the first page". -- Steven
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2011-05-31 09:46 -0700 |
| Message-ID | <0ae4faae-35ff-403d-944c-5e620a37b326@y27g2000prb.googlegroups.com> |
| In reply to | #6521 |
On May 29, 1:30 pm, Henry Olders <henry.old...@mcgill.ca> wrote: > I just spent a considerable amount of time and effort debugging a program. The made-up code snippet below illustrates the problem I encountered: > > def main(): > a = ['a list','with','three elements'] > print a > print fnc1(a) > print a > > def fnc1(b): > return fnc2(b) > > def fnc2(c): > c[1] = 'having' > return c > > This is the output: > ['a list', 'with', 'three elements'] > ['a list', 'having', 'three elements'] > ['a list', 'having', 'three elements'] > > I had expected the third print statement to give the same output as the first, but variable a had been changed by changing variable c in fnc2. > > It seems that in Python, a variable inside a function is global unless it's assigned. This rule has apparently been adopted in order to reduce clutter by not having to have global declarations all over the place. > > I would have thought that a function parameter would automatically be considered local to the function. It doesn't make sense to me to pass a global to a function as a parameter. > > One workaround is to call a function with a copy of the list, eg in fnc1 I would have the statement "return fnc2(b[:]". But this seems ugly. > > Are there others who feel as I do that a function parameter should always be local to the function? Or am I missing something here? > > Henry You want a functional language. You can simulate that in python by using tuples in place of lists. fnc2(c): c[1] = 'having' return c will of course then give you an error that tuples are not assignable (which seems to be what you want?) So you then use (something like) fnc2(c): return c[0:1] + c[2:]
[toc] | [prev] | [next] | [standalone]
| From | rusi <rustompmody@gmail.com> |
|---|---|
| Date | 2011-05-31 10:33 -0700 |
| Message-ID | <97dd84e0-c164-4d5e-a485-0fb356eece3a@34g2000pru.googlegroups.com> |
| In reply to | #6739 |
On May 31, 9:46 pm, rusi <rustompm...@gmail.com> wrote:
> So you then use (something like)
>
> fnc2(c): return c[0:1] + c[2:]
Er sorry -- that should have been
def fnc2(c): return c[0:1] + ('having',) + c[2:]
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.python
csiph-web