[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Use tuple-of-types with isinstance
commit 04546f858b1c7c7fe737acd0360d3a4c25e83d06
Author: Sean Robinson <seankrobinson@xxxxxxxxx>
Date: Fri Jan 4 15:41:16 2013 -0700
Use tuple-of-types with isinstance
Move to more Pythonic idiom for multiple type check. This form of
isinstance was added in Python 2.2, so it's safe for us to use.
Signed-off-by: Sean Robinson <seankrobinson@xxxxxxxxx>
---
stem/exit_policy.py | 2 +-
stem/util/conf.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/stem/exit_policy.py b/stem/exit_policy.py
index 677a3c9..f39fc75 100644
--- a/stem/exit_policy.py
+++ b/stem/exit_policy.py
@@ -88,7 +88,7 @@ class ExitPolicy(object):
def __init__(self, *rules):
# sanity check the types
for rule in rules:
- if not (isinstance(rule, str) or isinstance(rule, ExitPolicyRule)):
+ if not isinstance(rule, (str, ExitPolicyRule)):
raise TypeError("Exit policy rules can only contain strings or ExitPolicyRules, got a %s (%s)" % (type(rule), rules))
self._rules = None # lazily loaded series of ExitPolicyRule
diff --git a/stem/util/conf.py b/stem/util/conf.py
index 7f4cebe..2a6623b 100644
--- a/stem/util/conf.py
+++ b/stem/util/conf.py
@@ -539,7 +539,7 @@ class Config(object):
else: self._contents[key] = [value]
for listener in self._listeners: listener(self, key)
- elif isinstance(value, list) or isinstance(value, tuple):
+ elif isinstance(value, (list, tuple)):
if not overwrite and key in self._contents:
self._contents[key] += value
else: self._contents[key] = value
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits