It's been a while since I programmed regularly in C++, but I thought the right shift operator is for input (stream insertion). Also the python function for right shift is __rshift__() not __rrshift__(). It would be hard to do input like in C++ but since we are playing code golf:
class Cppio:
def __lshift__(self, other):
print(other, end="")
return self
def __rshift__(self, var):
var.append(input())
return self
class Endl:
def __str__(self):
return "\n"
class Mylist(list):
def __repr__(self):
return self[0]
cout = Cppio()
cin = Cppio()
endl = Endl()
somevar = Mylist()
cout << "C++ printing in python" << endl
cin >> somevar
cout << somevar << endl
$ python cout.py
C++ printing in python
C++ input in python
C++ input in python
2
u/random_cynic Nov 12 '19
It's been a while since I programmed regularly in C++, but I thought the right shift operator is for input (stream insertion). Also the python function for right shift is
__rshift__()not__rrshift__(). It would be hard to do input like in C++ but since we are playing code golf:I need a shower.