Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-23 Thread Jim Lee
On 06/23/2018 11:16 PM, Chris Angelico wrote: On Sun, Jun 24, 2018 at 4:08 PM, Jim Lee wrote: There are three locals: a, b, and result. Since result cannot be assigned a value until the list comp has been evaluated, I would expect the comp to return a value of "None" for result. An argumen

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-23 Thread Chris Angelico
On Sun, Jun 24, 2018 at 4:08 PM, Jim Lee wrote: > There are three locals: a, b, and result. Since result cannot be assigned > a value until the list comp has been evaluated, I would expect the comp to > return a value of "None" for result. An argument could also be made for [1, > 2, []], but on

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-23 Thread Jim Lee
On 06/23/2018 11:02 PM, Chris Angelico wrote: On Sun, Jun 24, 2018 at 3:44 PM, Jim Lee wrote: On 06/23/2018 10:03 PM, Steven D'Aprano wrote: I'd like to run a quick survey. There is no right or wrong answer, since this is about your EXPECTATIONS, not what Python actually does. Given this f

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-23 Thread Chris Angelico
On Sun, Jun 24, 2018 at 3:44 PM, Jim Lee wrote: > > > On 06/23/2018 10:03 PM, Steven D'Aprano wrote: >> >> I'd like to run a quick survey. There is no right or wrong answer, since >> this is about your EXPECTATIONS, not what Python actually does. >> >> Given this function: >> >> >> def test(): >>

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-23 Thread Jim Lee
On 06/23/2018 10:03 PM, Steven D'Aprano wrote: I'd like to run a quick survey. There is no right or wrong answer, since this is about your EXPECTATIONS, not what Python actually does. Given this function: def test(): a = 1 b = 2 result = [value for key, value in locals().item

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-23 Thread Steven D'Aprano
On Sun, 24 Jun 2018 15:18:49 +1000, Chris Angelico wrote: > Personally, I think it should give you [1, 2], the two values from the > function's locals. Thank you, that's the sort of answer I'm looking for. (I'm not saying I didn't read your long and involved analysis, only that I'm not looking

Re: Quick survey: locals in comprehensions (Python 3 only)

2018-06-23 Thread Chris Angelico
On Sun, Jun 24, 2018 at 3:03 PM, Steven D'Aprano wrote: > I'd like to run a quick survey. There is no right or wrong answer, since > this is about your EXPECTATIONS, not what Python actually does. > > Given this function: > > > def test(): > a = 1 > b = 2 > result = [value for key, val

Quick survey: locals in comprehensions (Python 3 only)

2018-06-23 Thread Steven D'Aprano
I'd like to run a quick survey. There is no right or wrong answer, since this is about your EXPECTATIONS, not what Python actually does. Given this function: def test(): a = 1 b = 2 result = [value for key, value in locals().items()] return result what would you expect the r

Re: translating foreign data

2018-06-23 Thread Chris Angelico
On Sun, Jun 24, 2018 at 1:23 PM, Steven D'Aprano wrote: > On Sun, 24 Jun 2018 12:53:49 +1000, Chris Angelico wrote: > > [...] >>> Okay, you want a bit-pattern. In hex: >>> >>> '0x313030e282ac' > [...] > >> Hmm. Actually, I'm a bit confused. >> > hex("100€".encode()) >> Traceback (most recent c

Re: translating foreign data

2018-06-23 Thread Steven D'Aprano
On Sun, 24 Jun 2018 12:53:49 +1000, Chris Angelico wrote: [...] >> Okay, you want a bit-pattern. In hex: >> >> '0x313030e282ac' [...] > Hmm. Actually, I'm a bit confused. > hex("100€".encode()) > Traceback (most recent call last): > File "", line 1, in > TypeError: 'bytes' object cannot

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2018 18:29:51 +0100, MRAB wrote: > You can already do something similar like this: > > def f(): > f.x += 1 > return f.x > f.x = 0 > > [snip] You can, but only as an illustration, not as a serious implementation. The whole point of static local variables is that they

Re: translating foreign data

2018-06-23 Thread Chris Angelico
On Sun, Jun 24, 2018 at 12:44 PM, Steven D'Aprano wrote: > You're joking, right? You can't possibly be so ignorant as to actually > believe that. You have, right in front of you, a news post or email > containing the text string "100€", and yet you are writing apparently in > full seriousness that

Re: translating foreign data

2018-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2018 17:52:55 -0400, Richard Damon wrote: > If you have more than just a number representing a value in the locale > currency, you can't ask the locale how to present/accept it. You're the only one saying that it has to be handled by the locale. -- Steven D'Aprano "Ever since I

Re: translating foreign data

2018-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2018 17:05:17 -0400, Richard Damon wrote: > On 6/23/18 11:27 AM, Steven D'Aprano wrote: >> On Sat, 23 Jun 2018 09:42:29 -0400, Richard Damon wrote: >> >>> On 6/23/18 9:05 AM, Marko Rauhamaa wrote: Ok. Here's a value for you: 100€ [...] > Locale based currency tra

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Steven D'Aprano
On Sun, 24 Jun 2018 00:37:36 +0100, Bart wrote: > Do you mean that if the same 'def' block is re-executed, it will create > a different instance of the function? (Same byte-code, but a different > set of everything else the function uses.) That's not as slow as you think it is. Everything that ca

Re: syntax difference

2018-06-23 Thread Gregory Ewing
Bart wrote: But 40 years ago it was just 'readln a,b,c'; it was just taken for granted. The problem with something like that is that it's really only useful for throwaway code. For any serious application, you need to deal with the possibility of malformed input, producing helpful diagnostics,

Re: syntax difference

2018-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2018 23:26:43 +0100, Bart wrote: > Then [40 years ago], the easy part was reading the three numbers. Now > that would be the more challenging part. # Get three numbers, separated by spaces, with no error-recovery. # If you try to read bad data, the process will fail. n1, n2, n3 = [

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2018 21:44:00 +0100, Bart wrote: > Since these references are created via the return g statement here: > > def f(): > def g(): > > return g > > (say to create function references i and j like this: > > i = f() > j = f() > ) > >

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Gregory Ewing
Bart wrote: Wow. (Just think of all the times you write a function containing a neat bunch of local functions, every time it's called it has to create a new function instances for each of those functions, even if they are not used.) Fortunately, function objects are small and cheap, essentiall

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Ben Bacarisse
Bart writes: > On 23/06/2018 23:25, Ben Bacarisse wrote: >> Bart writes: >> >>> On 23/06/2018 21:13, Chris Angelico wrote: On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: >>> > (At what point would that happen anyway; if you do this: >>> NONE of your examples are taking copies of th

Re: syntax difference

2018-06-23 Thread boB Stepp
On Sat, Jun 23, 2018 at 5:35 PM Bart wrote: > > On 23/06/2018 20:52, boB Stepp wrote: > The first programming exercise I ever did involved asking for three > numbers, then determining whether those numbers could form the sides of > a triangle. > > Then [40 years ago], the easy part was reading th

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Chris Angelico
On Sun, Jun 24, 2018 at 9:37 AM, Bart wrote: > On 23/06/2018 23:25, Ben Bacarisse wrote: >> >> Bart writes: >> >>> On 23/06/2018 21:13, Chris Angelico wrote: On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: >>> >>> > (At what point would that happen anyway; if you do this: >>> >>> >>>

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Bart
On 23/06/2018 23:25, Ben Bacarisse wrote: Bart writes: On 23/06/2018 21:13, Chris Angelico wrote: On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: (At what point would that happen anyway; if you do this: NONE of your examples are taking copies of the function. They all are making REFERENC

Re: syntax difference

2018-06-23 Thread Bart
On 23/06/2018 20:52, boB Stepp wrote: I've finally found time to examine this rather long, rambling thread. There is a place for various levels of programming language. I'm saying that Python which is always touted as a 'simple' language suitable for beginners, is missing a surprising number

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Ben Bacarisse
Bart writes: > On 23/06/2018 21:13, Chris Angelico wrote: >> On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: > >>> (At what point would that happen anyway; if you do this: > >> NONE of your examples are taking copies of the function. They all are >> making REFERENCES to the same function. That is

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/23/18 5:31 PM, Ben Finney wrote: > Richard Damon writes: > >> On 6/23/18 11:27 AM, Steven D'Aprano wrote: On 6/23/18 9:05 AM, Marko Rauhamaa wrote: > Richard Damon wrote: >> Data presented to the user should normally use his locale >> (unless he has specified something differ

Re: translating foreign data

2018-06-23 Thread Ben Finney
Richard Damon writes: > On 6/23/18 11:27 AM, Steven D'Aprano wrote: > >> On 6/23/18 9:05 AM, Marko Rauhamaa wrote: > >>> Richard Damon wrote: > >>> > Data presented to the user should normally use his locale > >>> > (unless he has specified something different). > >>> > >>> Ok. Here's a value for

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/23/18 11:27 AM, Steven D'Aprano wrote: > On Sat, 23 Jun 2018 09:42:29 -0400, Richard Damon wrote: > >> On 6/23/18 9:05 AM, Marko Rauhamaa wrote: >>> Ok. Here's a value for you: >>> >>> 100€ >>> >>> I see '1', '0', '0', '€'. What do you see in your locale (LC_MONETARY)? >> If I processed th

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Bart
On 23/06/2018 21:13, Chris Angelico wrote: On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: (At what point would that happen anyway; if you do this: NONE of your examples are taking copies of the function. They all are making REFERENCES to the same function. That is all. This is about your

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Chris Angelico
On Sat, Jun 23, 2018 at 10:41 PM, Bart wrote: > This is an example of a simple concept getting so out of hand that it will > either never be implemented, or the resulting implementation becomes > impractical to use. > > This is what we're trying to do: > > def nextx(): > static x = 0 >

Re: syntax difference

2018-06-23 Thread boB Stepp
I've finally found time to examine this rather long, rambling thread. On Wed, Jun 20, 2018 at 5:46 AM wrote: > > Yeah, people keep bringing that up when they run out of arguments. > > So, every programmer must always use the most advanced, most esoteric > features possible at every opportunity?

Re: translating foreign data

2018-06-23 Thread Peter J. Holzer
On 2018-06-23 12:41:33 -0400, Richard Damon wrote: > On 6/23/18 11:44 AM, Steven D'Aprano wrote: > > You're assuming that there will be a misinterpretation. That's an absurd > > assumption to make. There might be, of course, but the documentation for > > my document might be clear that comma is t

Re: translating foreign data

2018-06-23 Thread Peter J. Holzer
On 2018-06-23 12:11:34 -0400, Richard Damon wrote: > On 6/23/18 10:05 AM, Peter J. Holzer wrote: > > On 2018-06-23 08:41:38 -0400, Richard Damon wrote: > >> Once you open the Locale can of worms, EVERYTHING has a locale, to say > >> you aren't using a locale is to say you are writing > >> something

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread MRAB
On 2018-06-23 05:16, Chris Angelico wrote: On Sat, Jun 23, 2018 at 1:51 PM, Steven D'Aprano wrote: On Wed, 20 Jun 2018 14:18:19 +1000, Chris Angelico wrote: Ah. Yeah, that would be a plausible feature to add to Python. But in C, a static variable is basically the same thing as a global variab

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Bart
On 23/06/2018 14:32, Stefan Ram wrote: r...@zedat.fu-berlin.de (Stefan Ram) writes: def f(): def g(): g.x += 1 return g.x g.x = 0 return g Or, "for all g to share the same x": main.py def f(): def g(): f.x += 1 return f.x retu

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/23/18 11:44 AM, Steven D'Aprano wrote: > On Sat, 23 Jun 2018 08:12:52 -0400, Richard Damon wrote: > >> On 6/23/18 7:46 AM, Steven D'Aprano wrote: >>> On Sat, 23 Jun 2018 06:26:22 -0400, Richard Damon wrote: >>> If you know the Locale, then you do know what the decimal separator is, a

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/23/18 10:05 AM, Peter J. Holzer wrote: > On 2018-06-23 08:41:38 -0400, Richard Damon wrote: >> On 6/23/18 8:28 AM, Peter J. Holzer wrote: >>> On 2018-06-23 08:12:52 -0400, Richard Damon wrote: On 6/23/18 7:46 AM, Steven D'Aprano wrote: > If I'm in Australia, using the en-AU locale, ne

Re: translating foreign data

2018-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2018 08:12:52 -0400, Richard Damon wrote: > On 6/23/18 7:46 AM, Steven D'Aprano wrote: >> On Sat, 23 Jun 2018 06:26:22 -0400, Richard Damon wrote: >> >>> If you know the Locale, then you do know what the decimal separator >>> is, as that is part of what a locale defines. >> A locale

Re: translating foreign data

2018-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2018 09:42:29 -0400, Richard Damon wrote: > On 6/23/18 9:05 AM, Marko Rauhamaa wrote: >> Ok. Here's a value for you: >> >> 100€ >> >> I see '1', '0', '0', '€'. What do you see in your locale (LC_MONETARY)? > > If I processed that on my system I would either get $100, or an err

Re: "Data blocks" syntax specification draft

2018-06-23 Thread Abdur-Rahmaan Janhangeer
the tab separated idea is used in : e.g. see last section of files Abdur-Rahmaan Janhangeer https://github.com/Abdur-rahmaanJ > > -- https://mail.python.org/mailman/listinfo/python-list

Re: translating foreign data

2018-06-23 Thread Peter J. Holzer
On 2018-06-23 16:05:49 +0200, Peter J. Holzer wrote: > I don't think that's a useful way to look at it. "Locale" in > (non-technical) English means "place" or "site". The idea behind the > locale concept is that some conventions (e.g. how to write numbers or > how to write strings) depend on the pl

Re: translating foreign data

2018-06-23 Thread Marko Rauhamaa
Richard Damon : > On 6/23/18 9:05 AM, Marko Rauhamaa wrote: >> Richard Damon : >> >>> On 6/23/18 8:03 AM, Marko Rauhamaa wrote: I always know my locale. The locale is tied to the human user. >>> No, it should be tied to the data you are processing. >>In computing, a locale is a set of par

Re: translating foreign data

2018-06-23 Thread Peter J. Holzer
On 2018-06-23 08:41:38 -0400, Richard Damon wrote: > On 6/23/18 8:28 AM, Peter J. Holzer wrote: > > On 2018-06-23 08:12:52 -0400, Richard Damon wrote: > >> On 6/23/18 7:46 AM, Steven D'Aprano wrote: > >>> If I'm in Australia, using the en-AU locale, nevertheless I can generate > >>> a file using ,

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/23/18 9:05 AM, Marko Rauhamaa wrote: > Richard Damon : > >> On 6/23/18 8:03 AM, Marko Rauhamaa wrote: >>> I always know my locale. The locale is tied to the human user. >> No, it should be tied to the data you are processing. >In computing, a locale is a set of parameters that defines the

Re: translating foreign data

2018-06-23 Thread Marko Rauhamaa
Richard Damon : > On 6/23/18 8:03 AM, Marko Rauhamaa wrote: >> I always know my locale. The locale is tied to the human user. > No, it should be tied to the data you are processing. In computing, a locale is a set of parameters that defines the user's language, region and any special varian

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Ed Kellett
On 2018-06-23 06:21, Chris Angelico wrote: > Let's start finding all the edge cases that don't work, so I can work > on fixing them :) Very long functions (or, more specifically, functions with a very large number of consts) will likely prove annoying. signature.asc Description: OpenPGP digital

Re: Static variables [was Re: syntax difference]

2018-06-23 Thread Bart
On 23/06/2018 04:51, Steven D'Aprano wrote: On Wed, 20 Jun 2018 14:18:19 +1000, Chris Angelico wrote: Ah. Yeah, that would be a plausible feature to add to Python. But in C, a static variable is basically the same thing as a global variable, except that its name is scoped to the function. There

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/23/18 8:28 AM, Peter J. Holzer wrote: > On 2018-06-23 08:12:52 -0400, Richard Damon wrote: >> On 6/23/18 7:46 AM, Steven D'Aprano wrote: >>> On Sat, 23 Jun 2018 06:26:22 -0400, Richard Damon wrote: If you know the Locale, then you do know what the decimal separator is, as that is par

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/23/18 8:03 AM, Marko Rauhamaa wrote: > Richard Damon : >> If you know the Locale, then you do know what the decimal separator >> is, as that is part of what a locale defines. > I don't know what that sentence means. When you set the locale > >> The issue is that if you just know the encoding,

Re: translating foreign data

2018-06-23 Thread Peter J. Holzer
On 2018-06-23 08:12:52 -0400, Richard Damon wrote: > On 6/23/18 7:46 AM, Steven D'Aprano wrote: > > On Sat, 23 Jun 2018 06:26:22 -0400, Richard Damon wrote: > >> If you know the Locale, then you do know what the decimal separator is, > >> as that is part of what a locale defines. > > A locale defin

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/23/18 7:46 AM, Steven D'Aprano wrote: > On Sat, 23 Jun 2018 06:26:22 -0400, Richard Damon wrote: > >> If you know the Locale, then you do know what the decimal separator is, >> as that is part of what a locale defines. > A locale defines a set of common cultural conventions. It doesn't mandate

Re: translating foreign data

2018-06-23 Thread Marko Rauhamaa
Richard Damon : > If you know the Locale, then you do know what the decimal separator > is, as that is part of what a locale defines. I don't know what that sentence means. > The issue is that if you just know the encoding, you don't necessarily > know the locale. I always know my locale. The lo

Re: translating foreign data

2018-06-23 Thread Steven D'Aprano
On Sat, 23 Jun 2018 06:26:22 -0400, Richard Damon wrote: > If you know the Locale, then you do know what the decimal separator is, > as that is part of what a locale defines. A locale defines a set of common cultural conventions. It doesn't mandate the actual conventions in use in any specific d

Re: translating foreign data

2018-06-23 Thread Richard Damon
On 6/22/18 11:21 PM, Steven D'Aprano wrote: > On Fri, 22 Jun 2018 20:06:35 +0100, Ben Bacarisse wrote: > >> Steven D'Aprano writes: >> >>> On Fri, 22 Jun 2018 11:14:59 +0100, Ben Bacarisse wrote: >>> >> The code page remark is curious. Will some "code pages" have digits >> that are not AS

Re: ironpython not support py3.6

2018-06-23 Thread Peter J. Holzer
On 2018-06-22 17:20:29 -0700, denis.akhiya...@gmail.com wrote: > Either wait for IronPython 3.6, use COM interop, pythonnet, > subprocess, or things like gRPC. Based on PyPy experience, it is > probably 1-2 years of sponsored development to get a working > IronPython 3.6. What is the current state