Python Forum
Guido on Permanent Vacation from BDFL
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Guido on Permanent Vacation from BDFL
#11
One of the things I like about type hinting is that you can add the hints, do a bunch of refactoring, and then remove them. They can give you a very nice guard rail. Haven't seen it yet, but I also suspect they'll be great when publishing libraries.
Reply
#12
Does type hinting still count as type hinting if you put arbitrary descriptions in?

def do_stuff_with(things: ["list of strings"]) -> "bool or None, depending on args":
    return True if things else None
Reply
#13
Not sure how much that was tongue-in-cheek buuut... annotations were a feature before core Python was considering type hinting. So you could totally do that, but I wouldn't call it type hinting, since it's not programmatically readable. But you could do
from typing import List, Option

def do_stuff_with(things: List[str]) -> Option[bool]:
with a docstring explaining the relationships between the args and the return value.
Reply
#14
were people more upset over an assignment as an expression or the use of := which the lack of in Python was one of my many reasons for choosing Python?

(Jul-13-2018, 04:11 PM)micseydel Wrote:
(Jul-13-2018, 03:52 PM)nilamo Wrote: I looked at the pep, and was surprised that GvR was in support of it. I was under the impression that the rule about assignment not possible in expressions was one of his original purposes in Python, as having too many things in one line can get convoluted quickly.
Yeah, I was surprised too. I think having the assignment expression use a different operator from assignment statements helps, as do examples like this
if reductor := dispatch_table.get(cls):
    rv = reductor(x)
elif reductor := getattr(x, "__reduce_ex__", None):
    rv = reductor(4)
elif reductor := getattr(x, "__reduce__", None):
    rv = reductor()
else:
    raise Error("un(deep)copyable object of type %s" % cls)
it's probably := to make people want to avoid it. i know i will avoid it.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#15
I had to google what the hell := operator was. From that i determine its just =. Apparently in Golanguage its initialization and assignment. But I dont know why you would need that in python? Unless its suppose to be used with the new annotations?

Apparently i am getting behind not fluently using python on the new features...lol
Recommended Tutorials:
Reply
#16
(Jul-14-2018, 02:19 AM)metulburr Wrote: Unless its suppose to be used with the new annotations?

actually, assignment expressions - PEP572 and it was officially accepted
https://www.python.org/dev/peps/pep-0572/
https://www.reddit.com/r/Python/comments...fficially/
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#17
by having assignment expressions use a different operator, it avoids the confusion Guido was originally trying to avoid. the idea as i see it is that this distinguishes the different uses by which operator is chosen, allowing it to be known the explicit intentions of the coder. that it be := would discourage people from routinely using it for ordinary assignment (where the expression value can be ignored). perhaps such (mis)uses can then be flagged and rejected.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#18
I'm ok with a different operator for assignment in expressions. The main problem with just using =, is that it doesn't look all that different from == at a glance, which means you don't know there's something being assigned unless you look carefully. And the whole point of python, is that you shouldn't have to look carefully.
Reply
#19
After looking over it, I like it and I don't like it. I agree that it's a problem that would be good to solve, I've been running into it a lot lately. However, I would have preferred 'as' to a new operator.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#20
Do you think the new operator will replace as in with blocks?

with my_file := open("spam.txt"):
    # read file
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  invisible temporary files that become linked permanent Skaperen 0 931 Feb-21-2023, 12:22 AM
Last Post: Skaperen
  Microsoft Funds a Team with Guido van Rossum to Double the Speed of Python Larz60+ 0 1,507 May-20-2021, 11:48 PM
Last Post: Larz60+
  Guido van Rossum about starting contributing to CPython buran 0 2,321 Feb-18-2020, 04:44 PM
Last Post: buran
  Guido van Rossum Retires ichabod801 1 3,141 Oct-30-2019, 05:00 PM
Last Post: Larz60+
  MIT Interview with Guido Larz60+ 3 3,325 Nov-27-2018, 10:45 PM
Last Post: Larz60+
  Guido van Rossum does not care about the opinion of the community. Kirill_Dubovitskiy 12 8,081 Sep-14-2018, 06:33 PM
Last Post: micseydel
  Guido van Rossum: BDFL Python 3 retrospective snippsat 13 6,805 Mar-02-2018, 02:38 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020