org.python.core

Class PyDictionary

public class PyDictionary extends PyObject

A builtin python dictionary.
Field Summary
static Stringexposed_name
Constructor Summary
PyDictionary()
Create an empty dictionary.
PyDictionary(PyType subtype)
For derived types
PyDictionary(Hashtable t)
Create an new dictionary which is based on the hashtable.
PyDictionary(PyObject[] elements)
Create a new dictionary with the element as content.
Method Summary
voidclear()
Remove all items from the dictionary.
PyDictionarycopy()
Return a shallow copy of the dictionary.
PyObjectfromkeys(PyObject keys)
PyObjectfromkeys(PyObject keys, PyObject value)
PyObjectget(PyObject key, PyObject default_object)
Return this[key] if the key exists in the mapping, default_object is returned otherwise.
PyObjectget(PyObject key)
Return this[key] if the key exists in the mapping, None is returned otherwise.
inthashCode()
booleanhas_key(PyObject key)
Return true if the key exist in the dictionary.
booleanisSequenceType()
PyListitems()
Return a copy of the dictionarys list of (key, value) tuple pairs.
PyObjectiteritems()
Return an interator over (key, value) pairs.
PyObjectiterkeys()
Return an interator over (key, value) pairs.
PyObjectitervalues()
Return an interator over (key, value) pairs.
PyListkeys()
Return a copy of the dictionarys list of keys.
PyObjectpop(PyObject key)
Return a value based on key from the dictionary.
PyObjectpop(PyObject key, PyObject defaultValue)
Return a value based on key from the dictionary or default if that key is not found.
PyObjectpopitem()
Return a random (key, value) tuple pair and remove the pair from the dictionary.
PyObjectsetdefault(PyObject key)
Return this[key] if the key exist, otherwise insert key with a None value and return None.
PyObjectsetdefault(PyObject key, PyObject failobj)
Return this[key] if the key exist, otherwise insert key with the value of failobj and return failobj
StringtoString()
static voidtypeSetup(PyObject dict, PyType.Newstyle marker)
voidupdate(PyObject d)
Insert all the key:value pairs from d into this dictionary.
PyListvalues()
Return a copy of the dictionarys list of values.
int__cmp__(PyObject ob_other)
void__delitem__(PyObject key)
PyObject__eq__(PyObject ob_other)
PyObject__finditem__(int index)
PyObject__finditem__(PyObject key)
PyObject__iter__()
int__len__()
PyObject__ne__(PyObject ob_other)
boolean__nonzero__()
void__setitem__(PyObject key, PyObject value)

Field Detail

exposed_name

public static final String exposed_name

Constructor Detail

PyDictionary

public PyDictionary()
Create an empty dictionary.

PyDictionary

public PyDictionary(PyType subtype)
For derived types

Parameters: subtype

PyDictionary

public PyDictionary(Hashtable t)
Create an new dictionary which is based on the hashtable.

Parameters: t the hashtable used. The supplied hashtable is used as is and must only contain PyObject key:value pairs.

PyDictionary

public PyDictionary(PyObject[] elements)
Create a new dictionary with the element as content.

Parameters: elements The initial elements that is inserted in the dictionary. Even numbered elements are keys, odd numbered elements are values.

Method Detail

clear

public void clear()
Remove all items from the dictionary.

copy

public PyDictionary copy()
Return a shallow copy of the dictionary.

fromkeys

public PyObject fromkeys(PyObject keys)

fromkeys

public PyObject fromkeys(PyObject keys, PyObject value)

get

public PyObject get(PyObject key, PyObject default_object)
Return this[key] if the key exists in the mapping, default_object is returned otherwise.

Parameters: key the key to lookup in the dictionary. default_object the value to return if the key does not exists in the mapping.

get

public PyObject get(PyObject key)
Return this[key] if the key exists in the mapping, None is returned otherwise.

Parameters: key the key to lookup in the dictionary.

hashCode

public int hashCode()

has_key

public boolean has_key(PyObject key)
Return true if the key exist in the dictionary.

isSequenceType

public boolean isSequenceType()

items

public PyList items()
Return a copy of the dictionarys list of (key, value) tuple pairs.

iteritems

public PyObject iteritems()
Return an interator over (key, value) pairs.

iterkeys

public PyObject iterkeys()
Return an interator over (key, value) pairs.

itervalues

public PyObject itervalues()
Return an interator over (key, value) pairs.

keys

public PyList keys()
Return a copy of the dictionarys list of keys.

pop

public PyObject pop(PyObject key)
Return a value based on key from the dictionary.

pop

public PyObject pop(PyObject key, PyObject defaultValue)
Return a value based on key from the dictionary or default if that key is not found.

popitem

public PyObject popitem()
Return a random (key, value) tuple pair and remove the pair from the dictionary.

setdefault

public PyObject setdefault(PyObject key)
Return this[key] if the key exist, otherwise insert key with a None value and return None.

Parameters: key the key to lookup in the dictionary.

setdefault

public PyObject setdefault(PyObject key, PyObject failobj)
Return this[key] if the key exist, otherwise insert key with the value of failobj and return failobj

Parameters: key the key to lookup in the dictionary. failobj the default value to insert in the dictionary if key does not already exist.

toString

public String toString()

typeSetup

public static void typeSetup(PyObject dict, PyType.Newstyle marker)

update

public void update(PyObject d)
Insert all the key:value pairs from d into this dictionary.

values

public PyList values()
Return a copy of the dictionarys list of values.

__cmp__

public int __cmp__(PyObject ob_other)

__delitem__

public void __delitem__(PyObject key)

__eq__

public PyObject __eq__(PyObject ob_other)

__finditem__

public PyObject __finditem__(int index)

__finditem__

public PyObject __finditem__(PyObject key)

__iter__

public PyObject __iter__()

__len__

public int __len__()

__ne__

public PyObject __ne__(PyObject ob_other)

__nonzero__

public boolean __nonzero__()

__setitem__

public void __setitem__(PyObject key, PyObject value)