Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (45.3k 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'

Related questions

Browse Categories

...