Earlier quoted context omitted.
> Most Python programmers wouldn't see a need for that, but that can be attributed to Python not having the capability by default and so they've just internalised not to use dict for anything that needs to be a key. You're being extremely uncharitable here. To a Python programmer "using a dict as a key" is a nonsensical idea for the same reason "using a list as a key" is — both dicts and lists are mutable. Python pro…
Good information, and well put. A small quibble: you should probably almost never use tuple(), even on recent Python: >>> tuple(dict(a=1, b=2).items()) (('a', 1), ('b', 2)) >>> tuple(dict(b=2, a=1).items()) (('b', 2), ('a', 1)) Of course, if you can absolutely guarantee how the dictionary has been constructed, it is possible. No rules are absolute. But in my experience, frozenset() is probably better: >>> frozenset(d…
Python overtakes JavaScript as most questioned language on StackOverflow
91–100 of 166 posts
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#92Earlier quoted context omitted.
There is a bit more insight to be found by reversing that - Python is simpler than other programming languages and achieves that by sacrificing a little power. Compare it to C, which it has displaced as an introductory language. Python and C are superficially interchangeable to a beginner, but to learn C you have to invest time into pointers and memory management. Python sacrifices the efficiency of direct memory man…
> can't even use a dict as a dict key Curious, is this actually something you want to do often? While there is no hashable+immutable frozendict ala frozenset, you could throw one together or even define a hash function on a subclass and "swim at your own risk" not to mutate it later. I've encountered this enough with lists and the obvious solution is to cast them to tuples. Can't say I've found the same with dicts th…
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#93Earlier quoted context omitted.
> can't even use a dict as a dict key Curious, is this actually something you want to do often? While there is no hashable+immutable frozendict ala frozenset, you could throw one together or even define a hash function on a subclass and "swim at your own risk" not to mutate it later. I've encountered this enough with lists and the obvious solution is to cast them to tuples. Can't say I've found the same with dicts th…
Python probably has a set type, but a common general use case for use an associative array as a key is when making a set. dict = { "foo" : "bar" } set = { dict : true } set.has_key?(dict) # true I'm sure there are other use cases where dict keys can be convenient.
someset = {"one", "two", "three"}
"one" in someset # true
frozen = frozenset(someset)
somedict = {frozen: "example"}
frozen in somedict # true somedict[frozen] # "example"
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#94Earlier quoted context omitted.
What do you mean by index? This is what I think of when I hear "index": https://yeelight.readthedocs.io/en/latest/yeelight.html Rust does the same, as far as I've seen (although the docs are a bit too index-heavy). Do you mean something different?
Maybe they mean something more like this page https://yeelight.readthedocs.io/en/latest/genindex.html which your Sphinx setup appears to be generating but the theme doesn't seem to be linking to.
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#95Earlier quoted context omitted.
> ...it seems harder to memorize things in it vs others This x10. I love Python, and use it for small scripts when I get the chance (just used it to test some probabilities last night even), but it seems like I constantly have to look things up all the time in it and can't seem to remember even common, basic syntax in it, despite having used it quite a bit. I really don't know why. I can leave and come back to other…
Interesting - I had the complete opposite experience: Python was the first language I'd tried in a long time that just worked as I'd expected it to. After understanding the initial indenting rules, most of the code I tried could be written as pseudocode, which surprisingly worked the first time. I was really impressed, most languages have so many stupid syntax requirements, which really shouldn't be be needed these d…
They don‘t and many of the dynamic features of Python (and Ruby) cannot be efficiently compiled. That‘s why it relies heavily on C modules.
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#96In this sort of context, "most questioned" is probably not much more than a synonym for "most popular".
Couldn't disagree with you more. "most questioned" is some combination of: - many beginners - incomplete or outdated documentation - not taught (or taught well) in schools - SO users who don't search for old answers before posting again See how none of those things, even mixed together, are a good proxy for popularity? We don't know the mix of the above factors for Python, but without better analysis, the headline he…
I'd say that having many beginners alone is enough to qualify as "popularity". There are more people learning programming that programmers.
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#97Earlier quoted context omitted.
Couldn't disagree with you more. "most questioned" is some combination of: - many beginners - incomplete or outdated documentation - not taught (or taught well) in schools - SO users who don't search for old answers before posting again See how none of those things, even mixed together, are a good proxy for popularity? We don't know the mix of the above factors for Python, but without better analysis, the headline he…
> See how none of those things, even mixed together, are a good proxy for popularity? I'd say that having many beginners alone is enough to qualify as "popularity". There are more people learning programming that programmers.
By that definition, I'd guess that Python is near the top due to its recent dominance in data science, but Stack Overflow isn't proving or disproving the idea either way.
Using my definition (and likely yours), JavaScript is certainly the most popular. But it's hard to discount the many huge organizations using Java and C#. Their beginners might not be using Stack Overflow as heavily because they have in-house mentorship.
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#98Seems like the most difficult programming is no longer cache invalidation and naming things. Its now about strings, and to duplicate arrays ... The stats are skewed because hordes of beginners. Mainly driven by what schools teaches and what languages has the most hype. That said Python is huge . Damn you significant white space.
Like for this specific example:
https://stackoverflow.com/questions/2612802/how-to-clone-or-...
Knowing the right thing to do requires you be informed about the history of Python language design. Like you could just read the documentation and see that lists have a copy method but it doesn't give you a good grasp of what the alternatives are and why you might choose them. And prior to Python 3.3 you're expected to know that the best practice way to do this is to leverage an edge case in the slicing syntax or the list function. Doesn't matter if you're the best computer scientist in the world, sifting through the massive corpous of documentation and historical knowledge required to write good Python is nigh impossible unless you're willing to dedicate yourself Python.
This is something that languages need to tackle because the gap between doing a thing and doing that same thing in a way that follows language conventions and best practices is too damn high.
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#99For the last two decades people have complained about (C)Python not being multi-threaded, not jitted, not having tco, being to simplistic and so on. In practice it seem to have mattered very little. For the applications where it do matter, like if you are writing your own language vm, compiler (but see PyPy) or garbage collector, you have to ask "Yes, ok, but how often do you do that?"
Re: Python overtakes JavaScript as most questioned language on StackOverflow
#100Earlier quoted context omitted.
Maybe they mean something more like this page https://yeelight.readthedocs.io/en/latest/genindex.html which your Sphinx setup appears to be generating but the theme doesn't seem to be linking to.
Oh, thank you, that is extremely useful to include. Too bad Sphinx doesn't make these things easy, I spent some time reading the docs to figure out how to include a link to the index and there was no reference to it. In the end, this Stack Overflow answer was the only thing I found that actually mentioned how to create it: https://stackoverflow.com/a/42310803/28196