Creates a string representation that will invoke the specified object, with the specified arguments. Args: type_str (str): A string representing the object that should be invoked. args, kwargs: Arguments to pass along to the object. If a keyword argument
(type_str, *args, **kwargs)
| 123 | |
| 124 | @mod.export() |
| 125 | def make_invocable(type_str, *args, **kwargs): |
| 126 | """ |
| 127 | Creates a string representation that will invoke the specified object, |
| 128 | with the specified arguments. |
| 129 | |
| 130 | Args: |
| 131 | type_str (str): A string representing the object that should be invoked. |
| 132 | args, kwargs: |
| 133 | Arguments to pass along to the object. If a keyword argument |
| 134 | is set to None, it will be omitted. |
| 135 | |
| 136 | Returns: |
| 137 | str: A string representation that invokes the object specified. |
| 138 | |
| 139 | For example: |
| 140 | :: |
| 141 | |
| 142 | >>> make_invocable("MyClass", 0, 1, last=3) |
| 143 | "MyClass(0, 1, last=3)" |
| 144 | |
| 145 | >>> make_invocable("my_func", 0, 1, last=None) |
| 146 | "my_func(0, 1)" |
| 147 | """ |
| 148 | return make_invocable_impl(type_str, *args, **kwargs)[0] |
| 149 | |
| 150 | |
| 151 | @mod.export() |