mirror of
				https://github.com/Mikaela/Limnoria.git
				synced 2025-11-04 01:27:21 +01:00 
			
		
		
		
	Added rsplit function.
This commit is contained in:
		
							parent
							
								
									cae8905594
								
							
						
					
					
						commit
						1ac029a54c
					
				@ -126,5 +126,10 @@ def all(p, seq):
 | 
			
		||||
            return False
 | 
			
		||||
    return True
 | 
			
		||||
 | 
			
		||||
def rsplit(s, sep=None, maxsplit=-1):
 | 
			
		||||
    L = s[::-1].split(sep, maxsplit)
 | 
			
		||||
    L.reverse()
 | 
			
		||||
    return [s[::-1] for s in L]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
 | 
			
		||||
 | 
			
		||||
@ -88,5 +88,12 @@ class FunctionsTest(unittest.TestCase):
 | 
			
		||||
    def testIlen(self):
 | 
			
		||||
        self.assertEqual(itertools.ilen(iter(range(10))), 10)
 | 
			
		||||
 | 
			
		||||
    def testRsplit(self):
 | 
			
		||||
        self.assertEqual(rsplit('foo bar baz'), 'foo bar baz'.split())
 | 
			
		||||
        self.assertEqual(rsplit('foo bar baz', maxsplit=1),
 | 
			
		||||
                         ['foo bar', 'baz']) 
 | 
			
		||||
        self.assertEqual(rsplit('foo        bar baz', maxsplit=1),
 | 
			
		||||
                         ['foo        bar', 'baz'])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user