Challenge #3: Initializing a Class

Franccesco Orozco edited this page Apr 26, 2018 · 5 revisions

Difficulty: :star::star:

Test: pipenv run python -m unittest tests/test_challenge_3.py -f


Instructions

  • Import the package requests. Beware: It is more beneficial to load only the packages that you need, in this case you will need the method get from requests package.
  • Modify your IPInfo class inside ipinfo.py and define your initialization module. This initialization will require only one parameter of type string and will be called ip.
  • Create a Class Attribute named ip_data. This class attribute will requests a json response from the public API https://ipinfo.io/IP_NUMBER/json where IP_NUMBER is equal to the initialization parameter ip. To challenge yourself, try to make this JSON request in a single line.

TL;DR: Define your class initialization that accepts only one parameter => Create a class attributes that makes a json requests to https://ipinfo.io/IP_NUMBER/json


Documentation

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.