Skip to content

Instantly share code, notes, and snippets.

@sloria
Last active December 19, 2015 04:18
Show Gist options
  • Select an option

  • Save sloria/5895732 to your computer and use it in GitHub Desktop.

Select an option

Save sloria/5895732 to your computer and use it in GitHub Desktop.
_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))
@danriti

danriti commented Feb 28, 2014

Copy link
Copy Markdown

@sloria, looks like you got a typo on line 12?

edit: looks like another type on line 14:

would have to overwrite very method!

Should very be every?

@sloria

sloria commented Feb 28, 2014

Copy link
Copy Markdown
Author

Fixed. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment