Get an attribute off the `socket` module, or use a default.
(attr, default)
| 127 | |
| 128 | |
| 129 | def sgetattr(attr, default): |
| 130 | """Get an attribute off the `socket` module, or use a default.""" |
| 131 | sentinel = object() |
| 132 | result = getattr(socket, attr, sentinel) |
| 133 | if result is sentinel: |
| 134 | print("socket.%s does not exist" % attr) |
| 135 | return default |
| 136 | else: |
| 137 | print("socket.%s = %r" % (attr, result)) |
| 138 | return result |
| 139 | |
| 140 | |
| 141 | @check |
no outgoing calls
no test coverage detected
searching dependent graphs…