Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
db028d68
Commit
db028d68
authored
Oct 13, 2015
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added module::import statement
parent
93296696
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
1 deletions
+11
-1
example/example9.cpp
+4
-1
example/example9.py
+2
-0
example/example9.ref
+1
-0
include/pybind/pybind.h
+4
-0
No files found.
example/example9.cpp
View file @
db028d68
/*
/*
example/example9.cpp -- nested modules and internal references
example/example9.cpp -- nested modules, importing modules, and
internal references
Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>
Copyright (c) 2015 Wenzel Jakob <wenzel@inf.ethz.ch>
...
@@ -49,4 +50,6 @@ void init_ex9(py::module &m) {
...
@@ -49,4 +50,6 @@ void init_ex9(py::module &m) {
.
def
(
"get_a2"
,
&
B
::
get_a2
,
"Return the internal A 2"
,
py
::
return_value_policy
::
reference_internal
)
.
def
(
"get_a2"
,
&
B
::
get_a2
,
"Return the internal A 2"
,
py
::
return_value_policy
::
reference_internal
)
.
def_readwrite
(
"a1"
,
&
B
::
a1
)
// def_readonly uses an internal reference return policy by default
.
def_readwrite
(
"a1"
,
&
B
::
a1
)
// def_readonly uses an internal reference return policy by default
.
def_readwrite
(
"a2"
,
&
B
::
a2
);
.
def_readwrite
(
"a2"
,
&
B
::
a2
);
m
.
attr
(
"OD"
)
=
py
::
module
::
import
(
"collections"
).
attr
(
"OrderedDict"
);
}
}
example/example9.py
View file @
db028d68
...
@@ -9,6 +9,7 @@ print(example.__name__)
...
@@ -9,6 +9,7 @@ print(example.__name__)
print
(
example
.
submodule
.
__name__
)
print
(
example
.
submodule
.
__name__
)
from
example.submodule
import
*
from
example.submodule
import
*
from
example
import
OD
submodule_func
()
submodule_func
()
...
@@ -26,3 +27,4 @@ print(b.a1)
...
@@ -26,3 +27,4 @@ print(b.a1)
print
(
b
.
get_a2
())
print
(
b
.
get_a2
())
print
(
b
.
a2
)
print
(
b
.
a2
)
print
(
OD
([(
1
,
'a'
),
(
2
,
'b'
)]))
example/example9.ref
View file @
db028d68
...
@@ -16,6 +16,7 @@ A[42]
...
@@ -16,6 +16,7 @@ A[42]
A[42]
A[42]
A[43]
A[43]
A[43]
A[43]
OrderedDict([(1, 'a'), (2, 'b')])
B destructor
B destructor
A destructor
A destructor
A destructor
A destructor
include/pybind/pybind.h
View file @
db028d68
...
@@ -466,6 +466,10 @@ public:
...
@@ -466,6 +466,10 @@ public:
attr
(
name
)
=
result
;
attr
(
name
)
=
result
;
return
result
;
return
result
;
}
}
static
module
import
(
const
char
*
name
)
{
return
module
(
PyImport_ImportModule
(
name
),
false
);
}
};
};
NAMESPACE_BEGIN
(
detail
)
NAMESPACE_BEGIN
(
detail
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment