Some New Features in Python 3.9

Поделиться
HTML-код
  • Опубликовано: 31 июл 2024
  • In this video I go over four new features in Python 3.9: new syntax for merging/updating dicts, native timezone support, the use of collection classes as opposed to the typing model for type support, and removeprefix and removesuffix method for strings.
    Need one-on-one help with your project? I can help through my coaching program. Learn more here: prettyprinted.com/coaching
    docs.python.org/release/3.9.0...
    Get the code here: prettyprinted.com/l/wOS
    00:00 - Intro
    00:22 - Dict Merge/Update
    03:33 - Native Timezones
    06:22 - Collection Type Hints
    08:48 - str.removeprefix
    Twitter: / pretty_printed
    Github: github.com/prettyprinted

Комментарии • 217

  • @Raserei408
    @Raserei408 3 года назад +119

    EDIT: I am wrong. "b = b | a" is different from "b |= a" and "b |= a" is effectively identical to b.update(a) except that it returns b rather than None.
    ~Worth a mention that "b |= a" does *not* do the same thing as "b.update(a)". update modifies b, whereas |= creates a new dict and assigns b to it. If you had another variable c referencing the same dict as b, update would cause c to change but |= wouldn't.~

    • @rjhornsby
      @rjhornsby 3 года назад +1

      yeah ... when he was walking through the examples, I kept wondering what was happening w/r/t returning a new object vs modifying the existing object in place vs, as you point out - creating a new object and assigning it to one of the existing vars. I can see the usefulness, but the language syntax is making it tough to quickly assess if the result is what one intends - creating new, clobbering old etc.

    • @PanduPoluan
      @PanduPoluan 3 года назад +1

      Uhh, no. Have you actually tried it?
      |= uses __ior__(), or "in-place or". It is NOT a syntactic sugar for b = b | a.

    • @Raserei408
      @Raserei408 3 года назад +1

      @@PanduPoluan Woah. Wild. I read the PEP to confirm, and I got misdirected by the motivation for the non in-place union.

    • @Dani0x1B
      @Dani0x1B 3 года назад +1

      @@Raserei408 Yeah, python likes to break the "(a $= b) ≡ (a = a $ b)" for some reason. it's the same with += in lists, it does a concat _and modifies the original_.

    • @TheVoitel
      @TheVoitel 3 года назад

      No! op= asignments work in place (as longs as it’s possible), because that is the actual meaning of these assignments!

  • @koktszfung
    @koktszfung 3 года назад +104

    this is the first time I hear someone pronounce "str" as "stir" instead of "string"

    • @prettyprinted
      @prettyprinted  3 года назад +12

      I say 'stir' when talking about the str class and string when talking about what str classes represent. Can be confusing

    • @pvic6959
      @pvic6959 3 года назад +1

      @@prettyprinted to be fair I say "stir" in my mind lol. but then again my professor pronounced char as "chir" lol

    • @PanduPoluan
      @PanduPoluan 3 года назад

      @@prettyprinted I do it the same time, actually. Also, I pronounce "JSON" as "J'sown" not "Jason", because JSON is clearly a Klingon name not a US/UK name...

  • @TheSpacecraftX
    @TheSpacecraftX 3 года назад +77

    Timezones natively without libraries is a biggie.

    • @THEAAKASH07
      @THEAAKASH07 3 года назад

      @O. R.C it's from dateutil.tz import tz

  • @Codethier
    @Codethier 3 года назад +2

    I'm so glad i found your youtube channel i watched your ultimate flask tutorial on packt and it was amazing!

  • @sim4n6
    @sim4n6 3 года назад +1

    Please keep up such a great work for each new version.

  • @pele512
    @pele512 3 года назад +1

    The dict update is a nice and consistent syntactic sugar matching what set() was able to do in 3.7 already, neat!

  • @sundarrajan2575
    @sundarrajan2575 3 года назад +5

    removeprefix gonna be really useful.
    Thanks for the quick review 😊

    • @prettyprinted
      @prettyprinted  3 года назад +1

      You're welcome! Thanks for watching.

  • @ekmin2469
    @ekmin2469 3 года назад

    This is really good and easy to understand. Nice video

  • @el_munoz
    @el_munoz 3 года назад +36

    str.removepreffix sounds usefull to remove file extensions in a list comprehension to rename a bunch of files. And dict union share the same sintax as sets keeping the language logic.

    • @prettyprinted
      @prettyprinted  3 года назад +11

      I didn't think about file extensions. removesuffix does sound great for that. Thanks for watching!

    • @josemariasosaresendiz8286
      @josemariasosaresendiz8286 3 года назад +2

      @@prettyprinted Why adding redundant methods if you can already use .strip(), rstrip() and lstrip() ??

    • @beron_the_colossus
      @beron_the_colossus 3 года назад +11

      @@josemariasosaresendiz8286
      >>> drs = ["Dr. Coomer", "Drake", "The Doctor"]
      >>> names = [dr.lstrip("Dr. ") for dr in drs]
      >>> names
      ['Coomer', 'ake', 'The Doctor']

    • @sadhlife
      @sadhlife 3 года назад +5

      @@josemariasosaresendiz8286 lstrip actually removes a set of characters, not a string prefix, and if you confuse what it does you can get some nasty bugs

    • @raphael7308
      @raphael7308 3 года назад

      @@beron_the_colossus This confused me too. This explains it: www.python.org/dev/peps/pep-0616/#id16

  • @snoopyjc
    @snoopyjc 3 года назад +2

    Yes it’s long overdue having to use a separate pytz module, though you would think they would just fix or extend datetime.timezone!

  • @user-to1lb6dj6g
    @user-to1lb6dj6g 3 года назад +1

    PEP8:
    Method Names and Instance Variables
    Use the function naming rules: lowercase with words separated by underscores as necessary to improve readability.
    Python 3.9:
    str.removeprefix
    BOOOOOM!

  • @nastygambler2522
    @nastygambler2522 3 года назад +1

    You helped me a lot. Thank you

  • @Dht1kna
    @Dht1kna 3 года назад +11

    Lot of times when I wished there was a standard library function str.removeprefix/sufix

  • @vladislavyurkov9221
    @vladislavyurkov9221 3 года назад +30

    Respect for using Star Trek doctors in doctor's list!😄

    • @SurajTiwari020
      @SurajTiwari020 3 года назад +1

      Could be the doctor from Doctor Who too

    • @vladislavyurkov9221
      @vladislavyurkov9221 3 года назад +1

      @@SurajTiwari020 I think it's The Doctor from Star Trek Voyager. They named this character the same way😅

    • @prettyprinted
      @prettyprinted  3 года назад +1

      All Star Trek doctors :)

    • @SurajTiwari020
      @SurajTiwari020 3 года назад

      Well I've figure it out... that's me... I'm The Doctor.... 😂 😂 😂

    • @emilianovillarreal1744
      @emilianovillarreal1744 3 года назад

      has

  • @julienpiccini440
    @julienpiccini440 3 года назад +5

    Thanks for the quick overview.
    Removing typing import is moving python as typed language more and more.
    Maybe we will be able to see performance improvement from that.
    What do you think ?
    The dictionary is not that great from my point of view as something already existed for this and using update is more pythonic.

    • @prettyprinted
      @prettyprinted  3 года назад +4

      I don't think the typing stuff will have any effect on performance since it's not evaluated. Thanks for watching!

  • @EvanOfTheDarkness
    @EvanOfTheDarkness 3 года назад +1

    Nice. I can finally stop re-implementing the removeprefix, and removesuffix functions in every python program!
    Now if they would just fix the input and output streams, so you don't need to reopen them with errors="replace" every time, that would really make my day!

  • @akashdarji7131
    @akashdarji7131 3 года назад +1

    removePreFix() - on video time 11:20, you can also remove 2nd lines (names = []) lists

  • @islandcave8738
    @islandcave8738 3 года назад +3

    I have long used `a.split(b, 1)[-1]` to remove the prefix b from a in 1 line and `a.rsplit(b, 1)[0]` to remove the postfix b from a in 1 line. But remove prefix and remove postfix seems cleaner.

  • @justins.2138
    @justins.2138 3 года назад +1

    Thanks!

  • @anirangoncalvesbr
    @anirangoncalvesbr 3 года назад +22

    I just can't see what's the point bringing these new operators for functions already well established...
    Now we have two ways to perform the same functionality. Python used to be simple.
    There should be one-- and preferably only one --obvious way to do it
    Edit: Just to be clear the other changes are fine, I see myself making use of new String methods and maybe the new "timezone" lib.

    • @StanislavSchmidt1
      @StanislavSchmidt1 3 года назад +13

      These logical operators already existed for sets. If one thinks of dictionaries as sets of keys then it seems silly that python didn't have these operators for dictionaries in the first place.

    • @MrCreeper20k
      @MrCreeper20k 3 года назад +3

      It's also possible they may be planning to phase out, older, less intuitive, and less pythonic notation. I can't know for sure, but I think the best way to go about that is to release cleaner notation that everyone switches over to, and then later down the line announce the plan to deprecate old notation.

  • @mattmess1221
    @mattmess1221 3 года назад +7

    With the union operator (|), I'm hoping they end up allowing that for the Type classes. That way I can do str | int instead of Union[str, int]

    • @ewenlbh
      @ewenlbh 3 года назад +4

      This is planned for the next version (1.10): www.python.org/dev/peps/pep-0604/, and has already been successfully implemented and merged for cpython on github, see pull #21515: github.com/python/cpython/pull/21515

    • @nel_tu_
      @nel_tu_ 3 года назад +1

      @@ewenlbh did you mean 3.10 or am i missing sth?

  • @lawrencedoliveiro9104
    @lawrencedoliveiro9104 3 года назад +1

    Which is your favourite new feature? I was taken by the fact that the http module now includes the “418 IM_A_TEAPOT” status code. ;)
    docs.python.org/3/whatsnew/3.9.html

  • @ueyehdvdhoqlkdnbdggd
    @ueyehdvdhoqlkdnbdggd 3 года назад +1

    Great vid. I just don’t see myself merging dictionaries, but it looks easier than previous versions

    • @prettyprinted
      @prettyprinted  3 года назад

      I agree. Thanks for watching!

    • @seidenada526
      @seidenada526 3 года назад

      I feel the need to merge dictionaries came from the javascript community 👀

  • @thorvaldresearch1093
    @thorvaldresearch1093 3 года назад

    Id say the timezone stuff is the one thats good and long awaited. The rest i probably wont use that much.

  • @dexboi
    @dexboi 3 года назад

    dude can i get tensorflow for python 3.9 (link)

  • @rangabharath4253
    @rangabharath4253 3 года назад

    awesome

  • @hossamashraf4885
    @hossamashraf4885 3 года назад

    Thx

  • @davidjohnston4240
    @davidjohnston4240 3 года назад +2

    The str changes and dictionary merging will be nice. I do a lot of that and it's always fiddly code. Timezones are not so relevant to me but I'm sure others will find it useful. I saw there was greater flexibility with decorators too.

    • @SuperMarkusparkus
      @SuperMarkusparkus 3 года назад +2

      "Timezones are not so relevant to me but I'm sure others will find it useful"
      Yes it can be useful from time to time.

  • @ashtongrist
    @ashtongrist 3 года назад

    are you asking us questions or did you learn that inflection at youtube presenting school?

  • @toequantumspace
    @toequantumspace 3 года назад

    Thanks good job! Do you plan to cover new decorators?

    • @prettyprinted
      @prettyprinted  3 года назад

      I didn't look into them much because I couldn't think of a use case. I'll take a second look eventually though.

  • @user-hk3ej4hk7m
    @user-hk3ej4hk7m 3 года назад +1

    I would like to point out that the dict unpacking method, like the pipe operator, does not modify any of the dictionaries, instead you get a new dict with the merged contents. The update method modifies one of the dictionaries, this might not be what you want.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      Well, there's a reason why "augmented assignments" are also called "in-place operations"...

  • @_a_x_s_
    @_a_x_s_ 3 года назад +1

    Well, time flies... I learnt Python from 2.5. Now I am using Python 2.7 and 3.7 but the latest version has become 3.9... Python is not like what I have learnt at first. I can even see the attempt to make Python strong-typed. (Probably we can make a declaration at the beginning of the script to make it strong-typed?)
    However, I just want dev team to enhance the performance of Python so that I do not have to learn more and more new languages like Rust, Swift, Go, Julia, etc.

  • @TommiSvaerd
    @TommiSvaerd 3 года назад

    Great summary! I'm excited about typing, though i like that python is dynamically typed it's always a relief to have the option of types, its the same reason i prefer typescript over vanilla js. Will this make linting be available in VSCode?

    • @prettyprinted
      @prettyprinted  3 года назад

      I don't use linting in VS Code, but I'm sure there's some kind of type linter out there somewhere.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      It's already in VSCode for some time. Install both Microsoft's "Python" extension (ms-python.python) and Microsoft's "Pylance" extension (ms-python.vscode-pylance)

  • @rasmusnordstrom9947
    @rasmusnordstrom9947 3 года назад +2

    What's the difference between str.removeprefix and str.lstrip?
    names = [doctor.lstrip("Dr. ") for doctor in doctors]
    will give you the same result.
    Also why doesn't str.removeprefix follow PEP8? Shouldn't it be str.remove_prefix ?

    • @sexwax4191
      @sexwax4191 3 года назад +5

      lstrip removes a set of character not a fixed string. Look at the comments to Luis Munozs comment for an example.

  • @mikeberger1688
    @mikeberger1688 2 года назад

    I upgraded from 3.7 to 3.9 and have some tkinter widget placement issues. Has anyone else out there?

  • @semihaksoy8182
    @semihaksoy8182 3 года назад

    Is it better to download older versions such as 3.7 or 3.8? Because I think some of the modules and frameworks will not be valid for 3.9 version? Please answer...

    • @prettyprinted
      @prettyprinted  3 года назад

      The new versions only add features to the language, so they shouldn't break anything. But if you're working on an existing project, it might make sense to not upgrade unless you have to.

    • @9SMTM6
      @9SMTM6 3 года назад

      Typically the versioning is supposed to give you indications what you can update and what not.
      The rule ("semantic versioning") is that a version is written like this x.y.z with the names major.minor.patch
      A patch is supposed to introduce only fixes.
      A minor update will bring new features but will work with older versions just fine.
      Only a major update will bring potentially "breaking" changes (=changes that will stop code from working as intended).
      Which means if any software packet or language follows these rules you can always upgrade from 3.x to 3.y if y>=x.

  • @vaneakatok
    @vaneakatok 3 года назад +2

    it would have been cool if we had a list or set as an argument for remove prefix or suffix function
    that goes into the direction of regex

    • @prettyprinted
      @prettyprinted  3 года назад

      Yeah that would have been a good addition.

    • @novaria
      @novaria 3 года назад

      Or a sibling function removeprefixes([])

    • @aka5
      @aka5 3 года назад

      in all fairness, it already makes it so much easier to make your own implementation of that

    • @novaria
      @novaria 3 года назад

      @@aka5 not the point here. Having stuff like this embedded in the language itself is what would be cool. Of course it's easy to write it yourself but do you wanna copypasta that code snippet around your projects or import it from a custom library you've built? See my point?

    • @aka5
      @aka5 3 года назад

      @@novaria yes

  • @x0rn312
    @x0rn312 3 года назад +4

    I LOVE the Star Trek reference!

  • @Alche_mist
    @Alche_mist 3 года назад

    As I'm on Anaconda with its latency behind Python versions (i.e. I'm still working with Python 3.7), I'll probably build 'removepreffix' and 'removesuffix' into my collection of personal helper functions. Those seem too valuable not to have there.

  • @prathameshpatkar4172
    @prathameshpatkar4172 3 года назад

    Heyy , 👋👋👋
    Please make video about
    "Flask- pjax"
    We are waiting bro .

  • @TheVoitel
    @TheVoitel 3 года назад

    I do not really like the disjunction thing. Sets use disjuction for union, as it’s basically the same thing. But for dictionaries, well, one would expect | to be commutative. So doing a | b when needed might be useful, but instead of a |= b it still makes more sense to use a.update(b), since the latter clearly states the direction and the intent.
    The removeprefix stuff ... Well, it’s nice addition, but often you could just use lstrip for that.

  • @paborlouise319
    @paborlouise319 3 года назад +4

    All are great, but the last one(4) would be more useful.

    • @prettyprinted
      @prettyprinted  3 года назад

      I agree it would be useful in a bunch of situations. Thanks for watching!

  • @AlexanderYap
    @AlexanderYap 3 года назад +1

    So str.removeprefix does the same thing as re.sub('^Dr ','', str) ?

    • @ImWatchinYou
      @ImWatchinYou 3 года назад

      Yup, I hate it when they put in stupid functions already handled by better solutions

    • @Pimarko
      @Pimarko 3 года назад +3

      Except you dont need to include regex and easier for the eyes. Also you cant mess it up by accidently leaving the '^' from the start of the pattern. Probably less efficient also to use regex. There are already a lot of string based functions that can be solved with regex.

    • @nowhereman5956
      @nowhereman5956 3 года назад +3

      finishes it without importing re and makes the language more newbie friendly

    • @AlexanderYap
      @AlexanderYap 3 года назад

      The example given of removing titles from names is bad... how will this be used to remove other titles like Mr, Ms in addition to Dr? Just a big chain of if str.startswith()...

    • @PanduPoluan
      @PanduPoluan 3 года назад +1

      The difference is that "str.removeprefix" accepts the prefix as-is; if you use re.sub you must escape the special characters. Easy to do if the pattern is a literal, but hellish if the pattern is dynamic.
      A contrived example: If the prefix to remove is "1.*", then you'll going to bork the whole string unless you take good care of escaping the "." and the "*". Again, doable if it's a literal, but if the process gets the prefix from another place (say, read from a file), then you need to put that in consideration.

  • @armandgamingchannel7783
    @armandgamingchannel7783 3 года назад

    no longer need stack over flow?

  • @rosebae8171
    @rosebae8171 3 года назад

    I have python 3.7 and now I want to install Python 3.9 (the new one). So, should I uninstalled my last python first then I install 3.9?

    • @MrCreeper20k
      @MrCreeper20k 3 года назад

      managing python versions is an absolute pain. My recommendation is to invest a little bit of time installing miniconda and learning a couple of its commands and how its environments work. It lets you cleanly keep and manage different python environments. That way, if you install libraries, they only install onto the environment you choose. You can also easily choose your python version through there. Unfortunately, miniconda might be a little slow to add the new 3.9 version to its available python versions, so they might not have it just yet.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      If you're using Windows, you can simply install 3.9 in a different directory, and edit your PATH.
      On Linux, you'll be limited to whatever package is provided by your distro's maintainer; best to use the "pyenv" tool.

  • @varunrajkumar2764
    @varunrajkumar2764 3 года назад +2

    First to comment! Also, you should make a tutorial on monthly subcriptions with paypal.

    • @prettyprinted
      @prettyprinted  3 года назад +1

      I definitely want to cover integrating Paypal again. Thanks for watching!

    • @patriotsarechokers
      @patriotsarechokers 3 года назад

      @@prettyprinted #InDjango

  • @danielschmider5069
    @danielschmider5069 3 года назад +3

    What comes after 3.9?
    4.0?
    3.10?
    3.91?

  • @trustmub1
    @trustmub1 3 года назад

    so removeprefix is an extension function. can we create our own extension functions now in Python?

    • @prettyprinted
      @prettyprinted  3 года назад +1

      I'm not sure what you mean by an extension function, but removeprefix is just a method on the str class.

    • @seidenada526
      @seidenada526 3 года назад

      It is technically just another method of the string built-in. It's actually implemented by the interpreter, being faster than a python-land implementation. On another point, I don't believe extension methods will ever be accepted in Python, since it can easily confuse readers about "where this method comes from?"

    • @trustmub1
      @trustmub1 3 года назад

      @@prettyprinted just like what Kotlin has where you can extend a class with new functionality, the class being the receiver/type and the methog being the extension.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      @@trustmub1 You cannot add new methods/properties to the `str` class. You can, however, inherit the `str` class and add your own sets of methods.

  • @danielschmider5069
    @danielschmider5069 3 года назад

    its kinda weird that 7:38 doesnt find an error, since mylist is still not of type list... is that normal or irrelevant here?

    • @prettyprinted
      @prettyprinted  3 года назад +1

      Types don't get evaluated at all. The exist for external libraries to verify the code.

    • @danielschmider5069
      @danielschmider5069 3 года назад

      @@prettyprinted yes, but the verification passes, despite mylist not being a list, but a string?

    • @yeyu8521
      @yeyu8521 3 года назад

      @@danielschmider5069 I believe type hinting in python is only for IDE and mypy to ensure a single type for a declared variable, doing
      def do_print(a: int):
      print(a)
      do_print('b') # outputs: b
      is fine and python can still run it because like Pretty Printed said, in runtime, python don't evaluate data types

    • @PanduPoluan
      @PanduPoluan 3 года назад

      @@danielschmider5069 "typing" in Python serves only as hints to the user/programmer. Assigning a string to the mylist variable that has been hinted as a list won't cause an error, because Python is not statically-typed.
      Good IDEs will _warn_ you that "the value you assign to mylist _should_ be a list", but they won't stop you because Python itself doesn't care (the Python interpreter will 100% ignore the hints)

    • @danielschmider5069
      @danielschmider5069 3 года назад +1

      I realize Python doesnt interpret typehints, I'm specifically talking about mypy ignoring it. Is it because the same variable is defined a second time (line 6), ignoring the typehint that was introduced in line 3?

  • @nowhereman5956
    @nowhereman5956 3 года назад

    wow, I just noticed that I used lstrip / rstrip in a wrong way!!!

  • @anventia
    @anventia 3 года назад

    Wait for str.removeprefix would that be the same as doing str.replace("Dr. ", "")?
    I guess this can be useful for only removing it if its a prefix/suffix, and keeping it if its in the middle of the str.

    • @prettyprinted
      @prettyprinted  3 года назад

      Yeah it will ignore anything in the middle.

  • @diggzhang
    @diggzhang 3 года назад

    seems like scala?

  • @HLD202
    @HLD202 3 года назад

    Actually except the second one others was interesting

  • @reflacius7377
    @reflacius7377 3 года назад

    my python is cmd. why

  • @lonewolfcoding5208
    @lonewolfcoding5208 3 года назад

    i want python upgrade its graphics desktop and mobile
    and building mobile app on windows pc
    pls

  • @robertotomas
    @robertotomas 3 года назад +1

    I already had read about the release .. I mostly thought “ugh, these bizarre new operators suck”... but seeing the first couple of minutes of this video, I am 100% sold now on | - that’s a keeper (that should happen in other languages even)

  • @zer-vl8cv
    @zer-vl8cv 3 года назад

    mine looks like cmd

  • @dennisbarzanoff9025
    @dennisbarzanoff9025 3 года назад

    omg 14:27 why did that take so long

  • @dionbridger5944
    @dionbridger5944 3 года назад

    Apologies, but I am EXTREMELY doubtful that { **a, **b } is equivalent to a.update(b) in Python 3.9
    For one, this would break a lot of legacy code that relies on the existing semantics for { **a, **b } which is to construct a new dictionary and to leave a, b unchanged.
    The only sense in which your claim seems to be correct is that in the NEW dictionary, if both 'a' and 'b' contain a key X, the new dictionary will take the value in b in preference to the value in a.
    I tried scanning through "What's New In Python 3.9" and could not corroborate your claim there.
    I would be grateful if you could point me to the specific section in case I've missed it.
    - Dion

  • @informativecontent4778
    @informativecontent4778 3 года назад +1

    Still no i++ in python

    • @prettyprinted
      @prettyprinted  3 года назад +1

      i+= 1 is only one extra character :)

    • @AssemblyWizard
      @AssemblyWizard 3 года назад

      it's actually 3 more because spacing

  • @PanduPoluan
    @PanduPoluan 3 года назад

    I like the performance improvements of 3.7 + 3.8, and the friendlier sugars in 3.9 ... but too bad I still have to target 3.6 because at this moment it's the most widely deployed version (Ubuntu 18.04 comes with 3.6)

    • @ribosomerocker
      @ribosomerocker 3 года назад

      You shouldn't just limit your libraries or software to specific versions because they're the most deployed, use the versions that have features that you want to use. If your software that you're writing is actually good for the job and is worth it, they will bother updating Python for it.

    • @PanduPoluan
      @PanduPoluan 3 года назад +1

      @@ribosomerocker Well, installing non-mission-critical 3rd party libraries in Enterprise Production is a big no-no. Most features in 3.7

  • @bfkmnemonic
    @bfkmnemonic 3 года назад

    He build a time machine!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • @snorribjarnason8408
    @snorribjarnason8408 3 года назад

    This looks completely different from mine, why is that. Mine is just the basic, standard black screen.

    • @JustLaura404
      @JustLaura404 3 года назад

      Me too. Is there anyway to make it look like his?

    • @snorribjarnason8408
      @snorribjarnason8408 3 года назад

      @@JustLaura404 I think I figured it out, you have to download pycharm

    • @JustLaura404
      @JustLaura404 3 года назад

      @@snorribjarnason8408 kk Hope it works. Thanks for the feedback

    • @JustLaura404
      @JustLaura404 3 года назад

      @@snorribjarnason8408 I finally figured it out. You don't have to download pycharm. Just go to search on your windows , look for Python IDLE not the one u opened but a different one. Open it and then that's it

  • @SrIgort
    @SrIgort 3 года назад

    There is a remove prefix but not a add prefix? 🤔

    • @ribosomerocker
      @ribosomerocker 3 года назад

      Just append to the beginning of the string

    • @SrIgort
      @SrIgort 3 года назад +1

      @@ribosomerocker What if the prefix already exists in the beginning of the string?

    • @ribosomerocker
      @ribosomerocker 3 года назад

      Then don't? It's like saying removeprefix is faulty because it doesn't account for when the prefix was already removed and then it gets removed again if it exists

    • @SrIgort
      @SrIgort 3 года назад

      @@ribosomerocker The whole point of removeprefix is to only remove if the prefix exists and the implementation could be a simple if as shown in the video, the same thing is valid for addprefix only changing the fact that it would add instead of remove...

    • @ribosomerocker
      @ribosomerocker 3 года назад

      @@SrIgort Except something that already does that already exists... They can't just add something that is almost the same as something else (which is just adding up strings.) what you're looking for can be done in one line of code, ``prefix + string if not string.startswith(prefix)``

  • @dmitrybelyakov
    @dmitrybelyakov 3 года назад

    Beverly Crusher was hot

    • @prettyprinted
      @prettyprinted  3 года назад +1

      Thanks for watching!

    • @dmitrybelyakov
      @dmitrybelyakov 3 года назад

      @@prettyprinted My pleasure - I really like your channel!

  • @ashtongrist
    @ashtongrist 3 года назад

    so if you like just go ahead and answer it and then i'll go ahead if I just want to and so on

  • @sadhlife
    @sadhlife 3 года назад

    Doctor who reference yo

  • @Majnik_
    @Majnik_ 3 года назад

    Isn't removeprefix same as lstrip?

  • @guiorgy
    @guiorgy 3 года назад

    So you can add types to Python... Then what's the bloody point in using it?

  • @tomasemilio
    @tomasemilio 3 года назад

    very similar to [doctor.replace("Dr .", "") for doctor in doctor]

    • @nonavailable1755
      @nonavailable1755 3 года назад +5

      similar but not identical, the behavior is different when there is a "Dr. " in other places in the string, other than the start.

  • @Nirex_
    @Nirex_ 3 года назад

    More stuff to force everything to be updated...

    • @beach2550
      @beach2550 3 года назад

      Nothing was removed in this update though I don't think? It will probably be the case for python 4 but this update just added some functionality/alternative uses. Unless I have missed something

  • @philperry6564
    @philperry6564 3 года назад

    Using '|' is for Dict-Merging is beyond stupid. There was nothing wrong with {**dict_a, **dict_b}, especially since it was kinda unique. Including AugAssign as well, takes the Zen of Python and throws it out of the window.

    • @doc8527
      @doc8527 3 года назад +1

      same feeling, I used to like python syntax sugar since it's pretty easy comparing to others. But this one is purely stupid for the sake of "simplification" because the "bitwise operator" or " | " somehow is used in so many cases across different languages besides python. This one brings a lot of confusions for me, and dilute, pollute the original purpose of the operator.

  • @hyqhyp
    @hyqhyp 3 года назад

    Tsk tsk ... what would Guido say?

  • @snoopyjc
    @snoopyjc 3 года назад

    And the weirdest new feature: http status code 418 IM_A_TEAPOT

  • @xx133
    @xx133 3 года назад +1

    Value add to confusion ratio for new dictionary merge syntax is low... if something is broken, fix it or replace it, don’t add yet another way of doing it that’s slightly different than the original.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      This allows dicts to be handled similarly to sets without having to put in an "if isinstance()" or casting.

  • @johnstarfire
    @johnstarfire 3 года назад

    doctor = [x.replace("Dr. ","") for x in doctorlist]

    • @surajvkothari
      @surajvkothari 3 года назад +3

      It might replace Dr. or any other target from the rest of the string. string.removeprefix() only removes from the start.

    • @johnstarfire
      @johnstarfire 3 года назад

      @@surajvkothari This is so true...

  • @MasterSergius
    @MasterSergius 3 года назад +1

    Using pipe with two variables - bitwise OR, why the hell they made this confusion? Is it more clear than simple update? Damn, I'd better switch to Fortran

  • @shamrock1961
    @shamrock1961 3 года назад

    For someone who just started learning python it just confused things even.more..

    • @prettyprinted
      @prettyprinted  3 года назад +2

      Don't worry about these features yet. The things you see in every Python tutorial are the things that matter the most.

    • @seidenada526
      @seidenada526 3 года назад +1

      What got you confused, bro? Anyhow, you may not have to worry about these features just yet. Many libraries support only Python 3.6 or 3.7 (well, it depends on what field you work with).

  • @varma.
    @varma. 3 года назад

    Can someone tell why someone should learn a language that is still under development of features that most people would use? Legit question.. Don't want no sissy answers please...thnx

    • @pvic6959
      @pvic6959 3 года назад +1

      First, im curious to know what your reasoning is for someone NOT to learn a language that is still under development. Id like to hear your thoughts
      now to my perspective: most if not all, languages are actively under development until theyre old and deprecated. python 2.x is no longer under development. using your logic, youd want to use that one. but then the question is why would you want to use one thats old/deprecated/no longer being updated? also it comes down to what most people use. FORTRAN no longer gets any real updates (as far as I know) but no one uses it anymore (for the most part), so why would you use FORTRAN? these are all valid questions
      (also you could have stopped at "legit question", saying the rest made you come off a bit rude. not saying anything bad about you or your question but i wanted to mention it just incase you didnt catch it)

  • @shohjahonhamraqulov8439
    @shohjahonhamraqulov8439 3 года назад

    📢📢📢WANNA HAVE PYTHON 4.0

  • @ldohlj1
    @ldohlj1 3 года назад +3

    This is why I hate python! You never know if for something you're stuck doing there is a simple syntax like "a | ^ b .... -b | (a) >>> a" !!!

    • @ribosomerocker
      @ribosomerocker 3 года назад +1

      This is no reason to hate Python for... Ignorance is really not a reason to hate anything. It's like hating C++ for not knowing if there's a specific function already written for you to do the job but you don't know it.

    • @ldohlj1
      @ldohlj1 3 года назад

      @@ribosomerocker Except with C++ or other languages there is an finite number of functions and syntaxes. I can bet you a C++ programmers with 5 years of experience knows almost 80% of the available syntaxes and functions while a python programmer with the same amount of experience would only know about 15% of them.
      Apart from that, in C++, if you wonder which class or namespace of a certain library contains TimeSeries functions, you write "TimeSeries", while in python you gotta know whatever self-made "pandas" "kerbomint" "tityfish" "retronaut" shitty name they have put over their libraries...

    • @ribosomerocker
      @ribosomerocker 3 года назад +1

      @@ldohlj1 Python can not bave infinite numbers of functions and syntaxes... A C++ developer with 5 years of experience, while still only knowing 80% currently, will have less knowledge of C++ as years go by if they don't actually see what features are being added in every version of C++. Same goes with python, 5 years of experience would be enough to know basically the entirety of the standard library and syntax features, hell... I have only a year, and I am pretty sure I know more than 80% of Python, as of right now. I never heard of titty fishes in Python's standard library though.

  • @juicyjouissance3481
    @juicyjouissance3481 3 года назад +2

    so they just hlaf-merged shitty libraries to the core and implemented a horrible idiom to update dictionaries, don't mind why Guido left this train-wreck of a language.

    • @anirangoncalvesbr
      @anirangoncalvesbr 3 года назад

      In fact, it seems like this new behaviour was even supported by Guido himself. He supposedly stepped down from BDFL position because of core developers backslash on this release , starting from Py 3.8
      Kinda sad news to me, since I do share the same concerns as the people against these new syntactic sugar.

    • @lawrencedoliveiro9104
      @lawrencedoliveiro9104 3 года назад +1

      Feel free to stick to VBA.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      I like this idiom, actually.
      Now I can have same processing for set & dict.
      def do_something(o1, o2):
      rslt = copy.deepcopy(o1)
      rslt |= o2
      for i in rslt:
      # do things
      I can call do_something with a pair of sets or a pair of dicts and the code stays the same. Without the "dict union" operator, I'll have to do an ugly "if isinstance()" or casting.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      @@anirangoncalvesbr Well, Guido's not getting any younger, and he's getting tired of all the too-emotional debates as Python more and more popular. Newer members of the community might be "a bit too vocal" and that kind of "less respective" behavior tends to be contagious. PEP 572 was "the last straw" in the sense that Guido took a step back, saw that he can no longer be too invested in emotional things, and decided to no longer be the dictator.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      Also, Guido did not leave Python. He just stepped down from being the BDFL. He's still part of the core Python developers, and still actively give input & advice, but now people cannot dump things into his lap and expect him to make a decision on polarizing issues.

  • @JimmyWalters1
    @JimmyWalters1 3 года назад +2

    Every update, I like python less.

  • @junaidnasirkhan
    @junaidnasirkhan 3 года назад

    Bored 😲

  • @cipherxen2
    @cipherxen2 3 года назад

    So, nothing new, which will require a whole new version.
    Python already has stupid syntax, and there're introducing more stupid operators.

    • @aka5
      @aka5 3 года назад

      they created a whole new interpreter as well, amongst a bunch of other stuff not included in this 10 minute video about 4 new things.

    • @prettyprinted
      @prettyprinted  3 года назад

      Yeah these are the features that jumped out at me. There are more things included in the release.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      (1) You are not required to use the new "dict union" operator. It's optional. You can keep using .update()
      (2) Implementing the "union" operator is actually a good decision, since it allows dicts to be processed similarly to sets. No more casting and/or "if isinstance()" to implement different operations for dicts and sets.

    • @cipherxen2
      @cipherxen2 3 года назад

      @@PanduPoluan Correct. You are not required to use python also.

  • @Kanglese
    @Kanglese 3 года назад

    So do you start every sentence with "so"? Go back and listen to yourself. I had to stop watching after 20 "so's" before 2 minutes in, or so. So I hope you don't always talk like this, for your colleagues sake.

  • @russianbotfarm3036
    @russianbotfarm3036 3 года назад

    Too slow. I’ll go look it up.

  • @BrianStDenis-pj1tq
    @BrianStDenis-pj1tq 3 года назад

    Python seems to be losing its way with these unnecessary additions. It was simple and beautiful, now its getting short cuts which make it ugly.

    • @PanduPoluan
      @PanduPoluan 3 года назад

      Why is it ugly? If any, this allows dicts to be processed similarly to sets. No more casting and/or "if isinstance()" ladders to implement a similar (but not same) operation.

  • @veziop
    @veziop 3 года назад +2

    Why am I here I don’t even know how to code

    • @prettyprinted
      @prettyprinted  3 года назад +1

      You can always start learning.

    • @veziop
      @veziop 3 года назад

      @@prettyprinted yes i keep trying its been five years