A couple of small 2.6-isms.
We can use namedtuple and the new 0o octal literal notation.
This commit is contained in:
parent
2baf3c02ab
commit
747b895030
|
@ -64,6 +64,7 @@ is an `Arguments` object, which is a named tuple ``(args, kwargs)``.
|
|||
"""
|
||||
from __future__ import absolute_import, division, print_function, with_statement
|
||||
|
||||
import collections
|
||||
import functools
|
||||
import operator
|
||||
import sys
|
||||
|
@ -414,20 +415,4 @@ class Runner(object):
|
|||
else:
|
||||
return False
|
||||
|
||||
# in python 2.6+ this could be a collections.namedtuple
|
||||
|
||||
|
||||
class Arguments(tuple):
|
||||
"""The result of a yield expression whose callback had more than one
|
||||
argument (or keyword arguments).
|
||||
|
||||
The `Arguments` object can be used as a tuple ``(args, kwargs)``
|
||||
or an object with attributes ``args`` and ``kwargs``.
|
||||
"""
|
||||
__slots__ = ()
|
||||
|
||||
def __new__(cls, args, kwargs):
|
||||
return tuple.__new__(cls, (args, kwargs))
|
||||
|
||||
args = property(operator.itemgetter(0))
|
||||
kwargs = property(operator.itemgetter(1))
|
||||
Arguments = collections.namedtuple('Arguments', ['args', 'kwargs'])
|
||||
|
|
|
@ -87,7 +87,7 @@ def bind_sockets(port, address=None, family=socket.AF_UNSPEC, backlog=128, flags
|
|||
return sockets
|
||||
|
||||
if hasattr(socket, 'AF_UNIX'):
|
||||
def bind_unix_socket(file, mode=int('600', 8), backlog=128):
|
||||
def bind_unix_socket(file, mode=0o600, backlog=128):
|
||||
"""Creates a listening unix socket.
|
||||
|
||||
If a socket with the given name already exists, it will be deleted.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
------------
|
||||
|
||||
Instances of the following classes may be used in yield expressions
|
||||
in the generator.
|
||||
in the generator.
|
||||
|
||||
.. autoclass:: Task
|
||||
|
||||
|
@ -25,4 +25,10 @@
|
|||
Other classes
|
||||
-------------
|
||||
|
||||
.. autoclass:: Arguments
|
||||
.. class:: Arguments
|
||||
|
||||
The result of a yield expression whose callback had more than one
|
||||
argument (or keyword arguments).
|
||||
|
||||
The `Arguments` object can be used as a tuple ``(args, kwargs)``
|
||||
or an object with attributes ``args`` and ``kwargs``.
|
||||
|
|
Loading…
Reference in New Issue