.


:




:

































 

 

 

 





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 , , . , , .




:


: 2016-11-18; !; : 519 |


:

:

: , .
==> ...

1684 - | 1644 -


© 2015-2024 lektsii.org - -

: 0.011 .