[Python-ideas] Re: returning a namedtuple on dict.items()

2020-03-31 Thread Cameron Simpson
attribute names. I'm sure there must be other modules with similar facilities as well. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://

[Python-ideas] Re: General methods

2020-05-08 Thread Cameron Simpson
iment which motivates the proposal. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archiv

[Python-ideas] Re: Making asserts non-recoverable.

2020-05-13 Thread Cameron Simpson
mplete lack of consistency with every other exception type, seems very artificial. You'lll just push the devs from misusing asserts to misusing something else. _Are_ your devs catching AssertionError and preventing programme termination? Cheers, Cameron Simpson

[Python-ideas] Re: str.strip: argument maxstrip

2020-05-19 Thread Cameron Simpson
ing the Python 3.9 suggestion, what about: salt2 = salt.cutsuffix(('==', '=')) I appreciate this isn't as _general_ as a maxstrip param, but it seems to neatly address the single use case you've found. Cheers, Cameron Simpson ___

[Python-ideas] Re: How to propose a change with tests where the failing test case (current behaviour) is bad or dangerous

2020-05-21 Thread Cameron Simpson
ndary objective is to do it without zip exploding in the tester's face. The process here is: - bug exists (exploding zip) - write a test that fails when the bug exists - fix the bug - the test should now pass Step 2 eats an unbounded amount of disc (in this case, other bugs can go bad o

[Python-ideas] Re: len(path) == len(str(path))

2020-05-24 Thread Cameron Simpson
different to that measured by a numeric index. I think this makes me -1 on the proposal, also because str(Path) is so easy to do. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to pytho

[Python-ideas] Re: Function composition

2020-05-24 Thread Cameron Simpson
cut, also grep, also uniq... everything I used in the example). People forget that redirections may appear anywhere rather than just at the end of the command: output But I take your point on incremental build-the-pipeline, I do that a lot. Cheers, Cameron Simpson

[Python-ideas] Re: A shortcut to load a JSON file into a dict : json.loadf

2020-09-11 Thread Cameron Simpson
import them from your personal little module-of-three-line-functions. No need to publish to PyPI (extra work) - it's as easy to keep them locally unless you need them elsewhere. But don't rewrite - reuse! Cheers, Cameron Simpson ___ Pyth

[Python-ideas] Re: Curious : Why staticmethod if classmethods can do everything a static method can?

2020-09-11 Thread Cameron Simpson
't understand what you mean by "additionally is not limited by inheritance"? Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.pytho

[Python-ideas] Re: Curious : Why staticmethod if classmethods can do everything a static method can?

2020-09-11 Thread Cameron Simpson
Dan, I should preface this by saying I don't substantially disagree with you, I just work differently and want to show how and why. On 11Sep2020 21:24, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: >On 2020-09-12 at 09:57:10 +1000, >Cameron Simpson wrote

[Python-ideas] annotating PEP mentions (was: Naming Accepted PEPs as PAPs)

2020-09-21 Thread Cameron Simpson
a bit opaque. Since I use mutt it might be tractable for me to modify the display_filter I use to perform this edit. It'd need a small backing store to avoid having to do an HTTP callout on each reference, but I have one of those... Cheers, Cameron Simpson ___

[Python-ideas] Re: TextIOWrapper support for null-terminated lines

2020-10-25 Thread Cameron Simpson
have newlines in a filename(yuck) ... > >Spaces in filenames are just as bad, and much more common: But much easier to handle in simple text listings, which are newline delimited. You're really running into a horrible behaviour from xargs, which is one reason why GN

[Python-ideas] Re: TextIOWrapper support for null-terminated lines

2020-10-25 Thread Cameron Simpson
On 26Oct2020 09:45, Chris Angelico wrote: >On Mon, Oct 26, 2020 at 8:44 AM Cameron Simpson wrote: >> On 24Oct2020 13:37, Dan Sommers <2qdxy4rzwzuui...@potatochowder.com> wrote: >> >Spaces in filenames are just as bad, and much more common: >> >> But much easi

[Python-ideas] Re: Adding PyInstaller to the standard library

2020-11-19 Thread Cameron Simpson
ode and/or python version) are often a fair price to pay to "just give it to someone" and have it work. If it needs an update or bugfix I can just give them a newer one. BTW, py2app also has a "dev mode", a bit like pip's -e option, to use the

[Python-ideas] Re: Adding PyInstaller to the standard library

2020-11-19 Thread Cameron Simpson
robust way to ship something which Just Works. It may not be necessary in you environment or use cases, but in the very common case where you want users to just use something without installing a development environment to support it, it is the go. Cheers, Cameron Simpson ___

[Python-ideas] Re: Adding PyInstaller to the standard library

2020-11-21 Thread Cameron Simpson
ries (needed PyQt) They're end users; some are (variously) technical and some aren't, but none should need to be technical. I want them to copy an app to a new machine and be happy - drag'n'drop a single thing. Cheers, Cameron Simpson

[Python-ideas] Re: Adding PyInstaller to the standard library

2020-11-21 Thread Cameron Simpson
On 22Nov2020 13:22, Steven D'Aprano wrote: >On Sun, Nov 22, 2020 at 12:56:01PM +1100, Cameron Simpson wrote: >> On 21Nov2020 17:54, Chris Angelico wrote: >> >The range of people who (a) cannot install from PyPI and can only use >> >the stdlib, and (b) cannot deplo

[Python-ideas] Re: Making the for statement work better with nested functions

2020-11-26 Thread Cameron Simpson
... also x and y cannot shadow existing names ... I wouldn't want to let any "as" support a "new", but the one on "with" introduces a suite which nicely delineates a block. Cheers, Cameron Simpson ___ Python-ideas

[Python-ideas] Re: Making the for statement work better with nested functions

2020-11-26 Thread Cameron Simpson
.. The nearest Python equivalent is: i = blah() ... use i del i which feels fragile - accidental assignment to "i" later is not forbidden. Of course, in C variables must be declared. Not so easy with Python, syntacticly. Cheers, Cameron Simpson

[Python-ideas] Re: Making the for statement work better with nested functions

2020-11-27 Thread Cameron Simpson
On 27Nov2020 21:13, Steven D'Aprano wrote: >On Fri, Nov 27, 2020 at 08:32:04AM +1100, Cameron Simpson wrote: >> On 27Nov2020 00:25, Steven D'Aprano wrote: >> >Block scoping allows shadowing within a function. >> >> Just to this: it needn't. > >Y

[Python-ideas] Re: Making the for statement work better with nested functions

2020-11-29 Thread Cameron Simpson
on right now and does not mean that. So some indication of the special meaning would be required. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mai

Re: [Python-ideas] proposal: "python -m foo" should bind sys.modules['foo']

2017-01-17 Thread Cameron Simpson
Trying to get back to speed with PEP-499... On 06Aug2015 13:26, Nick Coghlan wrote: On 6 August 2015 at 10:07, Cameron Simpson wrote: I suspect "How Reloading Will Work" would need to track both module.__name__ and module.__spec__.name to reattach the module to both entires in s

Re: [Python-ideas] Ideas for improving the struct module

2017-01-19 Thread Cameron Simpson
ot %d bytes" % (offset0, datalen, len(data))) offset += datalen return data, offset Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Ideas for improving the struct module

2017-01-19 Thread Cameron Simpson
t is nonsemantic: I wish it let me put meaningless whitespace inside the format for readability). +1 on the proposal from me. Oh: subject to one proviso: reading a struct will need to return how many bytes of input data were scanned, not merely retur

Re: [Python-ideas] Ideas for improving the struct module

2017-01-20 Thread Cameron Simpson
to avoid making a weird incongruity, where only variable-length strings return the length actually parsed. Fully agree. Arguing for two API calls: the current one and one that also returns the scan length. Cheers, Cameron Simpson ___ Python-ideas mailing

Re: [Python-ideas] Ideas for improving the struct module

2017-01-20 Thread Cameron Simpson
. Have you read the struct module? Do you think your additions would be very intrusive to it, or relatively simple? Will the present performance be likely to be the same with your additions (not necessarily to cost to parse the new formats, but the performance with any existing fixed length

Re: [Python-ideas] Suggestion: Add shutil.get_dir_size

2017-05-02 Thread Cameron Simpson
ather niche function. Had you considered just calling "du" via subprocess and reading the number it returns? Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas

Re: [Python-ideas] Suggestion: Add shutil.get_dir_size

2017-05-03 Thread Cameron Simpson
m the kind of person who'd write his own for things like this sometimes also. Starting with Python's os.walk function would get you off the ground. If you end up with something clean and usable by others, publish it to PyPI. Cheers, Cameron Simpson __

Re: [Python-ideas] Improving Catching Exceptions

2017-06-22 Thread Cameron Simpson
deal with 3). Catching nested exception is not what people want many times. Isn't it? Why not? Can you explain further? I hope this real world example shows why the scenario is real, and that my discussion shows why for me at least it would be handy to _easily_ catch the "shallow"

Re: [Python-ideas] Improving Catching Exceptions

2017-06-22 Thread Cameron Simpson
On 22Jun2017 19:47, Andy Dirnberger wrote: On Jun 22, 2017, at 7:29 PM, Cameron Simpson wrote: try: foo(bah[5]) except IndexError as e: ... infer that there is no bah[5] ... Of course, it is possible that bah[5] existed and that foo() raised an IndexError of its own. One

Re: [Python-ideas] Improving Catching Exceptions

2017-06-23 Thread Cameron Simpson
On 24Jun2017 05:02, Steven D'Aprano wrote: On Fri, Jun 23, 2017 at 09:29:23AM +1000, Cameron Simpson wrote: On 23Jun2017 06:55, Steven D'Aprano wrote: >On Thu, Jun 22, 2017 at 10:30:57PM +0200, Sven R. Kunze wrote: >>We usually teach our newbies to catch exceptions as nar

Re: [Python-ideas] Improving Catching Exceptions

2017-06-23 Thread Cameron Simpson
On 23Jun2017 11:48, Nick Coghlan wrote: On 23 June 2017 at 09:29, Cameron Simpson wrote: This is so common that I actually keep around a special hack: def prop(func): ''' The builtin @property decorator lets internal AttributeErrors escape. While that can sup

Re: [Python-ideas] Improving Catching Exceptions

2017-06-23 Thread Cameron Simpson
On 23Jun2017 15:59, Paul Moore wrote: On 23 June 2017 at 15:20, Sven R. Kunze wrote: On 23.06.2017 03:02, Cameron Simpson wrote: How about something like this? try: val = bah[5] except IndexError: # handle your expected exception here else: foo(val) That is the

Re: [Python-ideas] Improving Catching Exceptions

2017-06-23 Thread Cameron Simpson
ere's some code to refactor using this construct now... Alas, no. It is existing syntax in Standard ML, not in Python. Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-i

Re: [Python-ideas] A suggestion for a do...while loop

2017-06-26 Thread Cameron Simpson
On 26Jun2017 13:30, Ethan Furman wrote: On 06/26/2017 01:20 PM, Mikhail V wrote: I dont't like "while True:" simply because it does not make enough visual distinction with the "while condition:" statement. My "while True:" loops look something like: whil

Re: [Python-ideas] + operator on generators

2017-06-30 Thread Cameron Simpson
rasings because the tail iterables ("chunks" and "blocks") are of unknown and potentially large size. And a few other cases whose uses are harder to succinctly describe, but generally "iterable flattening". So it is uncommon for me, but very useful when I wan

Re: [Python-ideas] + operator on generators

2017-06-30 Thread Cameron Simpson
lar keyword. Cheers, Cameron Simpson Trust the computer industry to shorten Year 2000 to Y2K. It was this thinking that caused the problem in the first place. - Mark Ovens ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.

Re: [Python-ideas] Add single() to itertools

2017-10-30 Thread Cameron Simpson
rors with distinct text for 0 and >1 failure. Cheers, Cameron Simpson (formerly c...@zip.com.au) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Add single() to itertools

2017-10-31 Thread Cameron Simpson
On 31Oct2017 22:50, Greg Ewing wrote: Koos Zevenhoven wrote: |defsingle(i): try: ||v =i.next() |||exceptStopIteration:raiseException('No values')|||try: ||i.next() ||exceptStopIteration: ||returnv||else: ||raiseException('Too many values')|||printsingle(name forname in('bob','fred')

Re: [Python-ideas] Why CPython is still behind in performance for some widely used patterns ?

2018-01-26 Thread Cameron Simpson
chine code when used). This isn't really an option for "pure" Python. Cheers, Cameron Simpson (formerly c...@zip.com.au) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Class autoload

2018-03-03 Thread Cameron Simpson
Personally, I'm -1 for an autoimport because it doesn't actually buy much, and -2 for any autoimport based on PHP semantics, which generally lead to "fail late" instead of "fail early". Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-12 Thread Cameron Simpson
ssion as name" camp, which I gather is already rejected. Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-12 Thread Cameron Simpson
On 13May2018 07:07, Cameron Simpson wrote: Similar to import statements, optional parentheses could be included in the grammar, allowing the name bindings to be split across multiple lines: if diff and g > 1 given ( diff = x - x_base, g = gcd(diff, n), ): return g

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-12 Thread Cameron Simpson
success. And that is entirely enabled by the implied scoping in the "if" statement. The above example is subtly wrong because I'm doing this from memory, but I had a very simple real world example bite me this way and it was a PITA to debug because the effect was so surprising. So mu

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-12 Thread Cameron Simpson
On 13May2018 00:51, MRAB wrote: On 2018-05-12 22:07, Cameron Simpson wrote: On 06May2018 02:00, Nick Coghlan wrote: Similar to import statements, optional parentheses could be included in the grammar, allowing the name bindings to be split across multiple lines: if diff and g > 1 gi

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-12 Thread Cameron Simpson
as with, import and except. Could someone point me to a post which nicely describes the rationale behind its rejection? I'm sure there's one in the many in this discussion but I've not found it yet. Cheers, Cameron Simpson _

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-12 Thread Cameron Simpson
d painful memories of being burned by that in C. That's not just speculation - it came up a number of times in the PEP 572 threads. Disclaimer: I'm not a core dev! Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-12 Thread Cameron Simpson
On 13May2018 14:23, Chris Angelico wrote: On Sun, May 13, 2018 at 2:05 PM, Cameron Simpson wrote: Could someone point me to a post which nicely describes the rationale behind its rejection? I'm sure there's one in the many in this discussion but I've not found

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-13 Thread Cameron Simpson
"not"...) fit this role. So as a matter of egonomic design "given" ought also to bind less tightly than "+". Arithmetic before logic before declaration before control, if you like. Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Inline assignments using "given" clauses

2018-05-13 Thread Cameron Simpson
On 13May2018 06:45, Eric V. Smith wrote: On 5/13/18 1:05 AM, Chris Angelico wrote: On Sun, May 13, 2018 at 2:58 PM, Cameron Simpson wrote: On 13May2018 14:23, Chris Angelico wrote: https://www.python.org/dev/peps/pep-0572/#alternative-spellings [...] I'd already looked at that pa

Re: [Python-ideas] Specifying Python version

2018-05-16 Thread Cameron Simpson
geset from maintenance, tread on the "3.3" with "2.5" Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-12 Thread Cameron Simpson
slice assignment: replace a sublist with another sequence. Yes I see, actually that is what I am saying - slice assignment has _replace_ semantics. Yes, but note that replacing an _empty_ part of the list _is_ an insert! Cheers, Cameron Simpson ___ P

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-15 Thread Cameron Simpson
already be written: L[len(L):len(L)]=[9] Cumbersome, I accept. But I've got a .append method. Cheers, Cameron Simpson ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

Re: [Python-ideas] Operator for inserting an element into a list

2018-06-16 Thread Cameron Simpson
On 16Jun2018 20:21, Mikhail V wrote: On Sat, Jun 16, 2018 at 4:44 AM, Cameron Simpson wrote: On 16Jun2018 02:42, Mikhail V wrote: Some things _should_ be syntax errors. Particularly things which may be typing errors. Suppose I'd meant to type: L[0] = item Silent breakage, requ

[Python-ideas] Re: CLI convenience?

2022-02-20 Thread Cameron Simpson
without polluting the command line space. That said, it isn't always a bad thing to provide a script. I do it myself. Choosing an name which is (a) expressive and (b) less likely to conflict with other's choices is important though. Cheers, Cameron Simpson

[Python-ideas] Re: Heterogeneous numeric data in statistics library

2022-05-12 Thread Cameron Simpson
vert to homogenous" followed by a _fast_ operation than an accept-heterogeneous-but-be-much-slower. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https

[Python-ideas] Re: Slice 'size' parameter (in the style of pairwise)

2022-06-04 Thread Cameron Simpson
) Indeed. But there's a reason we ty to avoid letting functions acquire many positional parameters. I appreciate that you're illustrating that deliberately. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.or

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-20 Thread Cameron Simpson
mple is from KML (Google map markup dialect) where IIRC a "ScreenOverlay" and a "screenoverlay" both existing with different semantics. Ugh. So indeed, I'd probably _want_ .upper to return a plain string and have special methods to do mo

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-20 Thread Cameron Simpson
ult - because such a string has substructure that seems to warrant careful thought. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/m

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-20 Thread Cameron Simpson
On 21Dec2022 17:00, Steven D'Aprano wrote: On Wed, Dec 21, 2022 at 09:42:51AM +1100, Cameron Simpson wrote: With str subtypes, the case that comes to my mind is mixing str subtypes. [...] So, yes, for many methods I might reasonably expect a new html(str). But I can contrive situations

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-23 Thread Cameron Simpson
tly example of naive/incorrect use. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Messag

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-23 Thread Cameron Simpson
On 24Dec2022 09:11, Chris Angelico wrote: On Sat, 24 Dec 2022 at 09:07, Cameron Simpson wrote: On 23Dec2022 22:27, Chris Angelico wrote: >I think this would be a useful feature to have, although it'll >probably end up needing a LOT of information (you can't just say &q

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-23 Thread Cameron Simpson
On 24Dec2022 14:35, Chris Angelico wrote: On Sat, 24 Dec 2022 at 13:15, Cameron Simpson wrote: My question was more: do you know, or do you have to look? I'll take another example. Take the list.index() method, which returns the index where a thing can be found. *Without checking

[Python-ideas] Re: Idea: Tagged strings in python

2022-12-23 Thread Cameron Simpson
On 24Dec2022 15:12, Chris Angelico wrote: On Sat, 24 Dec 2022 at 15:00, Cameron Simpson wrote: help(list.index) seems empty. Huh that's strange. I'm checking this in a few recent versions, and they all say "Return first index of value". Ugh. It isn't empty. B

[Python-ideas] Re: timedelta.strptime() and timedelta.strftime()

2023-02-02 Thread Cameron Simpson
f generality. I've used the above for some things. Personally, I _also_ keep my own helpers around, usually for special niche cases (more niche than your suggested `timedelta.strptime`): https://pypi.org/project/cs.dateutils/ https://github.com/cameron-simpson/css/blob/main/lib/python/cs/da

[Python-ideas] Re: Auto dedent -c arguments.

2023-04-05 Thread Cameron Simpson
On 05Apr2023 10:01, Lucas Wiman wrote: On Tue, Apr 4, 2023 at 7:19 AM Jonathan Crall wrote: Would there be any downside to the Python CLI automatically dedenting the input string given to -c? I can't think of any case off the top of my head where it would make a previously valid program inval

[Python-ideas] Re: "Curated" package repo?

2023-07-08 Thread Cameron Simpson
pam sources: good for a single "bad" actor (by my personal criteria) to ignore their (apparent) gaming of the ratings but not good for a swarm of robots. Cheers, Cameron Simpson ___ Python-ideas mailing list -- python-ideas@python.org To unsu

<    1   2