[Tutor] calling a method within a function

ALAN GAULD alan.gauld at btinternet.com
Wed Dec 8 10:11:59 CET 2010



> I understand... but don't blame me if it hurts your head ;)

First a few comments.

Theres an awful lot of superfluous "stuff" in there that would 
make it much easier to read and work with.
The docstring does not appear to be accurate and there 
are about 30 lines of commented code. Do you use a 
version control, system? That would avoid the need for 
all of that commenting.

Even so the function is very long and could be easily broken 
into smaller, more maintainable chunks that would help you
diagnose and manage problems more effectively.

In the class you assifn self to D in init?
If its just to avoid some typing you could just use D instead 
of self in the parameter list. The use of self is just a 
convention. However, for the sake of 3 characters I 
personally think its a convention worth following...

However, to your problem,...

> 
> The class is  here:
> http://python.pastebin.com/gPpep50Y
> 
> The function is here:
> http://python.pastebin.com/faK0vZ8U
> 
> The issue is with the  'reflectance' method of the FlightData class
> (line 76). You can see in the  class definition I now just add
> reflectance to self, but before I was trying  to return it, and in the
> function (line 38-40) I was calling the method to  get the array.

The reflectance method does not return anything, it will set 
your value to None.



HTH,

Alan G.



More information about the Tutor mailing list