newbie help ?

Fredrik Lundh fredrik at pythonware.com
Fri May 16 02:09:32 EDT 2003


John Hunter wrote:

> OK, cofe=code, loking=looking.   The former mistake looks like a typo
> and not dyslexia, since the 'f' is next to the 'd'.  That indicates
> carelessness.  Which is a problem in coding.

not necessarily; the compiler doesn't really care if you make typos
in the comments.

> Looks like zope.  That's good information you should provide in your
> post.

plone isn't zope, it's an application built on top of zope.

>     file=open("codes.txt",'r+') #open the file
>
> Danger.  'file' is a built-in name; don't use it as a variable name.

who cares?  Python doesn't, so why should you?

> And what is 'r+'?  I know 'w+' is open for writing in append mode.

nope.  w+ means truncate file, and open for reading and writing.

> Does r+ mean something?

it means open the file for reading and truncating, without truncating it.

> try inFile = open("codes.txt",'r')

and get an exception on the following line:

>             file.writelines(strCodes) #rewrite the file with missing code

(which he probably does, anyway, due to bad indentation)

>     file.close()# close the file
>
> Again, file is *a very bad name*.

no, it isn't.

> The comments I made are minor and syntactical

and mostly wrong, except for the

> You need to tell us what is wrong from your end; you say it isn't
> working, but don't say how/why.  No error messages are provided.

part, which is spot on.  you could have left it at that.

</F>








More information about the Python-list mailing list