Also, just to be clear, I think the idea of a library to sniff this information is great.
It's just the location of where this information is being stored that I'm focusing in on and asking about. It seems like it should be in a "neutral" location, and in particular different from / decoupled from the library above. One advantage of decoupling the sniffing library from the registry location is that it would allow for someone to write an improved library in the future (say "detectio") without forever locking in / requiring the old library to be installed. --Chris On Sat, Aug 18, 2018 at 12:50 AM, Chris Jerdonek <chris.jerdo...@gmail.com> wrote: > On Sat, Aug 18, 2018 at 12:20 AM, Nathaniel Smith <n...@pobox.com> wrote: >> On Fri, Aug 17, 2018 at 11:44 PM, Chris Jerdonek >> <chris.jerdo...@gmail.com> wrote: >>> On Fri, Aug 17, 2018 at 12:50 PM, Nathaniel Smith <n...@pobox.com> wrote: >>>> On Fri, Aug 17, 2018, 12:12 Chris Jerdonek <chris.jerdo...@gmail.com> >>>> wrote: >>>>> >>>>> Did you also think about whether it would be possible for a library to >>>>> advertise itself without having to depend on a third-party library >>>>> (e.g. using some sort of convention)? That would permit a less >>>>> "centralized" approach. >>>> >>>> >>>> What kind of convention do you have in mind? >>> >>> Good question. I don't claim to know the answer which is why I asked >>> if you had thought about it. The *kind* of thing I had in mind was to >>> set a variable with an agreed-upon name and value on an agreed-upon >>> module in the standard library -- though I agree that seems hacky as >>> stated. >>> >>> It does seem to me like something that should (already?) have a >>> general solution. What other ways does Python let things register or >>> "announce" themselves? >> >> Well, you could register an entry in an some global dict under an >> agreed-on key, like, say, sys.modules["sniffio"]. Of course, whenever >> you're mutating a global object like this you should worry about name >> collisions, but fortunately that particular dict has a good convention >> for reserving names. In fact there's a whole web service called "PyPI" >> devoted to managing those registrations! And then you might as well >> upload the code for accessing that variable to the web service, so >> everyone doesn't have to copy/paste it into their programs... ;-) > > Yes, I know. My original question was whether it would be possible > _without_ a third-party library. > > It just feels to me as overly heavy-weight to rely on all of that > infrastructure just to pick a key name. You have to rely on convention > for the "identifier string" anyways to prevent name collisions. (It > can still be misused.) And the sniffio docs already have code you have > to copy-and-paste anyways (not including the "have_sniffio = False" > code above). > > --Chris > > >> >> Now that packaging works reliably, it's a pretty good solution for >> this kind of thing IMHO. >> >> -n >> >> -- >> Nathaniel J. Smith -- https://vorpus.org _______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/