"...actually, maybe I shouldn't be giving this particular advice."


Underwear for people with penises, printed like an old British police box

(the implication is that it's bigger on the inside than it looks from the outside)

Hey Switch owners, tell me about Bug Fables.

A friend of mine is looking for help setting up a video streaming server. This is paid work! DM if you're interested. :boost_ok:

re: maybe long? Python 

@InspectorCaracal that is an excellent added benefit, yes. :)

Oh, another habit you might appreciate, given what you just mentioned: when I'm writing a script, I'll often set DEBUG=True near the top of my scripts, and then define a function like this:

def debug(msg):
print(f"DEBUG: {msg}")

and use that to print out status messages from my functions. It makes it easy to turn the status messages on and off, and it makes it easier to clean up later since I can search for a term for the status printer that I'm not using anywhere else. :)

@goodberry Over the years I've been on Linux there has been so much that I've had to fiddle with, poke at, and prod, not just to get it the way I want it but to get it to work properly at all, that it'd take too long to list. x_x

re: maybe long? Python 

@InspectorCaracal You don't have to make the function main(), either - you can have different functions depending on what arguments you pass to the script, or whatnot.

And of course, you can also just ignore this completely and write the script in the PHP fashion, and it'll work just fine!

maybe long? Python 

@InspectorCaracal Oh, speaking of main(): actually, there is a practice that I've gotten into the habit of that might help you feel better about Python (that's going to require some explaining, hopefully it's all simple):

In Python, you can import another script just by saying import <relative path to script>, except you change all the slashes to periods and exclude the extension. So if I'm in main.py and I want to import assets/helper.py, I write import assets.helper .

One of the benefits of this is that any script can be imported into another one, and so you might need a way to tell whether you're running the script as an import or from the command line. Python gives you a way to deal with this: if you're running from the command line, it assigns the value "__main__" to the magic variable __name__.

So at the bottom of any script that I think I might run from the command line, I put something like this:

if __name__ == "__main__":

And then I define a main() function that has all the stuff I want to run if I'm invoking the script directly. That way, the whole script can be imported separately if I want to pull it into something else, but it'll only do the chunky bits if I'm invoking it directly.

@InspectorCaracal @monorail In Python, it runs from top to bottom, but functions are hoisted so you can access them anywhere regardless of where in the source they're defined.

@monorail @InspectorCaracal it's how you'd print them out in a list, like

["Bob", "Alice", "Sam"]

0. "Bob"
1. "Alice"
2. "Sam"

(lmao fuck off markdown)

@mint @pocketghosts they are excited for the release of the Xbox Series S

what are they excited about, wrong answers only please (thx for the doodle @pocketghosts)

Show more
Elekk: Gameing and Other Delightful Pursuits

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!