
import sys


def unicodify(obj, encoding = "utf-8"):
    if isinstance(obj, basestring):
        if not isinstance(obj, unicode):
            object = unicode(obj, encoding)
    return obj


def p(*args, **kw):
    """Rough implementation of the Python 3 print function,
    http://www.python.org/dev/peps/pep-3105/

    def print(*args, sep=' ', end='\n', file=None)

    """
    kw.setdefault('encoding', 'utf-8')
    kw.setdefault('sep', ' ')
    kw.setdefault('end', '\n')
    kw.setdefault('file', sys.stdout)

    new_args = []
    for x in args:
        if not isinstance(x, basestring):
            new_args.append(repr(x))
        else:
            new_args.append(x)

    out = kw['sep'].join(x.encode(kw['encoding']) for x in new_args)

    kw['file'].write(out + kw['end'])


import sys


def unicodify(obj, encoding = "utf-8"):
    if isinstance(obj, basestring):
        if not isinstance(obj, unicode):
            object = unicode(obj, encoding)
    return obj


def p(*args, **kw):
    """Rough implementation of the Python 3 print function,
    http://www.python.org/dev/peps/pep-3105/

    def print(*args, sep=' ', end='\n', file=None)

    """
    kw.setdefault('encoding', 'utf-8')
    kw.setdefault('sep', ' ')
    kw.setdefault('end', '\n')
    kw.setdefault('file', sys.stdout)

    new_args = []
    for x in args:
        if not isinstance(x, basestring):
            new_args.append(repr(x))
        else:
            if kw['encoding'] is not None:
                new_args.append(x.encode(kw['encoding']))
            else:
                new_args.append(x)

    out = kw['sep'].join(new_args)

    kw['file'].write(out + kw['end'])

Support "encoding = None" argument
Support "encoding = None" argument
  
  import sys
  
  
  def unicodify(obj, encoding = "utf-8"):
      if isinstance(obj, basestring):
          if not isinstance(obj, unicode):
              object = unicode(obj, encoding)
      return obj
  
  
  def p(*args, **kw):
      """Rough implementation of the Python 3 print function,
      http://www.python.org/dev/peps/pep-3105/
  
      def print(*args, sep=' ', end='\n', file=None)
  
      """
      kw.setdefault('encoding', 'utf-8')
      kw.setdefault('sep', ' ')
      kw.setdefault('end', '\n')
      kw.setdefault('file', sys.stdout)
  
      new_args = []
      for x in args:
          if not isinstance(x, basestring):
              new_args.append(repr(x))
          else:
+             if kw['encoding'] is not None:
+                 new_args.append(x.encode(kw['encoding']))
+             else:
-             new_args.append(x)
+                 new_args.append(x)
  
-     out = kw['sep'].join(x.encode(kw['encoding']) for x in new_args)
+     out = kw['sep'].join(new_args)
  
      kw['file'].write(out + kw['end'])
  
Support "encoding = None" argument
## Code Before:

import sys


def unicodify(obj, encoding = "utf-8"):
    if isinstance(obj, basestring):
        if not isinstance(obj, unicode):
            object = unicode(obj, encoding)
    return obj


def p(*args, **kw):
    """Rough implementation of the Python 3 print function,
    http://www.python.org/dev/peps/pep-3105/

    def print(*args, sep=' ', end='\n', file=None)

    """
    kw.setdefault('encoding', 'utf-8')
    kw.setdefault('sep', ' ')
    kw.setdefault('end', '\n')
    kw.setdefault('file', sys.stdout)

    new_args = []
    for x in args:
        if not isinstance(x, basestring):
            new_args.append(repr(x))
        else:
            new_args.append(x)

    out = kw['sep'].join(x.encode(kw['encoding']) for x in new_args)

    kw['file'].write(out + kw['end'])

## Instruction:
Support "encoding = None" argument
## Code After:

import sys


def unicodify(obj, encoding = "utf-8"):
    if isinstance(obj, basestring):
        if not isinstance(obj, unicode):
            object = unicode(obj, encoding)
    return obj


def p(*args, **kw):
    """Rough implementation of the Python 3 print function,
    http://www.python.org/dev/peps/pep-3105/

    def print(*args, sep=' ', end='\n', file=None)

    """
    kw.setdefault('encoding', 'utf-8')
    kw.setdefault('sep', ' ')
    kw.setdefault('end', '\n')
    kw.setdefault('file', sys.stdout)

    new_args = []
    for x in args:
        if not isinstance(x, basestring):
            new_args.append(repr(x))
        else:
            if kw['encoding'] is not None:
                new_args.append(x.encode(kw['encoding']))
            else:
                new_args.append(x)

    out = kw['sep'].join(new_args)

    kw['file'].write(out + kw['end'])
