Esempio n. 1
0
        /// <summary>
        ///     Returns an attribute from the current Python object
        /// </summary>
        /// <param name="attribute"></param>
        /// <returns></returns>
        public PyObject Attribute(string attribute)
        {
            if (!IsValid || string.IsNullOrEmpty(attribute))
            {
                return(PySharp.PyZero);
            }

            PyObject result;

            if (!_attributeCache.TryGetValue(attribute, out result))
            {
                result = new PyObject(_pySharp, Py.PyObject_GetAttrString(this, attribute), true);
                _attributeCache[attribute] = result;
            }
            return(result);
        }