Package pycocoa :: Module internals
[frames] | no frames]

Module internals

Decorator property_RO, functions bytes2repr, bytes2str, iterbytes, lambda1, str2bytes and unicodec, singleton missing and private (INTERNAL) constants.


Version: 25.04.07

Functions
 
property_RO(method)
Decorator for Read_Only class/instance property.
 
bytes2repr(bytestr)
Represent bytes or str as b"...".
 
bytes2str(bytestr, dflt=missing, **name)
Convert bytes/unicode to str if needed.
 
iterbytes(bytestr)
Iterate bytes, yielding each as 1-str/byte.
 
str2bytes(strbytes, dflt=missing, **name)
Convert strbytes to bytes/unicode if needed.
 
unicodec(codec=None)
Get/set the unicode encoding, default "utf-8".
Variables
  missing = missing
Missing keyword argument value, singleton.
Function Details

property_RO(method)

 

Decorator for Read_Only class/instance property.

Parameters:
  • method - The callable to be decorated as Read_Only property.

Note: Like standard Python property without a property.setter and with an error message when trying to set.

bytes2repr(bytestr)

 

Represent bytes or str as b"...".

Parameters:
  • bytestr - bytes or str..
Returns:
Representation b'...' (str).

bytes2str(bytestr, dflt=missing, **name)

 

Convert bytes/unicode to str if needed.

Parameters:
  • bytestr - Original bytes, str or unicode.
  • dflt - Optional, default return value.
  • name - Optional name of bytestr argument, used for errors and missing dflt only.
Returns:
The str or dflt.
Raises:
  • TypeError - If bytestr is not bytes, str or unicode and if dflt is missing.

str2bytes(strbytes, dflt=missing, **name)

 

Convert strbytes to bytes/unicode if needed.

Parameters:
  • strbytes - Original str, bytes or unicode.
  • dflt - Optional, default return value.
  • name - Optional name of bytestr argument, used for errors and missing dflt only.
Returns:
The bytes or dflt.
Raises:
  • TypeError - If strbytes is not str, bytes or unicode and if dflt is missing.

unicodec(codec=None)

 

Get/set the unicode encoding, default "utf-8".

Parameters:
  • codec - A encoding (str or None).
Returns:
The previous encoding (str).

See Also: Codecs.