

import re
import sys
try:
    from html.entities import name2codepoint
except ImportError:
    from htmlentitydefs import name2codepoint

def htmlentitydecode(s):
    return re.sub(
        '&(%s);' % '|'.join(name2codepoint),
        lambda m: unichr(name2codepoint[m.group(1)]), s)

def smrt_input(globals_, locals_, ps1=">>> ", ps2="... "):
    inputs = []
    while True:
        if inputs:
            prompt = ps2
        else:
            prompt = ps1
        inputs.append(input(prompt))
        try:
            ret = eval('\n'.join(inputs), globals_, locals_)
            if ret:
                print(str(ret))
            return
        except SyntaxError:
            pass

def printNicely(string):
    if hasattr(sys.stdout, 'buffer'):
        sys.stdout.buffer.write(string.encode('utf8'))
        print()
    else:
        print(string.encode('utf8'))

__all__ = ["htmlentitydecode", "smrt_input"]



import re
import sys
try:
    from html.entities import name2codepoint
    unichr = chr
except ImportError:
    from htmlentitydefs import name2codepoint

def htmlentitydecode(s):
    return re.sub(
        '&(%s);' % '|'.join(name2codepoint),
        lambda m: unichr(name2codepoint[m.group(1)]), s)

def smrt_input(globals_, locals_, ps1=">>> ", ps2="... "):
    inputs = []
    while True:
        if inputs:
            prompt = ps2
        else:
            prompt = ps1
        inputs.append(input(prompt))
        try:
            ret = eval('\n'.join(inputs), globals_, locals_)
            if ret:
                print(str(ret))
            return
        except SyntaxError:
            pass

def printNicely(string):
    if hasattr(sys.stdout, 'buffer'):
        sys.stdout.buffer.write(string.encode('utf8'))
        print()
    else:
        print(string.encode('utf8'))

__all__ = ["htmlentitydecode", "smrt_input"]

Set unichr = chr for Python 3.
Set unichr = chr for Python 3.

  
  
  import re
  import sys
  try:
      from html.entities import name2codepoint
+     unichr = chr
  except ImportError:
      from htmlentitydefs import name2codepoint
  
  def htmlentitydecode(s):
      return re.sub(
          '&(%s);' % '|'.join(name2codepoint),
          lambda m: unichr(name2codepoint[m.group(1)]), s)
  
  def smrt_input(globals_, locals_, ps1=">>> ", ps2="... "):
      inputs = []
      while True:
          if inputs:
              prompt = ps2
          else:
              prompt = ps1
          inputs.append(input(prompt))
          try:
              ret = eval('\n'.join(inputs), globals_, locals_)
              if ret:
                  print(str(ret))
              return
          except SyntaxError:
              pass
  
  def printNicely(string):
      if hasattr(sys.stdout, 'buffer'):
          sys.stdout.buffer.write(string.encode('utf8'))
          print()
      else:
          print(string.encode('utf8'))
  
  __all__ = ["htmlentitydecode", "smrt_input"]
  
Set unichr = chr for Python 3.
## Code Before:


import re
import sys
try:
    from html.entities import name2codepoint
except ImportError:
    from htmlentitydefs import name2codepoint

def htmlentitydecode(s):
    return re.sub(
        '&(%s);' % '|'.join(name2codepoint),
        lambda m: unichr(name2codepoint[m.group(1)]), s)

def smrt_input(globals_, locals_, ps1=">>> ", ps2="... "):
    inputs = []
    while True:
        if inputs:
            prompt = ps2
        else:
            prompt = ps1
        inputs.append(input(prompt))
        try:
            ret = eval('\n'.join(inputs), globals_, locals_)
            if ret:
                print(str(ret))
            return
        except SyntaxError:
            pass

def printNicely(string):
    if hasattr(sys.stdout, 'buffer'):
        sys.stdout.buffer.write(string.encode('utf8'))
        print()
    else:
        print(string.encode('utf8'))

__all__ = ["htmlentitydecode", "smrt_input"]

## Instruction:
Set unichr = chr for Python 3.
## Code After:


import re
import sys
try:
    from html.entities import name2codepoint
    unichr = chr
except ImportError:
    from htmlentitydefs import name2codepoint

def htmlentitydecode(s):
    return re.sub(
        '&(%s);' % '|'.join(name2codepoint),
        lambda m: unichr(name2codepoint[m.group(1)]), s)

def smrt_input(globals_, locals_, ps1=">>> ", ps2="... "):
    inputs = []
    while True:
        if inputs:
            prompt = ps2
        else:
            prompt = ps1
        inputs.append(input(prompt))
        try:
            ret = eval('\n'.join(inputs), globals_, locals_)
            if ret:
                print(str(ret))
            return
        except SyntaxError:
            pass

def printNicely(string):
    if hasattr(sys.stdout, 'buffer'):
        sys.stdout.buffer.write(string.encode('utf8'))
        print()
    else:
        print(string.encode('utf8'))

__all__ = ["htmlentitydecode", "smrt_input"]
