[Tutor] [spoiler] Re: Shifting arrays as though they are a 'word'

Chip Wachob wachobc at gmail.com
Tue Oct 9 08:45:53 EDT 2018


Alan,

Thank you.

Another related question.  How do I know I want to do dir(int) vs.. I
don't know dir(long)?

And, when I do dir(int) I get the following results.  I must not be
seeing the from_bytes in this list...

>>> dir(int)
['__abs__', '__add__', '__and__', '__class__', '__cmp__',
'__coerce__', '__delattr__', '__div__', '__divmod__', '__doc__',
'__float__', '__floordiv__', '__format__', '__getattribute__',
'__getnewargs__', '__hash__', '__hex__', '__index__', '__init__',
'__int__', '__invert__', '__long__', '__lshift__', '__mod__',
'__mul__', '__neg__', '__new__', '__nonzero__', '__oct__', '__or__',
'__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__',
'__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__',
'__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__',
'__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__',
'__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__',
'__subclasshook__', '__truediv__', '__trunc__', '__xor__',
'bit_length', 'conjugate', 'denominator', 'imag', 'numerator', 'real']





On 10/9/18, Alan Gauld via Tutor <tutor at python.org> wrote:
> On 09/10/18 02:48, Chip Wachob wrote:
>
>>> bytearray(b'\x00\xff\x7f\x00')
>>> py> n = int.from_bytes(b, 'big')
>>
>> I'm not familiar with this int.from_bytes.
>>
>> Being new to Python, I don't have a mental library of these nifty
>> functions.  How / where does one find a library of these wonderful
>> functions so I can search to find something that might be really
>> handy?
>
> The interactive prompt.
>>>> dir(int)
>
> And the help() function
>
>>>> help(int)
>
> And finally the online documentation and search engine.
> But dir/help are usually faster.
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list