Import os, sys, system

I am learning some python with my dynamo, and this might be a generic question, but:
What is the difference between
import os
import sys
import system

I originally thought they are the same but I am starting think they are not?


Hi @cadman6735

It means your importing OS module in Python which provides a way of using operating system dependent functionality. Functions that the OS module provides allows you to interface with the
underlying operating system that Python is running on (Windows,Linux,Mac).

Python comes with around 100 modules available to import, and sys is one of them. The sys module is a set of functions which provide crucial information about how your Python script is interacting with the host system.

The sys modules has information about :

  • What version of Python is running
  • The path to the Python executable that is executing your script
  • The command line options used to execute your script
  • Any Python specific flags that have been set
  • Information about floating point values and their representation.
  • functions which can set what happens after each python instruction.
  • and a function to cleanly exit the Python interpreter.
  • and more too

Here are some examples that can use the functionality and data in it by using terms such as :

  • sys.argv : A list of strings which is the command line used to execute the script separated by spaces.
  • sys.exit() : Exit Python cleanly
  • sys.version : The Python version string

System module has information about:

  • System.Date
  • System.Windows.Forms
  • System.Web
  • System.Version
  • System.Media
    And Many more…

Hi Kulkul, thanks for the reply

So sys is, more inclusive to python system only and not windows system, they are separate things?

OS is a python door to the window operating system, while SYSTEM is a .NET door accessed by clr?

and OS is limited to python modules while the SYSTEM is full access to .NET?

as a wild guess of what I think I understand from your reply??