[Tutor] name 'x" is not defined
carme.colominas at gmail.com
Sat Oct 18 11:56:19 CEST 2008
thank you very much, very clear explanation, I will try with the beginner
2008/10/17 Alan Gauld <alan.gauld at btinternet.com>
> "carme colominas" <carme.colominas at gmail.com> wrote
>> I'm a linguist and absolut new on Python; I'm trying to follow the first
>> chapter of *Natural Language Processing in Python.
> I'm not familiar witrh it but if the code you have is from the first
> chapter then I suggest you should go through one of the beginner
> Python tutorials first.
> You don't say whether you know any other programjing languages
> but from your question it doesn't look like it so I'll suggest you
> try the Non Programmers tutorials:
> what does it mean that a function is not defined
>> and how to proceed?
> Traceback (most recent call last):
>> File "<pyshell#47>", line 2, in <module>
>> if fdist(word)>= 3:
>> NameError: name 'fdist' is not defined
> Note that it doesn't say the function is not defined it says
> the *name* is not defined. That's a different thing. These
> kinds of details matter in programming.
> A name can be as variable or a function or a class or
> a module or most any other kind of object in Python.
> Names have to be created before they are used in Python.
> In this case it is a function and we create it by defining
> the function or by importing the function from another module.
> The other possibility is to access it from another module
> which we have already imported - like you did with the
> words() function:
> You may just need to preface the fdist() function with the
> name of the module where it is defined.
> But all of this will makemuch more sense if you go through
> one of the tutorials on the link above.
> Alan Gauld
> Author of the Learn to Program web site
> Tutor maillist - Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor