General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Lawrence D’Oliveiro
Indently
comments
Comments by "Lawrence D’Oliveiro" (@lawrencedoliveiro9104) on "Indently" channel.
Previous
1
Next
...
All
I keep forgetting about setdefault. Must remember to use that more. And here’s another tip: deleting a dictionary entry that might not exist. Where del d[key] will raise KeyError if there is no such entry, d.pop(key, None) will not.
7
Python does ORC memory management, Java does not. Python can do function factories and class factories, Java cannot. The Python core language spec is about a quarter the size of the Java one. Can Java really do 4× as much? No it can’t.
5
It would compile OK, it just wouldn’t run. It works in Python versions 3.9 or later (just tested).
2
This is for static type checking, which some people prefer to use.
2
Those languages can’t do function factories and class factories though, can they.
2
Actually “l.clear()” would be more equivalent to “l[:] = []”
2
No, these are just type annotations. They don’t actually make a difference to the compiler.
1
Why doesn’t it work on 3.12? Language incompatibility? Build incompatibility?
1
@DeanJohnson-s8x If static type checking becomes compulsory, then it is no longer a dynamic language.
1
Python does ORC memory management, Java does not. Python can do function factories and class factories, Java cannot. The Python core language spec is about a quarter the size of the Java one. Can Java really do 4× as much? No it can’t.
1
This is why it helps to keep the Python library docs in your bookmark list!
1
Here’s the way I do it: if params != None ∶ if ( isinstance(params, dict) and all(isinstance(k, str) and isinstance(v, (int, str)) for k, v in params․items()) ) ∶ paramsstr = "&"․join \ ( "%s=%s" % (k, quote_url(str(v))) for k, v in params․items() )
1
elif ( isinstance(params, tuple) and all(isinstance(i, tuple) and len(i) == 2 for i in params) and all(isinstance(k, str) and isinstance(v, (int, str)) for k, v in params) ) ∶ paramsstr = "&"․join("%s=%s" % (k, quote_url(str(v))) for k, v in params) else ∶ raise TypeError("params are not a dict or tuple of suitable (key, value) pairs") ♯end if else ∶ paramsstr = "" ♯end if
1
This might be making use of the new “packrat parser” system to pull syntax tricks they couldn’t do before.
1
Python has an entirely separate “array” module. And then there are NumPy arrays.
1
Previous
1
Next
...
All