On Tue, 17 Oct 2023 at 12:55, Bongo Ferno via Python-list <python-list@python.org> wrote: > > Where I can ask python developers for a new feature? > > This feature would allow us to create short aliases for long object paths, > similar to the with statement. This would make code more readable and > maintainable. > > For example, if we have a long object like > "MyObject.stuff.longStuff.SubObject", we could create a short alias for it > like this: > > > aliasView my_object.stuff.long_stuff.sub_object as short_view > #Now, we can operate with the nested object using the short alias: > print(short_view.some_method()) > > This is much more concise and readable than having to write out the full > object path every time. >
You can actually just do that with simple assignment! short_view = my_object.stuff.long_stuff.sub_object print(short_view.some_method()) It'll work! ChrisA -- https://mail.python.org/mailman/listinfo/python-list