[Python-ideas] Re: Simple feature for argparse.py

2019-10-09 Thread Ryan Gonzalez
I believe you want Python 3.7's parse_intermixed_args: https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_intermixed_args A quick test seems to work: import argparse p = argparse.ArgumentParser() p.add_argument('files', nargs='*') p.add_argument('-f', '--force',

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

2019-07-30 Thread Ryan Gonzalez
I think you might find plac[1] and fire[2] rather interesting. I do feel an explicit __run__ would go against the spirit of "explicit is better than implicit" a bit... [1] https://micheles.github.io/plac/ [2] https://github.com/google/python-fire On Tue, Jul 30, 2019, 8:03 PM wrote: > Maybe

[Python-ideas] Re: Namespace context managers

2019-07-28 Thread Ryan Gonzalez
I feel like this could have some interesting side uses (typing on mobile so ignore the crappy indentation): with Namespace('a'): x = 1 y = 2 print(a.__dict__) # we now have a dict The GN build system flat-out has no dictionary / mapping type in favor of scopes like this. On Sun, Jul 28,

[Python-ideas] Re: Canceling thread in python

2019-06-19 Thread Ryan Gonzalez
IME in many of these cases you're better off using asyncio instead. -- Ryan https://refi64.com/ On Jun 20, 2019, 12:14 AM -0500, Matúš Valo , wrote: > Hi All, > > Currently it is not possible to "kill" thread which is blocked. The rationale > for this is handling situations when thread is

[Python-ideas] Re: Assign-in-place operator

2019-06-05 Thread Ryan Gonzalez
Think of it more like indexing a range. Say you have: L[:] = M[:] Which is the same as: L[0:len(L)] = M[0:len(M)] Which mentally you can think of like: L[0], L[1],...L[len(L)] = M[0],M[1],...M[len(M)] Slicing is just indexing that represents more than one element, and if you think about it

Re: [Python-ideas] A proper way to bring real interfaces to Python

2019-05-04 Thread Ryan Gonzalez
Worth maybe noting that this could play interestingly with PEP 484? -- Ryan (ライアン) Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else https://refi64.com/ On May 4, 2019, 8:24 PM -0500, Serge Matveenko , wrote: > Hi, all! > > I believe, almost everybody is familiar with the

Re: [Python-ideas] What factors led Guido to quit?

2019-02-03 Thread Ryan Gonzalez
- This is a mailing list for discussing ideas for Python, not theorizing about personal reasons for leaving a community, nor for writing prompts. - I would argue he left largely just due to people's influence outside this direct community, but also as a sort of "sign" that it was time to go. That

Re: [Python-ideas] AMEND PEP-8 TO DISCOURAGE ALL CAPS

2019-01-04 Thread Ryan Gonzalez
IMO it's good to have some sort of visual differentiation between constants and normal values. A lot of camelCase-based style guides use a k prefix (e.g. kMyValue), but Python doesn't use it (other than PascalCase for classes). If there were to be an alternative to ALL_CAPS for constants, I guess

Re: [Python-ideas] JS’ governance model is worth inspecting

2018-09-21 Thread Ryan Gonzalez
This feels a bit like apples and oranges. Babel's primary purpose is transpiling to run on older browsers, which isn't that much of an issue with Python. It's also complicated a bit by the large number of implementations that *must* be developed in sync, again due to running in user's browsers.

Re: [Python-ideas] "slur" vs "insult"?

2018-09-21 Thread Ryan Gonzalez
Kinda OT, but I believe the connotation is that slur is use of the word, whereas an insult is use directed at someone. For instance, if someone is having a conversation where they use the n-word, it's a racial slur. If they directly call someone that, it's an insult. On Fri, Sep 21, 2018, 9:45

Re: [Python-ideas] Deprecation utilities for the warnings module

2018-09-13 Thread Ryan Gonzalez
I have to say, this would be amazing! I've basically had to create many of these by hand over time, and I doubt I'm the only person who's wondered how this isn't in the stdlib! On Thu, Sep 13, 2018, 7:18 PM Ilya Kulakov wrote: > (Apologies if it's a duplicate. I originally posted to >

Re: [Python-ideas] Retire or reword the "Beautiful is better than ugly" Zen clause

2018-09-13 Thread Ryan Gonzalez
FWIW a big flag to me was putting an Urban Dictionary link under "references"... On Thu, Sep 13, 2018, 12:21 PM Anders Hovmöller wrote: > > > If I were to change anything, I'd drop the reference to "Zen". That > wasn't part of the original, and was added by someone else. If, e.g., a > Zen

[Python-ideas] Reminder about intent of messages (Was: Syntactic sugar to declare partial functions)

2018-08-12 Thread Ryan Gonzalez
Now that the discussion has officially devolved into something that has absolutely nothing to do with the original topic, I'd like to point out something: (Note that I have no affiliation with the managers of this mailing list at all and am just posting this as an outsider.) In Steven D'Aprano's

Re: [Python-ideas] Including the unparse module in the standard library

2018-07-12 Thread Ryan Gonzalez
If you want to get source code from an AST, you'd probably be better off with a more fully-featured library like Astor: https://github.com/berkerpeksag/astor On July 12, 2018 1:21:23 PM Andre Roberge wrote: In the cPython repository, there is an unparse module in the Tools section.

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

2018-06-12 Thread Ryan Gonzalez
^ is also used in regexes for matching the *beginning* of a string... Realistically, I don't think this proposal would be added, but if it were, ^ would be a horrible choice. That being said, I do understand the feeling of half your code being calls to .append or .extend. You could always do:

Re: [Python-ideas] Trigonometry in degrees

2018-06-07 Thread Ryan Gonzalez
You could always do e.g. math.sin(math.degress(radians)) and so forth... On June 7, 2018 3:07:21 PM Robert Vanden Eynde wrote: I suggest adding degrees version of the trigonometric functions in the math module. - Useful in Teaching and replacing calculators by python, importing

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

2018-05-11 Thread Ryan Gonzalez
On May 11, 2018 1:45:27 PM Tim Peters wrote: [Brendan Barnwell] . . . and it's true the latter is a bit more verbose in that case for little extra benefit. But when the locally-defined value is used within a more complicated expression (like the quadratic formula

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

2018-05-10 Thread Ryan Gonzalez
Probably going to completely lose this, but would it be possible to have a vote? +1 for either 'given' and/or ':='? On Thu, May 10, 2018 at 2:48 PM Guido van Rossum wrote: > Yes. > > On Thu, May 10, 2018, 13:18 Alexander Belopolsky < > alexander.belopol...@gmail.com> wrote: >

Re: [Python-ideas] A comprehension scope issue in PEP 572

2018-05-06 Thread Ryan Gonzalez
On May 6, 2018 8:41:26 PM Tim Peters wrote: In a different thread I noted that I sometimes want to write code like this: while any(n % p == 0 for p in small_primes): # divide p out - but what's p? But generator expressions hide the value of `p` that

Re: [Python-ideas] A "local" pseudo-function

2018-04-28 Thread Ryan Gonzalez
I'm pretty sure the debate about braces defining scope in Python has long-since ended... -- Ryan (ライアン) Yoko Shimomura, ryo (supercell/EGOIST), Hiroyuki Sawano >> everyone else https://refi64.com/ On April 28, 2018 9:37:57 PM Ken Hilton wrote: > local { m =

Re: [Python-ideas] A "local" pseudo-function

2018-04-28 Thread Ryan Gonzalez
I have to say, this idea feels really nice to me. It's far easier to read than := and separates the assignments and the result expression nicely. Others have brought up the same problem of = vs ==. IMO a solution could be to make a requirement that the last argument is NOT an assignment. In

Re: [Python-ideas] Dart like multi line strings identation

2018-03-31 Thread Ryan Gonzalez
I have to admit, regardless of how practical this is, it would surely get rid of a ton of textwrap.dedent calls all over the place... On March 31, 2018 9:50:43 AM Marius Räsener wrote: Hey List, this is my very first approach to suggest a Python improvement I'd think

Re: [Python-ideas] New PEP proposal -- Pathlib Module Should Contain All File Operations

2018-03-18 Thread Ryan Gonzalez
On Sun, Mar 18, 2018 at 4:16 PM, George Fischhof wrote: > Hi Jason, > > the status of os and shutil became this because of C functions in > implementation (I got something similar answer before) > ... > > What do you think, what would be a good way to solve this > - add stuff

Re: [Python-ideas] A proliferation of (un-)Pythonically programmatic pragmas

2017-11-13 Thread Ryan Gonzalez
Off the top of my head there's: - Offer a standard pragma-parser in the standard library's ast module that allows multiple pragmas per line. This is kind of the reason there's the weird ast vs typed_ast discrepancy right now, too. - Create a custom pragma syntax that doesn't use comments. Maybe

Re: [Python-ideas] PEP 563: Postponed Evaluation of Annotations, first draft

2017-09-11 Thread Ryan Gonzalez
One thing I want to point out: there are a lot of really useful Python libraries that have come to rely on annotations being objects, ranging from plac to fbuild to many others. I could understand something that delays the evaluation of annotations until they are accessed, but this seems really

Re: [Python-ideas] dict(default=int)

2017-05-29 Thread Ryan Gonzalez
Sometimes I feel that it would be neat of dict constructors (like proposed previously in the thread) could also be chained, e.g.: dict.ordered.default(int)(a=1, b=2) -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On May 29, 2017 2:06

Re: [Python-ideas] Tighten up the formal grammar and parsing a bit?

2017-05-15 Thread Ryan Gonzalez
I guess maybe if you overload the operators to return broken objects, maybe then they would be different? -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On May 15, 2017 9:50 AM, "Serhiy Storchaka" wrote: > On

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-27 Thread Ryan Gonzalez
*cough* I'll just drop this here a sec *cough*: https://code.activestate.com/recipes/580790-auto-assign-self-attributes-in-__init__-using-pep-/ On Thu, Apr 27, 2017 at 10:24 AM, Nick Coghlan wrote: > On 25 April 2017 at 11:08, Erik wrote: >> Hi. I

Re: [Python-ideas] Augmented assignment syntax for objects.

2017-04-25 Thread Ryan Gonzalez
FWIW I always liked Dart's/Ruby's/Crystal's/(Coffee|Moon)Script's/WhateverElse's style: class Cls { Cls(this.a); // IT'S MAGIC } but the Python equivalent is admittedly weirder: def ___init__(self, self.attr): partly because, it'd have to work on pretty much any other variable name, yet

Re: [Python-ideas] "import me" to display some summary of the current python installation

2017-04-11 Thread Ryan Gonzalez
...except it would break everybody who has a module named `me` (which admittedly isn't too common...). Something like `import this.what` or something like that would be cool, though. -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On

Re: [Python-ideas] What about regexp string litterals : re".*" ?

2017-04-03 Thread Ryan Gonzalez
Have you tried PyParsing and/or Grako? They're some of my favorites (well, I like PLY too, but I'm thinking you wouldn't like it too much). -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On Apr 3, 2017 3:26 AM, "Neil Girdhar"

Re: [Python-ideas] What about regexp string litterals : re".*" ?

2017-03-29 Thread Ryan Gonzalez
I feel like that borders on a bit too wordy... Personally, I'd like to see something like Felix's regular definitions: http://felix-lang.org/share/src/web/tut/regexp_01.fdoc#Regular_definitions._h -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else

Re: [Python-ideas] IDEA

2017-03-26 Thread Ryan Gonzalez
There are quite a few Python IDEs, like PyCharm, Ninja, Spyder, PyDev, and more. In addition, I would say that almost every currently existent text editor has at least *some* Python support (I personally use Howl, though I'll admit I'm rather biased, being part of the development team and all...

Re: [Python-ideas] Adding an 'errors' argument to print

2017-03-26 Thread Ryan Gonzalez
FWIW, using the ascii function does have the problem that Unicose characters will be escaped, even if the terminal could have handled them perfectly fine. -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On Mar 26, 2017 9:07 AM, "Nick

[Python-ideas] Adding an 'errors' argument to print

2017-03-24 Thread Ryan Gonzalez
Recently, I was working on a Windows GUI application that ends up running ffmpeg, and I wanted to see the command that was being run. However, the file name had a Unicode character in it (it's a Sawano song), and when I tried to print it to the console, it crashed during the encode/decode. (The

Re: [Python-ideas] Wrapper for ctypes

2017-03-07 Thread Ryan Gonzalez
Ever looked up cffi? You won't be disappointed. -- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else http://refi64.com On Mar 7, 2017 3:43 AM, "George Fischhof" wrote: > Hi Guys, > > right now I had to call functions from a dll, and I

[Python-ideas] List indexing multiple elements

2017-02-20 Thread Ryan Gonzalez
Apologies if this has already been covered! Right now, if you want to get multiple elements in a list, you have to do: elements = [mylist[a], mylist[b]] My proposal is two-folded: - Right now, a[b,c] is already valid syntax, since it's just indexing a with the tuple (b, c). The proposal is to

Re: [Python-ideas] A decorator to call super()

2017-01-31 Thread Ryan Gonzalez
https://github.com/kirbyfan64/mirasu \-- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >> everyone else ___ Python-ideas mailing list Python-ideas@python.org

Re: [Python-ideas] pathlib suggestions

2017-01-24 Thread Ryan Gonzalez
As another suggestion, I'd love an rmtree method analogous to shutil.rmtree. And maybe also a remove method, that basically does: if path.is_dir(): path.rmtree() else: path.unlink() \-- Ryan (ライアン) Yoko Shimomura > ryo (supercell/EGOIST) > Hiroyuki Sawano >>

Re: [Python-ideas] Python Reviewed

2017-01-10 Thread Ryan Gonzalez
I just want to point ONE thing out: On Jan 9, 2017 11:18 PM, "Simon Lovell" wrote: * General comment: I posted this because Googling didn't give me a satisfactory answer to why Python is the way that it is. I think I see it now. Guido hates keywords. I don't find this

Re: [Python-ideas] incremental hashing in __hash__

2016-12-27 Thread Ryan Gonzalez
You could always try to make a Python version of the C tuple hashing function[1] (requires the total # of elements) or PyPy's[2] (seems like it would allow true incremental hashing). API idea: hasher = IncrementalHasher() hasher.add(one_item_to_hash) # updates hasher.hash property with result #

Re: [Python-ideas] PEP 531: Existence checking operators

2016-10-29 Thread Ryan Gonzalez
On Oct 28, 2016 3:30 AM, "Nick Coghlan" wrote: > *snip* > > 1. Do we collectively agree that "existence checking" is a useful > general concept that exists in software development and is distinct > from the concept of "truth checking"? I'd hope so! > 2. Do we collectively

Re: [Python-ideas] Showing qualified names when a function call fails

2016-10-25 Thread Ryan Gonzalez
Also, as an extension of this idea, would it be possible to improve errors like this: class X: pass X() # object() takes no parameters to show the actual type instead of just 'object'? On Tue, Oct 25, 2016 at 4:48 PM, Ryan Gonzalez <rym...@gmail.com> wrote: > So, based on everyone's

Re: [Python-ideas] Showing qualified names when a function call fails

2016-10-25 Thread Ryan Gonzalez
So, based on everyone's feedback, I just created this: http://bugs.python.org/issue28536 On Mon, Oct 24, 2016 at 5:07 PM, Ryan Gonzalez <rym...@gmail.com> wrote: > I personally find it kind of annoying when you have code like this: > > > x = A(1, B(2, 3)) > > > and P

[Python-ideas] Showing qualified names when a function call fails

2016-10-24 Thread Ryan Gonzalez
I personally find it kind of annoying when you have code like this: x = A(1, B(2, 3)) and Python's error message looks like this: TypeError: __init__() takes 1 positional argument but 2 were given It doesn't give much of a clue to which `__init__` is being called. At all. The idea: when

Re: [Python-ideas] Proposal for default character representation

2016-10-12 Thread Ryan Gonzalez
On Oct 12, 2016 9:25 PM, "Chris Angelico" wrote: > > On Thu, Oct 13, 2016 at 12:56 PM, Mikhail V wrote: > > But as said I find this Unicode only some temporary happening, > > it will go to history in some future and be > > used only to study extinct

Re: [Python-ideas] Proposal for default character representation

2016-10-12 Thread Ryan Gonzalez
On Oct 12, 2016 4:33 PM, "Mikhail V" wrote: > > Hello all, > > *snip* > > PROPOSAL: > 1. Remove all hex notation from printing functions, typing, > documention. > So for printing functions leave the hex as an "option", > for example for those who feel the need for hex

Re: [Python-ideas] Add a method to get the subset of a dictionnary.

2016-10-12 Thread Ryan Gonzalez
That discussion seemed to mostly just conclude that dicts shouldn't have all set operations, and then it kind of just dropped off. No one really argued the subset part. -- Ryan [ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.

Re: [Python-ideas] PEP8 dictionary indenting addition

2016-10-11 Thread Ryan Gonzalez
On Oct 11, 2016 10:40 AM, "Erik Bray" wrote: > > On Sun, Oct 9, 2016 at 2:25 AM, Steven D'Aprano wrote: > > On Sat, Oct 08, 2016 at 09:26:13PM +0200, Jelte Fennema wrote: > >> I have an idea to improve indenting guidelines for dictionaries for better >

Re: [Python-ideas] from __pip__ import

2016-09-19 Thread Ryan Gonzalez
This sounds like a great idea, but I've seen stuff like this done before, and it never ends well. You end up with a gargantuan-sized rabbit hole, since running a basic script could now involve using an internet connection and potentially root permissions. IF one were to go this route, I prefer

Re: [Python-ideas] Null coalescing operator

2016-09-10 Thread Ryan Gonzalez
https://github.com/kirbyfan64/_frozensafemockobjectimplementation In all seriousness, though, I really feel like that would be the ultimate bug magnet, since it'd be easy to forget to un-wrap the object afterwards. -- Ryan [ERROR]: Your autotools build scripts are 200 lines longer than your