User Controls

When importing a method from a class do i need to specify __init__ and/or __self__?

  1. #1
    Sophie Pedophile Tech Support
    Say i have two Python files. File X is the main program that needs to import some functionality from a secondary supporting program we'll call Y.

    In program Y i have a class with a bunch of methods that return some stuff. Consider this.



    from Y import method_1



    # This is program Y

    class SomeClass():

    def __init__(self)
    self.var = SomeValue

    def method_1(): # This is the method i want to import functionality from
    # imagine we're doing some work here
    return SomeVeryImportantWork


    Do i have to do this? Do i have to do it differently? Why do i have to do it?

    Explain it to me like i'm 5.

    Post last edited by Sophie at 2017-12-26T12:59:26.196007+00:00
Jump to Top