[Tutor] sys module - what does "It is always available" mean in the docs?

Flynn, Stephen (L & P - IT) Steve.Flynn at capita.co.uk
Thu Aug 21 11:03:59 CEST 2014


The documentation (https://docs.python.org/3/library/sys.html) for
Python 3.4.1 says that "This module provides access to some variables
used or maintained by the interpreter and to functions that interact
strongly with the interpreter. It is always available."

I interpreted that last sentence as "It's built in", so I made the
assumption I didn't need to import it in order to use it.

This is not the case - it still needs to be imported before I can use
anything defined within it.

Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64
bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print(sys.maxsize)
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    print(sys.maxsize)
NameError: name 'sys' is not defined
>>> import sys
>>> print(sys.maxsize)
9223372036854775807
>>>  

So, what does the documentation mean by explicitly pointing out that sys
is always available? To me, it's misleading but I'm obviously missing a
subtlety.

I've asked this question on /learnpython on reddit recently and the best
explanation is that it's built by the interpreter at runtime, so it
can't fail to import due to a broken installation. Any other offers?


As an addendum, I fired up my local docs via "Module Docs" and "This is
always available" *isn't* in the docs page for sys. I'd assumed they
were built from the same sources but apparently not.
-- 
Steve Flynn


This email and any attachment to it are confidential.  Unless you are the intended recipient, you may not use, copy or disclose either the message or any information contained in the message. If you are not the intended recipient, you should delete this email and notify the sender immediately.

Any views or opinions expressed in this email are those of the sender only, unless otherwise stated.  All copyright in any Capita material in this email is reserved.

All emails, incoming and outgoing, may be recorded by Capita and monitored for legitimate business purposes. 

Capita exclude all liability for any loss or damage arising or resulting from the receipt, use or transmission of this email to the fullest extent permitted by law.


More information about the Tutor mailing list