Re: Python Dialogs

2024-05-06 Thread Chris Angelico via Python-list
On Tue, 7 May 2024 at 03:42, jak via Python-list  wrote:
>
> Loris Bennett ha scritto:
> > r...@zedat.fu-berlin.de (Stefan Ram) writes:
> >
> >>Me (indented by 2) and the chatbot (flush left). Lines lengths > 72!
> >
> > Is there a name for this kind of indentation, i.e. the stuff you are
> > writing not being flush left?  It is sort of contrary to
> > what I think of as "normal" indentation.  You seem to use it in all your
> > postings, too, which hurts my brain, but I guess that's my problem :-)
> >
> > [snip (40 lines)]
> >
>
> It's not just your problem. When the texts are particularly long and
> complex, I happen to use Google-Translator. It makes bad translations if
> the lines are interrupted by the newline, so I wrote a tool dedicated to
> Stefan and to all those who indent like him. This tool takes the text
> from the clipboard, removes all the superfluous spaces, combines all the
> lines in one and puts the result back into the clipboard. :-D
>

Fun fact: His posts are completely irrelevant to people who follow the
mailing list. Due to a dispute over permissions, his posts are blocked
at the gateway. So all of us folks who use the mailing list never need
to see the wonky indentation.

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


Re: Python Dialogs

2024-05-06 Thread jak via Python-list

Loris Bennett ha scritto:

r...@zedat.fu-berlin.de (Stefan Ram) writes:


   Me (indented by 2) and the chatbot (flush left). Lines lengths > 72!


Is there a name for this kind of indentation, i.e. the stuff you are
writing not being flush left?  It is sort of contrary to
what I think of as "normal" indentation.  You seem to use it in all your
postings, too, which hurts my brain, but I guess that's my problem :-)

[snip (40 lines)]



It's not just your problem. When the texts are particularly long and
complex, I happen to use Google-Translator. It makes bad translations if
the lines are interrupted by the newline, so I wrote a tool dedicated to
Stefan and to all those who indent like him. This tool takes the text
from the clipboard, removes all the superfluous spaces, combines all the
lines in one and puts the result back into the clipboard. :-D

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


Re: Python Dialogs

2024-05-06 Thread jak via Python-list

Stefan Ram ha scritto:

r...@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:

translation services are gonna interpret line breaks as


   I just beefed up my posting program to replace "gonna".

   Now I won't come across like some street thug, but rather
   as a respectable member of human society!

# replace complete words
replacements =\
{ rb'kind of': b'kind of',
   rb'trying to': b'trying to',
   rb'got to': b'got to',
   rb'gonna': b'going to',
   }
lines =\
[ re.sub( rb"\b(" + b"|".join( replacements.keys() ) + rb")\b",
 lambda x: replacements[ x.group() ], line )
   if len( line )and line[ 0 ]not in b'>|' else line for line in lines ]



I present to you the brutality to which your posts are subjected:

   for(d = s = pCLipb; *s != TEXT('\0'); s++)
   {
  if(d == pCLipb)
  {
 if(*s != TEXT(' ') && *s != TEXT('\n') && *s != TEXT('\r'))
*d++ = *s;
  }
  else if(*s == TEXT(' ') || *s == TEXT('\n') || *s == TEXT('\r'))
  {
 if(d[-1] != TEXT(' '))
*d++ = TEXT(' ');
  }
  else
 *d++ = *s;
   }
   *d = TEXT('\0');

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


Re: Python Dialogs

2024-05-04 Thread Peter J. Holzer via Python-list
On 2024-05-02 16:34:38 +0200, Loris Bennett via Python-list wrote:
> r...@zedat.fu-berlin.de (Stefan Ram) writes:
> >   Me (indented by 2) and the chatbot (flush left). Lines lengths > 72!
> 
> Is there a name for this kind of indentation, i.e. the stuff you are
> writing not being flush left?

Ramism.

> It is sort of contrary to what I think of as "normal" indentation.

Stefan is well known for doing everything contrary to normal convention.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Dialogs (Posting On Python-List Prohibited)

2024-05-03 Thread Alan Bawden via Python-list
Lawrence D'Oliveiro  writes:

   > Assume you have an expression "s.replace('a','b').replace('c','d').
   > replace('e','f').replace('g','h')". Its value is a string which
   > is the value of s, but with "a" replaced by "b", "c" replaced by
   > "d", "e" replaced by "f" and "g" replaced by "h". How to modify
   > this expression, so that "a", "c", "e", and "g", respectively,
   > are replaced only if they are words (but not parts of words)?

   import re

   replacements = (("a", "b"), ("c", "d"), ("e", "f"), ("g", "h"))

   text = "this be a test g eg"

   "".join \
 (
   repl.get(s, s)
   for repl in (dict(replacements),)
   for s in
   re.split("\\b(" + "|".join(re.escape(s[0]) for s in 
replacements) + ")\\b", text)
 )

How about just:

  repl = {
  "a" : "b",
  "c" : "d",
  "e" : "f",
  "g" : "h",
  }

  "".join(repl.get(s, s) for s in re.split(r"\b", text))

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


Re: Python Dialogs

2024-05-03 Thread Loris Bennett via Python-list
r...@zedat.fu-berlin.de (Stefan Ram) writes:

>   Me (indented by 2) and the chatbot (flush left). Lines lengths > 72!

Is there a name for this kind of indentation, i.e. the stuff you are
writing not being flush left?  It is sort of contrary to
what I think of as "normal" indentation.  You seem to use it in all your
postings, too, which hurts my brain, but I guess that's my problem :-) 

[snip (40 lines)]

-- 
This signature is currently under constuction.
-- 
https://mail.python.org/mailman/listinfo/python-list