Path.name, Path.uc_name and Path.b_name

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Path.name, Path.uc_name and Path.b_name

duplicity-talk mailing list

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


_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk
Reply | Threaded
Open this post in threaded view
|

Re: Path.name, Path.uc_name and Path.b_name

duplicity-talk mailing list
I think #2 would be preferred in the long run.  Gets my vote.

...Ken


On Wed, Nov 29, 2017 at 5:19 PM, Aaron via Duplicity-talk <[hidden email]> wrote:

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


_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk



_______________________________________________
Duplicity-talk mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/duplicity-talk