GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Pubsub surface uses long imports · Issue #827 · googleapis/google-cloud-python

Pubsub surface uses long imports #827

New issue
Copy link
New issue
Copy link
Closed
Closed
Pubsub surface uses long imports#827
Copy link
Assignees
tseaver
Labels
api: pubsubIssues related to the Pub/Sub API.
Milestone
Pub/Sub Future

Description

@jgeewax
jgeewax
opened on Apr 15, 2015
Issue body actions

In the pubsub surface docs page, we use long-style imports instead of the shortcut ones, that is:

from gcloud.pubsub.topic import Topic
topic = Topic('topic_name')

instead of

from gcloud import pubsub
topic = pubsub.Topic('topic_name')

or

from gcloud.pubsub import Topic
topic = Topic('topic_name')

Activity

Next
  1. jgeewax
    added
    docs
    api: pubsubIssues related to the Pub/Sub API.
    on Apr 15, 2015
  2. jgeewax
    added this to the Pub/Sub Future milestone on Apr 15, 2015
  3. dhermes commented on Apr 15, 2015

    @dhermes
    dhermes
    on Apr 15, 2015
    Contributor
    More actions

    @tseaver What is the overall future of this document?

  4. tseaver commented on Apr 16, 2015

    @tseaver
    tseaver
    on Apr 16, 2015
    Contributor
    More actions

    Dunno. In my mind, this kind of overview is useful for developers coming to the library fresh.

    I actually prefer the long imports, myself, as being more "explicit" than the convenience façades / shortcuts: they make it obvious where to go looking in the code when chasing bugs.

  5. jgeewax commented on Apr 16, 2015

    @jgeewax
    jgeewax
    on Apr 16, 2015
    ContributorAuthor
    More actions

    Dunno. In my mind, this kind of overview is useful for developers coming to the library fresh.

    I agree with this. I think the "here's how to do common stuff" is really helpful.

    I actually prefer the long imports, myself, as being more "explicit" than the convenience façades ...

    As you sort of hint, shorter is typically more convenient... I think we should optimize for that over all else.

  6. dhermes commented on Apr 16, 2015

    @dhermes
    dhermes
    on Apr 16, 2015
    Contributor
    More actions

    We don't want users to have to go look in code chasing for bugs. That's what documentation is for.

    Alex Martelli really impacted me at PyCon 2013 when he said:

    Don't take the fact that you are open source as an excuse to not give a good tutorial, example cases and a reference. In other words, no cowboy coding please

    (See slide 13.)

  7. tseaver commented on Apr 16, 2015

    @tseaver
    tseaver
    on Apr 16, 2015
    Contributor
    More actions

    I'm talking about chasing bugs in our code -- having to unwind aliases everywhere makes that extra hard.

  8. dhermes commented on Apr 16, 2015

    @dhermes
    dhermes
    on Apr 16, 2015
    Contributor
    More actions

    I was too. Why would we want our users to have to find our bugs?

  9. jgeewax commented on Apr 16, 2015

    @jgeewax
    jgeewax
    on Apr 16, 2015
    ContributorAuthor
    More actions

    Sure... so I still think that if we're putting convenience for the user first, the aliases are the better choice... Do we have any idea of how extra hard this becomes given aliases? If it becomes ridiculous, then I can let it drop. If it's not all that bad, ... I would vote that the convenience outweighs the extra work and I'd like to take it on...

  10. tseaver commented on Apr 16, 2015

    @tseaver
    tseaver
    on Apr 16, 2015
    Contributor
    More actions

    @dhermes one of the major wins for open-sourcing any library is that users help us find the bugs.

    @jgeewax I don't feel super-strongly about it, but I really don't share the "save a couple of characters in an import statement" sensibility: the only place that seems like a win to me is at the interactive prompt: I don't think many of our users are going to be typing imports directly there. I can live with it in the docs, though.

  11. tseaver commented on Apr 23, 2015

    @tseaver
    tseaver
    on Apr 23, 2015
    Contributor
    More actions

    @jgeewax would it be better if the "short form" was the only public / API version? I.e., we could rename the sub-modules (topic -> _topic) to indicate that they are not part of the API, and that clients should therefore not rely on them.

  12. dhermes commented on Apr 23, 2015

    @dhermes
    dhermes
    on Apr 23, 2015
    Contributor
    More actions

    Big time -1 on that suggestion

  13. tseaver commented on Apr 23, 2015

    @tseaver
    tseaver
    on Apr 23, 2015
    Contributor
    More actions

    Having more than one canonical place to import things is a Zen of Python violation: if the short form is the one we document everywhere, then why keep the long form as a public API? (I like the long form myself, but am trying to figure out what @jgeewax is looking for here).

    If the short form is just a convenience (e.g., for use at the REPL prompt), then the documentation should probably show the long form to indicate that it is the supported / public API form.

  14. jgeewax commented on Apr 29, 2015

    @jgeewax
    jgeewax
    on Apr 29, 2015
    ContributorAuthor
    More actions

    I definitely understand that we're strictly violating the ZoP... However we're also violating it in a few other places (ie, pubsub/__init__.py imports stuff from pubsub/api.py -- so we could use it from either spot, right?) That said, this isn't to say that breaking the rule in one place means we should always break it in another...

    Put simply: I think the usefulness and convenience of shorter imports is worth taking on the future potential issues of "more than one way to do things".

    Here's an example of BDFL doing the same thing to resolve https://code.google.com/p/appengine-ndb-experiment/issues/detail?id=102 --> https://code.google.com/p/appengine-ndb-experiment/source/detail?r=ed282c7ebf0b77882229e8a75f5340d5fa88d838&path=/ndb/__init__.py

  15. 2 remaining items

  16. tseaver
    added a commit that references this issue on Apr 29, 2015

    Merge pull request #844 from tseaver/827-pubsub_docs_short_form_imports

    d21bc3f
  17. JustinBeckwith
    assigned
    tseaver
    on Feb 1, 2021
  18. parthea
    added a commit that references this issue on Oct 21, 2023

    chore: move samples from python-docs-sample (#45)

    d369a34
  19. parthea
    added a commit that references this issue on Sep 18, 2025

    chore(python): update dependencies in .kokoro/docker/docs (#827)

    f0e524b
  20. parthea
    added 5 commits that reference this issue on Nov 22, 2025

    chore(main): release 2.20.0 (#827)

    ee58bde

    chore(deps): update all dependencies (#827)

    3b06073

    docs: Fix bad import path in migration guide (#827)

    596d894

    docs: update user guide/references for downscoped creds (#827)

    808d696

    chore: release 2.0.0 (#829)

    df3eed0
  21. parthea
    added 5 commits that reference this issue on Mar 6, 2026

    chore(deps): update dependency google-cloud-bigquery to v2.23.1 (#827)

    ff92859

    build(deps): [autoapprove] bump pygments from 2.13.0 to 2.15.0 (#827)

    cb92053

    chore(deps): update dependency importlib-metadata to v8.7.1 (#827)

    389b7df

    chore(python): allow client documentation to be customized in README (#…

    fb42d83

    chore(main): release 3.22.0 (#827)

    7321ea9
  22. parthea
    added a commit that references this issue on Sep 8, 2026

    docs: migrate code from googleapis/python-bigquery (#18303)

    23f9a74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @tseaver
    tseaver

Labels

api: pubsubIssues related to the Pub/Sub API.

Type

No type

Projects

No projects

    Milestone

    • Pub/Sub Future

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.