mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
	
		
			428 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			428 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
# List track info from CD player.
 | 
						|
 | 
						|
import cd
 | 
						|
 | 
						|
def main():
 | 
						|
	c = cd.open()
 | 
						|
	info = []
 | 
						|
	while 1:
 | 
						|
		try:
 | 
						|
			info.append(c.gettrackinfo(len(info) + 1))
 | 
						|
		except RuntimeError:
 | 
						|
			break
 | 
						|
	for i in range(len(info)):
 | 
						|
		start, total = info[i]
 | 
						|
		print 'Track', zfill(i+1), triple(start), triple(total)
 | 
						|
 | 
						|
def triple((a, b, c)):
 | 
						|
	return zfill(a) + ':' + zfill(b) + ':' + zfill(c)
 | 
						|
 | 
						|
def zfill(n):
 | 
						|
	s = `n`
 | 
						|
	return '0' * (2 - len(s)) + s
 | 
						|
 | 
						|
main()
 |