[Tutor] 'function' object has no attribute 'writer'

Walter Prins wprins at gmail.com
Mon Sep 5 18:21:33 CEST 2011

Hi Susana,

On 5 September 2011 17:08, Susana Iraiis Delgado Rodriguez <
susana.delgado_s at utzmg.edu.mx> wrote:

>   File "win.py", line 43, in boton4
>     writer = csv.writer(open(csv_name, 'w'))
> AttributeError: 'function' object has no attribute 'writer'
> I read a tutorial and csv has a writer function, I'm lost
Yes, the csv module has a writer function.  But read carefully!  The error
message isn't saying that the csv module doesn't have a writer function --
it says **function object** has no attribute 'writer'.  So... somehow Python
thinks that the name 'csv' refers to a function at the point in the code
where the error is thrown.  So how can this be?  You should be asking
yourself this question -- could it be that you've (for example) defined a
*function* called 'csv', thereby effectively effectively hiding the *module*
csv?  ;)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110905/a49ec34a/attachment.html>

More information about the Tutor mailing list