Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Document installing thriftrw modules #284

Open

Description

@abhinav

For generated modules, we should document how people can install them into sys.modules so that they can import from them more easily.

sys.modules[__name__] = thrift.load(..)

Activity

  1. ximyu commented on Oct 30, 2015

    @ximyu

    So after doing this I will be able to import a generated Thrift struct directly without importing the whole module first?

  2. abhinav commented on Oct 30, 2015

    @abhinav
    ContributorAuthor

    Yes. This is only partially documented in the thrift.load document right now, but basically you can do:

    # foo/bar.thrift
    
    import sys
    from tchannel import thrift
    
    sys.modules[__name__] = thrift.load(...)
    

    This replaces the module 'foo.bar' with the generated module. Then other modules can simply do,

    from foo.bar import MyService, SomeType
    
  3. ximyu commented on Oct 30, 2015

    @ximyu

    This is amazing. Thanks!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions