-
Notifications
You must be signed in to change notification settings - Fork 235
Open
Description
In the default pattern
import zeroconf
instance = zeroconf.Zeroconf()
browser = zeroconf.ServiceBrowser(
instance,
['_osc._udp.local.'],
handlers=[handler]
)
def handler(zeroconf, service_type, name, state_change):
# I cannot use zeroconf.ServiceStateChange.Added here, because zeroconf is not the import but the argument
passwe have the problem that handler() is receiving a named argument zeroconf that overloads import zeroconf and that we cannot change. If I defined
def handler(zc, service_type, name, state_change):
if state_change is zeroconf.ServiceStateChange.Added:
print(name)I would receive
TypeError: handler() got an unexpected keyword argument 'zeroconf'
To avoid it I would have to alias the import, which is a bit ugly:
import zeroconf as imported_zeroconf
def handler(zeroconf, service_type, name, state_change):
if state_change is imported_zeroconf.ServiceStateChange.Added:
print(name)It would be nice if the arguments were to be passed in as positional arguments, or named differently, so that the names didn't clash.
Metadata
Metadata
Assignees
Labels
No labels