# Explanation of list reference

Marko Rauhamaa marko at pacujo.net
Sun Feb 16 17:17:01 CET 2014

```Steven D'Aprano <steve+comp.lang.python at pearwood.info>:

> On Sun, 16 Feb 2014 12:52:58 +0200, Marko Rauhamaa wrote:
>> The syntactic awkwardness, then, explains why numbers don't have an
>> evolved set of methods (unlike strings).
>
> But numbers do have an evolved set of methods.
> [...]
> py> from decimal import Decimal
> py> [name for name in vars(Decimal) if not name.startswith("_")]
> ['canonical', 'exp', 'to_integral_value', 'logical_xor', 'imag',
> 'same_quantum', 'log10', 'max_mag', 'is_snan', 'to_eng_string', 'ln',
> 'is_normal', 'min', 'is_subnormal', 'to_integral_exact', 'is_nan',
> 'logb', 'is_qnan', 'logical_or', 'radix', 'real', 'max', 'normalize',
> 'as_tuple', 'is_canonical', 'is_zero', 'copy_negate', 'min_mag',
> 'next_plus', 'is_finite', 'number_class', 'scaleb', 'is_signed',
> 'compare_total', 'next_toward', 'adjusted', 'fma', 'rotate',
> 'logical_and', 'from_float', 'to_integral', 'next_minus',
> 'remainder_near', 'compare_signal', 'quantize', 'is_infinite',
> 'copy_sign', 'shift', 'compare_total_mag', 'copy_abs', 'compare',
> 'conjugate', 'logical_invert', 'sqrt']

That's more like it!

Alas:

>>> (2).sqrt()
AttributeError: 'int' object has no attribute 'sqrt'
>>> (2.0).sqrt()
AttributeError: 'float' object has no attribute 'sqrt'
>>> import math
>>> math.sqrt(2)
1.4142135623730951

Also, unfortunately:

>>> (2.0).hex()
'0x1.0000000000000p+1'
>>> (2).hex()
AttributeError: 'int' object has no attribute 'hex'

There's still some evolving to do. The "smallness" of numbers is still
shining through.

Marko

```