nl: call the method apps.setdefault with 2 arguments: pattern and an empty list, append to the resulting object pattern.namespace.
code: apps . setdefault ( pattern . app_name , [ ] ) . append ( pattern . namespace )