Python on Windows: Legacy vs New Features

Are you ready to learn how to install Python on Windows? It’s easy as pie (or maybe more like cake) with these simple steps!

First, the different ways you can download and install Python on your computer. If you want a default, system-wide installation that everyone can use, you can run this command from an elevated command prompt:

python-3.9.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0

This will install Python silently and add it to the system path so that all users on your computer can use it without having to manually set up their environment variables.

However, if you prefer a personal copy of Python for yourself (without the test suite), you can create a shortcut with this command:

python-3.9.0.exe /quiet Include_test=0

This will install Python silently and without running any tests. You’ll still have to manually add it to your environment variables, but that’s easy enough!

Now some of the newer features in Python that you might want to check out. For example, f-strings (formatted strings) allow you to embed expressions directly into string literals using the “f” prefix:

name = ‘John Doe’
age = 25
message = f’Hello, {name}! You are {age} years old.’

print(message)

This makes it much easier to create dynamic strings without having to use the “format()” function or concatenation. It also allows for more complex expressions and variables within your string literals!

Another new feature worth mentioning is the “async/await” syntax, which allows you to write asynchronous code that can handle multiple tasks at once:

import asyncio

def fetch_data():
# Simulate a long-running task (e.g., downloading data from the web)
await asyncio.sleep(3)

return ‘Data fetched!’

loop = asyncio.get_event_loop()
result = loop.run_until_complete(fetch_data())
print(result)

This allows for much cleaner and more efficient code when dealing with long-running tasks or multiple concurrent operations!

SICORPS