Created
February 13, 2014 03:11
-
-
Save hub-cap/8969075 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> def check_portstr(portstr): | |
... from_port, sep, to_port = portstr.partition('-') | |
... if not to_port: | |
... if not sep: | |
... to_port = from_port | |
... else: | |
... raise Exception("onoes") | |
... return from_port, to_port | |
... | |
>>> check_portstr("1-2") | |
('1', '2') | |
>>> check_portstr("1") | |
('1', '1') | |
>>> check_portstr("1-") | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "<stdin>", line 7, in check_portstr | |
Exception: onoes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment