[Python-ideas] Re: Scope painting

2019-07-17 Thread Andrew Barnert via Python-ideas
On Jul 17, 2019, at 20:23, Andrew Barnert via Python-ideas wrote: > >> On Jul 17, 2019, at 18:41, Yonatan Zunger wrote: >> >> I'm in the middle of developing a fancy heap profiler for Python (for those >> times when tracemalloc isn't enough), and in the p

[Python-ideas] Re: Scope painting

2019-07-18 Thread Andrew Barnert via Python-ideas
using it for scope painting interferes with using it for anything else, which could be a problem for some of the kinds of uses you’re talking about. So, it’s not a production solution. But considering how trivial it should be slap together something that works in Python 3.7, it may be good enough

[Python-ideas] Re: Scope painting

2019-07-19 Thread Ronald Oussoren via Python-ideas
Op 18 jul. 2019 om 03:41 heeft Yonatan Zunger het volgende geschreven: > Hi everyone, > > I'm in the middle of developing a fancy heap profiler for Python (for those > times when tracemalloc isn't enough), and in the process, thought of a small > change in the int

[Python-ideas] Re: Universal parsing library in the stdlib to alleviate security issues

2019-07-21 Thread Andrew Barnert via Python-ideas
whatever, they could just as easily be characters that are legal elsewhere in the URL as characters that happen to not be legal anywhere. (If you’re just talking about mitigating one particular attack after it’s been discovered, that’s a different story. If checking for \n patches things without w

[Python-ideas] Re: Universal parsing library in the stdlib to alleviate security issues

2019-07-23 Thread Andrew Barnert via Python-ideas
problems but otherwise provide the same behavior. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at

[Python-ideas] Re: Cartesian Product on `__mul__`

2019-07-25 Thread Andrew Barnert via Python-ideas
ut meaning type(lhs)(chain(…)) on some types, so why do the equivalent with @?) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archiv

[Python-ideas] Re: Cartesian Product on `__mul__`

2019-07-25 Thread Andrew Barnert via Python-ideas
, (a, b, c) is <, c>, etc. So, you don’t have to gloss over anything; s1 * s2 * s3 gives you elements ((a, b), c), but those are identical to elements (a, b, c). The reason it’s important in Python is that Python tuples aren’t mathematical tuples (except maybe for len==2). But then Py

[Python-ideas] Re: support toml for pyproject support

2019-07-26 Thread Andrew Barnert via Python-ideas
a specific) version in site-packages so they aren’t burdened by the release cycle. Would that not be appropriate for the way packaging needs TOML? ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to python-ideas-le...@python.

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Andrew Barnert via Python-ideas
ide effects, you want a statement. That’s why #3 is better than #2, beyond the watered memory. Sometimes you want to violate guidelines like that, but in that case it’s usually worth explicitly marking that you're doing so. Which you can do easily and concisely in today’s Python: #4 cons

[Python-ideas] Re: Namespace context managers

2019-07-26 Thread Andrew Barnert via Python-ideas
implement—and for everyone to understand future Python code—if it is. I don’t think anyone cares about fast locals here, and I hope nobody cares about things like super magic. But the differences in how variables in the namespace interact with functions and classes (and new-kind-of-namespa

[Python-ideas] Re: for ... except, with ... except

2019-07-26 Thread Andrew Barnert via Python-ideas
ust scrap the nice context managers and use finally, or add two more layers of indentation, or, most commonly, just punt on the problem and don’t handle errors correctly. So, I think adding with to the idea makes it a lot more compelling. ___ Python

[Python-ideas] Re: For-expression/throwaway comprehension

2019-07-26 Thread Andrew Barnert via Python-ideas
> there is no modification required? The maxlen of 0 means after determining that 0+1 > 0, the (C) function returns without even getting to the array manipulation stuff. Consuming the iterator in a for loop does even less work inside the loop, but it means the loop is in Python rather than C,

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Andrew Barnert via Python-ideas
hod was even one of the core examples. And, as PEP 570 points out, METH_FASTCALL makes that potentially true for pure Python functions as well, to the extent that some other stdlib functions might actually want to lose their keyword args. All that being said, this proposal seems like something th

[Python-ideas] Re: Add a "partial with placeholders" function to the functools module

2019-07-27 Thread Andrew Barnert via Python-ideas
th keyword arguments imo. Look at the signatures for range and isinstance: range takes an optional argument on the left (or, if you prefer, it’s an overload of two different signatures), which can’t even be expressed in Python syntax; isinstance takes a class or a tuple of classes in the same pa

[Python-ideas] Re: Utilities for easier debugging

2019-07-28 Thread Andrew Barnert via Python-ideas
in builtins named debug_context(), it seems like any feasible version of this could already be written and used in Python today. (The first one, using static frame info, should be about 3 lines of inspect calls.) > ?identifier > > would print "identifier: value." Repr as bef

[Python-ideas] Re: for ... except, with ... except

2019-07-29 Thread Andrew Barnert via Python-ideas
se, not something like for…else that some experts use but most people live without. (But I don’t have a better syntax to offer. I actually like with…except, if it were just for my use, but on reflection I can see why others find it confusing. Just like for…else.) ____

[Python-ideas] Re: for ... except, with ... except

2019-07-29 Thread Rob Cliffe via Python-ideas
worthwhile goal, and at present the only way to achieve it is with somewhat verbose and clunky code. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.py

[Python-ideas] Re: for ... except, with ... except

2019-07-29 Thread Andrew Barnert via Python-ideas
d of code really is a serious problem, then the proposal doesn’t solve it; we need a proposal everyone will be able to learn and use. (And if it’s not a serious problem, then the proposal isn’t needed in the first place.) _______ Python-ideas mailing list -- py

[Python-ideas] Re: Entrypoint function for modules (AKA if __name__ == '__main__' ) with built-in argument parsing

2019-07-30 Thread Andrew Barnert via Python-ideas
ment parsing > in it, for example: > > # main.py > def __run__(first_num, second_num, print_operation=False): Couldn’t you get nearly the same effect in Python today just by adding one line: __run__(*sys.argv[1:]) That doesn’t do any fancy parsing of the arguments, but, except fo

[Python-ideas] Re: Entrypoint function for modules (AKA if __name__ == '__main__' ) with built-in argument parsing

2019-07-30 Thread Andrew Barnert via Python-ideas
On Jul 30, 2019, at 20:49, Andrew Barnert via Python-ideas wrote: > > There are lots of great third-party libraries that make turning a function > into a command-line utility a lot easier than using argparse. I think > whenever you want anything more than argv and don’t want a

[Python-ideas] Re: Entrypoint function for modules (AKA if __name__ == '__main__' ) with built-in argument parsing

2019-07-30 Thread Andrew Barnert via Python-ideas
dirty scripts, but would be disastrous for many other programs.) So… never mind. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.p

[Python-ideas] Re: for ... except, with ... except

2019-07-31 Thread Rob Cliffe via Python-ideas
sure than coding) it helps to have as much information as possible at your fingertips.  Oh, I know you can always work through a trace (if one is available) to see exactly where an error occurred, but that takes time. ___ Python-ideas mailing

[Python-ideas] Re: for ... except, with ... except

2019-07-31 Thread Rob Cliffe via Python-ideas
should be implemented.  I just don't want its merits to be overlooked.) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Mess

[Python-ideas] Re: Entrypoint function for modules (AKA if __name__ == '__main__' ) with built-in argument parsing

2019-07-31 Thread Andrew Barnert via Python-ideas
the magic code know that print_operation is a flag that takes no arguments? Especially if I type this: python run.py —print_operation 1 2 With argparse, getopt, click, etc., this works because I’ve specified that it’s a zero-argument flag; if I hadn’t, it would be equivalent to —print_operati

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
e them (unless you want to from itertools import * they need minor edits). I think the original reason not to do so was that the module was pure C code, and the recipes don’t need to be in C, and are as useful as sample code as they are for direct use, so they should remain in Python. Given that

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
On Aug 1, 2019, at 09:27, Christopher Barker wrote: > > > >> On Thu, Aug 1, 2019 at 9:19 AM Andrew Barnert via Python-ideas >> wrote: > >> > Given that in 3.x every stdlib module is supposed to be in Python with an >> > optional C accelerator, >

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
On Aug 1, 2019, at 10:48, Eli Berkowitz wrote: > > In terms of an argument for why it should be included, for most Python users > the itertools recipes remain unseen. Sure. But do you also know all of the functions in the module? Would you notice or a new one got added? In practi

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Rob Cliffe via Python-ideas
to "bother". ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-idea

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
h that a lot faster than 3 years in. If not, the packaging team will probably be disappointed to hear it… (I have occasionally had other people insist that I shouldn’t tell users to pip install things… but those are the same people insisting I should always start by explaining how to do it i

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-01 Thread Andrew Barnert via Python-ideas
dation, where a list of packages can be given that > aren't category killers, but have been given the blessing of the > Python devs as "this is a good-quality, well-maintained package, and > can be depended on"? I agree. I don’t think more-itertools meets the category-killer

[Python-ideas] Re: Fwd: Re: PEP: add a `no` keyword as an alias for `not`

2019-08-02 Thread Andrew Barnert via Python-ideas
n_votes(votes)) if no >= total//2: # etc. I even found an actual example of the equivalent in some C++ code I had on my hard drive: if (no == ask(…)) { // … } In Python, that would be: if no == ask(…): Also, even if that weren’t a problem, this would be

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
On Aug 1, 2019, at 22:26, Brendan Barnwell wrote: > >> On 2019-08-01 12:31, Andrew Barnert via Python-ideas wrote: >>> On Aug 1, 2019, at 10:48, Eli Berkowitz wrote: >>> > >>> >In terms of an argument for why it should be included, for most Python >

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
rlier > in the thread someone said PEP 399 says all modules have to have a pure > Python implementation. But now you say everything in itertools MUST be > implemented in C? Why is that? Why can't we just put the Python > implementations of the recipes as-is directly into itertools?

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
of the pitch for yield from that I can’t remember.) ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at ht

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
e plus grouper plus some of the less trivial recipes (or, more simply, just all of them, to avoid bikeshedding arguments on each one) is. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] h

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-02 Thread Andrew Barnert via Python-ideas
On Aug 2, 2019, at 19:22, Brendan Barnwell wrote: > >> On 2019-08-02 19:16, Andrew Barnert wrote: >> >> So, that’s the way forward. You could port the recipes to C and >> change the docs recipes to be “roughly equivalent” Python code in the >> help for each func

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-03 Thread Andrew Barnert via Python-ideas
d to live without once you get used to them. Also, most of them are curses or otherwise full-screen. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailm

[Python-ideas] Re: For-expression/throwaway comprehension

2019-08-07 Thread Andrew Barnert via Python-ideas
ys I just rely on IPython’s, which completes filenames. But it doesn’t have quite the same features. On the one hand, it has Jedi awesomeness, which is hard to live without once you get used to it. (And it’s especially fun when the local C++ or Go fanatic tells you that Python sucks because there’

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-08 Thread Ronald Oussoren via Python-ideas
> On 8 Aug 2019, at 12:22, Richard Musil wrote: > > I have found myself in an awkward situation with current (Python 3.7) JSON > module. Basically it boils down to how it handles floats. I had been hit on > this particular case: > > In [31]: float(0.64417

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-08 Thread Andrew Barnert via Python-ideas
for when they switch to exponential numbers, and how they represent that. And a C++ library may well represent 64-bit integers above 1<<56 imprecisely, while Python won’t. And, beyond numbers, different libraries produce different white space, different ordering within dicts, and differ

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-08 Thread Andrew Barnert via Python-ideas
when the values are unchanged. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-08 Thread Rob Cliffe via Python-ideas
Would this work for you? import struct floatval = 0.6441726684570312 s = struct.pack("d", floatval) # converts floatval into a string (Python 2) or bytes (Python 3), of 8 raw bytes # then serialise s To be portable between different platforms, you would also need to store whether

[Python-ideas] Re: Exceptions with Message Templates

2019-08-08 Thread Andrew Barnert via Python-ideas
our example, since that’s what you did in version 1 and 2) now requires keyword boilerplate on every line where you construct one. And, since you generally construct and use a class many times, but only define it once, that’s adding a lot more boilerplate than it’s saving. Also, even in the defin

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-08 Thread Andrew Barnert via Python-ideas
u really do need support for raw output, you’d need a new hook besides default, say, rawdefault. This wouldn’t be hard. Other than passing it up and down the chain of APIs, the only trick should be the C and Python code down in _iterencode that that do this: o = _default(o)

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-08 Thread Andrew Barnert via Python-ideas
s you add in encode only affect the top-level value, not values inside arrays or objects. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-

[Python-ideas] Re: Exceptions with Message Templates

2019-08-08 Thread Andrew Barnert via Python-ideas
On Aug 8, 2019, at 15:01, Ryan Fox wrote: > > I don't see why you would want to access arguments by their position. Because that’s the way it’s worked since Python 1.x, and there’s tons of existing code that expects it, including the default __str__ and __repr__ for exceptions a

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-09 Thread Andrew Barnert via Python-ideas
ing problem at all, so if your argument is that we should include it to solve that problem, you need a new argument. —- * Python, and I believe simplejson, still conforms to RFC 7159, which was the standard until December 2017, so if you wanted to make an argument from 7159, that _might_

[Python-ideas] Re: Proposal: Use "for x = value" to assign in scope

2019-08-09 Thread Andrew Barnert via Python-ideas
complexity for the reader to deal with, so I think you’re still better off not doing it. (As a side note, you probably want a numerical stable average like the ones in statistics or numpy, rather than one that accumulates float rounding errors indiscriminately, but that’s another issue.) ___

[Python-ideas] Re: Exceptions with Message Templates

2019-08-09 Thread Andrew Barnert via Python-ideas
On Aug 9, 2019, at 12:00, Ryan Fox wrote: > > > If you’re wondering why this works, it’s because Error and InputError don’t > > override __new__. Which should make it obvious why a tutorial aimed at > > novices doesn’t get into the details, but that’s why Python has r

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-09 Thread Andrew Barnert via Python-ideas
he only JSON docs you ever receive are just individual numbers, and they’re all between -0.1 and -0.2, so the only possible error that can arise is this one. And so on. But I doubt any of those is common. ___ Python-ideas mailing list -- python-ideas@p

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-09 Thread Andrew Barnert via Python-ideas
thing to parse in the world, but why duplicate the parser (and potentially create new bugs) if you already have one? _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.pyth

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-09 Thread Andrew Barnert via Python-ideas
Decimal can’t solve for anyone; there’s no additional problem that Decimal can’t solve here that’s only faced by your weird app. > But an application > that cared about that would be pretty weird. So I think a > "use decimal" option would cover the vast majority of use > c

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-10 Thread Andrew Barnert via Python-ideas
explained in the docs.) JS implementations before ES5 serialized and parsed NaN, Infinity, and -Infinity, even though the informal spec said they shouldn’t. Lots of other libraries followed suit. (Some also accept or even produce nan, int, -inf, because that’s what most C libraries output—as do Pytho

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-10 Thread Andrew Barnert via Python-ideas
ple. The two strings that he’s complaining about are different string representations of the same float value. It’s not the value he’s complaining about, but the fact that Python won’t give him the same string representation for that float that his C++ library does, and therefore dumps(loads(…)) isn’

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-10 Thread Andrew Barnert via Python-ideas
g that you asked what you asked, and then pretending to have a different problem in hopes that different problem might be solved by the feature you asked for, so maybe the feature will be added so you can misuse it for what you really wanted. _______ Python-id

[Python-ideas] Re: hybrid implementation for PyLongObject (performance)

2019-08-12 Thread Andrew Barnert via Python-ideas
On Aug 11, 2019, at 19:01, [email protected] wrote: > > The idea is mixing `PyLongObject` with `Python 2's PyIntObject` > implementation. > > For example, on a 64-bit platform, if (an integer >=-9223372036854775808 and > <=9223372036854775807), PyLongObject uses a n

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-12 Thread Andrew Barnert via Python-ideas
e do it. So, you load a JSON document with the string “abc\/def”, you get the Python string “abc/def”, you dump it and get a JSON document with “abc/def”. JSON says the two documents are identical, but they obviously aren’t the same bytes. Similar issues include case for hex letters in \u escap

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-12 Thread Andrew Barnert via Python-ideas
he original JS reference implementation) break the spec in that way that it’s useful to have an option to do the same. (Even without that option, Python raises a ValueError instead of emitting null, but that’s not a way to get invalid JSON, it’s just a way to not get any JSON when the libra

[Python-ideas] Re: hybrid implementation for PyLongObject (performance)

2019-08-13 Thread Andrew Barnert via Python-ideas
mark. So again, I don’t think it’s likely anyone will volunteer if you don’t provide some reason to expect it to pan out. Even if you can’t edit hairy C code like longobject.c, you can write simple Python code and benchmark it, search the list archives, etc., just as well as anyone else. If that’s no

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-13 Thread Andrew Barnert via Python-ideas
at’s as readable as possible for a single line that meets the standards of an entry in all of JSONlines, NDJ, and LDJSON. But at the time nobody could have known about JSONlines, or that 7-bit-clean pretty-printed JSON would never be useful, etc. _____

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-13 Thread Andrew Barnert via Python-ideas
On Aug 13, 2019, at 11:21, Chris Angelico wrote: > > On Wed, Aug 14, 2019 at 3:12 AM Andrew Barnert via Python-ideas > wrote: >> >>> On Aug 13, 2019, at 01:04, Richard Musil wrote: >>> >>> Concerning the custom separators, and why the implementati

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-13 Thread Andrew Barnert via Python-ideas
On Aug 13, 2019, at 15:01, Eric V. Smith wrote: > >> On 8/13/2019 5:49 PM, Andrew Barnert via Python-ideas wrote: >> But I think the lazy-import-decimal-on-first-dump-with-use_decimal solves >> that, and solves it even better than __json__, even besides the fact that >

[Python-ideas] Re: Exception handling in objects

2019-08-14 Thread Andrew Barnert via Python-ideas
de local functions? Classes defined within the function? Exec from within the function (does it depend whose locals are passed)? What about a callable that’s not a function or class? Does it just catch exceptions raised inside the __call__ method itself? And so on. ______

[Python-ideas] Re: JSON encoder protocol (was Re: adding support for a "raw output" in JSON serializer)

2019-08-14 Thread Andrew Barnert via Python-ideas
o generate invalid JSON if they want to" is not > without precedent. Sure, and as soon as you discover another special case that millions of existing programs expect to be handled in a way that violates the RFC, that somehow nobody has noticed in the last 16 years, file a bug to handle that wit

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-14 Thread Andrew Barnert via Python-ideas
with you that we probably don’t want to add that support in the first place. But, as you say, at least some people disagree, so…) _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.pytho

[Python-ideas] Re: Exception handling in objects

2019-08-14 Thread Rob Cliffe via Python-ideas
e It seems to me this idea will help library users more correctly handle their exceptions if this is problematic. This will save time and make code more reliable. ___ Python-ideas mailing list -- [email protected] To unsubscribe send an email to

[Python-ideas] Re: JSON encoder protocol (was Re: adding support for a "raw output" in JSON serializer)

2019-08-14 Thread Andrew Barnert via Python-ideas
t be looked up anywhere. Avro is intentionally unversioned because it will never change, according to version 1.8 of the spec. And so on. We’re in great shape for the future. :) _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email

[Python-ideas] Re: JSON encoder protocol (was Re: adding support for a "raw output" in JSON serializer)

2019-08-14 Thread Andrew Barnert via Python-ideas
e it, and can go find a library for it themselves. Still, if Python had the “loose recommendations from core devs” links thing discussed in another thread, some of these packages might qualify. If someone really wants that, they should probably read over what’s been said about it so far an

[Python-ideas] Re: JSON encoder protocol (was Re: adding support for a "raw output" in JSON serializer)

2019-08-15 Thread Andrew Barnert via Python-ideas
expecting that one of the many JSON-based and JSON-like formats is going to become an official successor to JSON and take over its ubiquity. But that really isn’t likely (and you aren’t going to make it any more likely by arguing for it on python-ideas, and even less so by arguing for four of the

[Python-ideas] Re: JSON encoder protocol (was Re: adding support for a "raw output" in JSON serializer)

2019-08-15 Thread Andrew Barnert via Python-ideas
as shown any need for any of the other stuff. > * support for extensions to the JSON standard (JSON5, etc.) One guy saw a bunch of shiny new protocols (half of which are actually stagnant dead protocols) and thought that if the Python stdlib added support for all of them, they’d all take over t

[Python-ideas] Re: Extend ast with types for * instead of using raw lists

2019-08-16 Thread Andrew Barnert via Python-ideas
that accepts ast_list as a subclass. (The lists_as_nodes flag becomes slightly more complicated, but still pretty simple—and besides, that’s all under-the-covers code.) ___ Python-ideas mailing list -- [email protected] To unsubscribe send an emai

[Python-ideas] Re: JSON encoder protocol

2019-08-17 Thread Andrew Barnert via Python-ideas
n, provide exactly this functionality (usually under the name for_json, because __json__ has double underscores and is therefore reserved for Python and its stdlib), and there are definitely people who like it. If you read the simplejson docs, and search for code that imports it, you can

[Python-ideas] Re: Fwd: Optional kwarg for sequence methods in random module

2019-08-17 Thread Andrew Barnert via Python-ideas
et from choice?)_______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/lis

[Python-ideas] Re: Fwd: Optional kwarg for sequence methods in random module

2019-08-18 Thread Andrew Barnert via Python-ideas
the only thing anyone wants from it is something that doesn’t make sense, then maybe we’re better off without it? _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.py

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-23 Thread Andrew Barnert via Python-ideas
resources. The README explains that: “simplejson is the externally maintained development version of the json library included with Python 2.6 and Python 3.0”. This has multiple advantages: * It can evolve much more quickly than the 18-month stdlib cycle. Notice that it’s gone from 1.0 to 3.16.1

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-23 Thread Andrew Barnert via Python-ideas
23, 2019, at 08:16, Michael Hooreman wrote: > > Hello, > > I have a proposal to improve support of __main__.py (python -m foobar) > invocation to argparse.ArgumentParser > > You can find attached a PEP draft. > > Unfortunately, I'm not very confident on how to a

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-23 Thread Andrew Barnert via Python-ideas
One more thing: from reading your proposal, it sounds like your actual issue may be that you’ve got something you want to distribute to end-users who aren’t Python experts to run as `python -m spam`, and the usage messages they get back are confusing them? If so, why not just use a setuptools

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-23 Thread Andrew Barnert via Python-ideas
On Aug 23, 2019, at 09:45, Christopher Barker wrote: > > Andrew, thanks for the background. > >> On Fri, Aug 23, 2019 at 8:25 AM Andrew Barnert via Python-ideas >> wrote: > >> Also, IIRC, it doesn’t do any post-check; it assumes calling str on any >> De

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Andrew Barnert via Python-ideas
On Aug 24, 2019, at 00:25, Michael Hooreman wrote: > > In fact, I should add more than the python executable in prog: it must > contain -m and the package « classpath » But that’s not a valid prog. If you try to execute the program “python -m spam” with arguments “eggs” and “cheese”

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Andrew Barnert via Python-ideas
But, it this is THE only way correct way to do, why do python allows > __main__.py? This is a silly question. Imagine you were asking how to insert a value into the middle of a tuple, and, after telling you how you can sort of do the immutable equivalent of what you’re asking, I also pointed out

[Python-ideas] Re: Idea/PEP draft: Add support of __main__.py to argparse.ArgumentParser.prog

2019-08-24 Thread Andrew Barnert via Python-ideas
our scripts to munge the usage output might well be a better use of your time than days learning a new tool and adapting your workflow to it. That doesn’t mean we should necessarily change the stdlib of Python to encourage more people to build workflows like yours in the future instead of more

[Python-ideas] Re: adding support for a "raw output" in JSON serializer

2019-08-26 Thread Andrew Barnert via Python-ideas
needing it. This is important. Even if you come up with something better than simplejson, it’s highly unlikely to actually help you unless you can extract it into a backport that you can publish and maintain on PyPI, unless you only need the new feature for code whose release date is so far i

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Andrew Barnert via Python-ideas
*error with the null check). That isn’t that hard to add to a C-style language—and it actually fits better into Python, where there is no explicit dereferencing anywhere. And you can still “pass” an uninitialized variable or leave it out, because you’re not really passing anything, you’re just

[Python-ideas] Re: [new idea] dynamic return with using function argument

2019-08-26 Thread Andrew Barnert via Python-ideas
tvar)') but in the caller it will > require special syntax because the Python compiler can't know the signature > of the called function (this is not a limitation of the CPython bytecode > compiler but a feature of the language). Right; the caller can’t know any more than that

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread Andrew Barnert via Python-ideas
On Aug 26, 2019, at 16:03, [email protected] wrote: > > In Python strings are allowed to have a number of special prefixes: > >b'', r'', u'', f'' >+ their combinations. > > The proposal is to allow arbitrary (or letter-on

[Python-ideas] Re: Custom string prefixes

2019-08-26 Thread Andrew Barnert via Python-ideas
t’s declared or inferred to take a regex if that happens to be readable in your use case, so there’s no need for a suffix syntax.) Which is neat, but obviously not applicable to Python. > And your idea that ` ` is conceptually no different > than > ` ` is absolutely insightful. We

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
On Aug 26, 2019, at 23:43, Serhiy Storchaka wrote: > > 27.08.19 06:38, Andrew Barnert via Python-ideas пише: >> * JSON (register the stdlib or simplejson or ujson), > > What if the JSON suffix for? I think you’d mainly want it in combination with percent-, html-, or uu-equa

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
look more carefully at the C++ rules for that?) ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at htt

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
On Aug 27, 2019, at 08:52, Steven D'Aprano wrote: > >> On Tue, Aug 27, 2019 at 05:24:19AM -0700, Andrew Barnert via Python-ideas >> wrote: >> >> There is a possibility in between the two extremes of “useless” and >> “complete monster”: the prefix accept

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
ut I’d still do it at the REPL, and likely in real code as well. But I don’t think that choice would make my code worse (because when setup costs matter, I _wouldn’t_ make that choice), so I don’t see that as a problem. _______ Python-ideas mailing list -- pyt

[Python-ideas] Re: Add boolean attribute to datetime objects stating if they are tz-aware

2019-08-27 Thread Andrew Barnert via Python-ideas
a method? What happens if utcoffset raises NotImplementedError? (Or anything else, I suppose, but NotImplementedError is the documented behavior for the base class.) Should date get an attribute that’s always False, or is it sufficiently obvious to most people that dates are always nai

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
On Tuesday, August 27, 2019, 11:42:23 AM PDT, Serhiy Storchaka wrote: > 27.08.19 20:07, Andrew Barnert via Python-ideas пише: >> Before I get into this, let me ask you a question. What does the j suffix >> give us? You can write complex numbers without it just fine: >>

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
On Tuesday, August 27, 2019, 11:12:51 AM PDT, Chris Angelico wrote: >On Wed, Aug 28, 2019 at 3:10 AM Andrew Barnert via Python-ideas > wrote: >> Before I get into this, let me ask you a question. What does the j suffix >> give us? You can write complex numbers wi

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
On Aug 27, 2019, at 14:41, Chris Angelico wrote: > >> On Wed, Aug 28, 2019 at 6:03 AM Andrew Barnert wrote: >> >>> On Tuesday, August 27, 2019, 11:12:51 AM PDT, Chris Angelico >>> wrote: >>> If your conclusion here were "and that's why P

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
hung up on the fact that these affixes don’t really give us “literals” back in either 2013 or 2016, and I don’t want to rehash that argument. I could point out that nobody cares that -1 isn’t really a literal, and almost nobody cares that the CPython optimizer special-cases its way around that

[Python-ideas] Re: Custom string prefixes

2019-08-27 Thread Andrew Barnert via Python-ideas
27;t know how many there are. The only ones I can think of are "f" > for single-precision float, and the long and unsigned suffixes on > integers. Of the top of my head, there are also long long integers, and long doubles, and wide and three Unicode suffixes for char. Those probably

[Python-ideas] Re: Custom string prefixes

2019-08-28 Thread Andrew Barnert via Python-ideas
far, even Steven’s facetious quaternion example that he proposed as too ridiculous for anyone to actually want. Is it a flaw that there may or may not be some examples that nobody has been able to think of that might work with a much more complicated feature but won’t work with this fea

[Python-ideas] Re: Custom string prefixes

2019-08-28 Thread Andrew Barnert via Python-ideas
that they’d all be unfamiliar cryptic one-letter things, is likely to arise. ___________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-id

[Python-ideas] Re: Custom string prefixes

2019-08-28 Thread Andrew Barnert via Python-ideas
On Aug 28, 2019, at 01:05, Paul Moore wrote: > > On Wed, 28 Aug 2019 at 05:04, Andrew Barnert via Python-ideas > wrote: >> What matters here is not whether things like the OP’s czt'abc' or my 1.23f >> or 1.23d are literals to the compiler, but whether the

[Python-ideas] Re: Custom string prefixes

2019-08-28 Thread Andrew Barnert via Python-ideas
ple, it’s probably still worth looking at whether it’s feasible. _______ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message ar

<    1   2   3   4   5   6   7   8   9   10   >