[Tutor] write to a file
Jeff Shannon
jeff@ccvcorp.com
Tue, 20 Aug 2002 09:08:08 -0700
"Scot W. Stevenson" wrote:
> While we're here: Is there any possible problem hat could arise from giving
> a variable ('file' in this case) the same name as a function ('file', the
> function formerly know as 'open') ?
What happens is that the new variable "shadows" the old function. This means
that any time you use that name ('file', in this case), Python will find the
variable and *not* the function. So, if you're trying to call the function,
you will likely get a TypeError saying that 'type String is not callable' --
Python can only find the string variable, and the function is hidden.
Jeff Shannon
Technician/Programmer
Credit International