On Wed, Jun 27, 2012 at 08:47:08AM +0100, Alan Gauld wrote: > On 27/06/12 00:32, Elaina Ann Hyde wrote: > > > Thanks for the comment, the set type is no problem for me, this is > >just a variable that I call set... and it works great for my purposes, > > It may work just now but if you ever decide you need to use a Python set > you will be unable to because you have effectively hidden that data > type. And it's unlikely to beimmediately obvious why its not working. > That's why its a bad idea to use the built-in type names as variables.
This is called "shadowing a built-in", and is discouraged for exactly the reasons that Alan mentions. It is much less risky to shadow built-ins inside small functions, so you are not surprised that the built-in doesn't work as expected. When you do it deliberately to change the behaviour of a built-in, it is often called "monkey-patching"[1] which is a risky, sometimes useful but advanced technique. Nevertheless, any of these cases should be used with care, and only if necessary. [1] Sometimes called "raving insanity" *grin* -- Steven _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor