Esempio n. 1
0
        /// <summary>
        ///     Returns a dictionary item from the current Python object
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public PyObject DictionaryItem(PyObject key)
        {
            if (!IsValid || key.IsNull)
            {
                return(PySharp.PyZero);
            }

            PyObject result;

            if (!_dictionaryCache.TryGetValue(key, out result))
            {
                result = new PyObject(_pySharp, Py.PyDict_GetItem(this, key), false);
                _dictionaryCache[key] = result;
            }
            return(result);
        }