News for hackers. Stuff that matters.
Re:The Elements of Python Style by moonchrome on Monday January 04, 2016 @07:31PM (#10840013)
>No, no, no, no, no! Why not clarify what are those accepted arguments?

> What the following code is doing?

    def shuffle(args):  
        # do something
It's misusing the args - you shouldn't be using args/kwargs there in the first place - they should be used for forwarding and things like that - eg. you're writing a generic function decorator and things like that.

If you want a collection to operate on "cards" then pass cards as a collection, if you want to operate on abstract function parameters use args/kwargs

Re:The Elements of Python Style by andybak on Monday January 04, 2016 @08:19PM (#10840264)
Yep.

If you want meaningful names then do it explicitly:

    def shuffle(*args):
        cards = args
Much less likely to catch someone out.
Re:The Elements of Python Style by kevinastone on Monday January 04, 2016 @08:27PM (#10840304)
If that method only accepted Cards, that's more confusing and not something visible to a code hinter that will supply the method signature. `*cards` is more explicit when the expected parameter is a variable number of card parameters.
Re:The Elements of Python Style by encoderer on Monday January 04, 2016 @10:41PM (#10840975)
But it's not pythonic to care if something is a "Card" or not. All that matters is if looks and acts like a Card.
Re:The Elements of Python Style by Scarblac on Tuesday January 05, 2016 @04:54AM (#10842367)
I've never agreed with that. Without a good definition of what exactly it means to "look and act like a Card", large projects can easily get several slightly different definitions of what a Card is like, and nobody knows exactly which methods to use where (so what exactly do I need to implement so my class is a "file-like object"?). Horrible.

I call it smurf typing. If it smurfs like a smurf, smurfs like a smurf and possibly smurfs like a smurf, we consider it a smurf. Good luck with that information.