sync with O'Reilly Atlas
This commit is contained in:
@@ -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[]
|
||||
|
||||
@@ -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[]
|
||||
|
||||
@@ -3,7 +3,7 @@ import typing
|
||||
class Coordinate(typing.NamedTuple):
|
||||
|
||||
lat: float
|
||||
long: float
|
||||
lon: float
|
||||
|
||||
trash = Coordinate('foo', None) # <1>
|
||||
print(trash)
|
||||
|
||||
Reference in New Issue
Block a user