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

Method popif

tushare/util/demjson.py:1808–1816  ·  view source on GitHub ↗

Just like the pop() function, but only returns the character if the given predicate test function succeeds.

( self, testfn )

Source from the content-addressed store, hash-verified

1806 return s
1807
1808 def popif( self, testfn ):
1809 """Just like the pop() function, but only returns the
1810 character if the given predicate test function succeeds.
1811 """
1812 c = self.peek()
1813 if c and testfn(c):
1814 self.__pos.advance( c )
1815 return c
1816 return ''
1817
1818 def pop_while_in( self, chars ):
1819 """Pops a sequence of characters at the current position

Callers 1

popwhileMethod · 0.95

Calls 2

peekMethod · 0.95
advanceMethod · 0.80

Tested by

no test coverage detected