On python syntax...

Diez B. Roggisch deets_noospaam at web.de
Tue Nov 11 18:08:15 EST 2003


> While this solution would work, I'm less than happy that the
> programmer is left to ensure calls to Open are matched with calls to
> close.  It is significant to note that every call to open is at the
> beginning of a nested context, and every call to close is at the
> corresponing end of the same nested context.

Maybe you can take advantage of python beeing an interpreted language and
try to analyse the code fragment your programmer gives to you. As long as
he doesn't do any really nasty stuff, you could try to analyse the parse
tree and find blocks finishing without a close call. The parser module
would make this possible. I'm not sure if its possible to get a parse tree
out of a compiled function, but somewhere the source code must be, so you
should be able to access it.

Mind you, I never worked with that stuff before - I think it could be done,
but I'm not sure if its worth the effort :)

Regards,

Diez




More information about the Python-list mailing list