Python 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
DreamPie 1.2.1
>>> def mymap(xs, fn):
... return [fn(x) for x in xs]
>>> mymap('abc', ord)
0: [97, 98, 99]
>>> mymap('abc')
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
mymap('abc')
~~~~~^^^^^^^
TypeError: mymap() missing 1 required positional argument: 'fn'
>>> def mymap(xs, fn=...):
... return [fn(x) for x in xs]
>>> mymap('abc')
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
mymap('abc')
~~~~~^^^^^^^
File "<pyshell#3>", line 2, in mymap
return [fn(x) for x in xs]
~~^^^
TypeError: 'ellipsis' object is not callable
>>> def mymap(xs, fn=lambda x: x):
... return [fn(x) for x in xs]
>>> mymap('abc')
1: ['a', 'b', 'c']
>>> mymap('abc', ord)
2: [97, 98, 99]
>>> mymap('abc', lambda x: chr(ord(x) - 32))
3: ['A', 'B', 'C']
>>> def fn(a, b):
... assert type(a) == str
... assert type(b) == str
... return a + b
>>> fn('abc', 'ABC')
4: 'abcABC'
>>> fn(123, 456)
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
fn(123, 456)
~~^^^^^^^^^^
File "<pyshell#9>", line 2, in fn
assert type(a) == str
^^^^^^^^^^^^^^
AssertionError
>>> fn.__annotations__
5: {}
>>> def fn(a: str, b:str):
... assert type(a) == str
... assert type(b) == str
... return a + b
>>> fn.__annotations__
6: {'a': <class 'str'>, 'b': <class 'str'>}
>>> def fn(a: str, b:str) -> str:
... assert type(a) == str
... assert type(b) == str
... return a + b
>>> fn.__annotations__
7: {'a': <class 'str'>, 'b': <class 'str'>, 'return': <class 'str'>}
>>> def fn(a: (str, 666), b:'Haf!') -> 'blabla':
... assert type(a) == str
... assert type(b) == str
... return a + b
>>> fn.__annotations__
8: {'a': (<class 'str'>, 666), 'b': 'Haf!', 'return': 'blabla'}
>>> for x in range(5): print(x); print(x**2)
0
0
1
1
2
4
3
9
4
16
>>> for x in range(5): print(x)
... print(x**2)
0
1
2
3
4
16
>>>
...
>>> for x in range(5):
... print(x)
... print(x**2)
0
0
1
1
2
4
3
9
4
16
>>> for x in range(5):
... print(x)
... print(x**2)
0
1
2
3
4
16
>>> printf = print
>>> for x in range(5):
... printf(x)
... printf(x**2)
0
1
2
3
4
16
>>>