Last active
December 19, 2015 04:18
-
-
Save sloria/5895732 to your computer and use it in GitHub Desktop.
This file contains 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
_DEFAULT_PORT = 1234 | |
class SomeProtocol: | |
... | |
def __enter__(self): | |
self._client = socket() | |
self._client.connect( | |
(self.host, | |
self.port or _DEFAULT_PORT) | |
) | |
return self | |
# If you want to subclass SomeProtocol, you would have to overwrite every method! | |
# Better | |
class SomeProtocol: | |
_default_port = 1234 | |
... | |
def __enter__(self): | |
self._client = socket() | |
self._client.connect( | |
(self.host, | |
self.port or self._default_port)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sloria, looks like you got a typo on line 12?
edit: looks like another type on line 14:
Should
very
beevery
?