duplicity-talk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Duplicity-talk] Path.name, Path.uc_name and Path.b_name


From: Aaron
Subject: [Duplicity-talk] Path.name, Path.uc_name and Path.b_name
Date: Wed, 29 Nov 2017 23:19:04 +0000

Hello all,

I would appreciate views on the naming of the Unicode and bytes variants of a Path's filename.

Historically we have had Path.name, which has been a Python 2 string/bytes. For better Python 3 compatibility, we need to start moving towards all strings being Unicode and all bytes being bytes. As we still need to support Python 2 it is safest to keep the bytes version of the filename as well, rather than only keeping the Unicode version and converting on each use.

The three key options I see are:

  1. Use Path.uc_name for the Unicode version and Path.name for the bytes version, as I have done in my branch so far. Existing code does not need to change, but people may accidentally use Path.name when they want a string version of the filename.
  2. Globally rename Path.name to Path.b_name for the bytes version and use Path.uc_name for the Unicode version. This makes people think about which version they actually want.
  3. Use Path.name for the Unicode version and Path.b_name for the bytes version. This strongly encourages people to use the Unicode version (Python 3 style) unless they really need the bytes version (e.g. for a particular backend API or to access the file on disk).

I have currently gone for Option 1, as it is closest to what we are currently doing, but I think Option 2 may be most sensible if others agree.

Kind regards,

Aaron


reply via email to

[Prev in Thread] Current Thread [Next in Thread]