[Biopython-dev] Question about "class _Argument(_AbstractParameter):"

Vincent Davis vincent at vincentdavis.net
Sat May 17 13:39:29 UTC 2014


I don't understand how self.value = None can ever be anything but None?
Which then leads me to wonder how the assert in _ArgumentList can ever pass
"assert isinstance(self.value, list)"
Probably something I don't understand about how arguments work with
subclasses.

Here is an example
>>> exp1 = _ArgumentList(["input_bam", "in_bam", "input", "bam"], "Input
BAM", >>> filename=True, is_required=True)
>>> print(exp1.value)
>>> print(exp1.names)
None

['input_bam', 'in_bam', 'input', 'bam']


But this will never work?

print(exp1)




class _Argument(_AbstractParameter):
    """Represent an argument on a commandline.

    The names argument should be a list containing one string.
    This must be a valid Python identifer as it is used as the
    property name and as a keyword argument, and should therefore
    follow PEP8 naming.
    """
    def __init__(self, names, description, filename=False,
                 checker_function=None, is_required=False):
        #if len(names) != 1:
        #    raise ValueError("The names argument to _Argument should be a "
        #                     "single entry list with a PEP8 property
name.")
        self.names = names
        assert isinstance(description, basestring), \
               "%r for %s" % (description, names[-1])
        self.is_filename = filename
        self.checker_function = checker_function
        self.description = description
        self.is_required = is_required
        self.is_set = False
        *self.value = None*

class _ArgumentList(_Argument):
    """Represent a variable list of arguments on a command line, e.g.
multiple filenames."""
    *def __str__(self):*
*        assert isinstance(self.value, list), \*
*                "Arguments should be a list"*
    ........

Vincent Davis
720-301-3003



More information about the Biopython-dev mailing list