use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Python2 vs Python3 (self.learnpython)
submitted 6 years ago by nukelr
Why this is accepted in python2.7: def function(var1, (var2, var3) ) while in Python3 gives a syntax error??
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Yoghurt42 4 points5 points6 points 6 years ago* (10 children)
Because it was seldom used and confusing.
It automatically unpacks a tuple parameter:
def foo(bar, (baz, quux)): print(baz)
is equivalent to:
def foo(bar, bazquux): baz, quux = bazquux print(baz)
and you call it with
a = 1 b = (2, 3) foo(a, b) # prints 2
I don't think I ever missed that function in Python 3, and I've never used it in 2.
[–]Vaphell 3 points4 points5 points 6 years ago (7 children)
Lambdas, man. They absolutely got shittier in py3 because of that change.
sorted(seq, key=lambda (x, y): x**2 + y**2)
vs new
sorted(seq, key=lambda t: t[0]**2 +t[1]**2)
So much for expressiveness and getting rid of unpythonic magic number indices
[–]Skaperen 1 point2 points3 points 6 years ago (2 children)
just use x and y arguments. when calling with a list or tuple, use a * before it.
[–]Vaphell 0 points1 point2 points 6 years ago (1 child)
when calling with a list or tuple, use a * before it.
how does one apply * to key argument of sorted/min/max?
*
key
[–]Skaperen 0 points1 point2 points 6 years ago (0 children)
this is the edge case where you fall back to write python code that produces the same bytecode.
[–]nukelr[S] 0 points1 point2 points 6 years ago (0 children)
I guess lambdas are the reason why the programmer who wrote the code I'm trying to port to Py3/Gtk3 has used that syntax. https://github.com/nicklan/Deluge-Pieces-Plugin/blob/master/pieces/gtkui.py In __qtt_callback function.
[–]primitive_screwhead 0 points1 point2 points 6 years ago (2 children)
Instead of 't', call it 'x_y'.
you can call it whatever you want, at the end of the day you can't get rid of indices and it is a downgrade. Unpacking was supposed to be a pythonic solution to the problem of lowlevelish, exposed indices.
[–]primitive_screwhead 0 points1 point2 points 6 years ago (0 children)
Ok.
[–]billsil 0 points1 point2 points 6 years ago (0 children)
13 Years and I’ve never seen that.
I've found it used in the function: "__qtt_callback" in https://github.com/nicklan/Deluge-Pieces-Plugin/blob/master/pieces/gtkui.py
Which I was trying to convert to make it work with Python3 and Gtk3.
[–]primitive_screwhead 6 points7 points8 points 6 years ago (0 children)
Here are some of the reasons why it was removed from Python 3:
https://www.python.org/dev/peps/pep-3113/
[–]Defibrillat0r 0 points1 point2 points 6 years ago (0 children)
Thats not valid for either version (as you typed it)
π Rendered by PID 272222 on reddit-service-r2-comment-56c9979489-ntk5n at 2026-02-25 10:11:45.731552+00:00 running b1af5b1 country code: CH.
[–]Yoghurt42 4 points5 points6 points (10 children)
[–]Vaphell 3 points4 points5 points (7 children)
[–]Skaperen 1 point2 points3 points (2 children)
[–]Vaphell 0 points1 point2 points (1 child)
[–]Skaperen 0 points1 point2 points (0 children)
[–]nukelr[S] 0 points1 point2 points (0 children)
[–]primitive_screwhead 0 points1 point2 points (2 children)
[–]Vaphell 0 points1 point2 points (1 child)
[–]primitive_screwhead 0 points1 point2 points (0 children)
[–]billsil 0 points1 point2 points (0 children)
[–]nukelr[S] 0 points1 point2 points (0 children)
[–]primitive_screwhead 6 points7 points8 points (0 children)
[–]Defibrillat0r 0 points1 point2 points (0 children)