~pythonregexp2.7/python/issue2636-09-01+10

« back to all changes in this revision

Viewing changes to Doc/library/struct.rst

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-05-24 18:56:40 UTC
  • mfrom: (39055.1.22 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080524185640-59vz6l1f7qgixgal
Merged in changes from the Single-Loop Engine branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
233
233
native size and alignment are in effect; standard size and alignment does not
234
234
enforce any alignment.
235
235
 
 
236
Unpacked fields can be named by assigning them to variables or by wrapping
 
237
the result in a named tuple::
 
238
 
 
239
    >>> record = 'raymond   \x32\x12\x08\x01\x08'
 
240
    >>> name, serialnum, school, gradelevel = unpack('<10sHHb', record)
 
241
 
 
242
    >>> from collections import namedtuple
 
243
    >>> Student = namedtuple('Student', 'name serialnum school gradelevel')
 
244
    >>> Student._make(unpack('<10sHHb', s))
 
245
    Student(name='raymond   ', serialnum=4658, school=264, gradelevel=8)
236
246
 
237
247
.. seealso::
238
248