Generating a list of None

Nicolas Couture nicolas.couture at gmail.com
Thu Jul 14 22:25:41 EDT 2005


Hi,

Is it possible to generate a list of `None' ?

opts.__dict__.values() below could be represented by [None, None, None]

---
def get_options(opts):
    """Return True or False if an option is set or not"""
    vals = opts.__dict__.values()

    for val in vals:
        if val is not None:
            return True

    return False
---

This is how I'd like to see it:

---
def get_options(opts):
    """Return True or False if an option is set or not"""
    vals = opts.__dict__.values()

    for if vals is [None * len(vals)]:
        return False

    return True
---




More information about the Python-list mailing list