Tkinter and astral characters (was: Decoding bytes to text strings in Python 2)

2024-06-24 Thread Peter J. Holzer via Python-list
On 2024-06-24 01:14:22 +0100, MRAB via Python-list wrote: > Tkinter in recent versions of Python can handle astral characters, at least > back to Python 3.8, the oldest I have on my Windows PC. I just tried modifying https://docs.python.org/3/library/tkinter.html#a-hello-world-program to display

Re: Decoding bytes to text strings in Python 2

2024-06-23 Thread Chris Angelico via Python-list
On Mon, 24 Jun 2024 at 10:18, MRAB via Python-list wrote: > Tkinter in recent versions of Python can handle astral characters, at > least back to Python 3.8, the oldest I have on my Windows PC. Good to know, thanks! I was hoping that would be the case, but I don't have a Windows system to check

Re: Decoding bytes to text strings in Python 2

2024-06-23 Thread MRAB via Python-list
On 2024-06-24 00:30, Chris Angelico via Python-list wrote: On Mon, 24 Jun 2024 at 08:20, Rayner Lucas via Python-list wrote: In article , ros...@gmail.com says... > > If you switch to a Linux system, it should work correctly, and you'll > be able to migrate the rest of the way onto Python 3.

Re: Decoding bytes to text strings in Python 2

2024-06-23 Thread Chris Angelico via Python-list
On Mon, 24 Jun 2024 at 08:20, Rayner Lucas via Python-list wrote: > > In article , > ros...@gmail.com says... > > > > If you switch to a Linux system, it should work correctly, and you'll > > be able to migrate the rest of the way onto Python 3. Once you achieve > > that, you'll be able to

Re: Decoding bytes to text strings in Python 2

2024-06-23 Thread Rayner Lucas via Python-list
In article , r...@zedat.fu- berlin.de says... > > I didn't really do a super thorough deep dive on this, > but I'm just giving the initial impression without > actually being familiar with Tkinter under Python 2, > so I might be wrong! > > The Text widget typically expects text in Tcl

Re: Decoding bytes to text strings in Python 2

2024-06-23 Thread Rayner Lucas via Python-list
In article , ros...@gmail.com says... > > If you switch to a Linux system, it should work correctly, and you'll > be able to migrate the rest of the way onto Python 3. Once you achieve > that, you'll be able to operate on Windows or Linux equivalently, > since Python 3 solved this problem. At

Re: Decoding bytes to text strings in Python 2

2024-06-21 Thread Chris Angelico via Python-list
On Sat, 22 Jun 2024 at 03:28, Rayner Lucas via Python-list wrote: > I'm curious about something I've encountered while updating a very old > Tk app (originally written in Python 1, but I've ported it to Python 2 > as a first step towards getting it running on modern systems). > > I am using

Decoding bytes to text strings in Python 2

2024-06-21 Thread Rayner Lucas via Python-list
I'm curious about something I've encountered while updating a very old Tk app (originally written in Python 1, but I've ported it to Python 2 as a first step towards getting it running on modern systems). The app downloads emails from a POP server and displays them. At the moment, the code

Re: Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

2024-06-01 Thread Peter J. Holzer via Python-list
that > 11252) (in 10743) (it 10687)) > > > i think the latter is easier-to-read, so i use this code >(by Peter Norvig) This doesn't work well if your strings contain spaces: Lprint( [ ["Just", "three

Lprint = ( Lisp-style printing ( of lists and strings (etc.) ) in Python )

2024-05-31 Thread HenHanna via Python-list
;;; Pls tell me about little tricks you use in Python or Lisp. [('the', 36225), ('and', 17551), ('of', 16759), ('i', 16696), ('a', 15816), ('to', 15722), ('that', 11252), ('in', 10743), ('it', 10687)] ((the 36225) (and 17551) (of 16759) (i 16696) (a 15816) (to 15722) (that

Re: Match statement with literal strings

2023-06-07 Thread Jason Friedman via Python-list
> > The bytecode compiler doesn't know that you intend RANGE > to be a constant -- it thinks it's a variable to bind a > value to. > > To make this work you need to find a way to refer to the > value that isn't just a bare name. One way would be to > define your constants using an enum: > > class

Re: Match statement with literal strings

2023-06-07 Thread Chris Angelico via Python-list
On Thu, 8 Jun 2023 at 08:19, Jason Friedman via Python-list wrote: > > This gives the expected results: > > with open(data_file, newline="") as reader: > csvreader = csv.DictReader(reader) > for row in csvreader: > #print(row) > match row[RULE_TYPE]: > case "RANGE": > print("range") > case

Re: Match statement with literal strings

2023-06-07 Thread Greg Ewing via Python-list
On 8/06/23 10:18 am, Jason Friedman wrote: SyntaxError: name capture 'RANGE' makes remaining patterns unreachable The bytecode compiler doesn't know that you intend RANGE to be a constant -- it thinks it's a variable to bind a value to. To make this work you need to find a way to refer to the

Match statement with literal strings

2023-06-07 Thread Jason Friedman via Python-list
This gives the expected results: with open(data_file, newline="") as reader: csvreader = csv.DictReader(reader) for row in csvreader: #print(row) match row[RULE_TYPE]: case "RANGE": print("range") case "MANDATORY": print("mandatory") case _: print("nothing to do") This: RANGE = "RANGE"

Re: How to escape strings for re.finditer?

2023-03-02 Thread Grant Edwards
On 2023-03-02, Peter J. Holzer wrote: > [1] Personally I'd say you shouldn't use Outlook if you are reading > mails where line breaks (or other formatting) is important, but ... I'd shorten that to "You shouldn't use Outlook if mail is important." --

RE: How to escape strings for re.finditer?

2023-03-02 Thread avi.e.gross
. -Original Message- From: Python-list On Behalf Of Peter J. Holzer Sent: Thursday, March 2, 2023 3:09 PM To: python-list@python.org Subject: Re: How to escape strings for re.finditer? On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote: > On 2023-02-28 15:25:05 -0500, avi.e

Re: How to escape strings for re.finditer?

2023-03-02 Thread Peter J. Holzer
On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote: > On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote: > > I had no doubt the code you ran was indented properly or it would not work. > > > > I am merely letting you know that somewhere in the process of copying > > the code or the

Re: How to escape strings for re.finditer?

2023-03-01 Thread Thomas Passin
On 3/1/2023 12:04 PM, Grant Edwards wrote: On 2023-02-28, Cameron Simpson wrote: Regexps are: - cryptic and error prone (you can make them more readable, but the notation is deliberately both terse and powerful, which means that small changes can have large effects in behaviour); the

Re: How to escape strings for re.finditer?

2023-03-01 Thread Grant Edwards
On 2023-02-28, Cameron Simpson wrote: > Regexps are: > - cryptic and error prone (you can make them more readable, but the >notation is deliberately both terse and powerful, which means that >small changes can have large effects in behaviour); the "error prone" >part does not mean

RE: How to escape strings for re.finditer?

2023-02-28 Thread avi.e.gross
. Holzer Sent: Tuesday, February 28, 2023 7:26 PM To: python-list@python.org Subject: Re: How to escape strings for re.finditer? On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote: > On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote: > > It happens to be easy for me to fix but I

Re: How to escape strings for re.finditer?

2023-02-28 Thread Weatherby,Gerard
@python.org Subject: Re: How to escape strings for re.finditer? *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** Using str.startswith is a cool idea in this case. But is it better than regex for performance or reliability? Regex

Re: How to escape strings for re.finditer?

2023-02-28 Thread Peter J. Holzer
On 2023-03-01 01:01:42 +0100, Peter J. Holzer wrote: > On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote: > > It happens to be easy for me to fix but I sometimes see garbled code I > > then simply ignore. > > Truth to be told, that's one reason why I rarely read your mails to the > end.

Re: How to escape strings for re.finditer?

2023-02-28 Thread Peter J. Holzer
On 2023-02-28 15:25:05 -0500, avi.e.gr...@gmail.com wrote: > Jen, > > > > I had no doubt the code you ran was indented properly or it would not work. > > > > I am merely letting you know that somewhere in the process of copying > the code or the transition between mailers, my version is

Re: How to escape strings for re.finditer?

2023-02-28 Thread Cameron Simpson
On 28Feb2023 18:57, Jen Kris wrote: One question:  several people have made suggestions other than regex (not your terser example with regex you shown below).  Is there a reason why regex is not preferred to, for example, a list comp?  These are different things; I'm not sure a comparison

Re: How to escape strings for re.finditer?

2023-02-28 Thread Thomas Passin
On 2/28/2023 2:40 PM, David Raymond wrote: With a slight tweak to the simple loop code using .find() it becomes a third faster than the RE version though. def using_simple_loop2(key, text): matches = [] keyLen = len(key) start = 0 while (foundSpot := text.find(key, start))

RE: How to escape strings for re.finditer?

2023-02-28 Thread avi.e.gross
function that hides the loops inside a faster environment than the interpreter. -Original Message- From: Python-list On Behalf Of David Raymond Sent: Tuesday, February 28, 2023 2:40 PM To: python-list@python.org Subject: RE: How to escape strings for re.finditer? > I wrote my previ

RE: How to escape strings for re.finditer?

2023-02-28 Thread avi.e.gross
ython-list@python.org Subject: Re: How to escape strings for re.finditer? On 2/28/2023 1:07 PM, Jen Kris wrote: > > Using str.startswith is a cool idea in this case. But is it better > than regex for performance or reliability? Regex syntax is not a > model of simplicity, but in my si

RE: How to escape strings for re.finditer?

2023-02-28 Thread avi.e.gross
, February 28, 2023 12:58 PM To: avi.e.gr...@gmail.com Cc: 'Python List' Subject: RE: How to escape strings for re.finditer? The code I sent is correct, and it runs here. Maybe you received it with a carriage return removed, but on my copy after posting, it is correct: example = 'X - abc_degree

RE: How to escape strings for re.finditer?

2023-02-28 Thread David Raymond
> I wrote my previous message before reading this.  Thank you for the test you > ran -- it answers the question of performance.  You show that re.finditer is > 30x faster, so that certainly recommends that over a simple loop, which > introduces looping overhead.  >>     def

Re: How to escape strings for re.finditer?

2023-02-28 Thread Thomas Passin
On 2/28/2023 11:48 AM, Jon Ribbens via Python-list wrote: On 2023-02-28, Thomas Passin wrote: ... It is interesting, though, how pre-processing the search pattern can improve search times if you can afford the pre-processing. Here's a paper on rapidly finding matches when there may be up to

Re: How to escape strings for re.finditer?

2023-02-28 Thread Thomas Passin
pson Cc: Python List Subject: Re: How to escape strings for re.finditer? I haven't tested it either but it looks like it would work. But for this case I prefer the relative simplicity of: example = 'X - abc_degree + 1 + qq + abc_degree + 1' find_string = re.escape('abc_degree + 1') for ma

RE: How to escape strings for re.finditer?

2023-02-28 Thread avi.e.gross
To: python-list@python.org Subject: Re: How to escape strings for re.finditer? Op 28/02/2023 om 3:44 schreef Thomas Passin: > On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com wrote: >> And, just for fun, since there is nothing wrong with your code, this >> minor change is terser: >&g

Re: How to escape strings for re.finditer?

2023-02-28 Thread Thomas Passin
approach. But the regular expression strings would become harder to read. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jon Ribbens via Python-list
rone. Using a well-tested >>>> existing function becomes quite attractive. >>> >>> Sure, it all depends on what the real task will be.  That's why I >>> wrote "Without knowing how general your expressions will be". For the >>> example string, it's unl

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
, i + len(KEY)) >>> # prints: >>> 4 18 >>> 26 40 >>> >> I think it's often a good idea to use a standard library function instead of >> rolling your own. The issue becomes less clear-cut when the standard library >> doesn't do exactly what you need

Re: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
numbers of spaces around the symbols, OTOH, the > whole situation changes and then regexes would almost certainly be the best > approach. But the regular expression strings would become harder to read. > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

RE: How to escape strings for re.finditer?

2023-02-28 Thread Jen Kris via Python-list
ers before and/or after > for context. > > > -Original Message- > From: Python-list On > Behalf Of Jen Kris via Python-list > Sent: Monday, February 27, 2023 8:36 PM > To: Cameron Simpson > Cc: Python List > Subject: Re: How to escape strings for re.finditer? &

Re: How to escape strings for re.finditer?

2023-02-28 Thread Thomas Passin
ple string, it's unlikely that speed will be a factor, but who knows what target strings and keys will turn up in the future? On hindsight I think it was overthinking things a bit. "It all depends on what the real task will be" you say, and indeed I think that should be the

Re: How to escape strings for re.finditer?

2023-02-28 Thread Roel Schroeven
e a factor, but who knows what target strings and keys will turn up in the future? On hindsight I think it was overthinking things a bit. "It all depends on what the real task will be" you say, and indeed I think that should be the main conclusion here. -- "Man had always assumed tha

Re: How to escape strings for re.finditer?

2023-02-28 Thread Thomas Passin
less clear-cut when the standard library doesn't do exactly what you need (as here, where re.finditer() uses regular expressions while the use case only uses simple search strings). Ideally there would be a str.finditer() method we could use, but in the absence of that I think we still need

Re: How to escape strings for re.finditer?

2023-02-28 Thread Roel Schroeven
doesn't do exactly what you need (as here, where re.finditer() uses regular expressions while the use case only uses simple search strings). Ideally there would be a str.finditer() method we could use, but in the absence of that I think we still need to consider using the almost-but-not-quite

RE: How to escape strings for re.finditer?

2023-02-27 Thread avi.e.gross
where you left off. -Original Message- From: Python-list On Behalf Of Thomas Passin Sent: Monday, February 27, 2023 9:44 PM To: python-list@python.org Subject: Re: How to escape strings for re.finditer? On 2/27/2023 9:16 PM, avi.e.gr...@gmail.com wrote: > And, just for fun, si

Re: How to escape strings for re.finditer?

2023-02-27 Thread Thomas Passin
(example)): if example[i:].startswith(KEY): print(i, i + len(KEY)) # prints: 4 18 26 40 If you may have variable numbers of spaces around the symbols, OTOH, the whole situation changes and then regexes would almost certainly be the best approach. But the regular expression strings would

RE: How to escape strings for re.finditer?

2023-02-27 Thread avi.e.gross
n offsets but also show the exact text that matched or even show some characters before and/or after for context. -Original Message- From: Python-list On Behalf Of Jen Kris via Python-list Sent: Monday, February 27, 2023 8:36 PM To: Cameron Simpson Cc: Python List Subject: Re: How to escap

RE: How to escape strings for re.finditer?

2023-02-27 Thread avi.e.gross
l. Even better, you can make it return whatever you want. -Original Message- From: Python-list On Behalf Of Jen Kris via Python-list Sent: Monday, February 27, 2023 7:40 PM To: Bob van der Poel Cc: Python List Subject: Re: How to escape strings for re.finditer? string.count() only tell

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
tever with start and end ... > pos = end > > Many people go straight to the `re` module whenever they're looking for > strings. It is often cryptic error prone overkill. Just something to keep in > mind. > > Cheers, > Cameron Simpson > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list

Re: How to escape strings for re.finditer?

2023-02-27 Thread Cameron Simpson
On 28Feb2023 00:57, Jen Kris wrote: Yes, that's it.  I don't know how long it would have taken to find that detail with research through the voluminous re documentation.  Thanks very much.  You find things like this by printing out the strings you're actually working with. Not the original

Re: How to escape strings for re.finditer?

2023-02-27 Thread Cameron Simpson
, pos) if found < 0: break start = found end = found + len(substring) ... do whatever with start and end ... pos = end Many people go straight to the `re` module whenever they're looking for strings. It is often cryptic error prone overkill. J

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
ed only once then the str.find would be best.  >> >> I changed my re code after MRAB's comment, it now works.  >> >> Thanks much.  >> >> Jen >> >> >> Feb 27, 2023, 15:56 by >> c...@cskk.id.au>> : >> &

RE: How to escape strings for re.finditer?

2023-02-27 Thread avi.e.gross
Just FYI, Jen, there are times a sledgehammer works but perhaps is not the only way. These days people worry less about efficiency and more about programmer time and education and that can be fine. But it you looked at methods available in strings or in some other modules, your situation

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
00:11, Jen Kris wrote: > >> When matching a string against a longer string, where both strings have >> spaces in them, we need to escape the spaces.  >> >> This works (no spaces): >> >> import re >> example = 'abcdefabcdefabcdefg' >> find_stri

RE: How to escape strings for re.finditer?

2023-02-27 Thread avi.e.gross
m going further. -Original Message- From: Python-list On Behalf Of MRAB Sent: Monday, February 27, 2023 6:46 PM To: python-list@python.org Subject: Re: How to escape strings for re.finditer? On 2023-02-27 23:11, Jen Kris via Python-list wrote: > When matching a string against a longer string,

Re: How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
ing a string against a longer string, where both strings have >> spaces in them, we need to escape the spaces. >> >> This works (no spaces): >> >> import re >> example = 'abcdefabcdefabcdefg' >> find_string = "abc" >> for match in re.

Re: How to escape strings for re.finditer?

2023-02-27 Thread Cameron Simpson
On 28Feb2023 00:11, Jen Kris wrote: When matching a string against a longer string, where both strings have spaces in them, we need to escape the spaces.  This works (no spaces): import re example = 'abcdefabcdefabcdefg' find_string = "abc" for match in re.finditer(find_strin

Re: How to escape strings for re.finditer?

2023-02-27 Thread MRAB
On 2023-02-27 23:11, Jen Kris via Python-list wrote: When matching a string against a longer string, where both strings have spaces in them, we need to escape the spaces. This works (no spaces): import re example = 'abcdefabcdefabcdefg' find_string = "abc" for match in re.finditer(f

How to escape strings for re.finditer?

2023-02-27 Thread Jen Kris via Python-list
When matching a string against a longer string, where both strings have spaces in them, we need to escape the spaces.  This works (no spaces): import re example = 'abcdefabcdefabcdefg' find_string = "abc" for match in re.finditer(find_string, example):     print(match.start(),

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-24 Thread Barry Scott
t; > Date: Friday, October 7, 2022 at 1:30 PM > To: MRAB mailto:pyt...@mrabarnett.plus.com>> > Cc: python-list@python.org <mailto:python-list@python.org> > mailto:python-list@python.org>> > Subject: Re: Ref-strings in logging messages (was: Performan

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-08 Thread Weatherby,Gerard
hello" logging.basicConfig() logging.debug(Defer(some_expensive_function)) From: Python-list on behalf of Barry Date: Friday, October 7, 2022 at 1:30 PM To: MRAB Cc: python-list@python.org Subject: Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython) ***

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Julian Smith
On Fri, 7 Oct 2022 18:28:06 +0100 Barry wrote: > > On 7 Oct 2022, at 18:16, MRAB wrote: > > > > On 2022-10-07 16:45, Skip Montanaro wrote: > >>> On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames > >>> > >>> wrote: > >>> 1. T

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
ebug = logger_from(DEBUG) log_debug and log_debug(‘expensive %s’ % (complex(),)) Barry > > From: Python-list on > behalf of Barry > Date: Friday, October 7, 2022 at 1:30 PM > To: MRAB > Cc: python-list@python.org > Subject: Re: Ref-strings in logging messages (was: Pe

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Weatherby,Gerard
To: MRAB Cc: python-list@python.org Subject: Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython) *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. *** > On 7 Oct 2022, at 18:16, MRAB wr

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
> On 7 Oct 2022, at 18:16, MRAB wrote: > > On 2022-10-07 16:45, Skip Montanaro wrote: >>> On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames >>> wrote: >>> 1. The culprit was me. As lazy as I am, I have used f-strings all over the >>> place in

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread MRAB
On 2022-10-07 16:45, Skip Montanaro wrote: On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames wrote: 1. The culprit was me. As lazy as I am, I have used f-strings all over the place in calls to `logging.logger.debug()` and friends, evaluating all arguments regardless of whether the logger

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Barry
> On 7 Oct 2022, at 16:48, Skip Montanaro wrote: > > On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames > wrote: > >> 1. The culprit was me. As lazy as I am, I have used f-strings all over the >> place in calls to `logging.logger.debug()` and friends, evaluating

Re: Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Skip Montanaro
Dang autocorrect. Subject first word was supposed to be "f-strings" not "ref-strings." Sorry about that. S On Fri, Oct 7, 2022, 10:45 AM Skip Montanaro wrote: > > > On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames > wrote: > >> 1. The culprit was me. As laz

Ref-strings in logging messages (was: Performance issue with CPython 3.10 + Cython)

2022-10-07 Thread Skip Montanaro
On Fri, Oct 7, 2022 at 9:42 AM Andreas Ames wrote: > 1. The culprit was me. As lazy as I am, I have used f-strings all over the > place in calls to `logging.logger.debug()` and friends, evaluating all > arguments regardless of whether the logger was enabled or not. > I thought th

Re: on str.format and f-strings

2022-09-06 Thread Meredith Montgomery
Chris Angelico writes: > On Wed, 7 Sept 2022 at 03:52, Meredith Montgomery > wrote: >> >> It seems to me that str.format is not completely made obsolete by the >> f-strings that appeared in Python 3.6. But I'm not thinking that this >> was the objective of

Re: on str.format and f-strings

2022-09-06 Thread Chris Angelico
On Wed, 7 Sept 2022 at 03:52, Meredith Montgomery wrote: > > It seems to me that str.format is not completely made obsolete by the > f-strings that appeared in Python 3.6. But I'm not thinking that this > was the objective of the introduction of f-strings: the PEP at

Re: on str.format and f-strings

2022-09-06 Thread Meredith Montgomery
Julio Di Egidio writes: > On Tuesday, 6 September 2022 at 01:03:02 UTC+2, Meredith Montgomery wrote: >> Julio Di Egidio writes: >> > On Monday, 5 September 2022 at 22:18:58 UTC+2, Meredith Montgomery wrote: >> >> r...@zedat.fu-berlin.de (Stefan Ram) writes: >> > >> >> > , but with the

Re: on str.format and f-strings

2022-09-06 Thread Meredith Montgomery
Julio Di Egidio writes: > On Monday, 5 September 2022 at 22:18:58 UTC+2, Meredith Montgomery wrote: >> r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> > , but with the spaces removed, it's even one character >> > shorter than the format expression: >> > >> > eval('f"The name is {name} and

Re: on str.format and f-strings

2022-09-06 Thread Meredith Montgomery
*d) >>--8<---cut here---end--->8--- >>Is there a way to do this with f-strings? > > I cannot think of anything shorter now than: > > eval( 'f"The name is {name} and the email is {email}"', d ) > > , but with the spaces rem

on str.format and f-strings

2022-09-06 Thread Meredith Montgomery
It seems to me that str.format is not completely made obsolete by the f-strings that appeared in Python 3.6. But I'm not thinking that this was the objective of the introduction of f-strings: the PEP at https://peps.python.org/pep-0498/#id11 says so explicitly. My question is whether f

Re: Printing Unicode strings in a list

2022-04-30 Thread Chris Angelico
On Sun, 1 May 2022 at 00:03, Vlastimil Brom wrote: > (Even the redundant u prefix from your python2 sample is apparently > accepted, maybe for compatibility reasons.) Yes, for compatibility reasons. It wasn't accepted in Python 3.0, but 3.3 re-added it to make porting easier. It doesn't do

Re: Printing Unicode strings in a list

2022-04-30 Thread Vlastimil Brom
reasons for doing so and > will be moving to Python 3.x in due course. > > I have the following questions arising from the log: > > 1. Why does the second print statement not produce [ ║] or ["║"] ? > > 2. Should the second print statement produce [ ║] or ["║&qu

Re: Printing Unicode strings in a list

2022-04-28 Thread Rob Cliffe via Python-list
On 28/04/2022 14:27, Stephen Tucker wrote: To Cameron Simpson, Thanks for your in-depth and helpful reply. I have noted it and will be giving it close attention when I can. The main reason why I am still using Python 2.x is that my colleagues are still using a GIS system that has a Python

Re: Printing Unicode strings in a list

2022-04-28 Thread Jon Ribbens via Python-list
own str converter, so fall back to repr instead, which outputs '[', followed by the repr of each list item separated by ', ', followed by ']'. > 2. Should the second print statement produce [ ║] or ["║"] ? There's certainly no obvious reason why it *should*, and pretty dece

Re: Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
t; >2. Should the second print statement produce [ ║] or ["║"] ? > > Well, to me its behaviour is correct. Do you _want_ to get your Unicode > glyph? in quotes? That is up to you. But consider: what would be sane > output if the list contained the string "], [3," ?

Re: Printing Unicode strings in a list

2022-04-28 Thread Cameron Simpson
quotes? That is up to you. But consider: what would be sane output if the list contained the string "], [3," ? >3. Given that I want to print a list of Unicode strings so that their >characters are displayed (instead of their Unicode codepoint definitions), >is there a more Python

Printing Unicode strings in a list

2022-04-28 Thread Stephen Tucker
cond print statement not produce [ ║] or ["║"] ? 2. Should the second print statement produce [ ║] or ["║"] ? 3. Given that I want to print a list of Unicode strings so that their characters are displayed (instead of their Unicode codepoint definitions), is there a more Pythonic wa

[issue221207] % operator on strings not documented

2022-04-10 Thread admin
Change by admin : -- github: None -> 33443 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue456420] no __methods__ for lists, strings etc.

2022-04-10 Thread admin
Change by admin : -- github: None -> 35072 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue426740] pydoc: check bases for doc strings?

2022-04-10 Thread admin
Change by admin : -- github: None -> 34536 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue431848] mathmodule.c: doc strings & conversion

2022-04-10 Thread admin
Change by admin : -- github: None -> 34601 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue217004] Tools/compiler does not create doc strings

2022-04-10 Thread admin
Change by admin : ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue210661] cgi parsing of query strings (PR#356)

2022-04-10 Thread admin
Change by admin : ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue401309] Specialization of dictionaries for strings.

2022-04-10 Thread admin
Change by admin : ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue401299] add missing test for strings in file_writelines

2022-04-10 Thread admin
Change by admin : ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue505375] Make doc strings optional

2022-04-10 Thread admin
Change by admin : -- github: None -> 35941 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue502503] pickle interns strings

2022-04-10 Thread admin
Change by admin : -- github: None -> 35908 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue495601] Documentation strings should end with a

2022-04-10 Thread admin
Change by admin : -- github: None -> 35802 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue400912] modified \x behaviour for unicode strings

2022-04-10 Thread admin
Change by admin : ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue462849] Printing arbitrary Unicode strings

2022-04-10 Thread admin
Change by admin : -- github: None -> 35204 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue463093] File methods need doc strings

2022-04-10 Thread admin
Change by admin : -- github: None -> 35207 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue421214] splitlist() for raw and unicode strings

2022-04-10 Thread admin
Change by admin : -- github: None -> 34455 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue424335] richcompare for strings

2022-04-10 Thread admin
Change by admin : -- github: None -> 34507 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue410465] Allow pre-encoded strings as filenames

2022-04-10 Thread admin
Change by admin : -- github: None -> 34213 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue410336] pydoc patch for strings & lists

2022-04-10 Thread admin
Change by admin : -- github: None -> 34210 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue407538] pickling fails on Unicode strings with newlines

2022-04-10 Thread admin
Change by admin : -- github: None -> 34130 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue403349] Allow pickle.py to be using with Jython unicode strings

2022-04-10 Thread admin
Change by admin : -- github: None -> 33771 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue403636] Fix for null byte strings in SSL support of socketmodule.c

2022-04-10 Thread admin
Change by admin : -- github: None -> 33857 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

  1   2   3   4   5   6   7   8   9   10   >