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 unreasonable and ridiculous burden. > Functions have local variables for a reason.
Not all variables are local variables, and del exists to manage more than just name bindings. Deleting attributes and items from sequences are good uses for it, as is deleting global names which are not needed. You are right that del should not, generally, be used by beginners, and especially not for manually managing names. Fortunately, beginners are not usually inclined to write code like this: def spam(s): a = s.upper() b = s + "s" process(a, b) return do_something_else(a, b) del a, b, s as that would be both pointless and silly. Not only is the del line never reached by Python, but the local variables are automatically deleted when the function returns, so it is a waste of programmer time and effort to manually delete them. -- Steve _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor