#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0

    Calling a method without parameters


    If Builder() is a method without any parameter, is the following code:
    ...
    Builder
    ...


    calls the method Builder() ?

    Thanks !
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    39N 104.28W
    Posts
    158
    Rep Power
    3
    A method pertains to a class so you need to call it with the class reference: SomeClass.Builder. Furthermore, I think you still need the parentheses: SomeClass.Builder().
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by rrashkin
    A method pertains to a class so you need to call it with the class reference: SomeClass.Builder. Furthermore, I think you still need the parentheses: SomeClass.Builder().
    I think the method is belong to this classes. And there is no parentheses. That is why I ask...
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,889
    Rep Power
    481
    No. Builder refers to the method object.

    Builder() # calls the method


    If you wanted to pass a method to another function how would you do it?
    Code:
    def f(draw_method):
        image = draw_method()
        # work with image
    
    f(Builder)
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo