@@ -2053,9 +2053,9 @@ class default(object):
2053
2053
>>> sd.default.reset()
2054
2054
2055
2055
"""
2056
- # The class attributes device, channels, dtype and latency are only
2057
- # provided here for static analysis tools and for the docs.
2058
- # They're overwritten in __init__().
2056
+ _pairs = ' device' , ' channels' , ' dtype' , ' latency' , 'extra_settings'
2057
+ # The class attributes listed in _pairs are only provided here for static
2058
+ # analysis tools and for the docs. They're overwritten in __init__().
2059
2059
device = None , None
2060
2060
"""Index or query string of default input/output device.
2061
2061
@@ -2112,7 +2112,6 @@ class default(object):
2112
2112
:func:`query_devices`
2113
2113
2114
2114
"""
2115
-
2116
2115
extra_settings = _default_extra_settings = None , None
2117
2116
"""Host-API-specific input/output settings.
2118
2117
@@ -2121,7 +2120,6 @@ class default(object):
2121
2120
AsioSettings, WasapiSettings
2122
2121
2123
2122
"""
2124
-
2125
2123
samplerate = None
2126
2124
"""Sampling frequency in Hertz (= frames per second).
2127
2125
@@ -2168,17 +2166,13 @@ class default(object):
2168
2166
"""
2169
2167
2170
2168
def __init__ (self ):
2171
- # __setattr__() must be avoided here
2172
- vars (self )['device' ] = _InputOutputPair (self , '_default_device' )
2173
- vars (self )['channels' ] = _InputOutputPair (self , '_default_channels' )
2174
- vars (self )['dtype' ] = _InputOutputPair (self , '_default_dtype' )
2175
- vars (self )['latency' ] = _InputOutputPair (self , '_default_latency' )
2176
- vars (self )['extra_settings' ] = _InputOutputPair (self ,
2177
- '_default_extra_settings' )
2169
+ for attr in self ._pairs :
2170
+ # __setattr__() must be avoided here
2171
+ vars (self )[attr ] = _InputOutputPair (self , '_default_' + attr )
2178
2172
2179
2173
def __setattr__ (self , name , value ):
2180
2174
"""Only allow setting existing attributes."""
2181
- if name in ( 'device' , 'channels' , 'dtype' , 'latency' ) :
2175
+ if name in _pairs :
2182
2176
getattr (self , name )._pair [:] = _split (value )
2183
2177
elif name in dir (self ) and name != 'reset' :
2184
2178
object .__setattr__ (self , name , value )
0 commit comments