Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29972
| References | <95e88ca6-36ad-4820-8ecc-c9a788517430@googlegroups.com> <CA+vVgJW8-=Z880fyLYT23cV-=9CiTepX6f5Cjy8d7cT3BZ9SSQ@mail.gmail.com> |
|---|---|
| Date | 2012-09-24 20:06 -0400 |
| Subject | Re: which a is used? |
| From | Dwight Hutto <dwightdhutto@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1248.1348531603.27098.python-list@python.org> (permalink) |
On Mon, Sep 24, 2012 at 7:57 PM, Dwight Hutto <dwightdhutto@gmail.com> wrote: > On Mon, Sep 24, 2012 at 7:43 PM, Jayden <jayden.shui@gmail.com> wrote: >> Dear All, >> >> I have a simple code as follows: >> >> # Begin >> a = 1 >> >> def f(): >> print a >> >> def g(): >> a = 20 >> f() this prints a from calling f() function call print a wasn't in a class where it was self.a and changed, so it performed the function f which prints a and a = 1, but g just assigns the 20, and calls the f() function which shows a, there is no self.a, nor a class to show this in. >> >> g() >> #End >> >> I think the results should be 20, but it is 1. Would you please tell me why? >> >> Thanks a lot! >> >> -- >> http://mail.python.org/mailman/listinfo/python-list > > didn't return the value, or print it out > > > -- > Best Regards, > David Hutto > CEO: http://www.hitwebdevelopment.com -- Best Regards, David Hutto CEO: http://www.hitwebdevelopment.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
which a is used? Jayden <jayden.shui@gmail.com> - 2012-09-24 16:43 -0700
Re: which a is used? Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 19:57 -0400
Re: which a is used? Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 20:06 -0400
Re: which a is used? alex23 <wuwei23@gmail.com> - 2012-09-24 17:08 -0700
Re: which a is used? Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 21:13 -0400
Re: which a is used? alex23 <wuwei23@gmail.com> - 2012-09-24 19:14 -0700
Re: which a is used? Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 22:37 -0400
Re: which a is used? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-09-25 07:07 +0200
Re: which a is used? Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-25 01:30 -0400
Re: which a is used? alex23 <wuwei23@gmail.com> - 2012-09-25 05:48 -0700
Re: which a is used? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-25 08:44 +0100
Stop feeding the trolls (Was: which a is used?) D'Arcy Cain <darcy@druid.net> - 2012-09-25 09:53 -0400
Re: Stop feeding the trolls (Was: which a is used?) David Robinow <drobinow@gmail.com> - 2012-09-25 21:00 -0400
Re: Stop feeding the trolls (Was: which a is used?) Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-26 03:06 -0400
Re: Stop feeding the trolls (Was: which a is used?) alex23 <wuwei23@gmail.com> - 2012-09-26 17:40 -0700
Re: Stop feeding the trolls Ben Finney <ben+python@benfinney.id.au> - 2012-09-27 13:06 +1000
Re: Stop feeding the trolls Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-27 23:39 -0400
Re: Stop feeding the trolls (Was: which a is used?) Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-27 23:47 -0400
Re: Stop feeding the trolls (Was: which a is used?) Chris Angelico <rosuav@gmail.com> - 2012-09-28 14:40 +1000
Re: Stop feeding the trolls (Was: which a is used?) Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-28 00:50 -0400
Re: Stop feeding the trolls (Was: which a is used?) "Littlefield, Tyler" <tyler@tysdomain.com> - 2012-09-27 23:12 -0600
Re: Stop feeding the trolls (Was: which a is used?) Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-28 01:21 -0400
Re: Stop feeding the trolls (Was: which a is used?) rusi <rustompmody@gmail.com> - 2012-09-27 22:51 -0700
Re: Stop feeding the trolls (Was: which a is used?) Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-28 02:20 -0400
Re: Stop feeding the trolls (Was: which a is used?) Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-26 03:07 -0400
Re: which a is used? "Colin J. Williams" <cjw@ncf.ca> - 2012-09-25 08:52 -0400
Re: which a is used? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-09-25 07:06 +0200
Re: which a is used? Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-25 01:22 -0400
Re: which a is used? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-09-25 07:39 +0200
Re: which a is used? Terry Reedy <tjreedy@udel.edu> - 2012-09-25 01:05 -0400
Re: which a is used? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-25 01:18 +0000
Re: which a is used? Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 21:47 -0400
Re: which a is used? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-09-25 07:06 +0200
Re: which a is used? Dwight Hutto <dwightdhutto@gmail.com> - 2012-09-24 21:50 -0400
Re: which a is used? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2012-09-25 11:30 +0200
csiph-web