On 10/18/21 3:20 AM, Mathew Elman wrote:

> I don't know if this has been suggested before, or if this is outlandishly 
impossible
> (though I would be surprised if it was), so apologies in advance if so.
>
> I have on occasion come across a situation where I use/write a signature like 
this:
>
>      def insert_x_into_y(x, y):

Ugh, that is horrible.

> or worse
>
>      def insert_into(item, container):
>          ...

Actually, that looks fine -- the previous example was too verbose.


> where, despite a driving idea of python syntax being [readable] in english, 
the function
> signature is distinctly not english.

Where did you get that idea?  "executable psuedo-code" is a far cry from 
English.


> What would be really cool, is if python let you write function signatures 
like this:
>
>      def insert_(item)_into_(container):
>          ...
>
> where the arguments dispersed between the function name are positional only 
argument,
> and any key word arguments would have to go at the end.  It would create a 
function
> that could be called as:
>
>      insert_(1)_into_(my_list)

Why wouldn't you just use `my_list.insert(1) ?


> This sort of signature is particularly annoying for boolean checks like `isinstance` (N.B. I am _not_ suggesting changing any builtins), which one could wrap with:
>
>      def is_(obj)_an_instance_of_(type):
>          return isinstance(obj, type)

Sorry, way too verbose for me.  It is definitely possible to be *too* explicit.


While I agree it would be cool (and having written what I thought were some pretty cool things, like not needing to include the value for an enum member), in practice cool and get quite irritating.

--
~Ethan~
_______________________________________________
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 archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/SSAXYRPTQXB33JIIBVZAVYROZMLLYJ22/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to