[Python-Dev] PEP 622: Arrow for capture patterns

2020-09-05 Thread Ram Rachum
Hi everyone,

Sorry if this was proposed already. I looked here
https://www.python.org/dev/peps/pep-0622/#alternatives-for-constant-value-pattern,
search for "idea to make lookup semantics the default". I saw that a few
symbols like $ and ? were proposed, and I thought that maybe the annotation
syntax -> could indicate a capture expression, like so:

case x:
match Point(-> a, -> b):
...
match -> whatever:
do_something(whatever)

I like the arrow because it's easy to imagine the value "entering" the
variable. What do you think?


Thanks,
Ram.
___
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/F22RLCDGKVMIBQKIJZAQYV3YCD45R2IQ/
Code of Conduct: http://python.org/psf/codeofconduct/


[Python-Dev] lambda (x, y):

2014-01-24 Thread Ram Rachum
I don't like how in Python 3.x, you can't do this:

lambda (x, y): whatever

It's quite useful in Python 2

if I understand correctly, it's a side effect of such packed arguments not
being allowed in function definitions. (i.e. def instead of lambda)

Can you please refer me to the original discussion in which it was decided
to remove this grammar in Python 3? I'd like to understand the arguments
for it.


Thanks,
Ram.
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] str.rreplace

2014-01-24 Thread Ram Rachum
Question: Why is there no str.rreplace in Python?
___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] str.rreplace

2014-01-24 Thread Ram Rachum
You see, Antoine, *you* know that it's better asked on python-ideas because
you know it doesn't exist in Python, therefore it's an idea for an
addition. However, when a person like me asks this question, he does not
know whether it exists or not, so he can't know whether he's proposing a
new idea or whether it's something that exists under a different name or
whether that's something that can't exist because of some unknown reason
that the asker didn't think of.

Now that I know it doesn't exist, I'll ask this on python-ideas.


Thanks,
Ram.


On Fri, Jan 24, 2014 at 6:38 PM, Antoine Pitrou solip...@pitrou.net wrote:

 On Fri, 24 Jan 2014 18:32:17 +0200
 Ram Rachum r...@rachum.com wrote:
  Question: Why is there no str.rreplace in Python?

 What would it do?
 (also, I think such questions are better asked on python-ideas)

 Regards

 Antoine.


 ___
 Python-Dev mailing list
 Python-Dev@python.org
 https://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe:
 https://mail.python.org/mailman/options/python-dev/ram%40rachum.com

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] str.rreplace

2014-01-24 Thread Ram Rachum
Hmm, on one hand I understand the need for the separation between
python-dev and python-list, but on the other hand I don't think python-list
is a good place to discuss Python, the language.

I now looked at the 17 most recent python-list threads. Out of them:

 - 58% are about third-party packages.
 - 17% are off-topic (not even programming related)
 - 11% are 2-vs-3 discussions
 - 5% are job offers.
 - 5% (which is just one thread out of 17) is about Python the language.

So can you understand why someone would be reluctant to start a discussion
in python-list about Python the language there? Especially if this is the
same place where beginners might ask newbies questions about Python? (So
not only are actual Python questions just 5% of the content, non-newbie
questions are just a subset of that 5%.)



it's full of people asking about third-party Python packages, or asking
newbie questions.


On Fri, Jan 24, 2014 at 7:04 PM, Terry Reedy tjre...@udel.edu wrote:

 On 1/24/2014 11:32 AM, Ram Rachum wrote:

 Question: Why is there no str.rreplace in Python?


 Ram, this list is for discussing the development of the next few releases
 of CPython. General questions should go to python-list.

 --
 Terry Jan Reedy


 ___
 Python-Dev mailing list
 Python-Dev@python.org
 https://mail.python.org/mailman/listinfo/python-dev
 Unsubscribe: https://mail.python.org/mailman/options/python-dev/
 ram%40rachum.com

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] str.rreplace

2014-01-24 Thread Ram Rachum
I knew it didn't exist by that name, but couldn't know whether there was
another function that did the same thing or technique to make it not needed.

So I couldn't know whether it's new or not, therefore I couldn't know
whether it should be on python-ideas or not.


On Fri, Jan 24, 2014 at 7:31 PM, Brett Cannon br...@python.org wrote:




 On Fri, Jan 24, 2014 at 11:46 AM, Ram Rachum r...@rachum.com wrote:

 You see, Antoine, *you* know that it's better asked on python-ideas
 because you know it doesn't exist in Python, therefore it's an idea for an
 addition. However, when a person like me asks this question, he does not
 know whether it exists or not, so he can't know whether he's proposing a
 new idea or whether it's something that exists under a different name or
 whether that's something that can't exist because of some unknown reason
 that the asker didn't think of.

 Now that I know it doesn't exist, I'll ask this on python-ideas.


 I think there might be a language issue here because you originally said Why
 is there no str.rreplace in Python? which shows you already knew it didn't
 exist. Did you mean to say you wanted to know *why* it didn't exist?

 Even in that case, if searching for [python str.rreplace] didn't turn up
 anything then chances are there was no proposal, which makes it a new idea
 and thus belongs on python-ideas. Basically the rule of thumb is anything
 considered new goes to python-ideas first.

___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] str.rreplace

2014-01-24 Thread Ram Rachum
Okay, next time I'll ask on python-ideas. (I do hope that no one there will
be angry that I'm posting a question there rather than an idea...)


On Fri, Jan 24, 2014 at 7:41 PM, Brett Cannon br...@python.org wrote:




 On Fri, Jan 24, 2014 at 12:33 PM, Ram Rachum r...@rachum.com wrote:

 I knew it didn't exist by that name, but couldn't know whether there was
 another function that did the same thing or technique to make it not needed.

 So I couldn't know whether it's new or not, therefore I couldn't know
 whether it should be on python-ideas or not.


 So then you were simply wondering about its existence, for which you
 should go to python-list or python-ideas first. Python-ideas exists
 *explicitly* as a filter for this kind of question which is why people are
 saying it should have gone there first (or to python-list).

 If you have any doubt as to whether a question should go here or not, then
 err on the side of caution and post to python-ideas or python-list first.

 -Brett





 On Fri, Jan 24, 2014 at 7:31 PM, Brett Cannon br...@python.org wrote:




 On Fri, Jan 24, 2014 at 11:46 AM, Ram Rachum r...@rachum.com wrote:

 You see, Antoine, *you* know that it's better asked on python-ideas
 because you know it doesn't exist in Python, therefore it's an idea for an
 addition. However, when a person like me asks this question, he does not
 know whether it exists or not, so he can't know whether he's proposing a
 new idea or whether it's something that exists under a different name or
 whether that's something that can't exist because of some unknown reason
 that the asker didn't think of.

 Now that I know it doesn't exist, I'll ask this on python-ideas.


 I think there might be a language issue here because you originally said
 Why is there no str.rreplace in Python? which shows you already knew
 it didn't exist. Did you mean to say you wanted to know *why* it didn't
 exist?

 Even in that case, if searching for [python str.rreplace] didn't turn up
 anything then chances are there was no proposal, which makes it a new idea
 and thus belongs on python-ideas. Basically the rule of thumb is anything
 considered new goes to python-ideas first.




___
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Why can't I encode/decode base64 without importing a module?

2013-04-22 Thread Ram Rachum
Hi everyone,

Take a look at this question:

http://stackoverflow.com/questions/16122435/python-3-how-do-i-use-bytes-to-bytes-and-string-to-string-encodings/16122472?noredirect=1#comment23034787_16122472

Is there really no way to use base64 that's as short as:

b'whatever'.encode('base64')

Because doing this:

import codecs
codecs.decode(bwhatever, base64_codec)

Or this:

import base64
encoded = base64.b64encode(b'whatever')

Is cumbersome!

Why can't I do something like b'whatever'.encode('base64')? Or maybe using
a different method than `encode`?


Thanks,
Ram.
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com