b: a = b" in python? Can you shorten the following example? if file_size_download > file_size: file_size_...">All geek questions in one placeIs there a shorter way to write "if a> b: a = b" in python?Can you shorten the following example?if file_size_download > file_size: file_size_download = file_sizeIt looks pretty awkward for me.+4pythonKami Mar 26 '11 at 14:20source share2 answers a = min(a, b) It is short and concise.+20N 1.1 Mar 26 '11 at 14:22source shareAs a more general answer: a = b if a < b else a The previous answer works fine in this particular case, but it can be useful in cases where it is not just a comparison < .0WhyNotHugo Jun 30 '12 at 2:19source shareSource: https://habr.com/ru/post/1345341/More articles:Internet Radio Player Component for Delphi / C ++ Builder - delphissh crashes when called in windows service - sshConfiguring OpenAL for Visual Studio 2008 - visual-studio-2008Can I use the> operator in the KRL () query selector? - krlCreate label programmatically - iphoneChar * vs NSString * - cUsing block expectations with OCMock - objective-cRemoving certain sequential duplicates in a list - pythonWhy use clone ()? - c #awakeFromFetch with unmanaged property - objective-cAll Articles
Can you shorten the following example?
if file_size_download > file_size: file_size_download = file_size
It looks pretty awkward for me.
a = min(a, b)
It is short and concise.
As a more general answer:
a = b if a < b else a
The previous answer works fine in this particular case, but it can be useful in cases where it is not just a comparison < .
<
Source: https://habr.com/ru/post/1345341/More articles:Internet Radio Player Component for Delphi / C ++ Builder - delphissh crashes when called in windows service - sshConfiguring OpenAL for Visual Studio 2008 - visual-studio-2008Can I use the> operator in the KRL () query selector? - krlCreate label programmatically - iphoneChar * vs NSString * - cUsing block expectations with OCMock - objective-cRemoving certain sequential duplicates in a list - pythonWhy use clone ()? - c #awakeFromFetch with unmanaged property - objective-cAll Articles