CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 31 Jul 2025 04:02:53 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20120115064203
location: https://web.archive.org/web/20120115064203/https://wiki.python.org/moin/boost.python/WrappingEnums
server-timing: captures_list;dur=0.663117, exclusion.robots;dur=0.018251, exclusion.robots.policy;dur=0.007246, esindex;dur=0.012558, cdx.remote;dur=28.280915, LoadShardBlock;dur=311.112507, PetaboxLoader3.datanode;dur=101.014082, PetaboxLoader3.resolve;dur=128.443947
x-app-server: wwwb-app239
x-ts: 302
x-tr: 589
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
set-cookie: SERVER=wwwb-app239; 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, 31 Jul 2025 04:02:54 GMT
content-type: text/html; charset=utf-8
x-archive-orig-date: Sun, 15 Jan 2012 06:41:37 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=9fbd66ed103f208ad191b8cdcfdd068fdebe41af; expires=Sun, 15-Jan-2012 07:42:00 GMT; Max-Age=3600; Path=/
x-archive-orig-content-length: 12357
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sun, 15 Jan 2012 06:42:03 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="Fri, 12 Aug 2011 11:50:05 GMT", ; rel="memento"; datetime="Sun, 15 Jan 2012 06:42:03 GMT", ; rel="next memento"; datetime="Fri, 04 May 2012 16:27:53 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: alexa20120116-12/51_25_20120115064102_crawl103.arc.gz
server-timing: captures_list;dur=0.713087, exclusion.robots;dur=0.023435, exclusion.robots.policy;dur=0.008042, esindex;dur=0.011251, cdx.remote;dur=136.159398, LoadShardBlock;dur=247.330946, PetaboxLoader3.datanode;dur=88.286136, PetaboxLoader3.resolve;dur=246.131137, load_resource;dur=135.601465
x-app-server: wwwb-app239
x-ts: 200
x-tr: 581
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
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)