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


Groups > comp.lang.python > #60373

Re: Implement logic on object.attribute and object.attribute()

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: Implement logic on object.attribute and object.attribute()
Date 2013-11-24 09:21 -0500
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-4F23EB.09214724112013@news.panix.com> (permalink)
References <CA+DCN_uqn5OukuZ5QWWjJCUTksaFw50L03ZU7uqdm4a6ZOn7CA@mail.gmail.com> <mailman.3128.1385298299.18130.python-list@python.org> <529202e3$0$29993$c3e8da3$5496439d@news.astraweb.com> <mailman.3131.1385302390.18130.python-list@python.org>

Show all headers | View raw


In article <mailman.3131.1385302390.18130.python-list@python.org>,
 Chris Angelico <rosuav@gmail.com> wrote:

> On Mon, Nov 25, 2013 at 12:45 AM, Steven D'Aprano
> <steve+comp.lang.python@pearwood.info> wrote:
> > Not quite impossible. All you need is an object that behaves like a
> > string, except it has a __call__ method. Here's a sketch of a solution,
> > completely untested.
> >
> > class Magic_HTTP_Thing:
> >     @property
> >     def attribute(self):
> >         result = CallableStr(self.do_get())
> >         result.function = lambda: self.do_put()
> 
> Problem with that is that it'll still call do_get immediately. You'd
> have to somehow defer this call until it's actually _used_, which is
> why I dropped a mention of "converting to str?" - which would
> presumably be a __str__ method. But I still don't like the API.
> 
> ChrisA

If the REST interface is designed properly, all the GETs are 
nullipotent, so modulo efficiency, it should all work.

But, yeah, this seems really ugly.

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


Thread

Re: Implement logic on object.attribute and object.attribute() Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-11-24 05:04 -0800
  Re: Implement logic on object.attribute and object.attribute() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-24 13:45 +0000
    Re: Implement logic on object.attribute and object.attribute() Devin Jeanpierre <jeanpierreda@gmail.com> - 2013-11-24 06:04 -0800
    Re: Implement logic on object.attribute and object.attribute() Chris Angelico <rosuav@gmail.com> - 2013-11-25 01:13 +1100
      Re: Implement logic on object.attribute and object.attribute() Roy Smith <roy@panix.com> - 2013-11-24 09:21 -0500
        Re: Implement logic on object.attribute and object.attribute() Chris Angelico <rosuav@gmail.com> - 2013-11-25 01:31 +1100
    Re: Implement logic on object.attribute and object.attribute() Chris Angelico <rosuav@gmail.com> - 2013-11-25 01:13 +1100
    Re: Implement logic on object.attribute and object.attribute() Marc Aymerich <glicerinu@gmail.com> - 2013-11-24 15:16 +0100
    Re: Implement logic on object.attribute and object.attribute() Chris Angelico <rosuav@gmail.com> - 2013-11-25 01:37 +1100
      Re: Implement logic on object.attribute and object.attribute() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-24 15:11 +0000
    Re: Implement logic on object.attribute and object.attribute() Marc Aymerich <glicerinu@gmail.com> - 2013-11-24 15:34 +0100
    Re: Implement logic on object.attribute and object.attribute() Marc Aymerich <glicerinu@gmail.com> - 2013-11-24 15:48 +0100
    Re: Implement logic on object.attribute and object.attribute() Chris Angelico <rosuav@gmail.com> - 2013-11-25 01:57 +1100

csiph-web