Is requests in requests.get is class or package?

Typically who migrate to Python from C++, Java or any other object oriented language get feeling that everything that get appended with “.” followed by function name like “requests.get” have feeling that “requests” must be class.And then they open the source code, look for method “get” in class called requests. This they do as if they are told by “Kill grave“ of Jessica Jones. People who are initiated to python world and aware of PEP8 may think requests cant be class ,it must be package as it is not starting Capital letter. For very few this strikes. While Functions vs class debate will go in python world, requests.get ,discreetly marries both arguments.

How do you think that magic is happening?. It is simple. In any package , __init__.py, import methods that you want to tie to package as in requests example below.

Refer https://github.com/kennethreitz/requests/blob/master/requests/__init__.py

then you have it .You can marry all methods to package and use it as if you are calling methods on class,simple but very efficient. This is python antivirus to your “Kill grave” virus:)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.