Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

assert vs the fine manual

#217

Submitted by: dmaziuk@bmrb.wisc.edu

More of a wishlist I guess, but the docs state that psycopg2 has "connection" class and "cursor" class. If you believe that:

assert isinstance( conn, psycopg2.connection )
AttributeError: 'module' object has no attribute 'connection'

I can of course use 'psycopg2._psycopg.connection' and 'psycopg2._psycopg.cursor, but

1) the API says they should be "Connection" and "Cursor" (note: proper-cased),
2) sqlite3 does it right, so there's principle of least surprise there, and
3) your own fine manual is lying.

Not so good...

Reported by Psycopg website · May 21st, 2014 @ 06:19 PM

State: invalid
Milestone: none
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from new to invalid

    More of a wishlist I guess, but the docs state that psycopg2 has "connection" class and "cursor" class. If you believe that:

    assert isinstance( conn, psycopg2.connection ) AttributeError: 'module' object has no attribute 'connection'

    It's not stated in the DBAPI that this is the case. Because originally psycopg was a very strict dbapi module plus a well-defined extension submodules, these class are available from...

    I can of course use 'psycopg2._psycopg.connection' and 'psycopg2._psycopg.cursor, but

    Of course you could read the manual and discover that the classes are exposed in the psycopg2.extensions module; psycopg2._psycopg is an implementation detail

    1) the API says they should be "Connection" and "Cursor" (note: proper-cased),

    Probably but not really explicitly. I would have liked them uppercase too, but they are that way since 1999 (psycopg largely predates the PEP 8) and don't see any urge in changing them. There can be (and there are) several classes and they cannot be called all the same. That's why the DBAPI demands factory methods instead of publicly accessible classes.

    2) sqlite3 does it right, so there's principle of least surprise there, and

    don't see how this is relevant

    3) your own fine manual is lying.

    And why don't you tell where? And why haven't you provided a patch to fix them?

    Not so good...

    Are you trying to win a niceness contest?

    Closing this bug as being filed by a moronic troll. If you have patches to fix anything wrong send them us, otherwise write your own database adapter, mister not-so-good-ellipsis.

    May 21st, 2014 @ 09:36 PM