Python ; , . , , .
approximate_size():
def approximate_size(size, a_kilobyte_is_1024_bytes=True):
a_kilobyte_is_1024_bytes True. , ; , Python , True .
:
if __name__ == '__main__':
print(approximate_size(1000000000000, False)) ①
print(approximate_size(1000000000000)) ②
① | approximate_size() . approximate_size() a_kilobyte_is_1024_bytes False, False . |
② | approximate_size() . , ! , True, . |
.
>>> from humansize import approximate_size
>>> approximate_size(4000, a_kilobyte_is_1024_bytes=False) ①
'4.0 KB'
>>> approximate_size(size=4000, a_kilobyte_is_1024_bytes=False) ②
'4.0 KB'
>>> approximate_size(a_kilobyte_is_1024_bytes=False, size=4000) ③
'4.0 KB'
>>> approximate_size(a_kilobyte_is_1024_bytes=False, 4000) ④
File "<stdin>", line 1
SyntaxError: non-keyword arg after keyword arg
>>> approximate_size(size=4000, False) ⑤
File "<stdin>", line 1
SyntaxError: non-keyword arg after keyword arg
:
"<stdin>", 1
SyntaxError:
① | approximate_size() 4000 False a_kilobyte_is_1024_bytes. ( , , .) |
② | approximate_size() 4000 size False a_kilobyte_is_1024_bytes. ( , , .) |
③ | approximate_size() False a_kilobyte_is_1024_bytes 4000 size. (? , .) |
④ | , (). , , . |
⑤ | , , . ? 4000 size, , , , False a_kilobyte_is_1024_bytes. Python . , . |
|
|
. , , , , (. . , - ). Python . .
Python , (. documentation string, docstring). approximate_size() :
def approximate_size(size, a_kilobyte_is_1024_bytes=True):
''' .
:
size --
a_kilobyte_is_1024_bytes -- True ( ), 1024
False, 1000
: (string)
'''
.
[1] [2] . , , , , , . , .
, () , qq/.../ Perl 5. |
, , , , . , , , . . . , , . , , Python .
IDE Python , , . , , . |