I take my shitposts very seriously.

  • 2 Posts
  • 218 Comments
Joined 2 years ago
cake
Cake day: June 24th, 2023

help-circle








  • Check the wording. I said Mozilla, not Firefox.

    I think Firefox is a great product and want it to succeed, but lately Mozilla has been burning its reputation by chasing the advertising and AI trends. Make no mistake, they are a for-profit company. That doesn’t mean their products should be shunned, but they shouldn’t be exempt from skepticism and rational distrust simply for being the lesser evil.



  • Change this:

        print(calculate(splitter(expression)))
    

    to this:

        print(calculate(* splitter(expression)))
    

    The error is that calculate expects three float values (x, and y, and z), but splitter returns a tuple object ((x, y, z) as one object, similar to arrays in other languages):

    >>> type(splitter("1 + 2"))
    <class 'tuple'>
    

    Prepending a tuple or a list with a * operator (unpacking or splatting) unpacks the object into its individual items that are then passed to the function as separate arguments.

    In fact, str.split() already returns a tuple. By assigning multiple values at once in x, y, z = expression.split(), you actually unpack the returned tuple into individual values, then in return x, y, z, you pack those values into a tuple.