0 votes
1 view
in Python by (8.4k points)

For example:

requests.get() is a function with a period in it. How would I make my own function ex:

def foo():

    return 'bar'

And call said to function like this:

x.foo()

Not like this:

foo()

1 Answer

0 votes
by (16.8k points)

You can simply use python classes for it:

class x:

    def foo():

        return 'bar'

Or, simply use a staticmethod:

class x:

    @staticmethod

    def foo():

        return 'bar'

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...