Skip to content

Commit ceb0bd8

Browse files
committed
Switch to f-strings.
1 parent b14b2ad commit ceb0bd8

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

examples/magnetometer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,6 @@
7272
heading = round(heading)
7373

7474
# Note: Headings will not be correct until a full 360 deg calibration turn has been completed to generate amin and amax data
75-
print("Heading: {}".format(heading))
75+
print(f"Heading: {heading}")
7676

7777
time.sleep(0.1)

icm20948/__init__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,9 @@ def __init__(self, i2c_addr=I2C_ADDR, i2c_bus=None):
295295
x, y, z = imu.read_magnetometer_data()
296296
ax, ay, az, gx, gy, gz = imu.read_accelerometer_gyro_data()
297297

298-
print("""
299-
Accel: {:05.2f} {:05.2f} {:05.2f}
300-
Gyro: {:05.2f} {:05.2f} {:05.2f}
301-
Mag: {:05.2f} {:05.2f} {:05.2f}""".format(
302-
ax, ay, az, gx, gy, gz, x, y, z
303-
))
298+
print(f"""
299+
Accel: {ax:05.2f} {ay:05.2f} {az:05.2f}
300+
Gyro: {gx:05.2f} {gy:05.2f} {gz:05.2f}
301+
Mag: {x:05.2f} {y:05.2f} {z:05.2f}""")
304302

305303
time.sleep(0.25)

0 commit comments

Comments
 (0)