CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Wed, 16 Jul 2025 15:54:58 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20071208103537
location: https://web.archive.org/web/20071208103537/https://wiki.python.org/moin/boost%2Epython/WrappingEnums
server-timing: captures_list;dur=0.504961, exclusion.robots;dur=0.017120, exclusion.robots.policy;dur=0.008637, esindex;dur=0.011476, cdx.remote;dur=38.582461, LoadShardBlock;dur=425.177185, PetaboxLoader3.datanode;dur=160.112927, PetaboxLoader3.resolve;dur=178.453706
x-app-server: wwwb-app216
x-ts: 302
x-tr: 490
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app216; 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: Wed, 16 Jul 2025 15:54:58 GMT
content-type: text/html;charset=utf-8
x-archive-orig-date: Sat, 08 Dec 2007 10:35:37 GMT
x-archive-orig-server: Apache/2.0.54 (Debian GNU/Linux) mod_fastcgi/2.4.2
x-archive-orig-connection: close
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sat, 08 Dec 2007 10:35:37 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, 30 Dec 2006 22:40:59 GMT", ; rel="memento"; datetime="Sat, 08 Dec 2007 10:35:37 GMT", ; rel="next memento"; datetime="Fri, 12 Aug 2011 11:50:05 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: 52_1_20071208084132_crawl105-c/52_1_20071208103011_crawl107.arc.gz
server-timing: captures_list;dur=0.509998, exclusion.robots;dur=0.022549, exclusion.robots.policy;dur=0.011057, esindex;dur=0.011103, cdx.remote;dur=69.280731, LoadShardBlock;dur=194.556439, PetaboxLoader3.datanode;dur=209.141087, load_resource;dur=250.497643, PetaboxLoader3.resolve;dur=180.445712
x-app-server: wwwb-app216
x-ts: 200
x-tr: 554
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
boost.python/WrappingEnums
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'
EditText (last edited 2002-11-15 19:46:18 by MikeRovner)
DeleteCache (cached 2007-12-05 00:06:15)- Login
- Navigation
- Actions
- Your recent pages