Added __doc__ atrribute for tuple

This commit is contained in:
veera venky committed 2019-02-07 23:47:47 +05:30
1 parent 3d2d04596c
commit b85cf91a23
2 files changed
+11

No files matched your search

+2
View File
@@ -19,3 +19,5 @@ assert x > y, "tuple __gt__ failed"
b = (1,2,3)
assert b.index(2) == 1
assert b.__doc__ == "tuple() -> empty tuple\ntuple(iterable) -> tuple initialized from iterable's items\n\nIf the argument is a tuple, the return value is the same object."
+9
View File
@@ -290,6 +290,10 @@ pub fn tuple_contains(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
pub fn init(context: &PyContext) {
let tuple_type = &context.tuple_type;
let tuple_doc = "tuple() -> empty tuple
tuple(iterable) -> tuple initialized from iterable's items
If the argument is a tuple, the return value is the same object.";
context.set_attr(&tuple_type, "__add__", context.new_rustfunc(tuple_add));
context.set_attr(&tuple_type, "__eq__", context.new_rustfunc(tuple_eq));
context.set_attr(
@@ -313,5 +317,10 @@ pub fn init(context: &PyContext) {
context.set_attr(&tuple_type, "__le__", context.new_rustfunc(tuple_le));
context.set_attr(&tuple_type, "__gt__", context.new_rustfunc(tuple_gt));
context.set_attr(&tuple_type, "__ge__", context.new_rustfunc(tuple_ge));
context.set_attr(
&tuple_type,
"__doc__",
context.new_str(tuple_doc.to_string()),
);
context.set_attr(&tuple_type, "index", context.new_rustfunc(tuple_index));
}