MCPcopy
hub / github.com/waditu/tushare / __getitem__

Method __getitem__

tushare/util/demjson.py:1883–1899  ·  view source on GitHub ↗

Returns the character at the given index relative to the current position. If the index goes beyond the end of the input, or prior to the start when negative, then '' is returned. If the index provided is a slice object, then that range of characters is returned as

( self, index )

Source from the content-addressed store, hash-verified

1881 return popwhile( lambda c: not testfn(c), maxchars=maxchars )
1882
1883 def __getitem__( self, index ):
1884 """Returns the character at the given index relative to the current position.
1885
1886 If the index goes beyond the end of the input, or prior to the
1887 start when negative, then '' is returned.
1888
1889 If the index provided is a slice object, then that range of
1890 characters is returned as a string. Note that a stride value other
1891 than 1 is not supported in the slice. To use a slice, do:
1892
1893 s = my_stream[ 1:4 ]
1894
1895 """
1896 if isinstance( index, slice ):
1897 return self.peekstr( index.stop - index.start, index.start )
1898 else:
1899 return self.peek( index )
1900
1901
1902# ----------------------------------------------------------------------

Callers

nothing calls this directly

Calls 2

peekstrMethod · 0.95
peekMethod · 0.95

Tested by

no test coverage detected