I know it's a very dumb question. And it's all about the very basics. But unfortunately I'm very very short on time and can't read a Python book right now.
I have this issue. Well in GAE you a root main.py script.
And I have two classes which are stored in: htmlparser/HTMLParser htmlParser/BfsHTMLParser
And I cannot import them into main.py
¿Qué estoy haciendo mal?
But I catch:
NameError: global name 'BfsHTMLParser' is not defined
Would appreciate any help. Thank you.
p.s. I would also appreciate any book advice about Python basics like this :)
preguntado el 01 de febrero de 12 a las 14:02
from htmlparser import HTMLParser, BfsHTMLParser
Editar I'm afraid this is really basic Python stuff, and you aren't going to get far without reading a Python tutorial. Python is not Java, and the problem here is that you've imported the modules, but not the classes - in Python they are not the same thing.
If you've got classes named the same as the module files, now that you've imported the modules, you will need to instantiate them via
BfsHTMLParser.BfsHtmlParser. Of course, really you shouldn't package classes like that, but that's the situation you have.
Ok, currently I switched to BeautifulSoup Put the BeatifulSoup in the root and it's working.
But still the question of packaging logical code blocks remains open.