mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Fix up struct docstrings, add struct.pack_to function for symmetry
This commit is contained in:
		
							parent
							
								
									90bd0a554e
								
							
						
					
					
						commit
						1fcdc232db
					
				
					 3 changed files with 42 additions and 8 deletions
				
			
		|  | @ -62,6 +62,18 @@ def pack(fmt, *args): | |||
|         o = _compile(fmt) | ||||
|     return o.pack(*args) | ||||
| 
 | ||||
| def pack_to(fmt, buf, offset, *args): | ||||
|     """ | ||||
|     Pack the values v2, v2, ... according to fmt, write | ||||
|     the packed bytes into the writable buffer buf starting at offset. | ||||
|     See struct.__doc__ for more on format strings. | ||||
|     """ | ||||
|     try: | ||||
|         o = _cache[fmt] | ||||
|     except KeyError: | ||||
|         o = _compile(fmt) | ||||
|     return o.pack_to(buf, offset, *args) | ||||
| 
 | ||||
| def unpack(fmt, s): | ||||
|     """ | ||||
|     Unpack the string, containing packed C structure data, according | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Bob Ippolito
						Bob Ippolito