Python Forum
how hard is it to emulate print()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how hard is it to emulate print()
#1
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.
Reply
#2
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.
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Having a hard time conceptualizing how to print something MysticLord 6 3,124 Sep-19-2020, 10:43 PM
Last Post: MysticLord
  python3 emulate tail -f on remote server... support required anna 0 1,656 Jul-01-2020, 06:42 AM
Last Post: anna
  How hard is this? Phillips45 0 2,110 Jun-11-2018, 05:49 PM
Last Post: Phillips45

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020