GeezerVison is showing github.com — Pubsub surface uses long imports · Issue #827 · googleapis/google-cloud-python
Pubsub surface uses long imports #827DescriptionIn 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')Activitydhermes commented on Apr 15, 2015 @tseaver What is the overall future of this document? tseaver commented on Apr 16, 2015 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. jgeewax commented 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. dhermes commented on Apr 16, 2015 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.) tseaver commented on Apr 16, 2015 I'm talking about chasing bugs in our code -- having to unwind aliases everywhere makes that extra hard. dhermes commented on Apr 16, 2015 I was too. Why would we want our users to have to find our bugs? jgeewax commented 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... tseaver commented on Apr 16, 2015 @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. tseaver commented on Apr 23, 2015 @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. dhermes commented on Apr 23, 2015 Big time -1 on that suggestion tseaver commented on Apr 23, 2015 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. jgeewax commented on Apr 29, 2015 ContributorAuthor More actions
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|