This snippet defines a Print function which can be used with python 2.4, 2.5, 2.6 and 3.0 (for 3.0 this is just the built-in print function). It's interface is that of the python 3.0's print. It simplifies the task of writing transitional code which runs under python 2.5 and python 3.0.

# module cbprint
# (C) 2008 Gribouillis at

"""This module defines a Print function to use with python 2.x or 3.x.

  from cbprint import Print
  Print("hello", "world")

It's interface is that of python 3.0's print. See
__all__ = ["Print"]
import sys
  Print = eval("print") # python 3.0 case
except SyntaxError:
    D = dict()
    exec("from __future__ import print_function\np=print", D)
    Print = D["p"] # 2.6 case
    del D
  except SyntaxError:
    del D
    def Print(*args, **kwd): # 2.4, 2.5, define our own Print function
      fout = kwd.get("file", sys.stdout)
      w = fout.write
      if args:
        sep = kwd.get("sep", " ")
        for a in args[1:]:
      w(kwd.get("end", "\n"))
About the Author

Mind explorer.

where would you put this to have it as a built in function?
i have python 2.5 but it says python2.4.6 if that helps

@leegeorg07, you could make it built-in for the rest of the execution of your script by making it a part of the __builtins__ module by adding these lines at the end:

    import __builtin__   # use "builtins" in Python 3
    __builtin__.Print = Print

Although this practice is often frowned-up.

Gribouillis commented: good idea +13

@martineau you are knew to our forums, but we have a rule going on here: if the thread is older than 3 months, there's no need to resurface it. I'm not saying that your advice is bad. I'm just saying that @leegeorg07 posted his question 4 years ago, and I doubt he's still searching for an answer to it.

@Lucaci-Andrew, Yes I'm new to the forums and knew that @leegeorg07's message was old, but thought a reply was worthwhile mainly for any other folks who might stumble across the original code snippet and related thread as I myself did.

Lucaci Andrew commented: touché +6

As for my mistake, early in the morning.
As for your reply: this can be easily solved searching it through {insert your preferred search engine}.