Python read item state

I am trying to write python script to read one of my item state…I look at the example but not able to find place where to put the url and item…for example: my oh server setup port:1122 user:test pass:testing the item is “myceilinglight”…i want to write python script…i dont know where to input my setup in the code

def get_status(self, name):
""" Request updates for any item in group NAME from OpenHAB.
Long-polling will not respond until item updates.
# When an item in Group NAME changes we will get all items in the group
# and need to determine which has changed
url = ‘http://%s:%s/rest/items/%s’%(self.openhab_host,
self.openhab_port, name)
payload = {‘type’: ‘json’}
req = requests.get(url, params=payload,
if req.status_code !=
# Try to parse JSON response
# At top level, there is type, name, state, link and members array
members = req.json()[“members”]
for member in members:
# Each member has a type, name, state and link
name = member[“name”]
state = member[“state”]
do_publish = True
# Pub unless we had key before and it hasn’t changed
if name in self.prev_state_dict:
if self.prev_state_dict[name] == state:
do_publish = False
self.prev_state_dict[name] = state
if do_publish:
self.publish(name, state)