Advance topics
Advance topics
Unicode and byte strings: String changes; string basics; coding basic string; coding unicode strings; using bytes objects; Bytearray objects; Using text and binary files;Using unicode files; Other string tool.
Names and roles of string object types (in py2 and 3): str represent content store on a text file (unicode text including ASCII), bytes (binary data) and bitarray (mutable flavor of bytes) represent content stored on binary files. Ho do py3 string types differ in terms of operations: only str support string formatting operations. The str and bytes also have methods for encoding and decoding text. Code non-ASCII unicode char in a string: with hex and Unicode escapes. sometimen Latin-1 char can be pasted and it would be interpreted per the UTF-8 default. Differences between text and binary mode files in py3: binary modes not translate end-of-line sequence to and from the single char. Read unicode text file that contains text in different encoding than the default (yours): pass the name of the file's encoding to the open built-in. Create unicode text file in specific encoding format: pass it to open. Why ASCII text considered to be a kind of unicode text?: because its 7-bit range of values is a subset of most unicode encoding.
Management attributes: Why manage attributes?; Properties; Descriptors.
Difference between getattr and getattribute: getattr feteches of undefined attributes, code inside it can freely fetch other attributes if they are degined (in getattribute not). getattribute is called for every attribute fetch. Difference between properties and descriptors: properties serve a specific role (get, set and delete functions; created with a built-in function), while descriptors are more general (more flexible, is coded with a class; instance's state information, local state so they can avoid name collision in the instance). Relation between properties and decorators: Functional differences between getattr and getattribute and properties and descriptors:
Decorators: Coding function decorators; Managing functions and classes directly.
Meta-classes: To metaclass or not to metaclass; The metaclass model; Declarating metaclasses; Coding metaclasses; Inheritance and instance; Metaclass methods.
All good things:
Última actualización
¿Te fue útil?