import re


def parse_py(s, **kwargs):
    """Parse a string into a (nbformat, string) tuple."""
    pattern = r'# <nbformat>(?P<nbformat>\d+)</nbformat>'
    m = re.search(pattern,s)
    if m is not None:
        nbformat = int(m.group('nbformat'))
    else:
        nbformat = 2
    return nbformat, s