From: Barış Metin Date: Wed, 10 Mar 2010 10:23:43 +0000 (+0000) Subject: don't bother with isinstance, a better way to get an int or str. X-Git-Tag: PLCAPI-5.0-3^2~20 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=0b42798bd0912332d8659cf4bd7848007122b222;p=plcapi.git don't bother with isinstance, a better way to get an int or str. --- diff --git a/aspects/omfaspects.py b/aspects/omfaspects.py index a9bc179..7139b26 100644 --- a/aspects/omfaspects.py +++ b/aspects/omfaspects.py @@ -25,10 +25,11 @@ class BaseOMF(object): def get_slice(self, api, id_or_name): slice_filter = {} - if isinstance(id_or_name, str): + try: # if integer + slice_filter['slice_id'] = int(str(id_or_name)) + except ValueError: + # we have a string slice_filter['name'] = id_or_name - else: - slice_filter['slice_id']= id_or_name slice = Slices(api, slice_filter = slice_filter)[0] # don't bother to check for slice tags for the moment. we'll only # create XMPP pubsub groups for all slices