all string syntaxes (beginner) anthony explains

Поделиться
HTML-код
  • Опубликовано: 13 июл 2024
  • I've been recently teaching juice some python (over on the vods channel - @anthonywritescode-vods) and decided to record this into a standalone video!
    playlist: • anthony explains
    ==========
    twitch: / anthonywritescode
    dicsord: / discord
    twitter: / codewithanthony
    github: github.com/asottile
    stream github: github.com/anthonywritescode
    I won't ask for subscriptions / likes / comments in videos but it really helps the channel. If you have any suggestions or things you'd like to see please comment below!
  • НаукаНаука

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

  • @ChongFrisbee
    @ChongFrisbee Год назад +4

    This has been the most advanced beginner video I've seen. And I mean this literally, not sarcastically. Still beginner level, but realy informative in a non trivial way 10/10 'thumbsupemoji'

  • @Papalotis97
    @Papalotis97 Год назад +10

    i might be wrong but the \ at the end of the line is not specific to multiline strings, it's just a line continuation, that is why it also works for single quote strings

    • @dericmiguel1
      @dericmiguel1 Год назад

      you can also use parens, ( "foo"
      "bar" )

    • @anthonywritescode
      @anthonywritescode  Год назад +4

      it's slightly different for strings -- see the part on raw strings

  • @DavidDellsperger
    @DavidDellsperger Год назад +4

    Anthony provides 19 minutes, 22 seconds on great information regarding strings, at 19:23, "It's french and it's funny"...that's all I've taken away from this video, thanks Anthony! French == Funny

    • @qexat
      @qexat Год назад

      hon hon hon la f-chaîne de caractères

  • @rougebarbu
    @rougebarbu Год назад +2

    formfeed (FF in the ascii table) is for printers. They go to the top of next page. with linefeed (LF), even on a printer, you just go down one line

  • @mad_vegan
    @mad_vegan Год назад +1

    14:42 It's because the parser always looks at the character after the backslash and preserves it in the raw string. So it sees the \' at the end and includes both the backslash and the single quote. But then it thinks the string wasn't terminated and gives an error. Why it's implemented like this idk, it might be for performance.

  • @Cookie-mv2hg
    @Cookie-mv2hg Год назад

    Please do make a video about the "meta language" you mentioned with f-string!
    This is super helpful!!

  • @dorb1337
    @dorb1337 Год назад

    love the debugging option from 3.8 but I haven't found it useful in my projects yet😂😂

  • @senseikoudai6186
    @senseikoudai6186 Год назад

    I would love to hear more about the meta language of the f-strings. Maybe it you could actually make a video about it.

  • @cerealport2726
    @cerealport2726 Год назад

    i use raw strings to manage file and folder paths in Windows without a lot of extra effort. maybe it's a bad approach, but it seems to work...

    • @anthonywritescode
      @anthonywritescode  Год назад

      you know you can use forward slashes even on windows right?

    • @cerealport2726
      @cerealport2726 Год назад

      @@anthonywritescode Maybe it's just the Python 3.9 environment thats embedded in the data platform i use at work, but I get annoying messages that pop up when normal file paths are used, hence, the use of an "r"...

  • @samoylov1973
    @samoylov1973 Год назад

    Anthony, if you were to write Caesar cipher (where each letter is substituted with the one that is some places "behind it") how would you go about such a task. Say, "Hello, World!" with shift pattern of 3 letters. "a" becomes "d", "b" becomes "e" and so on.
    Could it be done with that print("a
    d") substitution. I understand that instead of "d" there should be some code in { } and f-string at the start.
    Thanks!

    • @anthonywritescode
      @anthonywritescode  Год назад +1

      `a
      d` doesn't really do a replace -- it just wipes the line rendering in the terminal
      for casar cipher I might use `str.translate` -- would be one of the few times I actually use it

  • @mrswats
    @mrswats Год назад

    Classig off-by-one errors 9:14

    • @mrswats
      @mrswats Год назад

      Also, baguette strings

  • @user-us8th9zn1g
    @user-us8th9zn1g Год назад +1

    f strings ❤

  • @PowerLlama
    @PowerLlama Год назад

    I've got a weird code problem I can't find an answer for…
    i have some functions i've written in python, but i can't call them directly from the package. instead i have to store them as strings, and then give those strings for the next program to run them independently. is there a way of converting a function to a string? right now i'm doing using the functions in testing and then when i'm done wrapping them in ''' multi line string arguments (and the '''/ is a great tip thanks for that). but of course that introduces typos and code duplication. weird problem (i think), would love to know your thoughts!

    • @anthonywritescode
      @anthonywritescode  Год назад

      that seems... very strange... are you sure you can't just use modules? otherwise you could use `inspect.getsource` + `exec` or something of the sort -- but sounds pretty hacky

    • @PowerLlama
      @PowerLlama Год назад

      @@anthonywritescode oh yeah, super hacky. basically in this app we use Nuke by The Foundry, a vfx app, you can create nodes in the dag with a python button, and in that button you can execute arbitrary python scripts. print('hello world') or whatever. and as long as the scripts are using built-ins and nuke methods, you can copy paste them around and expect them to work in other scripts. in a normal studio environment, i'd import thing thing.main(), but the way we're working we're passing around nuke scripts to people who don't have access to our central repository
      super hacky, i don't like doing it, but it's what we've settled on. seemed like a shot in the dark question but if anyone might have an answer it'd be you

  • @blizzard_inc
    @blizzard_inc Год назад +1

    did you forget to mention u-strings? Or was it a conscious decision?

    • @anthonywritescode
      @anthonywritescode  Год назад +1

      they don't do anything so I intentionally left them out

  • @SQADIqw
    @SQADIqw Год назад

    Cool ! Also funny thing, that some db libraries optimized for c style formatting, and if you use f strings they produce inefficient sql, because it was no f-strings during that times😅

    • @anthonywritescode
      @anthonywritescode  Год назад +4

      uh no that's not the reason -- using f-strings in sql is a security issue due to sql injection

  • @DavidDellsperger
    @DavidDellsperger Год назад +1

    How to...duh, duh, duhhhhhhhh...write python