FixedPoint

Mark McEahern marklists at mceahern.com
Thu Feb 7 16:56:57 EST 2002


Gerhard Häring wrote:
> There are two changes:
>
> 1) it really tests for "is None", which should be ok for all cases I can
> currently imagine.
>
> 2) It also tests for a _quote() method first, so users can more easily
> override the default quoting behaviour.

I like this!  I'm embarassed to say I didn't study the code enough to see
that I could have added a _quote() to FixedPoint rather than changing it's
__repr__.  That's neat!

> Hmm., while we're at it, we should probably change this test too: "in
> [ListType, TupleType]" Does anybody know how I can reliably test if
> something is a Sequence or is iterable?

I'm just thinking out loud here...  How about something like this:

	if hasattr(value, '__getitem__'):
		...

This may only work in 2.2:

	if hasattr(value, '__iter__'):
		...

I don't really have a good grasp of all the subtleties involved in testing
for sequence in a way that works across lots of different versions of
Python.

// mark





More information about the Python-list mailing list