idx可为负 idx can be negative
(self, idx, *outputs)
| 1880 | |
| 1881 | @safely_destruct_output_when_exp('outputs') |
| 1882 | def insert(self, idx, *outputs): |
| 1883 | """ |
| 1884 | idx可为负 |
| 1885 | idx can be negative |
| 1886 | """ |
| 1887 | direction = 1 if idx >= 0 else -1 |
| 1888 | for acc, o in enumerate(outputs): |
| 1889 | if not isinstance(o, Output): |
| 1890 | o = put_text(o) |
| 1891 | o.spec['scope'] = scope2dom(self.scope) |
| 1892 | o.spec['position'] = idx + direction * acc |
| 1893 | o.send() |
| 1894 | |
| 1895 | contents = [c if isinstance(c, Output) else put_text(c) for c in contents] |
| 1896 |