@jim@programming.dev

I like programming and anime.

I manage the bot /u/[email protected]

This profile is from a federated server and may be incomplete. Browse more on the original instance.

jim,
@jim@programming.dev avatar

I disagree. I think the default option should be what users expect, and users expect “copy” to do exactly that: copy without modifying the text.

jim,
@jim@programming.dev avatar

Ah yes, I’m sure the formal training received by doctors, nurses, lawyers, teachers, and engineers is just an over-hyped “education” that can all be replaced by online MOOCs.

There are real problems with education, especially with the costs, but “anything can be learned online” is the worst take I’ve heard in a long while.

jim,
@jim@programming.dev avatar

No sorry, that’s just fundamentally false. You can’t just learn titration techniques from watching a video. You can’t learn phlebotomy without an instructor watching you do it to a patient. Hell, you aren’t learning how to drive a car from playing a video game.

And I’m not sure where you are pulling the “if you are that powerful” from. You really have an ax to grind don’t you.

jim,
@jim@programming.dev avatar

Just because you can get part of your education remotely or through self-learning didn’t mean “anything can be learned online”.

And if you were hiring a math tutor for your kid, would you prefer a self-proclaimed expert from watching YouTube videos or would you want someone who got a degree from a credentialed university? And even if you don’t care, why are you surprised that others would be skeptical of the YouTube expert?

Remote learning can be fine for some things, and self learning through informal channels are also fine, but it’s not a full on replacement for formal education in all cases.

Python: Struggling with typing module's callable type

I have encountered the typing module’s callable type in a Python book, and saw it tangentially referenced in a couple of videos, but I still don’t really grasp what it is for, when to choose to use it, and how it works. (The O’Reilly text I am mostly using is more of a desktop reference than a textbook.)...

jim,
@jim@programming.dev avatar

The first way to use it is with any type annotation: you just use it for documentation.


<span style="color:#323232;"># int annotation
</span><span style="color:#323232;">def add_1_to_number(x: int) -> int:
</span><span style="color:#323232;">    return x + 1
</span><span style="color:#323232;">
</span><span style="color:#323232;"># callable annotation
</span><span style="color:#323232;">def printer(x: int, func: Callable[[int], int]) -> None:
</span><span style="color:#323232;">    results = func(x)
</span><span style="color:#323232;">    print(f"Your results: {results}")
</span>

These type annotations can help document and make editors parse your code to make suggestions/auto-complete work better.

The second way to use it is by creating a callable. A callable is an abstract base class that requires you to implement the __call__ method. Your new callable can be called like any function.


<span style="color:#323232;">class Greeter(Callable):
</span><span style="color:#323232;">
</span><span style="color:#323232;">    def __init__(self, greeting: str):
</span><span style="color:#323232;">        self.greeting = greeting
</span><span style="color:#323232;">
</span><span style="color:#323232;">    def __call__(self, name: str):
</span><span style="color:#323232;">        print(f"{self.greeting}, {name}")
</span><span style="color:#323232;">
</span><span style="color:#323232;">
</span><span style="color:#323232;">say_hello = Greeter("Hello") # say_hello looks like a function
</span><span style="color:#323232;">say_hello("jim")  # Hello, jim
</span>
jim,
@jim@programming.dev avatar

I feel the opposite. We should have mandatory voting for all federal general elections. Treat it like jury duty or taxes - voting is a civic duty. You should be compelled to cast a ballot even if you leave it blank because you have no preference.

Of course, this can only workwith automatic voter registration and 100% mail-in ballots.

jim,
@jim@programming.dev avatar

"I can read this Perl scrip"t should translate to “I’m lying”.

jim,
@jim@programming.dev avatar

Most of us have bad memories of over-complex hierarchies we regret seeing, but this is probably due to the dominance of OOP in recent decades.

This sentence here is why inheritance gets a bad reputation, rightly or wrongly. Inheritance sounds intuitive when you’re inheriting Vehicle in your Bicycle class, but it falls apart when dealing with more abstract ideas. Thus, it’s not immediately clear when and why you should use inheritance, and it soon becomes a tangled mess.

Thus, OO programs can easily fall into a trap of organizing code into false hierarchies. And those hierarchies may not make sense from developer to developer who is reading the code.

I’m not a fan of OO programming, but I do think it can occasionally be a useful tool.

jim,
@jim@programming.dev avatar

Lots of people here lamenting about this. But the truth is that good code is easy to modify/delete.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • random
  • uselessserver093
  • Food
  • aaaaaaacccccccce
  • test
  • CafeMeta
  • testmag
  • MUD
  • RhythmGameZone
  • RSS
  • dabs
  • KamenRider
  • TheResearchGuardian
  • KbinCafe
  • Socialism
  • oklahoma
  • SuperSentai
  • feritale
  • All magazines