(aPyCollection, conversionHelper=None)
Convert a Python collection (dict, list, tuple, string) into an
    Objective-C collection.

    If conversionHelper is defined, it must be a callable.  It will be called
    for any object encountered for which propertyListFromPythonCollection()
    cannot automatically convert the object.   The supplied helper function
    should convert the object and return the converted form.  If the conversion
    helper cannot convert the type, it should raise an exception or return
    None.
Convert a Python collection (dict, list, tuple, string) into an
    Objective-C collection.
Convert a Python collection ( dict list tuple string ) into an Objective - C collection .
def propertyListFromPythonCollection(aPyCollection, conversionHelper=None):
    """
    Convert a Python collection (dict, list, tuple, string) into an
    Objective-C collection.

    If conversionHelper is defined, it must be a callable.  It will be called
    for any object encountered for which propertyListFromPythonCollection()
    cannot automatically convert the object.   The supplied helper function
    should convert the object and return the converted form.  If the conversion
    helper cannot convert the type, it should raise an exception or return
    None.
    """
    if isinstance(aPyCollection, dict):
        collection = Foundation.NSMutableDictionary.dictionary()
        for aKey in aPyCollection:
            if not isinstance(aKey, basestring):
                raise TypeError("Property list keys must be strings")
            convertedValue = propertyListFromPythonCollection(
                aPyCollection[aKey], conversionHelper=conversionHelper)
            collection[aKey] = convertedValue
        return collection
    elif isinstance(aPyCollection, (list, tuple)):
        collection = Foundation.NSMutableArray.array()
        for aValue in aPyCollection:
            convertedValue = propertyListFromPythonCollection(aValue,
                conversionHelper=conversionHelper)
            collection.append(aValue)
        return collection
    elif isinstance(aPyCollection, (datetime.datetime, datetime.date)):
        return Foundation.NSDate.dateWithTimeIntervalSince1970_(
            time.mktime(aPyCollection.timetuple()))
    elif decimal is not None and isinstance(aPyCollection, decimal.Decimal):
        return fromPythonDecimal(aPyCollection)
    elif isinstance(aPyCollection, PYTHON_TYPES):
        # bridge will convert
        return aPyCollection
    elif conversionHelper is not None:
        return conversionHelper(aPyCollection)
    raise TypeError("Type '%s' encountered in Python collection; don't know how to convert." % type(aPyCollection))
def propertyListFromPythonCollection ( aPyCollection , conversionHelper = None ) : if isinstance ( aPyCollection , dict ) : collection = Foundation . NSMutableDictionary . dictionary ( ) for aKey in aPyCollection : if not isinstance ( aKey , basestring ) : raise TypeError ( "Property list keys must be strings" ) convertedValue = propertyListFromPythonCollection ( aPyCollection [ aKey ] , conversionHelper = conversionHelper ) collection [ aKey ] = convertedValue return collection elif isinstance ( aPyCollection , ( list , tuple ) ) : collection = Foundation . NSMutableArray . array ( ) for aValue in aPyCollection : convertedValue = propertyListFromPythonCollection ( aValue , conversionHelper = conversionHelper ) collection . append ( aValue ) return collection elif isinstance ( aPyCollection , ( datetime . datetime , datetime . date ) ) : return Foundation . NSDate . dateWithTimeIntervalSince1970_ ( time . mktime ( aPyCollection . timetuple ( ) ) ) elif decimal is not None and isinstance ( aPyCollection , decimal . Decimal ) : return fromPythonDecimal ( aPyCollection ) elif isinstance ( aPyCollection , PYTHON_TYPES ) : # bridge will convert return aPyCollection elif conversionHelper is not None : return conversionHelper ( aPyCollection ) raise TypeError ( "Type '%s' encountered in Python collection; don't know how to convert." % type ( aPyCollection ) )