[Tutor] Looping over histogram plots
Alan Gauld
alan.gauld at btinternet.com
Wed Jun 27 09:47:08 CEST 2012
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.
eg:
myList = [1,2,3,3,4,5,6,3,1,5]
myUniqueList = list(set(mylist)) # remove duplicates
In your program the second line would fail.
If you are confident you will never use sets then its not an issue, but
these decisions have a habit of coming back to bite you in the future!
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list