Re: .title() - annoying mistake

2021-03-21 Thread Robert Latest via Python-list
Chris Angelico wrote:
> On Sun, Mar 21, 2021 at 4:31 AM Robert Latest via Python-list
> wrote:
>>
>> Mats Wichmann wrote:
>> > The problem is that there isn't a standard for title case,
>>
>> The problem is that we owe the very existence of the .title() method to too
>> much weed being smoked during Python development. It makes specific
>> assumptions about a specific use case of one specific language. It doesn't
>> get more idiotic, frankly.
>>
>
> The problem is that you haven't read the documentation :) It very carefully
> does NOT define itself by language, and its behaviour is identical regardless
> of the language used.

The documentation says: "The algorithm uses a simple language-independent
definition of a word as groups of consecutive letters..."

Yes, I get that. But the purpose it (improperly) serves only makes sense in the
English language. Which is also the reason they called it title() and not
capitalize_words(). Frankly, I can't think of any situation where this method
would have any use -- in any language, including English. It is just a
completely arbitrary feature, as would be a function that capitalizes only the
last letter of each word.

robert
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Benjamin Schollnick
>> The problem is that you haven't read the documentation :) It very carefully
>> does NOT define itself by language, and its behaviour is identical regardless
>> of the language used.
> 
> The documentation says: "The algorithm uses a simple language-independent
> definition of a word as groups of consecutive letters..."
> 
> Yes, I get that. But the purpose it (improperly) serves only makes sense in 
> the
> English language. Which is also the reason they called it title() and not
> capitalize_words(). Frankly, I can't think of any situation where this method
> would have any use -- in any language, including English. It is just a
> completely arbitrary feature, as would be a function that capitalizes only the
> last letter of each word.

I’m sorry Robert, but just because it doesn’t meet your requirements, doesn’t 
mean it’s useless.

I use .title to normalize strings for data comparison, all the time.  It’s a 
perfect alternative to
using .UPPER or .lower.  

Right in the documentation, it specifically acknowledges .title working in 
foreign character sets. 

So while I feel for the fact that it doesn’t met your requirements, please keep 
in mind, it does meet other peoples requirements.  

As with everything here, it’s open source.  If you feel that there should be a 
revised version that does met your requirements create it, or gather a bunch of 
people and go the route of SCANDIR and open-source it, and petition that it be 
moved into the standard library.

Since this seems to be bugging you this much, come up with a solution.  

I suspect the problem you are going to have is that in effect you’ll be 
creating a multi-language parser, even worse, you may have to add nameparsing 
into this.

Good luck.

- Benjamin



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Chris Angelico
On Sun, Mar 21, 2021 at 10:31 PM Robert Latest via Python-list
 wrote:
>
> Chris Angelico wrote:
> > On Sun, Mar 21, 2021 at 4:31 AM Robert Latest via Python-list
> > wrote:
> >>
> >> Mats Wichmann wrote:
> >> > The problem is that there isn't a standard for title case,
> >>
> >> The problem is that we owe the very existence of the .title() method to too
> >> much weed being smoked during Python development. It makes specific
> >> assumptions about a specific use case of one specific language. It doesn't
> >> get more idiotic, frankly.
> >>
> >
> > The problem is that you haven't read the documentation :) It very carefully
> > does NOT define itself by language, and its behaviour is identical 
> > regardless
> > of the language used.
>
> The documentation says: "The algorithm uses a simple language-independent
> definition of a word as groups of consecutive letters..."
>
> Yes, I get that. But the purpose it (improperly) serves only makes sense in 
> the
> English language.

Why? Do titles not exist in other languages? Does no other language
capitalize words in book or other titles?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Albert-Jan Roskam
   On 20 Mar 2021 23:47, Cameron Simpson  wrote:

 On 20Mar2021 12:53, Sibylle Koczian  wrote:
 >Am 20.03.2021 um 09:34 schrieb Alan Bawden:
 >>The real reason Python strings support a .title() method is surely
 >>because Unicode supports upper, lower, _and_ title case letters, and
 >>tells you how to map between them. [...]
 >>
 >But that's exactly what he's doing, with a result which is documented,
 >but not really satisfactory.

   
   This would be a good
   start: 
https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
   It could be locale-dependent. What I also don't like about .title() is
   that it messes up abbreviations ("Oecd")
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Richard Damon
On 3/21/21 8:19 AM, Albert-Jan Roskam wrote:
>On 20 Mar 2021 23:47, Cameron Simpson  wrote:
>
>  On 20Mar2021 12:53, Sibylle Koczian  wrote:
>  >Am 20.03.2021 um 09:34 schrieb Alan Bawden:
>  >>The real reason Python strings support a .title() method is surely
>  >>because Unicode supports upper, lower, _and_ title case letters, and
>  >>tells you how to map between them. [...]
>  >>
>  >But that's exactly what he's doing, with a result which is documented,
>  >but not really satisfactory.
>
>
>This would be a good
>start: 
> https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
>It could be locale-dependent. What I also don't like about .title() is
>that it messes up abbreviations ("Oecd")

The built in title() function is basically an intentionally 80%
solution. It handles the simple cases simply, and if you might have the
more complicated cases, you have to handle that yourself because to
specify what the 'right' answer would be is basically impossible to do
in general (because there are conflicting definitions, and some things
require context beyond what just its input provides).

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Robert Latest via Python-list
Benjamin Schollnick wrote:
>
> I’m sorry Robert, but just because it doesn’t meet your requirements, doesn’t
> mean it’s useless.
>
> I use .title to normalize strings for data comparison, all the time.  It’s a
> perfect alternative to using .UPPER or .lower.  
>
> Right in the documentation, it specifically acknowledges .title working in
> foreign character sets. 
>
> So while I feel for the fact that it doesn’t met your requirements, please
> keep in mind, it does meet other peoples requirements.  
>
> As with everything here, it’s open source.  If you feel that there should be
> a revised version that does met your requirements create it, or gather a
> bunch of people and go the route of SCANDIR and open-source it, and petition
> that it be moved into the standard library.
>
> Since this seems to be bugging you this much, come up with a solution.  

I agree with everything you say. Especially the open source part. But wouldn't
you agree that .title() with all its arbitrary specificity to appear in the
very core of a general purpose language is quite an oddity?

robert
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Robert Latest via Python-list
Chris Angelico wrote:
> On Sun, Mar 21, 2021 at 10:31 PM Robert Latest via Python-list
> wrote:
>> Yes, I get that. But the purpose it (improperly) serves only makes sense in
>> the English language.
>
> Why? Do titles not exist in other languages? Does no other language
> capitalize words in book or other titles?

I wonder if .title() properly capitalizes titles in any language. It doesn't in
English (nor does it purport to), so it begs the question why it is there in
the first place. German and Spanish don't have any special capitalization rules
for titles; I don't know about any other languages. 

robert
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Chris Angelico
On Mon, Mar 22, 2021 at 2:16 AM Robert Latest via Python-list
 wrote:
>
> Chris Angelico wrote:
> > On Sun, Mar 21, 2021 at 10:31 PM Robert Latest via Python-list
> > wrote:
> >> Yes, I get that. But the purpose it (improperly) serves only makes sense in
> >> the English language.
> >
> > Why? Do titles not exist in other languages? Does no other language
> > capitalize words in book or other titles?
>
> I wonder if .title() properly capitalizes titles in any language. It doesn't 
> in
> English (nor does it purport to), so it begs the question why it is there in
> the first place. German and Spanish don't have any special capitalization 
> rules
> for titles; I don't know about any other languages.
>

It correctly title-cases a single character, as has been pointed out
already. Attempting to do this with upper() or lower() will give
incorrect results. So if you want to define language-specific rules
(maybe with a regex) for splitting into words and subwords, you can
then use title() and lower() to perform the actual changes.

Treat it as a building-block rather than as a magical "do what I want"
function, and it is incredibly useful, and in fact, is the only way to
be correct.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Paul Bryan
The topic of titles is complex, and would be significant undertaking to
automate. It's not only highly language-dependent, it's also based on
the subject work itself, and subject to guidelines of those charged
with indexing such works.

MusicBrainz guidelines:
https://wiki.musicbrainz.org/Style/Titles
https://wiki.musicbrainz.org/Style#Language_specific_guidelines

Wikipedia guidelines:
https://en.wikipedia.org/wiki/Wikipedia:Naming_conventions_(capitalization)
https://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style/Titles#Capital_letters

Addressing such complexities isn't going to be baked into the
simplistic `str.title` method. As demonstrated by the OP, it will
almost certainly come up short, even in the simplest use case. I
suggest the best approach then is to find (or write) a module that
addresses the specific use case, not try to address such shortcomings
in `str`.

Paul

On Sun, 2021-03-21 at 23:01 +1100, Chris Angelico wrote:
> On Sun, Mar 21, 2021 at 10:31 PM Robert Latest via Python-list
>  wrote:
> > 
> > Chris Angelico wrote:
> > > On Sun, Mar 21, 2021 at 4:31 AM Robert Latest via Python-list
> > >  wrote:
> > > > 
> > > > Mats Wichmann wrote:
> > > > > The problem is that there isn't a standard for title case,
> > > > 
> > > > The problem is that we owe the very existence of the .title()
> > > > method to too
> > > > much weed being smoked during Python development. It makes
> > > > specific
> > > > assumptions about a specific use case of one specific language.
> > > > It doesn't
> > > > get more idiotic, frankly.
> > > > 
> > > 
> > > The problem is that you haven't read the documentation :) It very
> > > carefully
> > > does NOT define itself by language, and its behaviour is
> > > identical regardless
> > > of the language used.
> > 
> > The documentation says: "The algorithm uses a simple language-
> > independent
> > definition of a word as groups of consecutive letters..."
> > 
> > Yes, I get that. But the purpose it (improperly) serves only makes
> > sense in the
> > English language.
> 
> Why? Do titles not exist in other languages? Does no other language
> capitalize words in book or other titles?
> 
> ChrisA

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Benjamin Schollnick

> I agree with everything you say. Especially the open source part. But wouldn't
> you agree that .title() with all its arbitrary specificity to appear in the
> very core of a general purpose language is quite an oddity?

No, because it book ends the issue.

Upper - Converts everything to uppercase
Lower - Converts everything to lowercase

Title - Covers the cases in-between upper/lower.  

I’ll agree that if title was to respect language definitions, that there would 
be a problem here…  But it specifically states otherwise.

And as I mentioned the sheer amount of work that would be needed would probably 
cover a phd dissertation or more…  It’s a huge problem set to respect one 
language, let alone all languages.  

So the only answer is to not respect the languages, and leave that up to a 
later implementation or for someone else to assist in adding in support.

Heck, how do we prevent it from titlecasing abbreviations?  (This is plain text 
not XML….  If it was XML it would be easy!)

- Benjamin


-- 
https://mail.python.org/mailman/listinfo/python-list


thought

2021-03-21 Thread Quentin Bock
I had a recent thought about someone's wifi/network connection and password.
Could it be possible to create a program that will randomize a new password
every 24 hours (letters and numbers) and when the program is opened (or
notification would be sent) you can see the new password to log into the
wifi?
If so what would be required to do this, and what skillset would you need
to write this code if possible. If this isn't possible with python, then
what program is it possible with?


Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Chris Angelico
On Mon, Mar 22, 2021 at 5:40 AM Benjamin Schollnick
 wrote:
> Heck, how do we prevent it from titlecasing abbreviations?  (This is plain 
> text not XML….  If it was XML it would be easy!)

We haven't managed to teach humans how to do that, so I doubt we'll
ever teach a simple standard library function to do it.

*cough*XMLHttpRequest*cough*

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: thought

2021-03-21 Thread Chris Angelico
On Mon, Mar 22, 2021 at 6:03 AM Quentin Bock  wrote:
>
> I had a recent thought about someone's wifi/network connection and password.
> Could it be possible to create a program that will randomize a new password
> every 24 hours (letters and numbers) and when the program is opened (or
> notification would be sent) you can see the new password to log into the
> wifi?
> If so what would be required to do this, and what skillset would you need
> to write this code if possible. If this isn't possible with python, then
> what program is it possible with?

Generating passwords is easy. How do you manage the logins though? Is
it going to involve reconfiguring the wifi router? If so, you'll need
knowledge specifically about the router you're working with.

For the basic idea of "a new password every X time", I'd recommend
looking into Time-based One-Time Passwords or TOTPs. They're often
used for two-factor authentication (those things that say "enter this
six-digit number" are usually TOTPs), and for that purpose, they
usually cycle about every minute or thereabouts; but the same ideas
would apply to a daily password too.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Richard Damon
On 3/21/21 2:39 PM, Benjamin Schollnick wrote:
>> I agree with everything you say. Especially the open source part. But 
>> wouldn't
>> you agree that .title() with all its arbitrary specificity to appear in the
>> very core of a general purpose language is quite an oddity?
> No, because it book ends the issue.
>
> Upper - Converts everything to uppercase
> Lower - Converts everything to lowercase
>
> Title - Covers the cases in-between upper/lower.  
>
> I’ll agree that if title was to respect language definitions, that there 
> would be a problem here…  But it specifically states otherwise.
>
> And as I mentioned the sheer amount of work that would be needed would 
> probably cover a phd dissertation or more…  It’s a huge problem set to 
> respect one language, let alone all languages.  
>
> So the only answer is to not respect the languages, and leave that up to a 
> later implementation or for someone else to assist in adding in support.
>
> Heck, how do we prevent it from titlecasing abbreviations?  (This is plain 
> text not XML….  If it was XML it would be easy!)
>
>   - Benjamin

One important thing to remember is that there ARE a few characters that
are themselves 'Title case', so we can't live with just upper and lower.
These all are 'digraphs', i.e. look like two letters, but this glyph
does act as a single character for many purposes. One example that has
been given is Dz which is different than Dz.

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Grant Edwards
On 2021-03-20, Robert Latest via Python-list  wrote:
> Mats Wichmann wrote:
>> The problem is that there isn't a standard for title case,
>
> The problem is that we owe the very existence of the .title() method to too
> much weed being smoked during Python development. It makes specific 
> assumptions
> about a specific use case of one specific language. It doesn't get more
> idiotic, frankly.

Ah, you've never used PHP then?

I haven't checked but it's a fair bit that PHP has 3-4 different
built-in ways to do it, and they're all broken in interestingly
unpredictable ways.

--
Grant



-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Grant Edwards
On 2021-03-20, Alan Bawden  wrote:
> Sibylle Koczian  writes:
>
>Am 20.03.2021 um 09:34 schrieb Alan Bawden:
>>
>> When you write that code to capitalize your book titles, you should be
>> calling .title() rather than .upper() if you are doing it right.
>>
>But that's exactly what he's doing, with a result which is documented, but
>not really satisfactory.
>
> Sorry, what I wrote was ambiguous.  What I _meant_ was that when you
> replace x.title() with my_title(x) , then in the definition of my_title
> you will be calling both .lower() and .title() on individual characters,
> but you will probably _never_ be calling .upper().

Does Python have any way to convert a character to titlecase? The
documentation for .title() explicitly states that it will convert a
character to upper case, not to title case.

--
Grant




-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Grant Edwards
On 2021-03-21, Chris Angelico  wrote:
> On Mon, Mar 22, 2021 at 2:16 AM Robert Latest via Python-list 
>  wrote:
>
>> I wonder if .title() properly capitalizes titles in any language. It doesn't 
>> in
>> English (nor does it purport to), so it begs the question why it is there in
>> the first place. German and Spanish don't have any special capitalization 
>> rules
>> for titles; I don't know about any other languages.
>>
>
> It correctly title-cases a single character, as has been pointed out
> already.

Not according to the docs. The doc states that .title() converts the
first character characger in each "word" to _upper_ case. Is the doc
wrong?

If you want titlecase, then you should call str.capitalize() which
(again according to the doc) converts the first character to _title_
case (starting in v3.8).

--
Grant


-- 
https://mail.python.org/mailman/listinfo/python-list


thought

2021-03-21 Thread Quentin Bock
Note: Previous comments have been made on this, this is my reply to another
response of this question.
I would have it so, the "admin" of the program would be able to change if
devices are allowed on that network, and would also be able to remove and
make certain devices always receive a password to input. It would not
involve reconfiguring the router, it would involve the devices attempting
to connect to it, but it wouldn't reconfigure the router itself; this would
merely provide another layer of security upon your wifi. I think that
certain features might rely on the reconfiguration of the router, but for
my question no I don't think it would.



Virus-free.
www.avast.com

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Benjamin Schollnick
>> Heck, how do we prevent it from titlecasing abbreviations?  (This is plain 
>> text not XML….  If it was XML it would be easy!)
> 
> We haven't managed to teach humans how to do that, so I doubt we'll
> ever teach a simple standard library function to do it.
> 
> *cough*XMLHttpRequest*cough*

True, but I was thinking that it would be easy in XML because the XML/HTML 
would be able to have metadata helping to define the components in the text 
stream.  

And this is probably more of a pseduo-html, but that’s because I do more work 
in HTML then I do in pure XML.  XML I usually just tell the system to output, 
instead of craft by hand…  


blah blah this is a sentence that has the abbreviation 
NASA in it.


But that doesn’t help title, because it only handles pure plaintext.  

As many people have pointed out, or I think they meant to point out, there is 
no place in the text string to put metadata that would help assist parsing the 
string.  By definition the text can’t have metadata, since it’s plaintext.  

- Benjamin


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Chris Angelico
On Mon, Mar 22, 2021 at 9:04 AM Grant Edwards  wrote:
>
> On 2021-03-21, Chris Angelico  wrote:
> > On Mon, Mar 22, 2021 at 2:16 AM Robert Latest via Python-list 
> >  wrote:
> >
> >> I wonder if .title() properly capitalizes titles in any language. It 
> >> doesn't in
> >> English (nor does it purport to), so it begs the question why it is there 
> >> in
> >> the first place. German and Spanish don't have any special capitalization 
> >> rules
> >> for titles; I don't know about any other languages.
> >>
> >
> > It correctly title-cases a single character, as has been pointed out
> > already.
>
> Not according to the docs. The doc states that .title() converts the
> first character characger in each "word" to _upper_ case. Is the doc
> wrong?
>
> If you want titlecase, then you should call str.capitalize() which
> (again according to the doc) converts the first character to _title_
> case (starting in v3.8).
>

Hmm, maybe it's different in 3.10, but the docs I'm seeing look fine.
But maybe there's a better way to word it for both of them.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread MRAB

On 2021-03-21 22:30, Chris Angelico wrote:

On Mon, Mar 22, 2021 at 9:04 AM Grant Edwards  wrote:


On 2021-03-21, Chris Angelico  wrote:
> On Mon, Mar 22, 2021 at 2:16 AM Robert Latest via Python-list 
 wrote:
>
>> I wonder if .title() properly capitalizes titles in any language. It doesn't 
in
>> English (nor does it purport to), so it begs the question why it is there in
>> the first place. German and Spanish don't have any special capitalization 
rules
>> for titles; I don't know about any other languages.
>>
>
> It correctly title-cases a single character, as has been pointed out
> already.

Not according to the docs. The doc states that .title() converts the
first character characger in each "word" to _upper_ case. Is the doc
wrong?

If you want titlecase, then you should call str.capitalize() which
(again according to the doc) converts the first character to _title_
case (starting in v3.8).



Hmm, maybe it's different in 3.10, but the docs I'm seeing look fine.
But maybe there's a better way to word it for both of them.

Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 
bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

help(str.title)

Help on method_descriptor:

title(self, /)
Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all 
remaining

cased characters have lower case.

'\N{LATIN CAPITAL LETTER DZ}', '\N{LATIN SMALL LETTER DZ}' and '\N{LATIN 
CAPITAL LETTER D WITH SMALL LETTER Z}' are all digraphs, so is it 
correct to say that .title() uppercases the first character? Kind of.

--
https://mail.python.org/mailman/listinfo/python-list


Pips for python2 and python3

2021-03-21 Thread Tim Johnson

Using ubuntu 20.04 as a recent install
with python3 (3.8.5) which was installed as part of the
original distribution install
and
python2 (2.7.18) that has been installed using apt.

I have a large amount of utilities written in python2 which I need to 
maintain

until I convert that code to python3

I see numerous caveats regarding the installing of pips for both these 
versions.


I would welcome advice on how to proceed which could very well be 
accomplished

by links to relevant discussions or documentation.

thanks
--

Tim
tj49.com

--
https://mail.python.org/mailman/listinfo/python-list


Re: Pips for python2 and python3

2021-03-21 Thread MRAB

Tn 2021-03-21 23:13, Tim Johnson wrote:

Using ubuntu 20.04 as a recent install
with python3 (3.8.5) which was installed as part of the
original distribution install
and
python2 (2.7.18) that has been installed using apt.

I have a large amount of utilities written in python2 which I need to
maintain
until I convert that code to python3

I see numerous caveats regarding the installing of pips for both these
versions.

I would welcome advice on how to proceed which could very well be
accomplished
by links to relevant discussions or documentation.


I'd suggest using the pip module:

python2 -m pip

and:

python3 -m pip
--
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Richard Damon
On 3/21/21 7:31 PM, MRAB wrote:
> On 2021-03-21 22:30, Chris Angelico wrote:
>> On Mon, Mar 22, 2021 at 9:04 AM Grant Edwards
>>  wrote:
>>>
>>> On 2021-03-21, Chris Angelico  wrote:
>>> > On Mon, Mar 22, 2021 at 2:16 AM Robert Latest via Python-list
>>>  wrote:
>>> >
>>> >> I wonder if .title() properly capitalizes titles in any language.
>>> It doesn't in
>>> >> English (nor does it purport to), so it begs the question why it
>>> is there in
>>> >> the first place. German and Spanish don't have any special
>>> capitalization rules
>>> >> for titles; I don't know about any other languages.
>>> >>
>>> >
>>> > It correctly title-cases a single character, as has been pointed out
>>> > already.
>>>
>>> Not according to the docs. The doc states that .title() converts the
>>> first character characger in each "word" to _upper_ case. Is the doc
>>> wrong?
>>>
>>> If you want titlecase, then you should call str.capitalize() which
>>> (again according to the doc) converts the first character to _title_
>>> case (starting in v3.8).
>>>
>>
>> Hmm, maybe it's different in 3.10, but the docs I'm seeing look fine.
>> But maybe there's a better way to word it for both of them.
>>
> Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928
> 64 bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
 help(str.title)
> Help on method_descriptor:
>
> title(self, /)
>     Return a version of the string where each word is titlecased.
>
>     More specifically, words start with uppercased characters and all
> remaining
>     cased characters have lower case.
>
> '\N{LATIN CAPITAL LETTER DZ}', '\N{LATIN SMALL LETTER DZ}' and
> '\N{LATIN CAPITAL LETTER D WITH SMALL LETTER Z}' are all digraphs, so
> is it correct to say that .title() uppercases the first character?
> Kind of.

I think the clarification calling them upper cased characters is close
enough considering that there are only 31 title cased characters, all
digraphs.

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pips for python2 and python3

2021-03-21 Thread Dan Stromberg
On Sun, Mar 21, 2021 at 6:14 PM MRAB  wrote:

> Tn 2021-03-21 23:13, Tim Johnson wrote:
> > Using ubuntu 20.04 as a recent install
> > with python3 (3.8.5) which was installed as part of the
> > original distribution install
> > and
> > python2 (2.7.18) that has been installed using apt.
> >
> > I have a large amount of utilities written in python2 which I need to
> > maintain
> > until I convert that code to python3
> >
> > I see numerous caveats regarding the installing of pips for both these
> > versions.
> >
> > I would welcome advice on how to proceed which could very well be
> > accomplished
> > by links to relevant discussions or documentation.
> >
> I'd suggest using the pip module:
>
> python2 -m pip
>
> and:
>
> python3 -m pip
>
I agree with this advice.

Here's a more complete example:
python3 -m pip install treap
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pips for python2 and python3

2021-03-21 Thread Tim Johnson



On 3/21/21 5:14 PM, MRAB wrote:

Tn 2021-03-21 23:13, Tim Johnson wrote:

Using ubuntu 20.04 as a recent install
with python3 (3.8.5) which was installed as part of the
original distribution install
and
python2 (2.7.18) that has been installed using apt.

I have a large amount of utilities written in python2 which I need to
maintain
until I convert that code to python3

I see numerous caveats regarding the installing of pips for both these
versions.

I would welcome advice on how to proceed which could very well be
accomplished
by links to relevant discussions or documentation.


I'd suggest using the pip module:

python2 -m pip

and:

python3 -m pip

Understood. In addition, I 'm pretty sure that all I need to do is
copy dist-utils from my old machine to the new one. The python2
versions of the two machines are very close.

thank you MRAB

--
Tim
tj49.com

--
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Chris Angelico
On Mon, Mar 22, 2021 at 12:26 PM Richard Damon  wrote:
>
> On 3/21/21 7:31 PM, MRAB wrote:
> > On 2021-03-21 22:30, Chris Angelico wrote:
> >> On Mon, Mar 22, 2021 at 9:04 AM Grant Edwards
> >>  wrote:
> >>>
> >>> On 2021-03-21, Chris Angelico  wrote:
> >>> > On Mon, Mar 22, 2021 at 2:16 AM Robert Latest via Python-list
> >>>  wrote:
> >>> >
> >>> >> I wonder if .title() properly capitalizes titles in any language.
> >>> It doesn't in
> >>> >> English (nor does it purport to), so it begs the question why it
> >>> is there in
> >>> >> the first place. German and Spanish don't have any special
> >>> capitalization rules
> >>> >> for titles; I don't know about any other languages.
> >>> >>
> >>> >
> >>> > It correctly title-cases a single character, as has been pointed out
> >>> > already.
> >>>
> >>> Not according to the docs. The doc states that .title() converts the
> >>> first character characger in each "word" to _upper_ case. Is the doc
> >>> wrong?
> >>>
> >>> If you want titlecase, then you should call str.capitalize() which
> >>> (again according to the doc) converts the first character to _title_
> >>> case (starting in v3.8).
> >>>
> >>
> >> Hmm, maybe it's different in 3.10, but the docs I'm seeing look fine.
> >> But maybe there's a better way to word it for both of them.
> >>
> > Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928
> > 64 bit (AMD64)] on win32
> > Type "help", "copyright", "credits" or "license" for more information.
>  help(str.title)
> > Help on method_descriptor:
> >
> > title(self, /)
> > Return a version of the string where each word is titlecased.
> >
> > More specifically, words start with uppercased characters and all
> > remaining
> > cased characters have lower case.
> >
> > '\N{LATIN CAPITAL LETTER DZ}', '\N{LATIN SMALL LETTER DZ}' and
> > '\N{LATIN CAPITAL LETTER D WITH SMALL LETTER Z}' are all digraphs, so
> > is it correct to say that .title() uppercases the first character?
> > Kind of.
>
> I think the clarification calling them upper cased characters is close
> enough considering that there are only 31 title cased characters, all
> digraphs.
>

But it's wrong, and it would lead people to the exact error of
thinking that it's the same as upper() on str[0] and lower() on the
rest.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Pips for python2 and python3

2021-03-21 Thread MRAB

On 2021-03-22 01:34, Tim Johnson wrote:


On 3/21/21 5:14 PM, MRAB wrote:

Tn 2021-03-21 23:13, Tim Johnson wrote:

Using ubuntu 20.04 as a recent install
with python3 (3.8.5) which was installed as part of the
original distribution install
and
python2 (2.7.18) that has been installed using apt.

I have a large amount of utilities written in python2 which I need to
maintain
until I convert that code to python3

I see numerous caveats regarding the installing of pips for both these
versions.

I would welcome advice on how to proceed which could very well be
accomplished
by links to relevant discussions or documentation.


I'd suggest using the pip module:

python2 -m pip

and:

python3 -m pip

Understood. In addition, I 'm pretty sure that all I need to do is
copy dist-utils from my old machine to the new one. The python2
versions of the two machines are very close.

thank you MRAB


By "very close", I hope you mean that they're both Python 2.7.x.
--
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Richard Damon
On 3/21/21 10:28 PM, Chris Angelico wrote:
> On Mon, Mar 22, 2021 at 12:26 PM Richard Damon  
> wrote:
>> On 3/21/21 7:31 PM, MRAB wrote:
>>> On 2021-03-21 22:30, Chris Angelico wrote:
 On Mon, Mar 22, 2021 at 9:04 AM Grant Edwards
  wrote:
> On 2021-03-21, Chris Angelico  wrote:
>> On Mon, Mar 22, 2021 at 2:16 AM Robert Latest via Python-list
>  wrote:
>>> I wonder if .title() properly capitalizes titles in any language.
> It doesn't in
>>> English (nor does it purport to), so it begs the question why it
> is there in
>>> the first place. German and Spanish don't have any special
> capitalization rules
>>> for titles; I don't know about any other languages.
>>>
>> It correctly title-cases a single character, as has been pointed out
>> already.
> Not according to the docs. The doc states that .title() converts the
> first character characger in each "word" to _upper_ case. Is the doc
> wrong?
>
> If you want titlecase, then you should call str.capitalize() which
> (again according to the doc) converts the first character to _title_
> case (starting in v3.8).
>
 Hmm, maybe it's different in 3.10, but the docs I'm seeing look fine.
 But maybe there's a better way to word it for both of them.

>>> Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928
>>> 64 bit (AMD64)] on win32
>>> Type "help", "copyright", "credits" or "license" for more information.
>> help(str.title)
>>> Help on method_descriptor:
>>>
>>> title(self, /)
>>> Return a version of the string where each word is titlecased.
>>>
>>> More specifically, words start with uppercased characters and all
>>> remaining
>>> cased characters have lower case.
>>>
>>> '\N{LATIN CAPITAL LETTER DZ}', '\N{LATIN SMALL LETTER DZ}' and
>>> '\N{LATIN CAPITAL LETTER D WITH SMALL LETTER Z}' are all digraphs, so
>>> is it correct to say that .title() uppercases the first character?
>>> Kind of.
>> I think the clarification calling them upper cased characters is close
>> enough considering that there are only 31 title cased characters, all
>> digraphs.
>>
> But it's wrong, and it would lead people to the exact error of
> thinking that it's the same as upper() on str[0] and lower() on the
> rest.
>
> ChrisA

If it didn't mention that it was generating a 'titlecase' that could be
an argument, but since for 99.99% of characters Title Casing is
identical to upper case (and that character IS called the upper case),
but for the 31 listed digraphs, it means the titlecase version of that
digraph where the first 'letter' in the digraph is like the upper case
of its equivalent, and the second 'letter' in the digraph is like the
lower case of its equivalent.

Basically, titlecasing a word IS making the first letter upper case and
the rest lower case UNLESS the first letter is on of the 31 digraphs
which have a special titlecase version, then that is used for the first
letter. That gets pretty wordy for an explanation string.

-- 
Richard Damon

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: .title() - annoying mistake

2021-03-21 Thread Chris Angelico
On Mon, Mar 22, 2021 at 2:00 PM Richard Damon  wrote:
> Basically, titlecasing a word IS making the first letter upper case and
> the rest lower case UNLESS the first letter is on of the 31 digraphs
> which have a special titlecase version, then that is used for the first
> letter. That gets pretty wordy for an explanation string.

It title cases. I don't understand what's a problem here. With
str.casefold(), there's no detailed explanation of how it's usually
equivalent to lowercasing - it just says that it returns a string
suitable for caseless comparisons. Unicode defines many things about
characters, and often the differences don't matter to a large subset
of those characters, but the differences exist for a reason, and lying
in the docstring isn't going to help anything.

It doesn't "uppercase unless it's one of this small group of
characters". It "title cases".

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list