Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #50501

Re: Callable or not callable, that is the question!

From Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com>
Newsgroups comp.lang.python
Subject Re: Callable or not callable, that is the question!
Date 2013-07-12 08:41 +0200
Message-ID <11l4ba-u4l.ln1@satorlaser.homedns.org> (permalink)
References <n6n2ba-ubg.ln1@satorlaser.homedns.org> <mailman.4586.1373551911.3114.python-list@python.org>

Show all headers | View raw


Am 11.07.2013 16:11, schrieb Peter Otten:
> Ulrich Eckhardt wrote:
>> Bug or feature?
>
> No bug. Missing feature if you come up with a convincing use-case.

class Parser:
     def _handle_bool(input):
         # ...
         pass

     types = {'bool': _handle_bool,
              'boolean': _handle_bool,}

     def parse(self, line):
         t,s,v = line.partition(':')
         handler = types[t]
         return handler(v)

I want a utility function that really behaves just like a function. I'd 
prefer to nest it inside the class that uses it, to make the code easier 
to understand. Since I don't want the implicit self-binding either, I 
would use staticmethod to make this clear, too.

Since I can live without any of this, it's not a big issue. What is to 
me a big issue though is the fact that Python behaves unexpectedly and 
reading Steven's response and the link there, it seems I'm not alone.

Greetings!

Uli


Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Callable or not callable, that is the question! Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-07-11 15:05 +0200
  Re: Callable or not callable, that is the question! Peter Otten <__peter__@web.de> - 2013-07-11 16:11 +0200
    Re: Callable or not callable, that is the question! Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-07-12 08:41 +0200
      Re: Callable or not callable, that is the question! Duncan Booth <duncan.booth@invalid.invalid> - 2013-07-12 07:36 +0000
        Re: Callable or not callable, that is the question! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-12 09:49 +0000
          Re: Callable or not callable, that is the question! Peter Otten <__peter__@web.de> - 2013-07-12 12:36 +0200
  Re: Callable or not callable, that is the question! Jason Swails <jason.swails@gmail.com> - 2013-07-11 10:28 -0400
  Re: Callable or not callable, that is the question! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-07-12 02:12 +0000
    Re: Callable or not callable, that is the question! Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-12 01:11 -0600

csiph-web