Re: [Tutor] Variable reference

2015-07-08 Thread Peter Otten
Steven D'Aprano wrote: > When writing a script or application, name management is not a big deal. > But in a library, temporary variables are pollution. They make it harder > for the users of your library to tell what's part of the API and what > isn't, and they make "from module import *" less

Re: [Tutor] Variable reference

2015-07-07 Thread Steven D'Aprano
On Tue, Jul 07, 2015 at 06:50:25PM +0200, Peter Otten wrote: [...] > > Not so. The point of del being a statement is that it should be > > considered an operation on the *reference*, not the *value* of the > > reference. So: > > > > x = 23 > > delete(x) # if it existed, it would see the value 23

Re: [Tutor] Variable reference

2015-07-07 Thread Danny Yoo
>> It's a work-around for the fact that >> Python doesn't have dedicated syntax to say "operate on the reference >> foo" rather than the value of foo. > > I think Danny's point was that you should not micromanage name bindings at > all. Then Alan added that del is useful for dicts etc. on which I r

Re: [Tutor] Variable reference

2015-07-07 Thread Peter Otten
Steven D'Aprano wrote: > On Tue, Jul 07, 2015 at 04:08:30PM +0200, Peter Otten wrote: > >> For dicts and lists a method would work as well. Even now you can write >> >> items.pop(index) # instead of del items[index] >> lookup.pop(key) # del lookup[key] >> >> If you find the name pop() random or

Re: [Tutor] Variable reference

2015-07-07 Thread Steven D'Aprano
On Tue, Jul 07, 2015 at 04:08:30PM +0200, Peter Otten wrote: > For dicts and lists a method would work as well. Even now you can write > > items.pop(index) # instead of del items[index] > lookup.pop(key) # del lookup[key] > > If you find the name pop() random or hard to discover a delete() metho

Re: [Tutor] Variable reference

2015-07-07 Thread Peter Otten
Alan Gauld wrote: > On 07/07/15 01:18, Danny Yoo wrote: >> I'd also add that the 'del' statement has near-zero utility. >> >> 'del' is a language blemish. It should not be used by beginners, >> because it asks them to try to manually manage the lifetime of their >> variable names. That's an unre

Re: [Tutor] Variable reference

2015-07-06 Thread Steven D'Aprano
On Mon, Jul 06, 2015 at 05:18:16PM -0700, Danny Yoo wrote: > I'd also add that the 'del' statement has near-zero utility. > > 'del' is a language blemish. It should not be used by beginners, > because it asks them to try to manually manage the lifetime of their > variable names. That's an unreas

Re: [Tutor] Variable reference

2015-07-06 Thread Steven D'Aprano
On Mon, Jul 06, 2015 at 07:25:10PM +0530, Suresh Nagulavancha wrote: > Hello everyone > I want to know about the variables dereference First you need to know how variables reference. When you assign a value to a variable, we say that we "bind the value to the variable's name": spam = 42 tells

Re: [Tutor] Variable reference

2015-07-06 Thread Alan Gauld
On 07/07/15 01:18, Danny Yoo wrote: I'd also add that the 'del' statement has near-zero utility. 'del' is a language blemish. It should not be used by beginners, because it asks them to try to manually manage the lifetime of their variable names. That's an unreasonable and ridiculous burden. F

Re: [Tutor] Variable reference

2015-07-06 Thread Danny Yoo
I'd also add that the 'del' statement has near-zero utility. 'del' is a language blemish. It should not be used by beginners, because it asks them to try to manually manage the lifetime of their variable names. That's an unreasonable and ridiculous burden. Functions have local variables for a re

Re: [Tutor] Variable reference

2015-07-06 Thread Alan Gauld
On 06/07/15 14:55, Suresh Nagulavancha wrote: Hello everyone I want to know about the variables dereference Code is in python 27 Let my variable be foo="hello python" Print foo del foo What del command here actually doing Python variables are stored internally in a dictionary. del removes the n

[Tutor] Variable reference

2015-07-06 Thread Suresh Nagulavancha
Hello everyone I want to know about the variables dereference Code is in python 27 Let my variable be foo="hello python" Print foo del foo What del command here actually doing , is it dereferencing or deleting the variable along with value it stored? Thank you Suresh Nagulavancha _