-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
class Product(Struct):
# Product name of 20 bytes.
name = Str(20)
# Product quantity (0 to 255).
# default: signed=False
quantity = Int(1)
# Weight in Kilogram (Kg) (0 to 167,772,15)
weight = Int(3)
# volume in liters (L) (0 to 65,536)
volume = Int(2)
# Unite volume and weight fields and share same memory space.
# Then, total will be 3 bytes instead of 5 bytes.
__unions__ = [('volume', 'weight')]
class Person(Struct):
# String name of 15 bytes.
name = Str(20)
# Gender of 1 byte (Char)
gender = Char()
# Age integer of 1 byte (0 to 255)
age = Int(1)
# Integer money of 8 bytes (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
money = Int(8, signed=True)
# 1 bit boolean fields (total: 1 byte)
# default: Bool(1, bits=True)
is_extroverted = Bool()
works_remotely = Bool()
is_vegetarian = Bool()
exercises_regularly = Bool()
has_driver_license = Bool()
enjoys_cooking = Bool()
has_pets = Bool()
likes_to_travel = Bool()
shopping_cart = Product[None]
class Family(Struct):
# Store a Person struct for mother.
mother = Person
# Store a Person struct for father.
father = Person
# Unlimited childrens.
# (This is only possible because it is the last field
# of the struct, otherwise the number of items must be specified)
children = Person[None]
class PNG(Struct):
signature = Constant(b'\x89PNG\r\n\x1a\n')
...Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Projects
Status
No status