On Sat, Sep 09, 2017 at 02:33:18PM -0700, Victor Stinner 
<victor.stin...@gmail.com> wrote:
> I was able to find a real keyboard, so here is a more complete code:
> ---
> class Noop:
>     def __call__(self, *args, **kw):
>         return self
>     def __enter__(self, *args, **kw):
>         return self
>     def __exit__(self, *args):
>         return
>     def __repr__(self):
>         return 'nope'
> ---
> 
> Example:
> ---
> noop = Noop()
> print(noop)
> print(noop())
> with noop() as nope:
>     print(nope)
> with noop as well:
>     print(well)
> ---
> 
> Output:
> ---
> nope
> nope
> nope
> nope
> ---
> 
> IHMO the real question is if we need a Noop.nope() method?

   Yep. It must return self so one can chain as many calls as she wants.

> Victor

Oleg.
-- 
     Oleg Broytman            http://phdru.name/            p...@phdru.name
           Programmers don't die, they just GOSUB without RETURN.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to