[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Ricky Teachey
> > So I do not have extensive experience with mypy but I don't see how it > would help. The entire issue that is that `str` is an instance of > `Iterable[str]` so how is mypy going to catch my error of passing a single > string instead of an iterable of strings to a function? > > ... > > I like t

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Caleb Donovick
So I do not have extensive experience with mypy but I don't see how it would help. The entire issue that is that `str` is an instance of `Iterable[str]` so how is mypy going to catch my error of passing a single string instead of an iterable of strings to a function? However the ability to distin

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread Nick Timkovich
I guess I'm confused if you want (e.g.) `python json.py` to do something but not `python -m json` to call the same file (a different way), given you're in the directory. nick@lappy386:~/Code$ echo "{}" | python -m json.tool {} nick@lappy386:~/Code$ touch json.py nick@lappy386:~/Code$ echo "{}" | p

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Dominik Vilsmeier
I agree, a warning that is never converted to an error indicates that this is more about style than behavior (and in that sense it is use case specific). It would also be annoying for people that intentionally iterate over strings and find this a useful feature. So this sounds more like the job f

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Eric V. Smith
On 2/24/2020 4:20 PM, Alex Hall wrote: Just add the appropriate code to filter that category of warnings. I think you have the option of two lines of Python code or one environment variable. I can assure you that many users will not know how to do either of those things. Eric On Mon, Feb

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread jdveiga
I see... never use this feature. I make extensive use of running modules from local (non-PYTHONPATH) directories. When these modules import (local) sub-modules, the best and simplest method I have found is running them from top directory of the corresponding application. I can run any module in

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Paul Moore
On Mon, 24 Feb 2020 at 20:13, Alex Hall wrote: > > > Conversely, I can't remember a case where I've ever accidentally > > iterated over a string when I meant not to. > > Do you ever return a string from a function where you should have returned a > list containing one string? Or similarly passed

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread jdveiga
Eryk Sun wrote: > On 2/24/20, jdve...@gmail.com jdve...@gmail.com wrote: > > > > It is the intended and the expected behaviour. The > > working directory is > > always added to the sys.path. > > You mean always in this particular context, i.e. the working directory > is added normally when executin

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread André Roberge
On Mon, Feb 24, 2020 at 6:04 PM Eryk Sun wrote: > On 2/24/20, jdve...@gmail.com wrote: > > > > I try to use along with -m (`python -I -m a.b`) and get this error: > "python: > > Error while finding module specification for 'a.b' (ModuleNotFoundError: > No > > module named 'a')". > > This is a us

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Eric V. Smith
On 2/24/2020 2:59 PM, Guido van Rossum wrote: The biggest problem remains that 99% of your explanation (and that of others who seem to understand what you want) uses the words of the application domain (statistics, stochastic variables, distributions) in a way that is unhelpful to convey your n

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread Eryk Sun
On 2/24/20, jdve...@gmail.com wrote: > > I try to use along with -m (`python -I -m a.b`) and get this error: "python: > Error while finding module specification for 'a.b' (ModuleNotFoundError: No > module named 'a')". This is a use case for -m that requires adding the working directory to sys.pat

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Aaron Hall via Python-ideas
Yes, at this point I think I must concede the battle. I thought I had discussed this with core developers in the past, but I couldn't find the results. So here we have it - making `~` a binary operator as well is a no-go. Perhaps some better advocate than I will take it up in the future. Thank

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Bruce Leban
--- Bruce On Mon, Feb 24, 2020 at 1:19 PM Alex Hall wrote: > I think maybe you forgot to reply to the list as well? > > I did mean to reply to the list, so adding it back in. > How many scripts do you have where your own code directly iterated over a > string? How hard do you think it would

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread Eryk Sun
On 2/24/20, jdve...@gmail.com wrote: > > It is the intended and the expected behaviour. The working directory is > always added to the sys.path. You mean always in this particular context, i.e. the working directory is added normally when executing a command via -c or a module as a script via -m.

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread jdveiga
Nick Timkovich wrote: > > Are you familiar with the -I option for "isolated mode"? > https://docs.python.org/3/using/cmdline.html#id2 > -I > Run Python in isolated mode. This also implies -E and -s. In isolated mode > sys.path contains neither the script’s directory nor the user’s > site-packages

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread jdveiga
Alex Hall wrote: > > Conversely, I can't remember a case where I've ever > > accidentally > > iterated over a string when I meant not to. > > Do you ever return a string from a function where you should have returned > a list containing one string? Or similarly passed a string to a function? > Forg

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Alex Hall
Just add the appropriate code to filter that category of warnings. I think you have the option of two lines of Python code or one environment variable. On Mon, Feb 24, 2020 at 11:16 PM David Mertz wrote: > On Mon, Feb 24, 2020 at 4:08 PM Alex Hall wrote: > >> Even when there is a wealth of code

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Chris Angelico
On Tue, Feb 25, 2020 at 8:16 AM David Mertz wrote: > > On Mon, Feb 24, 2020 at 4:08 PM Alex Hall wrote: >>> >>> Even when there is a wealth of code out there that will become broken >>> by this change? >> >> >> Not broken, just noisy. > > > Noisy *IS* broken! > > In some ways it's one of the wors

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread David Mertz
On Mon, Feb 24, 2020 at 4:08 PM Alex Hall wrote: > Even when there is a wealth of code out there that will become broken >> by this change? > > > Not broken, just noisy. > Noisy *IS* broken! In some ways it's one of the worst kinds of broken. Working with libraries that import other libraries

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread David Mertz
I may have led in that direction, and I know R only passingly, not well. But my understanding is that thinking of a data structure that gets parsed by an evaluator, e.g. "do a linear regression with this structure (and a DataFrame)" is better than a lambda. I'm sure it's possible to describe this

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Alex Hall
On Mon, Feb 24, 2020 at 9:12 PM Chris Angelico wrote: > On Tue, Feb 25, 2020 at 5:52 AM Alex Hall wrote: > > > > Of course consistency is valuable. I am asking how it is automatically > more valuable than "better or worse", which isn't an idea that makes sense > to me. Consistency isn't axiomati

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Ricky Teachey
As one of those who 1. thinks there IS a problem, 2. that the problem is bigger than most of the people on this thread seem to think, I am nevertheless in agreement that tackling the problem by changing the language to outlaw direct str iteration would just be far, far too disruptive. I am much mo

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Alex Hall
I would like to reiterate a point that I think is very important and many people seem to be brushing aside. We don't have to *break* existing code. We can get a lot of value, at least in terms of aiding debugging, just by adding a warning. That warning never has to evolve into an exception, certain

[Python-ideas] Re: Add logging to subprocess.Popen

2020-02-24 Thread Eryk Sun
On 2/24/20, Guido van Rossum wrote: > > The stdlib does very little logging of its own -- logging is up to > the application. It's not logging per se, but the standard library does have an extensive and growing list of audit events that are intended to assist with testing, logging and security mo

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Jim Baker
I am no expert on R, but R lazily evaluates arguments to functions; see https://cran.r-project.org/doc/manuals/r-devel/R-lang.html#Argument-evaluation (plus the rest of that page, which is the language spec). Tilde is strictly used for modeling. Also relevant would be the operator precedence https:

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Serhiy Storchaka
24.02.20 22:02, Guido van Rossum пише: Hm, that's actually an interesting take. Can you compare it to the kind of "quoting" that happens in a lambda? Is there some kind of translation of the OP's original example (Lottery ~ Literacy + Wealth + Region) to a lambda involving those words? I thin

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Alex Hall
> Conversely, I can't remember a case where I've ever accidentally > iterated over a string when I meant not to. Do you ever return a string from a function where you should have returned a list containing one string? Or similarly passed a string to a function? Forgotten to put a trailing comma in

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Brandt Bucher
I agree with the numerous posters who have brought up the backward-compatibility concern. This change *would* break lots of code. At the same time, this bites me consistently, so I'd like to do something soon... at least sooner than 6.0 ;). I believe that this is better solved by static analysi

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Guido van Rossum
On Mon, Feb 24, 2020 at 11:00 AM David Mertz wrote: > Well... also, the meaning in R is quite a bit different from any of the > meanings suggested by Wolfram. In fact, although the most common use in R > is "depends on", it's technically just a generic delayed evaluation without > any inherent s

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Dominik Vilsmeier
But that behavior is specific to Jupyter and so it could similarly provide auto-complete or syntax highlighting for usage of `smf.ols(formula=...)`. Like PyCharm provides syntax highlighting for strings used as the `pattern` argument for the various functions of the `re` module. So if it's only fo

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Guido van Rossum
The biggest problem remains that 99% of your explanation (and that of others who seem to understand what you want) uses the words of the application domain (statistics, stochastic variables, distributions) in a way that is unhelpful to convey your needs to those who are in a position to implement a

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Alex Hall
I'm currently creating my own FOSS platform/course for teaching Python to beginners: https://github.com/alexmojaki/python_init (sorry, it's very new and under construction so there's no docs yet). The content moves to for loops relatively quickly, and for quite a while the only thing they loop over

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread Nick Timkovich
On Mon, Feb 24, 2020 at 11:51 AM Brianvanderburg2 via Python-ideas < python-ideas@python.org> wrote: > When running a python script directly, the directory of that script gets > added to sys.path. When running as a module "python -m", it looks like an > empty string gets added to sys.path, which

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread jdveiga
Paul Moore wrote: > On Mon, 24 Feb 2020 at 16:23, Alex Hall alex.moj...@gmail.com wrote: > you have to establish that your > behaviour is significantly better than the status quo, and I don't > think that you're doing that at the moment. And IMO, you're never > likely to do so simply by quoting num

[Python-ideas] Re: Control adding script path/CWD to sys.path

2020-02-24 Thread jdveiga
Brianvanderburg2 wrote: > This is just an idea, which may not in practice be a major problem but can at > times be > an inconvenience.  I thought I had posted this in the "python -m" thread a > little while > back but checking my history it does't appear I did, I do apologize if this > is a > du

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread André Roberge
On Mon, Feb 24, 2020 at 3:01 PM Alex Hall wrote: > Snip > > From the assumptions in this scenario, we're talking about a beginner - > specifically one who might have trouble understanding the kinds of things > we're discussing, and who has never iterated over a string before (which, > if I am to

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Chris Angelico
On Tue, Feb 25, 2020 at 5:52 AM Alex Hall wrote: > > Of course consistency is valuable. I am asking how it is automatically more > valuable than "better or worse", which isn't an idea that makes sense to me. > Consistency isn't axiomatically valuable, it's valuable for reasons such as > what yo

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread David Mertz
Well... also, the meaning in R is quite a bit different from any of the meanings suggested by Wolfram. In fact, although the most common use in R is "depends on", it's technically just a generic delayed evaluation without any inherent semantics at all. Or, that is to say, tilde is just a certain

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Alex Hall
Of course consistency is valuable. I am asking how it is automatically more valuable than "better or worse", which isn't an idea that makes sense to me. Consistency isn't axiomatically valuable, it's valuable for reasons such as what you've explained which ultimately boil down to what's better or w

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread jdveiga
Aaron Hall wrote: > The context for this is statistics , so I'll quote Wolfram on tilde in the > context of > statistics: http://mathworld.wolfram.com/Tilde.html > "In statistics, the tilde is frequently used to mean "has the distribution > (of)," for > instance, X∼N(0,1) means "the stochastic (r

[Python-ideas] Control adding script path/CWD to sys.path

2020-02-24 Thread Brianvanderburg2 via Python-ideas
This is just an idea, which may not in practice be a major problem but can at times be an inconvenience.  I thought I had posted this in the "python -m" thread a little while back but checking my history it does't appear I did, I do apologize if this is a duplicate. When running a python script

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Aaron Hall via Python-ideas
The context for this is statistics , so I'll quote Wolfram on tilde in the context of statistics: http://mathworld.wolfram.com/Tilde.html "In statistics, the tilde is frequently used to mean "has the distribution (of)," for instance, X∼N(0,1) means "the stochastic (random) variable X has the di

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Brandt Bucher
This seems like a feature looking for a use-case. I don't think the use case presented is good enough, since in this thread I've seen it given three incompatible operator priorities (higher than `+`, lower than `+`, and one that seems to be a sort of assignment?) and a handful of loosely relate

[Python-ideas] Re: Is this metaconversation helpful?

2020-02-24 Thread Antoine Pitrou
On Mon, 24 Feb 2020 09:16:12 -0800 Christopher Barker wrote: > This is an honest question: > > Is it helpful to anyone taking part in this conversation about the > conversation to have it? > > I don’t think it’s helpful to the list as a whole, honestly. Agreed. Especially as it seems to be reh

[Python-ideas] Is this metaconversation helpful?

2020-02-24 Thread Christopher Barker
This is an honest question: Is it helpful to anyone taking part in this conversation about the conversation to have it? I don’t think it’s helpful to the list as a whole, honestly. I suggest next time the conversation gets a bit heated or offensive, and someone points it out, that everyone invol

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Paul Moore
On Mon, 24 Feb 2020 at 16:23, Alex Hall wrote: > Roughly, though I think you might be hearing me wrong. There is lots of > existing code that correctly and intentionally iterates over strings. And > code that unintentionally does it probably doesn't live for long. But if you > took a random sam

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Dominik Vilsmeier
On 24.02.20 13:24, Rhodri James wrote: This seems a lot like trying to shoehorn something in so one can write idiomatic R in Python.  That on the whole sounds like a bad idea; a friend of mine use to say he could write FORTRAN in any language but no one else could read it.  Wouldn't it be more p

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Dominik Vilsmeier
I don't see what's wrong with the status quo:     smf.ols(formula='Lottery ~ Literacy + Wealth + Region', data=df) If I understand correctly you want to use instead:     smf.ols(formula=df.Lottery ~ df.Literacy + df.Wealth + df.Region) Or since some people favor indexing over attribute access

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Chris Angelico
On Tue, Feb 25, 2020 at 3:21 AM Alex Hall wrote: > > It is not a question of right or wrong, better or worse. It is a question > > of being consistent. > > Why would that be the question? Why is consistency more important than > "better or worse"? How can you make such a bold claim? > Inconsis

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Alex Hall
> Are you implying that we should deprecate the `in` operator for strings No, we should definitely keep the `in` operator. We can revisit the best wording for the error/warning message later, my point is just that it should be more considerate to beginners than "TypeError: 'str' object is not iter

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Alex Hall
> A library implemented in a confusing way is not an example of nothing wrong on Python strings. (I myself has made this stupid mistake many times and I cannot blame neither Python nor sqlite for being careless.) > In my humble opinion, your example does not prove that iterable strings are faulty.

[Python-ideas] Re: Add logging to subprocess.Popen

2020-02-24 Thread Guido van Rossum
But couldn't you just write a simple helper function/class that handles your usual workflow? Why does this deserve in the stdlib? (The stdlib does very little logging of its own -- logging is up to the application.) On Mon, Feb 24, 2020 at 2:24 AM Rémi Lapeyre wrote: > Every time I use subproces

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread David Mertz
On Mon, Feb 24, 2020, 9:27 AM Rhodri James wrote: > On 23/02/2020 18:33, Steve Jorgensen wrote: > > In many ways, a string is more useful to treat as a scalar than a > collection, so drilling down into collections and ending up iterating > individual characters as the leaves is often 1 step too f

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread David Mertz
In mathematics, in my recollection, the tilde is used for 1. Unary approximate number 2. Binary equivalence 3. Binary congruence/isomorphism The last is more formally an equal sign with tilde on top: ≅. I think maybe just simplified for chalk boards where context makes it clear. Those are all aki

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Rhodri James
On 23/02/2020 18:33, Steve Jorgensen wrote: In many ways, a string is more useful to treat as a scalar than a collection, so drilling down into collections and ending up iterating individual characters as the leaves is often 1 step too far. I think the key word here should be "sometimes". A

[Python-ideas] Re: Communication on mailing lists [was: Add a __valid_getitem_requests__ protocol]

2020-02-24 Thread Rhodri James
As the instigator here, I think it's my duty to clarify my intent on a few things. On 24/02/2020 08:49, Ethan Furman wrote: On 02/23/2020 03:01 PM, Steven D'Aprano wrote: But I am part of this community, and if I'm too scared to state my opinions for fear of retaliation, then I'm not really pa

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Richard Damon
On 2/24/20 7:24 AM, Rhodri James wrote: This seems a lot like trying to shoehorn something in so one can write idiomatic R in Python.  That on the whole sounds like a bad idea; a friend of mine use to say he could write FORTRAN in any language but no one else could read it.  Wouldn't it be mo

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Rhodri James
On 24/02/2020 00:59, Brendan Barnwell wrote: On 2020-02-23 16:32, Guido van Rossum wrote: > Assuming that the reader is familiar with the example `Lottery ~ > Literacy + Wealth + Region` is *not* going to work. I have literally no > idea from what field that is taken or what the purpose of the

[Python-ideas] Re: Communication on mailing lists [was: Add a __valid_getitem_requests__ protocol]

2020-02-24 Thread Paul Moore
On Mon, 24 Feb 2020 at 08:52, Ethan Furman wrote: > In fact, when I first read Rhodri's post I thought it meant something along > the lines of: programming language -> pie in the sky perfection. Hence, it > is possible to be too terse. I feel that this discussion has got out of hand, and it wo

[Python-ideas] Re: Add a __valid_getitem_requests__ protocol

2020-02-24 Thread Paul Moore
On Mon, 24 Feb 2020 at 02:44, MRAB wrote: > > On 2020-02-24 02:22, Chris Angelico wrote: > > On Mon, Feb 24, 2020 at 1:00 PM C. Titus Brown wrote: > >> > >> WHATS WRONG WITH TOP POSTING IN ALL CAPS AND NO PUNCTUATION!?!?!?! > >> > >> :) > > > > Oh, it's alright, you just put all the punctuation a

[Python-ideas] Re: Incremental step on road to improving situation around iterable strings

2020-02-24 Thread Paul Moore
On Sun, 23 Feb 2020 at 02:52, Chris Angelico wrote: > > On Sun, Feb 23, 2020 at 1:15 PM Ethan Furman wrote: > > > > On 02/22/2020 04:37 PM, Chris Angelico wrote: > > > > > Do any of the core devs agree with those two assertions? > > > > If posts to -Ideas required core dev agreement this would be

[Python-ideas] Add logging to subprocess.Popen

2020-02-24 Thread Rémi Lapeyre
Every time I use subprocess.run and others I find myself writing boilerplate code to log program calls and their results. Could we log those directly in subprocess.py so that we could just set a "subprocess" logger instead? Rémi ___ Python-ideas mail

[Python-ideas] Re: Make ~ (tilde) a binary operator, e.g. __sim__(self, other)

2020-02-24 Thread Serhiy Storchaka
24.02.20 02:27, Aaron Hall via Python-ideas пише: I have no behavior for integers in mind. I would expect high-level libraries to want to implement behavior for it. - sympy - pandas, numpy, sklearn, statsmodels - other mathematically minded libraries (monadic bind or compose?) To do this we ne

[Python-ideas] Communication on mailing lists [was: Add a __valid_getitem_requests__ protocol]

2020-02-24 Thread Ethan Furman
On 02/23/2020 03:01 PM, Steven D'Aprano wrote: I've been sitting on this email for the best part of a week. It hasn't been an easy decision to decide to send it, because I expect it will ruffle some feathers, including someone who, last time I ruffled his feathers, banned me from one of the othe