Implement logic on object.attribute and object.attribute()
rosuav at gmail.com
Sun Nov 24 15:37:12 CET 2013
On Mon, Nov 25, 2013 at 1:16 AM, Marc Aymerich <glicerinu at gmail.com> wrote:
> ... def do_get(self):
> ... # Do a HTTP GET request.
> ... return "Get stuff"
> ... def do_put(self):
> ... # Do a HTTP PUT request.
> ... return "Put stuff"
To make this a bit more realistic, try this instead - tying in with
what I said in response to Roy:
# Like a string, but callable.
"this must be overridden on the instance"
result = CallableString(self.do_get())
result.function = lambda: self.do_put()
# Do a HTTP GET request.
print("Doing the GET call, please wait...")
return "Get stuff"
# Do a HTTP PUT request.
print("Doing the PUT call, please wait...")
return "Put stuff"
(PUT or POST, makes no difference; I think you were looking for POST,
but Steven wrote PUT here so I'll use that for simplicity)
Doing the GET call, please wait...
Doing the PUT call, please wait...
And that's what you don't want happening. Your PUT / POST calls are
going to take twice as long as they should.
More information about the Python-list