Re: doctest environment question

2007-05-22 Thread Gabriel Genellina
En Tue, 22 May 2007 08:57:29 -0300, tag <[EMAIL PROTECTED]> escribió: > On 22 May, 10:11, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: >> The version given by Peter Otten may do what you want, but I'd consider >> if >> you really need an announce_function in the first place, given all the >> o

Re: doctest environment question

2007-05-22 Thread tag
On 22 May, 10:11, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > The version given by Peter Otten may do what you want, but I'd consider if > you really need an announce_function in the first place, given all the > other ways you already have to do the same thing. > Implicitely rebinding globals

Re: doctest environment question

2007-05-22 Thread tag
On 22 May, 10:11, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > The version given by Peter Otten may do what you want, but I'd consider if > you really need an announce_function in the first place, given all the > other ways you already have to do the same thing. > Implicitely rebinding globals

Re: doctest environment question

2007-05-22 Thread tag
On 22 May, 10:11, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > The version given by Peter Otten may do what you want, but I'd consider if > you really need an announce_function in the first place, given all the > other ways you already have to do the same thing. > Implicitely rebinding globals

Re: doctest environment question

2007-05-22 Thread Gabriel Genellina
En Tue, 22 May 2007 04:21:06 -0300, tag <[EMAIL PROTECTED]> escribió: > Here's a function which rebinds a function at the top level of a > module (it won't work for nested functions). > def announce_function(f): > ... " Rebind f within a module so that calls to f are announced. " > ...

Re: doctest environment question

2007-05-22 Thread Peter Otten
tag wrote: > On 22 May, 08:59, Peter Otten <[EMAIL PROTECTED]> wrote: >> inspect.getmodule(f) returns None because f() is not defined in a module. > OK. But there was a module when I ran interactively? Yes. Looking into the doctest source, there is a -- deprecated -- class called Tester that pr

Re: doctest environment question

2007-05-22 Thread tag
On 22 May, 08:59, Peter Otten <[EMAIL PROTECTED]> wrote: [snip] > inspect.getmodule(f) returns None because f() is not defined in a module. OK. But there was a module when I ran interactively? > You can either move f() to a helper module and then > > from helper_module import f Yes. > or modi

Re: doctest environment question

2007-05-22 Thread Peter Otten
tag wrote: > Thanks again Peter. Here's something much closer to what I really want > to do. You should be able to cut and paste this post into a file > "post.txt". Running the command `python -c "import doctest; > doctest.testfile('post.txt')"` gives a test failure even though > everything works

Re: doctest environment question

2007-05-22 Thread tag
On 21 May, 22:17, Peter Otten <[EMAIL PROTECTED]> wrote: > If these don't work you'll have to give a bit more context. > > Peter Thanks again Peter. Here's something much closer to what I really want to do. You should be able to cut and paste this post into a file "post.txt". Running the command `

Re: doctest environment question

2007-05-21 Thread Peter Otten
tag wrote: > On 21 May, 18:53, Peter Otten <[EMAIL PROTECTED]> wrote: >> The doctest code is executed in a module without a __name__, it seems. >> Unfortunately (in this case) the builtin module serves as a fallback >> helping out with its own name: >> >> >>> __name__ >> '__main__' >> >>> del __na

Re: doctest environment question

2007-05-21 Thread tag
On 21 May, 18:53, Peter Otten <[EMAIL PROTECTED]> wrote: > The doctest code is executed in a module without a __name__, it seems. > Unfortunately (in this case) the builtin module serves as a fallback > helping out with its own name: > > >>> __name__ > '__main__' > >>> del __name__ > >>> __name__ >

Re: doctest environment question

2007-05-21 Thread Peter Otten
[EMAIL PROTECTED] wrote: > I'm not making progress with the following and would appreciate any > help. > > Here's an interpreted Python session. > import sys def f(): pass > ... this_module = sys.modules[__name__] delattr(this_module, 'f') f() > Traceback (most recent ca

doctest environment question

2007-05-21 Thread thomas . guest
I'm not making progress with the following and would appreciate any help. Here's an interpreted Python session. >>> import sys >>> def f(): pass ... >>> this_module = sys.modules[__name__] >>> delattr(this_module, 'f') >>> f() Traceback (most recent call last): File "", line 1, in NameError: n