Ignore:
Timestamp:
Nov 22, 2015, 7:28:10 PM (4 years ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Use `if` expression instead of slightly obscure tuple indexing

Instead of

  command_type = ("STOR", "RETR")[is_read_mode]

use

  command_type = "RETR" if is_read_mode else "STOR"

The latter is much clearer. I assume the previous code was from a time
when Python didn't have `if` expressions yet and I didn't want to
write an `if` statement.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • ftputil/file.py

    r1564 r1611  
    8181            self._session.voidcmd(command)
    8282        # Make transfer command.
    83         command_type = ("STOR", "RETR")[is_read_mode]
     83        command_type = "RETR" if is_read_mode else "STOR"
    8484        command = "{0} {1}".format(command_type, path)
    8585        # Force to binary regardless of transfer type (see above).
Note: See TracChangeset for help on using the changeset viewer.