Это видео недоступно.
Сожалеем об этом.
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/aso...
stream github: github.com/ant...
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!
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
you can also use parens, ( "foo"
"bar" )
it's slightly different for strings -- see the part on raw strings
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'
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
hon hon hon la f-chaîne de caractères
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
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.
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!
`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
Please do make a video about the "meta language" you mentioned with f-string!
This is super helpful!!
I would love to hear more about the meta language of the f-strings. Maybe it you could actually make a video about it.
love the debugging option from 3.8 but I haven't found it useful in my projects yet😂😂
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...
you know you can use forward slashes even on windows right?
@@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"...
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!
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
@@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
did you forget to mention u-strings? Or was it a conscious decision?
they don't do anything so I intentionally left them out
Classig off-by-one errors 9:14
Also, baguette strings
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😅
uh no that's not the reason -- using f-strings in sql is a security issue due to sql injection
How to...duh, duh, duhhhhhhhh...write python
f strings ❤