On Fri, Jul 20, 2018 at 4:25 PM, Brian Oney via Python-list <python-list@python.org> wrote: > PS: Can I twiddle bits in Python?
You sure can! With most of the same operators that you would in C. The main difference is that Python's integers don't have word size limits; instead of working with, say, 32-bit integer, you just work with "an integer" and it could be a lot larger. For instance, you can take the integer 1 and shift it by any number of places, thus getting any power of two that you want: >>> 1 << 10 1024 >>> 1 << 20 1048576 >>> 1 << 30 1073741824 >>> 1 << 5000 14124670321394260368352096670161473336688961751845411168136880858571181698427075125580891263167115263733560320843136608276420383806997933833597118572663992343105177785186539901187799964513170706937349821263132375255311121537284403595090053595486073341845340557556673680156558740546469964049905084969947235790090561757137661822821643421318152099155667712649865178220417406183093923917686134138329401824022583869272559614700514424328107527562949533909381319896673563360632969102384245412583588865687313398128724098000883807366822180426443291089403078902021944057819848826733976823887227990215742030724757051042384586887259673589180581872779643575301851808664135601285130254672682300925021832801825190734024544986318326563798786219851104636298546194958728111913990722800438594288095395881655456762529608691688577482893444994136241658867532694033256110366455698262220683447421981108187240492950348199137674037982599879141187980271758388549857511529947174346924111707023039810337861523279371029099265644 4842895511830355733152020804157920090041811951880456705515468349446182731742327685989277607620709525878318766488368348965015474997864119765441433356928012344111765735336393557879214937004347568208665958717764059293592887514292843557047089164876483116615691886203812997555690171892169733755224469032475078797830901321579940127337210694377283439922280274060798234786740434893458120198341101033812506720046609891160700284002100980452964039788704335302619337597862052192280371481132164147186514169090917191909376 >>> Have fun! ChrisA -- https://mail.python.org/mailman/listinfo/python-list