CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 24 Jul 2025 21:48:10 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20110812115005
location: https://web.archive.org/web/20110812115005/https://wiki.python.org/moin/boost.python/WrappingEnums
server-timing: captures_list;dur=0.747247, exclusion.robots;dur=0.030277, exclusion.robots.policy;dur=0.014581, esindex;dur=0.015849, cdx.remote;dur=39.447203, LoadShardBlock;dur=479.323216, PetaboxLoader3.datanode;dur=198.250012, PetaboxLoader3.resolve;dur=173.545789
x-app-server: wwwb-app221
x-ts: 302
x-tr: 549
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app221; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 24 Jul 2025 21:48:11 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Fri, 12 Aug 2011 11:50:05 GMT
x-archive-orig-server: Apache/2.2.16 (Debian)
x-archive-orig-vary: Cookie,User-Agent,Accept-Language
x-archive-orig-set-cookie: MOIN_SESSION_80_ROOT_moin=aca5de646cbf0941e348287e8693fc9dd5f31877; expires=Fri, 12-Aug-2011 12:50:00 GMT; Max-Age=3600; Path=/
x-archive-orig-content-length: 12100
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Fri, 12 Aug 2011 11:50:05 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Tue, 10 Oct 2006 07:12:51 GMT", ; rel="prev memento"; datetime="Sat, 08 Dec 2007 10:35:37 GMT", ; rel="memento"; datetime="Fri, 12 Aug 2011 11:50:05 GMT", ; rel="next memento"; datetime="Sun, 15 Jan 2012 06:42:03 GMT", ; rel="last memento"; datetime="Wed, 14 Feb 2024 17:29:09 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: WPO-20110812113821-crawl438/WPO-20110812114457-01731.warc.gz
server-timing: captures_list;dur=0.562986, exclusion.robots;dur=0.027964, exclusion.robots.policy;dur=0.015071, esindex;dur=0.015881, cdx.remote;dur=41.466372, LoadShardBlock;dur=187.921671, PetaboxLoader3.datanode;dur=224.381097, PetaboxLoader3.resolve;dur=620.805178, load_resource;dur=717.781158
x-app-server: wwwb-app221
x-ts: 200
x-tr: 999
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
boost.python/WrappingEnums - PythonInfo Wiki
User
For example, let's define an object in module namespace to represent enum:
#include <boost/python.hpp> using namespace boost::python; enum color { red = 1, green = 2, blue = 4 }; color identity_(color x) { return x; } BOOST_PYTHON_MODULE(enum_ext) { enum_<color>("color") .value("red", red) .value("green", green) .value("blue", blue) ; def("identity", identity_); }
The usage is follows:
>>> from enum_ext import * >>> identity(color.red) enum_ext.color.red >>> identity(color.green) enum_ext.color.green >>> identity(color.blue) enum_ext.color.blue >>> identity(color(1)) enum_ext.color.red >>> identity(color(2)) enum_ext.color.green >>> identity(color(3)) enum_ext.color(3) >>> identity(color(4)) enum_ext.color.blue >>> try: identity(1) ... except TypeError: pass ... else: print 'expected a TypeError'
boost.python/WrappingEnums (last edited 2008-11-15 14:01:18 by localhost)