Python Forum
Python got it right; ls got it wrong
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python got it right; ls got it wrong
#1
Python got it right. ls and sort both got it wrong.
Output:
lt1/pdh /home/pdh 80> python -c 'print ord("-"),ord("0")' 45 48 lt1/pdh /home/pdh 81> python -c 'print sorted(["yes0","yes-list.txt"])' ['yes-list.txt', 'yes0'] lt1/pdh /home/pdh 82> ls -1 yes-list.txt yes0 yes0 yes-list.txt lt1/pdh /home/pdh 83> printf 'yes-list.txt\nyes0\n'|sort yes0 yes-list.txt lt1/pdh /home/pdh 84>
i guess i need to rewrite these commands in Python. i was going to rewrite my rls command in Pythpn so it would be easier to add new features. but no hurry as it (the original version written in C) also sorted the listing right.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
Read this however. You may need to export LC_ALL=C
Reply
#3
(Aug-10-2018, 07:39 AM)Gribouillis Wrote: Read this however. You may need to export LC_ALL=C
that seems to break UTF-8.

so Python's sort doesn't follow the same "standards" as the sort command?
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020