Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    BinaryFlags 1.0

    Download button

    No screenshots available
    Downloads: 49  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Tyler Kennedy | More programs
    Other/Proprietary Li... / FREE
    September 19th, 2012, 15:51 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    BinaryFlags description

    Handle binary flag in Python

    BinaryFlags is a tiny Python library that can handle binary flags.

    Example

    from binflags import BinaryFlags

    # Define the possible flags.
    access_flags = BinaryFlags('>H', {
     'acc_public': 0x0001,
     'acc_final': 0x0010,
     'acc_super': 0x0020,
     'acc_interface': 0x0200,
     'acc_abstract': 0x0400,
     'acc_synthetic': 0x1000,
     'acc_annotation': 0x2000,
     'acc_enum': 0x4000
    })

    # Toggle some flags.
    print(b.value) # 0
    b.acc_enum = 1
    print(hex(b.value)) # 0x4000
    b.acc_enum = False
    print(hex(b.value)) # 0x0
    b.acc_interface = True
    b.acc_annotation = 1
    print(hex(b.value)) # 0x2200

    # Pack to a string
    print(b.pack())

    # And unpack from a string
    b.unpack(io.read(2))



    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    binary flags | Python module | Python library | Python | binary | flags

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM