Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.
...ord(c)<=0xff: s += u"\\x%02x" % ord(c) elif ord(c)<=0xffff: s += u"\\u%04x" % ord(c) else: s += u"\\U%08x" % ord(c) return (s, exc.end) else: raise TypeError("can't handle %s" % exc.__name__) def xmlcharrefreplace(exc): if isinstance(exc, (UnicodeEncodeError, UnicodeTranslateError)): s = u"" for c in exc.object[exc.start:exc.end]: s += u"&#%d;" % o...
...ord(adapters.lana[i]) if win32wnet.Netbios(ncb) != 0: continue ncb.Reset() ncb.Command = netbios.NCBASTAT ncb.Lana_num = ord(adapters.lana[i]) ncb.Callname = '*'.ljust(16) ncb.Buffer = status = netbios.ADAPTER_STATUS() if win32wnet.Netbios(ncb) != 0: continue status._unpack() bytes = status.adapter_address[:6] if len(bytes) != 6: continue return int.from_bytes(bytes, 'big') This becomes: for i in range(adapters.length): nc...
...ord(byte))). pkginfo (optional) -- The file containing the distribution meta-data (as specified in PEP 241). Note that if this is not included, the distribution file is expected to be in .tar format (gzipped and bzipped compressed are allowed) or .zip format, with a PKG-INFO file in the top-level directory it extracts (package-1.00/PKG-INFO). infomd5sum (required if pkginfo field is present) -- The MD5 hash of the uploaded meta-data, encoded in ASCII representing the hexadecimal representation ...
...order functions like map. These new methods intentionally do NOT offer the same level of general integer support as the existing int.to_bytes conversion method, which allows arbitrarily large integers to be converted to arbitrarily long bytes objects. The restriction to only accept positive integers that fit in a single byte means that no byte order information is needed, and there is no need to handle negative numbers. The documentation of the new methods will refer readers to int.to_bytes for ...
...ord, string) and the somewhat less obvious: import array def g2(string): return array.array('b', string).tolist() Timing these reveals that g2() is about five times as fast as g1(). There's a catch though: g2() returns integers in the range -128..127, while g1() returns integers in the range 0..255. If you need the positive integers, g1() is going to be faster than anything postprocessing you could do on the result from g2(). (Note: since this essay was wr...
...ord, co.co_code) newconsts = list(co.co_consts) codelen = len(newcode) i = 0 while i < codelen: opcode = newcode[i] if opcode in ABORT_CODES: return f # for simplicity, only optimize common cases if opcode == LOAD_GLOBAL: oparg = newcode[i+1] + (newcode[i+2] << 8) name = co.co_names[oparg] if name in env and name not in stoplist: value = env[name] try: ...
...ord(c) for c in initializer] else: if encoding is not None: raise TypeError("no encoding allowed for this initializer") tmp = [] for c in initializer: if not isinstance(c, int): raise TypeError("initializer must be iterable of ints") if not 0 <= c < 256: raise ValueError("initializer element out of range") tmp.append(c) initializer = tmp new = <new bytes object of leng...
...ordinals only up to 2**16 - 1. This range corresponds to a range in Unicode known as the Basic Multilingual Plane. There are now characters in Unicode that live on other "planes". The largest addressable character in Unicode has the ordinal 17 * 2**16 - 1 (0x10ffff). For readability, we will call this TOPCHAR and call characters in this range "wide characters". Glossary Character Used by itself, means the addressable units of a Python Unicode string. Code point A code point is an integer betw...
...Ordinals Since Unicode 3.0 has a 32-bit ordinal character set, the implementation should provide 32-bit aware ordinal conversion APIs: ord(u[:1]) (this is the standard ord() extended to work with Unicode objects) --> Unicode ordinal number (32-bit) unichr(i) --> Unicode object for character i (provided it is 32-bit); ValueError otherwise Both APIs should go into __builtins__ just like their string counterparts ord() and chr(). Note that Unicode provides space f...
...ord arguments, ord() does not, but there is no way of telling just by reading the documentation that this is true. Syntax And Semantics From the "ten-thousand foot view", and ignoring *args and **kwargs for now, the grammar for a function definition currently looks like this: def name(positional_or_keyword_parameters, *, keyword_only_parameters): Building on that perspective, the new syntax for functions would look like this: def name(positional_only_parameters, /, positional_or_keyword_par...
...ord(p[0]) << 7)) & mask for c in p: x = ((1000003 * x) ^ ord(c)) & mask x = (x ^ len(p)) & mask x = (x ^ hashsecret.suffix) & mask if x == -1: x = -2 return x FNV is a simple multiply and XOR algorithm with no cryptographic properties. The randomization was not part of the initial hash code, but was added as counter measure against hash collision attacks as explained in oCERT-2011-003 [ocert]. Because FNV is not a cryptographic hash al...
...orderings. Classes or types that want to implement (in)equality tests but not the ordering operators (i.e. unordered types) should implement == and !=, and raise an error for the ordering operators. It is possible to define types whose rich comparison results are not Boolean; e.g. a matrix type might want to return a matrix of bits for A < B, giving elementwise comparisons. Such types should ensure that any interpretation of their value in a Boolean context raises an exception, e.g. by defin...
...ord | | - Keyword only -- Positional only where / and * are optional. If used, these symbols indicate the kind of parameter by how the arguments may be passed to the function: positional-only, positional-or-keyword, and keyword-only. Keyword parameters are also referred to as named parameters. Positional-or-Keyword Arguments If / and * are not present in the function definition, arguments may be passed to a function by position or by keyword. ...