0

My second argument is not printed ? anybody pls explain

https://code.sololearn.com/ceOqe24nEB77/?ref=app

23rd May 2023, 5:06 AM
Prafull Epili
Prafull Epili - avatar
5 Answers
+ 7
Prafull Epili , > print in python2 was not a function but a statement (keyword). > by using log - letters, numbers only the first argument will be available in the class.
23rd May 2023, 9:40 AM
Lothar
Lothar - avatar
+ 2
The one tutorial I found for creating custom statements in Python involves modifying the Python source code and recompiling it. I doubt anyone would go that far... so if you want comma separated arguments, you're stuck with function overrides and the inevitable ().
23rd May 2023, 9:54 AM
Bob_Li
Bob_Li - avatar
+ 1
try this: class Print: def __sub__(self,*data): print(*data) log = Print() pairs = [('a',1),('b',2),('c',3)] letters, numbers = zip(*pairs) log - (letters,numbers) why not just use: def log(*args): print(*args) log(letters,numbers)
23rd May 2023, 6:11 AM
Bob_Li
Bob_Li - avatar
+ 1
I think it's impossible. you can use an intermediate variable temp = letters,numbers log - temp but you're still converting to tuple implicitly. What's wrong with print()? The print statement was dropped for good reasons, imho. Evolution is inevitable. Or if you must, why not just use python2?
23rd May 2023, 6:34 AM
Bob_Li
Bob_Li - avatar
0
hi Bob_Li thanks for the reply but I don't want to use () that's the reason I created log - i am trying to create the python2 print function
23rd May 2023, 6:14 AM
Prafull Epili
Prafull Epili - avatar