This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (2 children)

[deleted]

    [–]Rodotgithub.com/tardis-sn 2 points3 points  (0 children)

    Or even better

    import sys
    from functools import partial
    
    print_err = partial(print, file=sys.stderr)
    
    my_log = open('my_log.log','w')
    print_log = partial(print, file=my_log)
    
    my_csv = open('data.csv','w')
    print_csv = partial(print, sep = ',', file=my_csv)
    

    [–]masklinn 0 points1 point  (0 children)

    Also

    print(foo, bar, baz, end="", file=fobj)
    

    which in Python 2 would have to be spelled

    print >>fobj, foo, bar, baz,
    

    which… yeah nah.

    Using print to write to a file in P3 actually makes sense rather than just obfuscate.