Uh oh!
There was an error while loading. Please reload this page.
Add Slice function for range type - #83
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Codecov Report
@@ Coverage Diff @@## master #83 +/- ##
==========================================
+ Coverage 68.84% 68.98% +0.13%
==========================================
Files 59 59 Lines 10545 10588 +43 ==========================================
+ Hits 7260 7304 +44 + Misses 2775 2774 -1
Partials 510 510
Continue to review full report at Codecov.
|
570ec8e to
b39bd4eCompare
corona10
left a comment
There was a problem hiding this comment.
Please add unittests in here
https://github.com/go-python/gpython/blob/master/py/tests/range.py
ghost
commented
Sep 18, 2019
CPython (v3.7.4) has an additional type check that raises an exception on wrong types like: classC:
def__index__(self):
return1r=range(10)
assertlen(r[:C()]) ==1# len(r[:1.1]) -> Exception |
corona10
commented
Sep 23, 2019
@HyeockJinKim Please rebase the PR and reflect @Tim-St 's review. |
corona10
left a comment
There was a problem hiding this comment.
Please follow the comment I left.
Crate a new range object by calculating start, stop, and step when slice is entered as argument to the __getitem__ function of the range Fixesgo-python#77
If __index__ is defined when class is used as index value, __index__ value is used.
HyeockJinKim
commented
Sep 26, 2019
ghost
commented
Sep 26, 2019
@HyeockJinKim For example: classC:
def__index__(self):
return"abc"r[:C()]Should raise Maybe it would be good to first call Also the following should throw an Exception like in CPython: But I think that is quite much work to implement, so we could also just handle this as a new issue. The following code results are different in CPython (sorry, I didn't find this before): r=range(10)
r[-2::-2] # r[-2::2] is ok r[-2::-1]
r[:-2:-1]
r[-2:-2:-2] |
Crate a new range object by calculating start,
stop, and step when slice is entered as argument
to the getitem function of the range
Fixes#77