Skip to content

Commit 8806e76

Browse files
author
Guillaume Fraux
committed
Create Python instances without arguments
1 parent 6452507 commit 8806e76

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/macros.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
macro_rules! create_instance {
2+
($py: ident, $Type: ty) => ({
3+
let class = $py.get_type::<$Type>();
4+
let instance: $Type = class.call($py, ::cpython::PyTuple::empty($py), None).unwrap().extract($py).unwrap();
5+
instance
6+
});
27
($py: ident, $Type: ty, $args: expr) => ({
38
let class = $py.get_type::<$Type>();
49
let instance: $Type = class.call($py, $args, None).unwrap().extract($py).unwrap();

0 commit comments

Comments
 (0)