Fredrik Lundh wrote:
> Scott David Daniels wrote:
>
>> Nope. idempotent: f(f(x)) = f(x)
>> That is, after doing it once, repeating it won't hurt.
>
> http://en.wikipedia.org/wiki/Idempotence_%28computer_science%29
>
>
>
Thank you (Scott and Fredrik) for the correction.
--
bruno desthuillier
Scott David Daniels wrote:
> Nope. idempotent: f(f(x)) = f(x)
> That is, after doing it once, repeating it won't hurt.
http://en.wikipedia.org/wiki/Idempotence_%28computer_science%29
--
http://mail.python.org/mailman/listinfo/python-list
Bruno Desthuilliers wrote:
> ... idempotent -> no side effects.
Nope. idempotent: f(f(x)) = f(x)
That is, after doing it once, repeating it won't hurt.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
On 10/11/06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> Theerasak Photha wrote:
> > On 10/11/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> >
> >> can be a lot better than a 30-level traceback that ends with a line
> >> looking something like
> >>
> >> fnut.index(gah)
> >
> > Despite lon
On 2006-10-11, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> A.T.Hofkamp wrote:
>> On 2006-10-11, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
>>> Now the real question : what if the object is not an instance of any of
>>> the types, but still support the expected interface ?
>>>
>>
>> one po
Theerasak Photha a écrit :
> On 10/11/06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
>
> > Now the real question : what if the object is not an instance of any of
> > the types, but still support the expected interface ?
>
> Perhaps:
>
> try:
> for attribute in ['foo', 'bar', '__baz__']:
>
A.T.Hofkamp wrote:
> On 2006-10-11, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
>> Now the real question : what if the object is not an instance of any of
>> the types, but still support the expected interface ?
>>
>
> one possible answer: Use ZopeInterfaces
> (and ask objects 'do you implement
On 2006-10-11, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
>
> Now the real question : what if the object is not an instance of any of
> the types, but still support the expected interface ?
>
one possible answer: Use ZopeInterfaces
(and ask objects 'do you implement interface X' rather than 'a
Theerasak Photha wrote:
> On 10/11/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
>
>> can be a lot better than a 30-level traceback that ends with a line
>> looking something like
>>
>> fnut.index(gah)
>
> Despite long experience with Perl, I am not a big follower of the
> "goose_level: blah"
Theerasak Photha wrote:
> I'll do that as soon as my green noggin figures out what 'idempotent' means.
"Acting as if used only once, even if used multiple times", to quote
the first explanation I saw on the google result page.
and from the irony department, googling for "indempotent" provides an
On 10/11/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> can be a lot better than a 30-level traceback that ends with a line
> looking something like
>
> fnut.index(gah)
Despite long experience with Perl, I am not a big follower of the
"goose_level: blah" method of error reporting...
> also,
Theerasak Photha wrote:
>> Now the real question : what if the object is not an instance of any of
>> the types, but still support the expected interface ?
>
> Perhaps:
>
> try:
> for attribute in ['foo', 'bar', '__baz__']:
> getattr(mystery_object, '__%s__' % attribute)
> except Attribute
On 10/11/06, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> Now the real question : what if the object is not an instance of any of
> the types, but still support the expected interface ?
Perhaps:
try:
for attribute in ['foo', 'bar', '__baz__']:
getattr(mystery_object, '__%s__' % attribu
Theerasak Photha wrote:
> I wrote this for someone else to take an object and list of types,
> then check if obj is one of those types,
This is already what isinstance(obj, tuple_of_types) does.
> raising an error otherwise.
>
> Is it enough to rely on side effects or absence thereof, or should
On 10/11/06, Ben Finney <[EMAIL PROTECTED]> wrote:
> "Theerasak Photha" <[EMAIL PROTECTED]> writes:
>
> > On 10/11/06, Ben Finney <[EMAIL PROTECTED]> wrote:
> > > Why have you re-implemented (a less-functional version of) 'isinstance'?
> >
> > Ignorance, I think. But the issue is resolved now. Than
On 10/11/06, Ben Finney <[EMAIL PROTECTED]> wrote:
> "Theerasak Photha" <[EMAIL PROTECTED]> writes:
> Far better is to take the objects passed, *use* them in the way that
> you need to use them, and catch exceptions that get raised at the
> point where there is enough context to handle them. This
"Theerasak Photha" <[EMAIL PROTECTED]> writes:
> On 10/11/06, Ben Finney <[EMAIL PROTECTED]> wrote:
> > Why have you re-implemented (a less-functional version of) 'isinstance'?
>
> Ignorance, I think. But the issue is resolved now. Thank you.
Hopefully it is also merely ignorance that leads you t
"Theerasak Photha" <[EMAIL PROTECTED]> writes:
> I wrote this for someone else to take an object and list of types,
> then check if obj is one of those types, raising an error otherwise.
This is a way of programming known as "Look Before You Leap" (LBYL).
It is most likely a mistake to do this in
Theerasak Photha wrote:
> I wrote this for someone else to take an object and list of types,
> then check if obj is one of those types, raising an error otherwise.
>
> Is it enough to rely on side effects or absence thereof, or should I
> put return True in here somewhere?
>
> def test_obj_type(obj
On 10/11/06, Ben Finney <[EMAIL PROTECTED]> wrote:
> Why have you re-implemented (a less-functional version of) 'isinstance'?
Ignorance, I think. But the issue is resolved now. Thank you.
http://www.stanford.edu/~spqrsyc/crew/crew%20-%20ignorance.gif
"It's amazing how much easier it is for a te
"Theerasak Photha" <[EMAIL PROTECTED]> writes:
> I wrote this for someone else to take an object and list of types,
> then check if obj is one of those types, raising an error otherwise.
>
> Is it enough to rely on side effects or absence thereof, or should I
> put return True in here somewhere?
>
Theerasak Photha wrote:
> I wrote this for someone else to take an object and list of types,
> then check if obj is one of those types, raising an error otherwise.
note that a call to your function is pretty much equivalent to
assert isinstance(obj, types)
which has the additional advan
I wrote this for someone else to take an object and list of types,
then check if obj is one of those types, raising an error otherwise.
Is it enough to rely on side effects or absence thereof, or should I
put return True in here somewhere?
def test_obj_type(obj, types):
for type in types:
i
23 matches
Mail list logo