0
My second argument is not printed ? anybody pls explain
5 Respuestas
+ 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.
+ 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 ().
+ 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)
+ 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?
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