This is what I'm doing:
from sys import stdin
value = stdin.readline()
I'm looking for a way to do this: (code doesn't work, I tried.)
from sys import stdin.readline as read
value = read()
Is there any way to achieve this? Or should I stick to using stdin.readline()
?
My only reason for needing this is readability (to me) and less code, and it is for only online competitive programming, not for production-level code, where I understand that it's better to be explicit.
You cannot import a method of an object ( stdin.readline
) separately from the object ( stdin
). Incidentally, stdin.readline()
is more readable than read()
because it explains from which source data is read.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.