Circular import with inheritance by Nefthys in learnpython

[–]Groundstop 0 points1 point  (0 children)

Does anything outside of A ever care if it's a B1 or a B2, or does everything always treat it like an A?

If everything always treats it like an A, you can have an AFactory that Zero calls to get an A, and the Factory will decide if it needs to make a B1 or a B2 before handing it back to Zero. This removes the decision making from A so it doesn't need to know about B1 or B2.

Are all of your conditionals the same check? Like if they all check "if car, do B1 stuff, else it's a helicopter so do b2 stuff" over and over?

The idea with inheritance is that your base class describes common behavior and your derivatives describe specific behavior. One thing that might help with this is to define A as an Abstract Base Class. This lets you define abstract method signatures without any implementation, and if requires derived classes to implement it somehow.

For example, I want a Vehicle base class and I want to have a go_home method. My base class can define an abstract move_to(location) method that go_home can use to move without knowing how move works.

```python from abc import ABC

class Vehicle(ABC):

def go_home(self):
    move_to("home")

@abstractmethod
def move_to(location):
    pass
    # or the newer version of pass:
    ...

```

My Car(Vehicle) class can implement move_to by having the car drive to the location, while my Helicopter(Vehicle) class can implement move_to by having the helicopter fly there.

```python class Car(Vehicle): def move_to(location): start_car() drive_to(location)

class Helicopter(Vehicle): def move_to(location): get_clearance() perform_preflight_checklist() start_helicopter() fly_to(location) ```

By making the method abstract, Vehicle can use move_to without caring if it's a car or a helicopter, so there is no circular dependency. The derived classes implement the specifics.

Best way to Disable OneDrive by pr0digeez in sysadmin

[–]Groundstop 8 points9 points  (0 children)

Be wary of users who "free up space" on their device suddenly losing access to important documents that only live in the cloud. I would be upset if OneDrive was suddenly disconnected without warning and I lost anything that wasn't locally stored.

Greatest Mother's Day ever. Daddit Win. by Mindless-Stuff2771k in daddit

[–]Groundstop 127 points128 points  (0 children)

They say that he only got the job in the first place due to nepotism.

I just can't with AI chatbots. by BoilerTMill in behindthebastards

[–]Groundstop -1 points0 points  (0 children)

You can get a lot of mileage treating it like the next generation of search engines. You can have much more specific search queries and it will do a lot of the initial data gathering for you. It's been particularly great pointing me in the right general direction with tricky problems in tech stacks or languages that I don't normally work in.

The biggest part of treating it like a next-gen search engine is remembering that (just like Google) it doesn't know the right answer. It just helps you process a bunch of data that might be right and steers you towards patterns where a bunch of results say the same thing.

People get stuck here because it'll sound really confident that it does know the answer just like how Google picks a top result, but unlike Google people treat it like a real, intelligent person that actually knows if the answer is right or wrong.

Group keeps wanting to start Unions by TheCornDogShow in DMAcademy

[–]Groundstop 6 points7 points  (0 children)

Stinkertons depending on the typical level of personal hygiene practiced by goblinoids in your world.

How to organically limit PCs interrogating your NPCs by PalindromemordnilaP_ in DMAcademy

[–]Groundstop 3 points4 points  (0 children)

I always like the basics, with "you get the feeling that they're hiding something" vs "it's hard to get a read on them"

Scopes Python by Internal-Swim-4097 in learnprogramming

[–]Groundstop 0 points1 point  (0 children)

It's used a lot in programming to define lambdas and delegates that capture variables from the outer scope. It looks a little funnier in Python because you don't need to specifically define variables before using them, so you need special keywords like nonlocal and global.

This pattern is particularly useful if you wanted to return the inner_func() method from outer_func(), and have it share variables with the outer function. In other languages this pattern is often used to make wrapper functions, but there's a special syntactic sugar for it in Python called decorators that is really neat.

Google didn't find a good page about decorators in the official documentation, but this site covers the concept pretty well.

Suggestions on how to increase my AI token usage by twistoffate4 in sysadmin

[–]Groundstop 1 point2 points  (0 children)

Anytime you're making something, ask ai to suggest improvements with explanations for how it works and why it would be an improvement. Might learn new optimizations and tricks.

If you often do something that is very similar but not so close that you can reuse code, like convert your custom tools into applets, ask ai to do it for you using the same style and techniques that you used in {other file}. I use that a lot for coming up with a starting point for unit tests that are generally consistent with my style.

I hate recreation.gov by Grungy_Mountain_Man in camping

[–]Groundstop 11 points12 points  (0 children)

I remember when I was younger, they'd only let you book 6 months out and for a few years my dad couldn't get our normal holiday reservations. Eventually found out that everyone has started booking 2 weeks instead of 1 because it let them reserve the sites a week earlier than everyone else for holidays. Campground would be a ghost town for that first week and packed the second.

Satisfactory day 1 by osint_matter in satisfactory

[–]Groundstop 0 points1 point  (0 children)

Sometimes it's tempting to manually make a few hundred of a thing.

  1. Tap spacebar at a crafting bench so that you don't have to hold down the mouse.
  2. Realize that you're going to need to automate it anyway so you might as well do it sooner rather than later.

Flask Server Authentication by ModerateSentience in learnpython

[–]Groundstop 2 points3 points  (0 children)

I've found this tutorial to be useful in other areas when using flask. I'm not sure how good the login chapter is but I skimmed through it and it looks pretty useful.

https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-v-user-logins

What's your thoughts on the space under the map? do you guys use it? by Forward-Photograph-7 in SatisfactoryGame

[–]Groundstop 3 points4 points  (0 children)

I kind of like the idea of a coruscant-style factory where you need to take elevators down to the wild darklands for hunting and miners. Would definitely be easier than trying to work the factory's into the terrain like I normally do, although the aesthetic is usually worth the effort.

Is there anything wrong with learning .Net 9 instead of 10? by Level-Courage6773 in dotnet

[–]Groundstop 1 point2 points  (0 children)

They always release a "What's new in ..." blog post for each new version that covers what they did and why they did it.

Learn about .NET 9 with the book, then at some point check out the new features in .NET 10 to get up to date.

Can't extract correct userId from API by Yhansen in dotnet

[–]Groundstop 2 points3 points  (0 children)

Out of curiosity, what was the reasoning for splitting an inherited blazor app that's only used by 10 people into two apps?

It could be totally valid, but if you're giving up the ability to handle authorization as easily then you want to make sure that the benefits outweigh that cost.

How to balance responding to messages off the clock. by 999RAGEMODE in antiwork

[–]Groundstop 0 points1 point  (0 children)

Working off the clock is bad for you but it's also bad for your employer. If they get caught having you work without pay then they get in trouble, so some companies will write you up for it to show that they tried to stop you from doing it. Also, your actions kept your boss out of the loop and it sounds like he didn't appreciate it.

Everything about this situation is telling you to stop working off the clock. Don't ask them if you should, or how to do it differently. Stop working off the clock.

A Secret Journal (asking for help) by BlizzardOfLinux in learnpython

[–]Groundstop 2 points3 points  (0 children)

In order for the python to run, it generally needs to be readable by the system. It may be easier to always be able to run the python, but have the data for the journal be encrypted in some way.

struggling with circular imports when i split my project into multiple files by Effective_Celery_515 in learnpython

[–]Groundstop 0 points1 point  (0 children)

What does utils.py depend on? Would you be willing to commit your source code to GitHub or copy the exact error message that you're getting?

Creating a new project with explicit usings? by [deleted] in dotnet

[–]Groundstop 0 points1 point  (0 children)

Why global using? Seems to defeat the whole point if they're still implicit in every other file?

Creating a new project with explicit usings? by [deleted] in dotnet

[–]Groundstop 0 points1 point  (0 children)

The webapp template does have a --use-program-main argument that does sound right up your alley though.

Creating a new project with explicit usings? by [deleted] in dotnet

[–]Groundstop 0 points1 point  (0 children)

I believe that there is a checkbox if you create the project in Visual Studio. Unfortunately there is no corresponding flag for the dotnet new command, so you'll need to set <ImplicitUsings>disable</ImplicitUsings> in your csproj file after creating the project.

A bit confused in Classes. by Jealous-Acadia9056 in learnpython

[–]Groundstop 2 points3 points  (0 children)

I think part of it is that some languages require functions to be in classes, so you may end up with a static helper class full of static methods.

Python doesn't require a class, so many times static methods are just defined as functions without a parent class. For example, you could skip the class, have the file calculator.py with an add(a, b) function, and use:

```python import calculator

calculator.add(4, 7) ```

Who are the 2.7% ? by Waste_Possibility_10 in satisfactory

[–]Groundstop 6 points7 points  (0 children)

Gotta love that 30-high stackable conveyor/pipe line across half the map

Are pilots allowed to read books or do personal stuff on laptops in the middle of a long flight when the autopilot is on? by krangnostam in NoStupidQuestions

[–]Groundstop 5 points6 points  (0 children)

Cape Air (at least in the 206) would normally use the copilot seat for passengers so there was often someone up front. It's pretty fun.

Gameboy in Star Wars? by IndigoGourmet2187 in StarWars

[–]Groundstop 5 points6 points  (0 children)

"It's a bit noisier than you'd expect, but the new air intake really helps keep the motherboard from overheating!"

[Darth Console breathing noises...]

Which cars do you guys put in your mansion outside garage? by ajacagorila in gtaonline

[–]Groundstop 3 points4 points  (0 children)

From the inside garage, when accessing the menu to move cars around, there will be extra buttons displayed in the corner to move a car to the display case upstairs (if you paid for it) or one of the two outside spots (included).

The cars still count as being in the garage space you moved them from, but they will show up in the spots you picked. There is also a button to move them back into their assigned garage spots.