sync with O'Reilly Atlas

This commit is contained in:
Luciano Ramalho
2021-06-26 13:42:28 -03:00
parent e986e3bdc0
commit f0f160844d
26 changed files with 308 additions and 1004 deletions

View File

@@ -13,10 +13,10 @@ from typing import NamedTuple
class Coordinate(NamedTuple):
lat: float
long: float
lon: float
def __str__(self):
ns = 'N' if self.lat >= 0 else 'S'
we = 'E' if self.long >= 0 else 'W'
return f'{abs(self.lat):.1f}°{ns}, {abs(self.long):.1f}°{we}'
# end::COORDINATE[]
we = 'E' if self.lon >= 0 else 'W'
return f'{abs(self.lat):.1f}°{ns}, {abs(self.lon):.1f}°{we}'
# end::COORDINATE[]

View File

@@ -5,7 +5,7 @@ This version has a field with a default value::
>>> moscow = Coordinate(55.756, 37.617)
>>> moscow
Coordinate(lat=55.756, long=37.617, reference='WGS84')
Coordinate(lat=55.756, lon=37.617, reference='WGS84')
"""
@@ -15,6 +15,6 @@ from typing import NamedTuple
class Coordinate(NamedTuple):
lat: float # <1>
long: float
lon: float
reference: str = 'WGS84' # <2>
# end::COORDINATE[]
# end::COORDINATE[]

View File

@@ -3,7 +3,7 @@ import typing
class Coordinate(typing.NamedTuple):
lat: float
long: float
lon: float
trash = Coordinate('foo', None) # <1>
print(trash)