lmao python is literally javascript tier brainlet language
Lmao python is literally javascript tier brainlet language
Other urls found in this thread:
docs.python.org
docs.python.org
twitter.com
somebody explain
there's nothing surprising or "wtf" about what you've written
being this retarded
some_dist is overwritten for no reason other than python being javascript tier brainlet language
>Explicit is better than implicit.
>this
mfw it's true :o
It's overwritten because that's what you told the program to do.
OP is a moron who doesn't understand programming.
Whats happening is enumerate is producing a tuple like (0, w)/(1, t)/(2, f). Slightly more detailed:
for i, some_dict[i] in enumerate is taking the first element in the tuple and assigning it as a key in the dictionary, while some_dict[i] is taking the second element in and adding it as a value. The whole thing then transforms a tuple like (0, w) into a key/value pair like {0: w}.
so you're saying that quantifier changing the state of variables is a perfectly normal thing?
to be fair, stightly is. `i` might not be binded for `some_dict[i]`
how do you think the code you've written should behave
it does exactly what you wrote
dict(enumerate(some_string)) is better
you entirely missed the point of this pic
>This thread again
i contains: 0, 1, 2
i inside some_dict[i] contains: w, t, f
because OP wrote some_dict[i] instead of just i, they (w, t, f) get appended to some_dict
Not really, OP is confused as to why adding an element to a dictionary is adding an element to a dictionary.
>confusing __getitem__ with __setitem__
>adding an element to a dictionary
literally where
>"i don't know python therefore it are dumb lole
docs.python.org
it's behaving exactly as expected and documented. learn the language.
enumerate() takes enumerable object and creates a generator (index, value) over all values
the in-binding in for loop takes e.g. (0, "w") tuple
1) assigns to `i` value 0
2) assigns to `some_dict[i]` where `i` is now 0 - thus to `some_dict[0]` value "w"
and iterates next
this would not be an expected behavior in majority of languages with pattern matching as in `some_dict[i]` the `i` would not be binded yet
if the docs said to fuck your mother then fucking your mother would be normal?
>implying it isn't
It would be expected and you would be a retard if you say it isn't without reading the docs.
imagine being that autistic
>comparing Lisp for sane people to a garbage called python
OP please
>all this first year cs students defending their shitty memelanguage
10/10, op
i understand that programming is difficult and that it can be frustrating at times, but if simple concepts like different languages having different semantics is too difficult for you, it might be time to look into other things to do with your life.
the absolute state of this board, how can people defend this garbage?
>HURRRR IT'S DOCUMENTED SO IT DOESN'T MATTER IF IT'S RETARDED
I'm sorry, you forgot to attach detailed description of semantics you use in your post, all I could understand is that you're a retard
>have preconceived notions of how the language should work not based on the reference documentation
>turn out wrong
>"WAAAH WHY DOESN'T IT CATER TO ME IT'S SO BAD"
>This is slightly unintuitive and I don't understand it, it must be retarded.
op pls
>slightly
it's the exact same semantics as regular variable assignments.
itt: brainlet op getting btfo
explain this, pythonfags
mfw it's true :O
lmao python is officially a retard language
pythonfags btfo'd
somebody explain
Python, as all dynamic languages apart from lisp, is a shitshow for retarded brainlets who failed cs 101
A language isn't only for loops
if that's what i wanted then yes
so, for you?
>>> a = []
>>> a.append(a)
>>> a
[[...]]
behaves differently on my machine (Python 3.6.7)
>implying a for loops are atomic
>brainletting this hard
you are explicitly assigning to some_dict[i] just like you're assigning to i right before the comma in the very same statement
so it's an undefined behavior?
>>> True = False
>>> print 1 if True else 0
0
or difference in specs between versions, OP didn't post his python version so can't be sure
Seriously though Python isn't nearly as bad as JS. Python 3 cleaned up the language rather nicely. Writing a modern JSX interpreter is insane, there's like 10 alternative syntaxes for declaring a damned function. I'm sure someone more familiar with JSX could find all sorts of rough edges in the parser.
Can confirm.
>replying seriously to a shitpost bait
>Seriously though Python isn't nearly as bad as JS.
Lmao at asying this when Python is like 5 times slower than JS
I personally think the enumerate(some_string) is redundant boilerplate. If you're using it in a for loop, then of course you're looking to iterate over it. As long as some_string is iterable, then it should try to access the iterator.
Python is twice as fast to write, and supports code bases twice as large as JS.
>Python is twice as fast to write
Nice goalpost moving
you personally are an idiot
Literally false. Python doesn't even have proper anonymous functions or object restructuring.
Python is half as fast to write, and supports code bases half as large as JS.
>Python is slow as shit
>Literally false
>Python doesn't even have proper anonymous functions or object restructuring
So are you bashing or praising Python
Epic
this thread:
>i = 123
>for i in range(10):
>pass
>i
>9
>OMG HURRDURR PYTHON IS RETARDED, IT IMPLICITLY ASSIGNS VALUES TO MUH VARIABLES
t. brainlet who doesn't understand recursion
a is passed by reference not by value
>>> a = []
>>> a.append(a)
>>> a
[[...]]
>>> [[1]] == [[1]]
True
>>> a == [[...]]
False
it's literally doing exactly what it is supposed to
>>>
cannot reproduce, post your specs
>>>> True = False
>>>> print 1 if True else 0
>0
me use outdated version of programming language
me get mad
>>> a == [[...]]
False
>>> ... == Ellipsis
True
>>> a == [[Ellipsis]]
False
>>> a[0] == a
True
>>> b = [[...]]
>>> b[0] == b
False
>>> a = []
>>> a.append(a)
>>> a
[[...]]
>>> b = []
>>> b.append(b)
>>> b
[[...]]
>>> a == b
Traceback (most recent call last):
File "", line 1, in
RecursionError: maximum recursion depth exceeded in comparison
Nah, all languages do that nowadays, actually. Sorry you have to deal with such an ancient, verbose language.
when comparing a with itself, like a[0] == a, it sees that the references are the same, and returns True. when comparing two different objects it has to check contents, and it can't do that because they are infinitely recursive.
I don't even know why it bothered to recognize recursive series as a value if they're not going to allow value comparison on them. It's cute, but it serves no purpose if you can only compare it to itself. It's just wankery.
Seems like it would be possible to support at the CPython level by just checking for recursive object IDs.
>literally
sigh...
can someone point to the part of the documentation that explains why this happens?
because it seems like a really stupid way for that code to work and I don't see it anywhere
Why are you making comments about a language you clearly know nothing about? Enumerate is a convenience function to get the indexes, not a requirement.
What's up with absolutely braindead people dissing on dynamic langs all day?
Like not even obscure features but only slightly unintuitive features that are well defined and probably make a lot of sense in the context of the given language.
It's like that image of JS with B. Eich where majority of the things is just standard compliant IEEE754 float stuff the language isn't even responsible for, because it's handled by your hardware FPU.
There are no particularly special semantics at play here, just assignment in for loops.
docs.python.org
"Each item in turn is assigned to the target list using the standard rules for assignments"
enumerate("wtf") produces
[(0, 'w'), (1, 't'), (2, 'f')]
i gets assigned 0, some_dict[i] assigned to w.
then i gets assigned 1, some_dict[i] assigned to t.
oh, now i get it, that makes sense
sorry i just woke up a while ago and im in brainlet mode
non-brainlet user
no issue if you use different variable
>>> a = []
>>> b = []
>>> b.append(a)
>>> b
[[]]
what's wrong?
it behaves correctly since True is now False
print 1 if True else 0
is equal
print 1 if False else 0
I think he's making fun of the fact that he could assign False to True.
No it's not you flaming retard.
>Python doesn't even have proper anonymous functions
yes it does
I can't believe how triggered this thread is. Jow Forums is full of fucking Pythonistas, I should have known.
>I don't understand for loops
That's the equivalent of this
int x = 10
for (x=0; x 2
// SHIT LANGUAGE REEEEE
see
can someone explain this to me? i dont get it
...
Yeah, I'd prefer they make it explicit somehow, like requiring a symbol of some sort to make sure you meant to do that
t. Python dev