Posts: 4,558
Threads: 1,463
Joined: Sep 2016
how hard is it to emulate the print() function? i have a thing which i want code to be made like it is printing. but the thing gets the lines that be printed and goes things with it. or should i use that thing that lets you print to a string (is it a generator)?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 544
Threads: 15
Joined: Oct 2016
Not hard to emulate print.
import time
from sys import stdout, version_info
V = version_info
def tick():
if V.major == 3 and V.minor > 2:
return time.perf_counter()
else:
return time.clock()
def main():
string_buffer = list('Printing')
intervals = 0.2
clock = intervals + tick()
while len(string_buffer):
if tick() > clock:
stdout.write(string_buffer.pop(0))
stdout.flush()
clock += intervals
main()
99 percent of computer problems exists between chair and keyboard.
Posts: 4,558
Threads: 1,463
Joined: Sep 2016
what is that code supposed to do?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.