Python does not have built-in support for Arrays, but Python Lists can be used instead. If you must work with arrays in Python you will have to import a library, like the NumPy library. Key Value arrays In python you use Dictionaries for this
All posts by
malloc
Temporary memory example
Working With Directories
We use pathlib and forward slashes so that the Path() function can be used to automatically convert backslash to forward slash on Linux systems. Does directory exist? Create Directory
Auto running your program – Linux
Auto-running a Python file within a terminal window See our page here. Auto running a program with auto restart on crash See our page here. Make the .sh file executable and then run it. To forcibly exit use: CTRL+C
Write File
Write text file Write binary file
Defines
See Constants
Constants
In Python there aren’t specifically constants, you just assign a value to a variable as you normally would. You could assign a new value to it later if you wanted, but for a constant you just don’t. PI = 3.14GRAVITY = 9.8MY_STRING = ‘Hello world’ Creating constants in a different file Create the file called, […]
Installing Python in Windows
Download the latest version from: https://www.python.org/downloads/ Ensure you are admin and run the installer, select “Customize installation”Ensure “for all users” is checkedPress Next Install Python for all users = checked Add Python to environmental variables = Checked Removing the MAX_PATH Limitation Using regedit, set LongPathsEnabled to 1 in the registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem. Updating Python to […]
.3 Using Visual Studio Code
Resources https://code.visualstudio.com/docs/python/python-tutorial Creating a new Python project VS Code menu > File > Open Folder Open a folder that will be your workspace (you can just open an empty folder you’ve created). Turn off Dropbox if your folder is within Dropbox (causes file access issues for us at times) Now create a virtual environment for […]
Running Python scripts & programs
Using the Windows command prompt This is the format of what you need to enter python Instructs that you want to use python.exe for this. Sometimes you need to enter “python3” instead of “python”, if that’s what your .exe is named. This assumes you have the path to python.exe added to your Windows PATH environmental […]