简体   繁体   中英

What is positional argument follows keyword argument?

I received the following error:

  File "ex01", line 15
    download(urlbase=dna[0], str) and \
                             ^
SyntaxError: positional argument follows keyword argument

This is my code

class Gene(object):
    def __init__(self, dna, exon_regions):
        """
        dna: string or (urlbase, filename) tuple
        exon_regions: None, list of (start, end) tuples or (urlbase, filename) tuple
        In case of (urlbase, filename) tuple the file is downloaded and read.
        """
        if isinstance(dna, (list, tuple)) and \
                len(dna) == 2 and isinstance(dna[0], str) and \
                isinstance(dna[1], str):
                    download(urlbase=dna[0], str) and \
                            dna = read_dnafile(dna[1])
        elif isinstance(dna, str):
            pass
        else:
            raise TypeError(
                    'dna=%s is not string or (urlbase, filename) '\
                            'tuple' %(dna, type(dna)))
            self._dna = dna

Can you please explain what is wrong with the code?

I received the following error:

  File "ex01", line 15
    download(urlbase=dna[0], str) and \
                             ^
SyntaxError: positional argument follows keyword argument

This is my code

class Gene(object):
    def __init__(self, dna, exon_regions):
        """
        dna: string or (urlbase, filename) tuple
        exon_regions: None, list of (start, end) tuples or (urlbase, filename) tuple
        In case of (urlbase, filename) tuple the file is downloaded and read.
        """
        if isinstance(dna, (list, tuple)) and \
                len(dna) == 2 and isinstance(dna[0], str) and \
                isinstance(dna[1], str):
                    download(urlbase=dna[0], str) and \
                            dna = read_dnafile(dna[1])
        elif isinstance(dna, str):
            pass
        else:
            raise TypeError(
                    'dna=%s is not string or (urlbase, filename) '\
                            'tuple' %(dna, type(dna)))
            self._dna = dna

Can you please explain what is wrong with the code?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM