Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards


Header <boost/python/dict.hpp>


Class dict
Class dict synopsis


Exposes a TypeWrapper for the Python dict type.


Class dict

Exposes the mapping protocol of Python's built-in dict type. The semantics of the constructors and member functions defined below can be fully understood by reading the TypeWrapper concept definition. Since dict is publicly derived from object, the public object interface applies to dict instances as well.

Class dict synopsis

namespace boost { namespace python
   class dict : public object

      template< class T >
      dict(T const & data);

      // modifiers
      void clear();
      dict copy();

      template <class T1, class T2>
      tuple popitem();

      template <class T>
      object setdefault(T const &k);

      template <class T1, class T2>
      object setdefault(T1 const & k, T2 const & d);

      void update(object_cref E);
      template< class T >
      void update(T const & E);

      // observers
      list values() const;
      object get(object_cref k) const;

      template<class T>
      object get(T const & k) const;

      object get(object_cref k, object_cref d) const;
      object get(T1 const & k, T2 const & d) const;

      bool has_key(object_cref k) const;

      template< class T >
      bool has_key(T const & k) const;

      list items() const;
      object iteritems() const;
      object iterkeys() const;
      object itervalues() const;
      list keys() const;


using namespace boost::python;
dict swap_object_dict(object target, dict d)
    dict result = extract<dict>(target.attr("__dict__"));
    target.attr("__dict__") = d;
    return result;

Revised 30 September, 2002

© Copyright Dave Abrahams 2002.