IX_py Python Functions by D@CC on 2022 C Mar 20 Keywords: ICH180R2, PiR2, pir2, ix_py.py ambLight, digLight, callEvery, textpack, textunpack, marker, audioHDMI, eorCalc, eSpeak, f3, inputWTO, isInstance, show, sho, sho3, commandOS mid, pack, wait_Select_Std_pi, weatherHat Pro, ix, D@CC, "ICH In Charge", ICH_InCharge. Python, pico, MMBasic. vector, MehInCharge MehInCharge.com, ePhotoCaption.com, Cytron, MakerpHAT, "Maker Pi Pico" , PiR2A, PiR2C, PiR2D, PiR2null, Tkinter This is a list of the Python IX functions or subroutines written by David@ColeCanada.com for use with the Raspberry Pi. Other related routines have been written for use with a Raspberry pico board. To distinguish the Pi routines from the Pico routines, a suffix of "_pi.py" or "_pico.py" is often used. A suffix of "_py.py" marks a generic Python routine that is usable with/without Pi/Pico hardware. Routines applicable to both may have a suffix of ".py". These routines are stored in a Python library or package named "ix_py". These routines are accessed by using a prefix of "ix_py.". For use by Python-3, they must all be located in the same folder as the calling program. For use by Thonny, these routine must be defined in the single ix_py.py package definition. For Thonny, the ix_py.py file must be located in the same folder as the calling program, but they must also be declared as a package using the Thonny "tools" menu. Please notify the author of any errors or issues that result from the use of this software. There is a small amount of interdependence between these functions. Some of these functions are designed to be used with specific Raspberry Pi devices. More information can be found in my article 155 ( http://ephotocaption.com/a/155/155.html ), Another package of Python functions is used in the PiR2 system. It is documented elsewhere. Another package of functions will be created to access the capabilities of the Raspberry Pico. They include the creation and use of a vector of readings. They will also be documented elsewhere. Also see Article 215 IX Function Repository (ISO9003) These functions are copyrighted by (c) ICH180R2. These functions are packed into a single text file named "IX_package.py". The size of this package is under 4 MegB. This package can be unpacked using the textunpack.py program listed below. The functions are designed for personal use but are available for use in any non-commercial devices. check Article 164 for many functions Check Fla52S for many pi routines Previously Unknown Repositories isinstance() #python function: used in f3() in Article 155 mid() # used in MySQL mid$() # used in PicoMite MMBASIC mid() # used in f3() or Vectors or show()? pack() # defined in Tkinter (GUI) # defined in textpack() by O'Reilly ########################################################################## PYTHON PROGRAMS USED FOR SOFTWARE TESTING List of programs that call functions/subroutines (Some are txt files that describe python programs.) afTest07.py ambTHP_Wind_ambLight_LED_btn_A4_py.txt BME280_Read_A.py BME280PlusWind_and_ambLight_C3.py diagnoseGPIO_pi.py digLightTest_pi.py / PiCole_digLight.py email_using_python3.txt eorCheck.py Example_Intermediate_Calls_V61.txt fstringExamples.py Install_Notes_2020LDec23.txt live_panel.py makeVectorVIX.py nd3(x) piButtonSwitchesT9_On_pi.py pir2main.py v60 pir2_Install.html SDL_Pi_INA3221.py sensing21.py test_control_eMail_v05.py test_timer03_take01.py test_TMP102A.py testGPIO_pi.py IX_textpack.py IX_textunpack.py testPlotB.py testUtime.py wait_Select_Stdin.py For an updated list of all the iodevices that I envisioned see: Article 128/PIR2_CONTR_FUNC_08.pdf Repository: Article 174 ***************************************************** afTest07.py ***************************************************** test Thonny packages and globals ************************* functions: show(), outModels(), get_buy(), find() Repository: Article 146 Repository: Fla52S ***************************************************** ambTHP_Wind_ambLight_LED_btn_A4_py.txt * ***************************************************** import time from w1thermsensor import W1ThermSensor import board import busio import adafruit_bme280 i2c = busio.I2C(board.SCL, board.SDA) import adafruit_ads1x15.ads1015 as ADS from adafruit_ads1x15.analog_in import AnalogIn import RPi.GPIO as GPIO Functions: AnalogIn(), setmode(),setup(),output(), sleep(),Adafruit_BME280_I2C(), ADS1015(), bme.temperature, bme.pressure, bme.humidity, chanA1.value, chanA3.value, chan.value, input(), output(), Install_Notes_2020LDec23.txt Repository: Desktop_2021CMar15.zip Repository: Fla56S /home/pi/ *.zip ******************************* BME280_Read_A.py * ****************************** read temp,press,humid from Weatherhat Pro *********************** Source 1: https://bc-robotics.com/tutorials/raspberry-pi-weather-station-part-2/ import time from w1thermsensor import W1ThermSensor import board import busio import adafruit_bme280 Functions: sleep(), bme.temperature, bme.pressure, bme.humidity WeatherHat Pro ************************* A program to read my modifiied version of this board: PiR2D3 See my EPC Article 146 Source 20 for the source code. Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\BME280PlusWind_and_ambLight_C3.py Repository: Fla52S ***************************************************** BME280PlusWind_and_ambLight_C3.py * ***************************************************** original software for the WeatherHat Pro import time from w1thermsensor import W1ThermSensor import board import busio import adafruit_bme280 i2c = busio.I2C(board.SCL, board.SDA) import adafruit_ads1x15.ads1015 as ADS from adafruit_ads1x15.analog_in import AnalogIn Repository: not yet written ************************** diagnoseGPIO_pi.py * ************************** GPIO pin diagnostics ************************* A program to diagnose errors or bad components attached to the Pi GPIO pins. Repository: Fla52S Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\digLightTest.py ************************ digLightTest_pi.py * PiCole_digLight.py * ************************ tests a photoCell ********************** A photo-cell can be used to measaure the analog value of ambient light, but it can also be used as a binary (digital) value of light/dark. Total darkness occurs when the photo-cell is covered. This light/dark situation is similar to a push-button which is what digLight returns as a binary value. If the photocell is lit, the program says "lit", if not lit the program says "dark" Repository: E:\PiR2_old_from Fla53S\python_60\email_using_python3.txt Repository: Fla53S Repository: pthon_60 ***************************** email_using_python3.txt * ***************************** This text file describes how to create an email using Python ***************************** Source:Source: https://www.raspberrypi.org/forums/viewtopic.php?t=86441 class Emailer: def sendmail(self, recipient, subject, content): Functions: emailOut() also see email_walk.txt for a program to receive emails Repository: C:\Users\mrmyr\Documents\2022\BUsC\_Fla58D064G_2022B09\BUs_byHand\_Fla52S032G\pi_folderD_2021G19\Desktop\Python_new\util_py\eorCheck_py.py Repository: Fla52S ************************* eorCheck.py tests it * ************************* This routine calculates an "eor checksum" of all the chaaracters in a text flle. This checksum can be stored somewhere to ensure that a text file or program has not been altered. Repository: E:\PiR2_old_from Fla53S\python_60\Example_Intermediate_Calls_V61.txt Repository: Fla53S ******************************************** Example_Intermediate_Calls_V61.txt * ******************************************** This function is a new planned version of pir2 It defines a new set of acquire/control functions **************************** not yet programmed Functions: callLog(), makeLogRecord(), callAcquire((), callControl(), id(), pir2main(), pir2(), Repository: E:\PiR2_old_from Fla53S\python_60\fstringExamples.py Repository: Fla53S ******************************************** fstringExamples.py * ******************************************** This program prints variables using various python formats **************************** Functions: rv(), fstringExamples(), main() Repository: Desktop_2021CMar15.zip Repository: Fla56S /home/pi/ *.zip ***************************************** Install_Notes_2020LDec23.txt * **************************************** How to install a new SD (create new 56 from bad 52 backuip) *********************** Source 1: gdoc Repository: E:\PiR2_old_from Fla53S\python_60\live_panel.py Repository: Fla53S ******************************* live_panel.py v4 * ****************************** version 4 of a live GUI panel for pir2 using Tkinter? using recent value array *********************** Functions: PiR2_fstring(), rv(), live_panel(), fix(), write(), bup_recentV(), rest_recentV(), Repository: Fla52S032G prj_vectorMath Repository: . . . . tstampVIX ************************ makeVectorVIX.py * ************************ Import math Library: vectorMathLibrary_2021FJun09.py makes a Vector (for readings) tested by VectorMath_py.py * This program creates a vector of values. The values define a regular wave pattern. Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\nd3.py Repository: Fla52S & Fla56S REpository: E:\BUs_byHand\2021GJul19\_Fla56S032G\home\pi\Desktop_2021CMar15.zip\Desktop\Python\ ********************** nd3() * ********************** simple version of f3() ********************** precursor to f3() Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\piButtonSwitchesT9_On_pi.py *********************************** piButtonSwitchesT9_On_pi.py * *********************************** test piButtonSwitches ********************** import time import RPi.GPIO as GPIO Repository: E:\PiR2_old_from Fla53S\python_60\pir2main.py Repository: Fla53S ******************************* pir2main.py v60 or 61 * ****************************** version to work with a live panel for pir2 using recent value array *********************** from subprocess import call import os from os import system, name from time import sleep import RPi.GPIO as GPIO Functions: callControl(), callLog(), pir2((), callAcquire(), pir2_exitPiR2(), PIR2_Initialize(), pir2_acquireAllPhysical(), pir2main(), Repository: Article 142 as of 2020 Repository: ********************** pir2_Install.html * ********************** describes how to install the PiR2 software lists the "future" PiR2 parameters (iodevices) Repository: 3221Code.txt in Article 143 ************************* SDL_Pi_INA3221.py * ************************* from datetime import datetime import smbus Functions: smbus.SMBus, sleep() self._write_register_little_endian(), _write((), _read(), _read_register_little_endian(), _getBusVoltage_raw(), _getShuntVoltage_raw(), getBusVoltage_V(), getShuntVoltage_mV(), getCurrent_mA(), getBusVoltage_V(), getShuntVoltage_mV(), getCurrent_mA(), Repository: C:\Users\mrmyr\Documents\2022\deW7\Documents\BUs_ByH\2022\2020FJun30_FlashDrives\Fla50D016G\Pi_BU_2020EMay27_pi\Desktop\PiR2\python\sensing21.py Repository: Fla50 ************************* sensing21.py * ************************* testing GPIO21 ********************** import RPi.GPIO as GPIO Repository: E:\PiR2_old_from Fla53S\python_60\test_control_eMail_v05.py Repository: Fla53S ******************************** test_control_eMail_v05.py * ******************************** This program is my first function to send email from a python program ******************************** import os import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase from email import encoders Functions: control_eMail(), Repository: C:\Users\mrmyr\Documents\2022\BUsC\_Fla58D064G_2022B09\BUs_byHand\_Fla52S032G\pi_folderD_2021G19\Desktop\Python_new\prj_timer\test_timer03_take01.py Repository: . . . . . /prj_timer\test_timer03_take01.py Repository: Fla52S ********************** test_timer03_take01.py * ********************** This program tests the timer for async io (i.e. a task scheduler) This program will call the specified function every N seconds. ********************** imports: asyncio, time uses functions: foo, fooLoopEnd, fooTick,countdown, frange, callEvery get_event_loop, call_later ,run_forever, close, call_later call_at NB "frange" defines an iterator eg iter=(start,stop, step) but stop=None is allowed. Repository: C:\Users\mrmyr\Documents\2022\deW7\Documents\BUs_ByH\2022\2020FJun30_FlashDrives\Fla50D016G\Pi_BU_2020EMay27_pi\Desktop\PiR2\python\test_TMP102A.py Repository: Fla50S ************************ test_TMP102A.py * *********************** # test_TMP102A.py" #test the I2C acquire_tempId00 method ********************** import time import smbus import pir2A functions: def acquire_tempId00(),init_I2C_Bus( Repository: Fla52S ********************** testGPIO_pi.py * testGPIO.py * ********************** tests the RPi GPIO pins ********************** This program tests the reading and writing of control signals from/to two GPIO pins of a Raspberry Pi. It makes the led blink twice, then continually reads the pushButton. If the pushbutton is high; the led is turned on. if low; the led is turned off. Repository: see Source ************************ textpack programs * ************************ Source: https://www.oreilly.com/library/view/programming-python-second/0596000855/ch04s05.html these 2 programs pack a group of functions for easy movement textpack.py textunpack.py ********************** NB the IX_Marker = '#' + ':'*10 + 'textpak=>' These two programs pack/unpack a group of text files and/or programs into a single text file. This facilitates the moving of a large number of programs from one folder to another (or from one PC to another). See my program: IX_textpack.py Repository: Fla52S ********************** testPlotB.py * ********************** This program creates a plot of a vector of samples ********************** Source: https://www.educba.com/list-operations-in-python/ functions: plot(), plotVector(), changeInRC() Repository: Article 164 ********************** testUtime * ********************** tests UNIX time converstions ********************** This program tests the functions defined to facilitate the use of UNIX time by these programs and functions. Repository: Fla52S & Fla56S Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\Wait_Select_Stdin.py Repository: E:\BUs_byHand\2021GJul19\_Fla56S032G\home\pi\Desktop_2021CMar15.zip\Desktop\Python\ ************************** wait_Select_Stdin.py * ************************** This program asks the operator to respond to a question within N seconds. It is used to verify whether a user/operator is present. ********************** import sys from select import select Functions: select() ######################################################################### USEABLE IX FUNCTIONS / SUBROUTINES IX Functions List (as of 2022CMar12 by D@CC) ambLight() audioHDMI() commandOS() digLisht() eorCalc() eorCheck() espeak() f3() inputWTO() isInstance() listShow() mid() pack() piButton() pir2() (planned routine for new pir2 system) plot() show() show3() Talker() wait_Select_Std_pi.py weatherHatPi system pico System Repository: ambRead_pkg.py on Fla53S ********************** ambLight_pi.py * ********************** reads a photoCell ********************** A photo-cell can be used to measaure the analog value of ambient light, but it can also be used as a binary (digital) value of light/dark. Total darkness occurs when the photo-cell is covered (e.g. by a finger). This light/dark situation is similar to a push-button which is what digLight returns as a binary value. Because the Raspberry Pi cannot read analog values, an external ADC device is necessary (e.g. WeatherHap Pro, Pico, Seeed PN 03030279 that uses a ti ADS1115.) The related digital routine digLight can be used to measure light/dark as a binary value without need for an ADC. Also for Seeed ADS1115 Raspberry Pi board (AIN0,AIN1,AIN2,AIN3). Repository: Article 155 ********************** audioHDMI() * ********************** this function plays an audio file on HDMI0 ********************** This function permits an audio file to be output via an HDMI channel. Repository: Article 155 ********************** commandOS() * ********************** this function executes a system command and returns the result ********************** This function can notify the user/operator of a Raspberry Pi via a printed message. It can ask a question and channel the response back to the calling program. Repository: Article 146 & 158 & 174 ********************** digLight() * ********************** this function reads the ambient as the binary values: ight and dark. ********************** This function reads a binary value (0:dark , 1:light). Any Raspberry GPIO pin can be used to read digLight(). To do this a photo-cell (and 6K0 resistor) must be connected to a GPIO pin. A related function named "ambLight()" can read the analogy value of the ambient light. Repository: Article 174 ********************** eorCalc * ********************** calculates eor integer checksum of a text file. Repository: Article 142 Repository: Fla50D ********************** espeak() * ********************** converts any txt file into spoken words directly or into a wav file ********************** Source: https://www.dexterindustries.com/howto/make-your-raspberry-pi-speak/ Also see espeak2.txt for more info. This function converts a text file into an audio wav. This facilitates the communication to a user / operator. The generic voice sounds like it is robot-produced. Repository: C:\Users\mrmyr\Documents\2022\deW7\Documents\BUs_ByH\2022\2020FJun30_FlashDrives\Fla50D016G\Pi_BU_2020EMay27_pi\Desktop\PiR2\python\espeakIP.py Repository: Fla50S ********************** espeakIP.py * ********************** converts any txt file into spoken words directly or into a wav file ********************** ALso see callespeak.py from subprocess import call call(["espeak","-s140 -ven+18 -z","Hello From Mike"]) /callespeak.py This function converts an IP address into an audio wav. This facilitates the communication to a user / operator, The generic voice sounds like it is robot-produced. Repository: Article 155 Repository: C:\Users\mrmyr\Documents\2022\DevC\MyPagesC\Globat\ePhotoCaption.com\a\155\ix_py.py ********************** f3() * ********************** f3 when printed, formats an int, float or string in -999999.999 format ********************** This function converts a number into an 11 character printable format with 3 digits to the right of the decimal point. The incoming number can be in any of the following formats: string, bool, int, float. Very small and very large numbers will be represented in scientific notation (e.g. "+0.123E23" ). Non-numbers result in printing the error string "f3:Bad Type". Repository: Article 174 ********************** get_global() * ********************** returns True if variable is of type Str ********************** These routines permit the main program to set and get global variables. Functions: access_global_list_definition(), access_global(), get_global(), set_global() get_targTempL0(), isTypeStr() Repository: Fla52S Repository: Article 155 ********************** inputWTO() * ********************** this function inputs a string from the user, but only waits N seconds ********************** This function prompts the user/operator to type in a response within the specified time. It accepts a reply that is returned to the calling program. Repository: python function ********************** isinstance() * ********************** used by f3() ********************** Repository: Article 174 ********************** isTypeStr() * ********************** returns True if variable is of type Str ********************** Repository: Article 155 ********************** ix_py.py * ix_py.txt * ********************** This is the original set of ix functions ********************** f3, inputWto, inputWTO, printShow Repository: Article 155 ********************** listSho() * ********************** this function shows the value of a variable ********************** This function is related to the show3 which is used to (optionally) print the value of a variable if the second parameter is True. If the second paramenter is False, nothing is output, permitting debugging control. Because it cannot be imported, listSho prints the function allowing it to be copy and pasted into the source code of the main program. Repository: Unknown ********************** mid() * ********************** incomplete routine to test the type of variable ********************** It will return b,c,s,f if the variable is boolean, complex, string or float I may be used in Vectors or in f3() or in show(). More sleuthing is required. Repository: na (defined and used in textpack() ********************** pack() * ********************** defined and used in textpack.py and in IX_textpack.py Also used in Tkinter for python GUI ********************** Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\piButtonSwitchesT9_On_pi.py ********************** piButton() * ********************** This function treats a GPIO pushButton input and/or a photoCell as a pushButton. It should return a "0" when not "pushed" and return a "1" when "pushed." ********************** Repository: Fla52S ********************** plot() * ********************** this function plots a short (64 char) vector on the screen uses plotVector, changeInRC() ********************** A vector is used to house a series of numerical values. These values are often a set of readings of a parameter (e.g. ambient light). One use is to house a waveform. This function will plot the waveform of the real values to a screen. The time when each sample was taken can be stored as the second (imaginary) component of each reading. Repository: Article 174 ********************** show() * ********************** this function prints a variable when debugging also used as show3() and sho() and listSho() ********************** Also see listSho(). Repository: Article 174 ********************** show3() * ********************** this function prints a variable when debugging ********************** See listSho. Repository: Article 153 ********************** Talker() * ********************** Source: https://github.com/romilly/pico-code/blob/master/docs/talker.md this function talks to the pico from the pi ********************** from talker import Talker blinker(), send(), receive, close() Run pip3 install pyserial. on the pico: gist software as main Repository: Fla52S ************************** weatherHatPi system * ************************** weatherHat functions ********************** This is a set of routines that facilitate the use of the Seeed WheaterHat Pro device. It contains electronics to measure ambTemp, ambHum and ambPress. It also contains 3 usable ADC (Analog to Digital Converter) points. It can be used to measure a remote temperature and to control one or more digital output points. The author has modified this Hat for use by the PiR2 system. Stored in C:\Users\mrmyr\Documents\2022\DocsC\RPi\IX_Python_Library\IX_Python_Functions.txt Backed up in Fla58S064G\E:\BUs_byHand\2022CMar11\IX_Python_Functions.txt Stored in C:\Users\mrmyr\Documents\2022\DocsC\RPi\IX_Python_Library\IX_Python_Functions.txt ############################################################################################### PYTHON PICO FUNCTIONS AND TEST PROGRAMS List of pico functions / programs fadeLed_pico.py PiPico_vs_Pi.txt printTimTemp.py Python_vs_MicroPython.txt signalGenerator_pico.py squareWave_pico.py test_blinkLED.py testLeds_pico.py testTxC_pico.py Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\PiPico\signalGenerator_pico.py Repository: Fla52 ****************************** fadeLed_pico.py * ****************************** this pico program produces a sine wave in a Vector using a Pico. Example of using PIO for PWM, and fading the brightness of an LED. ********************** from machine import Pin from rp2 import PIO, StateMachine, asm_pio from time import sleep functions: pwm_prog class PIOPWM def __init__ def set Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\PiPico\PiPico_vs_Pi.txt Repository: Fla52S *********************** PiPico_vs_Pi.txt * *********************** BC-Robotics SKU: RAS-200 CAD$7.95 *********************************************** This merely describes a little Pi-Pico board Repository: pi_folderD_2021G19 Repository: Fla52S ************************* printTimTemp.py * ************************* This causes the pico to print the Time and Temp. The Pi will "see" these values on the ser port ********************** import machine import utime Repository: E:\BUs_byHand\2021GJul19\_Fla52S032G\pi_folderD_2021G19\Desktop\Python\PiPico\signalGenerator_pico.py Repository: Fla52 ****************************** signalGenerator_pico.py * ****************************** this pico program produces a sine wave in a Vector using a Pico ********************** from time import sleep_us, sleep_ms import _thread functions: read_pot() Repository: pi_folderD_2021G19 Repository: Fla52S *************************** squareWave_pico.py * *************************** This causes the pico to generate a square wave ********************** import machine import utime Functions: tick(), init(), pin(), toggle() Repository: home/pi Repository: Fla56S ************************* test_blinkLED.py * ************************* This blinks the leds on the pico ********************** import RPi.GPIO as GPIO import time Functions: setmode(), setup(), output(), sleep(), input() Repository: pi_folderD_2021G19 Repository: Fla52S ************************* testLeds_pico.py * ************************* This tests the leds on the pico ********************** from machine import Pin import time Functions: pin(), value(), sleep() Repository: pi_folderD_2021G19 Repository: Fla52S ************************* testTxC_pico.py * ************************* This was designed to communication with the pico using the uart, but was found to not be needed, I think ********************** import os import utime from machine import UART, Pin Functions: serTx_pico(), bChar(), txParse(), txChar(), sendThisPack(), sendLastPack(), serRx_pico(), mpyRead() stored in C:\Users\mrmyr\Documents\2022\DocsC\RPi\IX_Python_Library\IX_Python_Functions.txt stored online in Article 174 /IX_Python_Functions.txt ********************************************************************************************************** Executable Scripts on Unix Unix and Linux users: you can also make text files of Python source code directly executable by adding a special line at the top with the path to the Python interpreter and giving the file executable permission. For instance, type this code into a text file called myscript: #!/usr/bin/python print 'And nice red uniforms' The first line is normally taken as a comment by Python (it starts with a #); but when this file is run, the operating system sends lines in this file to the interpreter listed after #! on line 1. If this file is made directly executable with a shell command of the form chmod +x myscript, it can be run directly without typing python in the command, as though it were a binary executable program: % myscript a b c And nice red uniforms When run this way, sys.argv will still have the script's name as the first word in the list: ["myscript", "a", "b", "c"], exactly as if the script had been run with the more explicit and portable command form python myscript a b c. Making scripts directly executable is actually a Unix trick, not a Python feature, but it's worth pointing out that it can be made a bit less machine dependent by listing the Unix env command at the top instead of a hardcoded path to the Python executable: #!/usr/bin/env python print 'Wait for it...' When coded this way, the operating system will employ your environment variable settings to locate your Python interpreter (your PATH variable, on most platforms). If you run the same script on many machines, you need only change your environment settings on each machine (you don't need to edit Python script code). Of course, you can always run Python files with a more explicit command line: % python myscript a b c This assumes that the python interpreter program is on your system's search path setting (otherwise, you need to type its full path), but it works on any Python platform with a command line. Since this is more portable, I generally use this convention in the book's examples, but consult your Unix manpages for more details on any of the topics mentioned here. Even so, these special #! lines will show up in many examples in this book just in case readers want to run them as executables on Unix or Linux; on other platforms, they are simply ignored as Python comments. Note that on recent flavors of Windows, you can usually also type a script's filename directly (without the word python) to make it go, and you don't have to add a #! line at the top. Python uses the Windows registry on this platform to declare itself as the program that opens files with Python extensions (.py and others). This is also why you can launch files on Windows by clicking on them. Source: http://www.aksiom.net/stuff/docs/OReilly.Programming.Python.3rd.Edition.Aug.2006/0596009259/python3-CHP-3-SECT-7.html # by D@CC on 2022CMar11 #/ExecutableScriptsOnUnix.txt