On Wed, Feb 17, 2010 at 9:38 AM, mk <span dir="ltr"><<a href="mailto:mrkafk@gmail.com">mrkafk@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

It works. But if I'd like to def print_internal_date in PYFileInfo body like so:<br>
<br>
class PYFileInfo(FileInfo):<br>
    'python file properties'<br>
<br>
    def print_internal_date(self, filename):<br>
        f = open(filename + 'c', "rb")<br>
        data = f.read(8)<br>
        mtime = struct.unpack("<i", data[4:])<br>
        return time.asctime(time.gmtime(mtime[0]))<br>
<br>
    tagdata = {'compiled_fname': lambda x: x + 'c',<br>
                'size': os.path.getsize,<br>
                'internal_date': PYFileInfo.print_internal_date<br>
            }<br></blockquote><div> </div><div>You don't have to (and can't) refer to the class within the body. Class statements are sort of... odd. They are code which is directly executed, and the results are then passed into a metaclass/type/whatever and a class object is created. While within the class body, the class doesn't exist yet.</div>

<div><br></div><div>But you don't need it to.</div><div><br></div><div>Just do:</div><div><br></div><div>   'internal_date': print_internal_date</div><div><br></div><div>The 'def' is in the same local scope as 'tagdata' is.</div>

<div><br></div></div><div name="mailplane_signature">--S</div>