Re: Need help with "with-statement-compatible" object

2007-12-19 Thread Dmitry Teslenko
On Dec 19, 2007 12:14 PM, Peter Otten <[EMAIL PROTECTED]> wrote: > def __enter__(self): > # ... > return self > > should help. That helps. Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Need help with "with-statement-compatible" object

2007-12-19 Thread Peter Otten
Dmitry Teslenko wrote: > Hello! > I've made some class that can be used with "with statement". It looks this > way: > > class chdir_to_file( object ): > ... > def __enter__(self): > ... > > def __exit__(self, type, val, tb): > ... > def get_chdir_to_file(file_path): > return c

Need help with "with-statement-compatible" object

2007-12-19 Thread Dmitry Teslenko
Hello! I've made some class that can be used with "with statement". It looks this way: class chdir_to_file( object ): ... def __enter__(self): ... def __exit__(self, type, val, tb): ... def get_chdir_to_file(file_path): return chdir_to_file(file_path) ... Snippet with obj