On Wednesday, February 15, 2017 at 2:52:55 AM UTC-8, Antoon Pardon wrote: > Op 15-02-17 om 07:28 schreef Steven D'Aprano:
> > E.g. http://code.activestate.com/recipes/580750 > > > > does nothing more that define > > > > echo = sys.stdout.write > > > > Why not use sys.stdout.write directly? Or print? If I saw somebody using > > this recipe in production code, in the way shown, I'd refactor it to just > > use print. There's no advantage to re-inventing the wheel this way. > > On reason to use this is for some easy "logging", you use echo to help > in debugging and afterwards you can either define echo as an empty > function or something easy to find to comment out. > > -- > Antoon Pardon. Agreed, I have done things like this myself, but within functions, not at the global level. The "echo" name could be assigned to some other function elsewhere in the code. I use the name reassignment to direct the function's logging information -- to a console, to a GUI, or to "/dev/null" by creating an empty function. -- https://mail.python.org/mailman/listinfo/python-list