Ad
  • Default User Avatar

    professional dev either, but in my opinion, "clever code", "tricky" or "tricky to understand at first glance" would not be of value to large teams (in a serious manner), if people would spend the time they could be actually working trying to understand something someone else has done in order to use it, or modify it (maybe?), it won't be so productive. It is really cool to see someone knowledgeable enough to write code like this, it shows that he knows the language well, and can do things not so many people would try to do, it's tricky, elegant, and very clever as many people wrote here, no doubt about it! But if you're in a team, you have deadlines, basically, you're trying to spend more time coding rather than staring at someone else's code thinking "how does this even work" or something similar, basically it's hurting the workflow instead of making it easier for the team to understand it right away and come up with things faster. To make a comparison, imagine you have to use math to do something, in math, you can do things in many ways and get the same outcome, but sometimes you can use formulas to make more extended calculations take less time, in this case, "the formula" would be making the code easier to read, so that anyone that knows the language enough (not necessarily THAT much) can spend little time trying to understand it, and more time being productive. Clever or tricky code is like having a math problem solved with many calculations instead of using any formulas to make it shorter and easier to understand. I don't really know if that analogy is understandable enough to address the situation, but I tried to explain my point, lol.
    There are instances where clever code is used to make the program more efficient (using Big O notation to calculate the algorithm's efficiency/complexity), 100%, but I'd stick with "easier to understand" over "clever/tricky" if maximum efficiency wasn't a goal, or if it didn't really have an advantage compared to simpler code.
    English is not my first language, sorry if I didn't write everything correctly.

  • Default User Avatar

    I'm stuck, exactly like you did, the same thing, just that the raise: Exception("ERROR!") doesn't work for me... every test is a success, but this "raise an error" thing is bugged, i tried with the "except", also with just a raise ValueError or something, and it does not work in any way.