[DB-SIG] Result Set Inconsistencies
magnus at thinkware.se
Thu Jul 17 22:06:21 EDT 2003
At Wed, 16 Jul 2003 12:36:29 -0600, "Orr, Steve" <sorr at rightnow.com> wrote:
>Why the inconsistencies in .fetch* result sets?
>Module fetchall Result Set
>MySQLdb tuple of tuples
>cx_Oracle list of tuples
>DCOracle2 list of lists
The relaxed API spec is a feature, not a bug, in my opinion.
Personally I think a list of tuples (like cx_Oracle uses)
embodies the meaning of these types in Python best, but
there might be all sorts of implementation aspects that
leads interface developers to do it differently.
It's also typical for Python to have such relaxed APIs. The
late binding and signature based polymorphism of Python is
generally considered a strength, not a liability, and the
importance of this flexibility is one reason why it's hard
to implement interface specifications for Python.
A key in successful Python programming is to not assume more
about data than you need and can... So don't overspecify
interfaces. It will just lead to reduced flexibility for no
good reason. APIs in most other languages are more strict
because most other languages are unable to handle the kind
of flexibility that Python can handle.
Since the spec only specifies a sequence, you shouldn't make
assumptions like Danny Yoo did in his example. Just becase
a program happens to run in a certain context, we can't
assume that the program is correct.
Magnus Lycka (It's really Lyckå), magnus at thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language
More information about the DB-SIG