FixedPoint

Mark McEahern marklists at mceahern.com
Thu Feb 7 11:22:48 EST 2002


Steve Holden wrote:
> Since the *intent* for None is that there should only ever be one
> object of type None, the better test would be
>
>     if something is None

Thanks, that's how I generally test for None--I didn't know the bit about
"there should only ever be one."

However, you wrote:

> which can easily be used without requiring any changes to FixedPoint.

Well, sure, I could easily change my local copy of PyPgSql's PgSQL.py.  But
it seems like in this case it makes more sense for me to change my local
copy of FixedPoint.py.  Hmm, I'm having a hard time articulating *why*
though.  I guess because we use PyPgSql more, it's actively maintained,
etc.--I'm better off not maintaining our own branching of that code.

Of course, I could ask the PyPgSql folks not to test for None like that.
But then they're going to say, "how's the bug actually happening?"  And I'm
going to have to tell them I'm sending a FixedPoint instance as a param to
cursor.execute().  And *that* only works because I modified FixedPoint.py's
__repr__ to return str(self).  As you can tell, at the moment, I'm just
flying by the seat of my pants trying to make something work.

> Good general rule: if Tim made it that way, it's supposed to be
> that way :-)

I tend to agree.  However, do you think he purposefully avoided making the
code resilient to frippery like this?

	if FixedPoint(1.0) == None:
		...

Should it be resilient to code like that?  In the case of PyPgSql, one could
argue I'm using it incorrectly by passing it a FixedPoint to squirt into the
db.  But then that merely means I haven't framed my question correctly.  ;-)

Cheers,

// mark





More information about the Python-list mailing list