Changeset 1727:2652fb65ded9


Ignore:
Timestamp:
Dec 26, 2018, 8:15:44 PM (3 months ago)
Author:
Stefan Schwarzer <sschwarzer@…>
Branch:
default
Message:
Use `print` as a function in non-code

Add parentheses for `print` calls in

- documentation
- docstrings
- comments
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • doc/ftputil.txt

    r1711 r1727  
    185185    ...     f = open("not_there")
    186186    ... except IOError as obj:
    187     ...     print obj.errno
    188     ...     print obj.strerror
     187    ...     print(obj.errno)
     188    ...     print(obj.strerror)
    189189    ...
    190190    2
     
    199199    ...     f = ftp_host.open("not_there")
    200200    ... except IOError as obj:
    201     ...     print obj.errno
    202     ...     print obj.strerror
     201    ...     print(obj.errno)
     202    ...     print(obj.strerror)
    203203    ...
    204204    550
     
    327327
    328328    with ftputil.FTPHost(server, user, password) as ftp_host:
    329         print ftp_host.listdir(ftp_host.curdir)
     329        print(ftp_host.listdir(ftp_host.curdir))
    330330
    331331After the ``with`` block, the ``FTPHost`` instance and the
     
    913913        ftp_host2.remove("some_file")
    914914        # `ftp_host1` will still see the obsolete cache entry!
    915         print ftp_host1.stat("some_file")
     915        print(ftp_host1.stat("some_file"))
    916916        # Will raise an exception since an `FTPHost` object
    917917        # knows of its own changes.
    918         print ftp_host2.stat("some_file")
     918        print(ftp_host2.stat("some_file"))
    919919
    920920At first sight, it may appear to be a good idea to have a shared cache
     
    939939        ftp_host1.stat_cache.invalidate(absolute_path)
    940940        # Will now raise an exception as it should.
    941         print ftp_host1.stat("some_file")
     941        print(ftp_host1.stat("some_file"))
    942942        # Would raise an exception since an `FTPHost` object
    943943        # knows of its own changes, even without `invalidate`.
    944         print ftp_host2.stat("some_file")
     944        print(ftp_host2.stat("some_file"))
    945945
    946946The method ``invalidate`` can be used on any *absolute* path, be it a
     
    12391239            for line in input_file:
    12401240                # Do something with the line, e. g.
    1241                 print line.strip().replace("ftplib", "ftputil")
     1241                print(line.strip().replace("ftplib", "ftputil"))
    12421242
    12431243For more on file objects, see the section `File objects`_ in the
  • ftputil/__init__.py

    r1726 r1727  
    1313    # Example session
    1414    with ftputil.FTPHost("ftp.domain.com", "me", "secret") as host:
    15         print host.getcwd()  # e. g. "/home/me"
     15        print(host.getcwd())  # e. g. "/home/me"
    1616        host.mkdir("newdir")
    1717        host.chdir("newdir")
  • ftputil/lrucache.py

    r1713 r1727  
    9595        cache['foo'] = contents
    9696
    97     print cache.size # Maximum size
    98 
    99     print len(cache) # 0 <= len(cache) <= cache.size
     97    print(cache.size) # Maximum size
     98
     99    print(len(cache)) # 0 <= len(cache) <= cache.size
    100100
    101101    cache.size = 10 # Auto-shrink on size assignment
     
    104104        cache[i] = i
    105105
    106     if 0 not in cache: print 'Zero was discarded.'
     106    if 0 not in cache: print('Zero was discarded.')
    107107
    108108    if 42 in cache:
     
    110110
    111111    for j in cache:   # iterate (in LRU order)
    112         print j, cache[j] # iterator produces keys, not values
     112        print(j, cache[j]) # iterator produces keys, not values
    113113    """
    114114
  • ftputil/sync.py

    r1723 r1727  
    8282        #TODO Handle setting of target mtime according to source mtime
    8383        # (beware of rootdir anomalies; try to handle them as well).
    84         #print "Making", target_dir
     84        #print("Making", target_dir)
    8585        if self._target.path.isfile(target_dir):
    8686            raise ftputil.error.SyncError(
    87                   "target dir '{}' is actually a file".format(target_dir))
     87                    "target dir '{}' is actually a file".format(target_dir))
    8888        # Deliberately use an `isdir` test instead of `try/except`. The
    8989        #  latter approach might mask other errors we want to see, e. g.
     
    100100        #TODO Handle setting of target mtime according to source mtime
    101101        # (beware of rootdir anomalies; try to handle them as well).
    102         #print "Syncing", source_file, "->", target_file
     102        #print("Syncing", source_file, "->", target_file)
    103103        source = self._source.open(source_file, "rb")
    104104        try:
Note: See TracChangeset for help on using the changeset viewer.