News for hackers. Stuff that matters.
Re:Python Idioms in Rust by kbenson on Friday March 30, 2018 @02:32PM (#16718622)
> I suppose we all look at the world from the perspective of our own experience.

Yes, but in addition to that, I think you can likely sell an idea to people much easier when it's couched in something they are already familiar with. There's been lots said about the functional programming capabilities of Rust, but if people don't already equate what they do as following some functional paradigm, they might find themselves uninterested in the discussion.

I think Python especially, with its "one way to do it" and (my perception) how people adhere to "the way to do it in Python", there's a good chance some people don't really know when they are using common functional patterns.

Re:Python Idioms in Rust by spyspy on Friday March 30, 2018 @03:06PM (#16718899)
> Python especially, with its "one way to do it"

Despite being a core tenet of the language, Python is _really, really_ bad at following that rule. I agree with everything else you're saying, though. Those are still Python idioms even if they originated elsewhere.

Re:Python Idioms in Rust by davidcuddeback on Friday March 30, 2018 @03:27PM (#16719068)
I think people take the "one way to do it" tenet a little too seriously. It comes from PEP20 [1], which to me seems to have a more jestful than dogmatic tone:

> There should be one-- and preferably only one --obvious way to do it.

> Although that way may not be obvious at first unless you're Dutch.

If I remember my history correctly, this was poking fun as Perl's "TIMTOWTDI" [2].

It also says one obvious way to do it. It doesn't preclude there being more than one way.

[1] https://www.python.org/dev/peps/pep-0020/

[2] https://en.wikipedia.org/wiki/There%27s_more_than_one_way_to...

Re:Python Idioms in Rust by jerf on Friday March 30, 2018 @03:46PM (#16719231)
In 2004, "There should be only one way to do it" was a more realistic goal. 2004 puts us at Python 2.4 or so, but I think that's just when it got formalized into a PEP, it was around for a while before then. If we step back two years to 2002, we get to Python 2.1. We are now pre-generators, pre-with statement, pre-itertools, pre-decorators, and a lot of other things (useful itertools, etc.). There more often was only one sensible way to do a thing. Python evolved, but PEP20 didn't.
Re:Python Idioms in Rust by davidcuddeback on Friday March 30, 2018 @03:59PM (#16719334)
> 2004 puts us at Python 2.4 or so, but I think that's just when it got formalized into a PEP

I didn't notice the date on the PEP, but I think you're right. I remember reading it when I learned Python circa 2002.

Found this (from 1999): https://mail.python.org/pipermail/python-list/1999-June/0019....

Re:Python Idioms in Rust by xapata on Friday March 30, 2018 @04:30PM (#16719565)
The "obvious way" changes over time, as the language improves.
Re:Python Idioms in Rust by codetrotter on Friday March 30, 2018 @03:13PM (#16718945)
How so? Comprehensions vs loops vs recursive functions vs in some cases map/reduce/filter is the only example I can think of.
Re:Python Idioms in Rust by strkek on Friday March 30, 2018 @03:23PM (#16719034)
There's also strings.

    'foo ' + bar
    'foo {}'.format(bar)
    'foo %s' % bar
    f'foo {bar}'
Re:Python Idioms in Rust by BerislavLopac on Saturday March 31, 2018 @12:15PM (#16723858)
As well as the string templates almost nobody knows about (https://docs.python.org/3.6/library/string.html#template-str...):

    Template('$foo bar').substitute(foo='foo')