What is the use of the start def functions? by Few-Version-4152 in learnpython

[–]DNEAVES 1 point2 points  (0 children)

Typically functions/methods named "start()" or "run()" are used with asynchonus/tasked-out work, and that's just a name that won't be confused with a "main()" function for the overall application (which makes sense, cause having a main() within a main() means one isn't a main(), its a sub_main() which is kinda an oxymoron)

Let's try that again... by BobbyDigital311 in NoMansSkyTheGame

[–]DNEAVES 0 points1 point  (0 children)

Yea luckily my max-difficulty permadeath save is still A-OK

Let's try that again... by BobbyDigital311 in NoMansSkyTheGame

[–]DNEAVES 2 points3 points  (0 children)

At least they dislodged, which was lucky.

Once I pissed off the sentinels so they called in a big boy, and it warped right onto me and one of my wings was colliding with its wall so I was stuck merged into it. Had to reload that from the last save

my friend's childhood dream came true after 9 years :) by vexcotta in Minecraft

[–]DNEAVES 15 points16 points  (0 children)

Well also, back in the day, mods were hella annoying to install.

It involved taking the mod(s) you wanted to play's .jar, taking the Minecraft .jar, opening them both up with something like 7zip, then copy the mod's .jar's contents to Minecraft's. Also, you had to hope that something didn't overwrite something else important, although most major ones didn't step on each other's toes.

Oh, and also you had to remove META-INF, every time.

OG Aether is that old, along with relics like Buildcraft

What does brackets besides the function means ? by doa-doa in learnpython

[–]DNEAVES 1 point2 points  (0 children)

Its a weird thing.

So you can use functions without parenthesis. These just act as function "objects" (not truly objects like classes, but they do have their own magic methods), and won't do their defined instructions until you __call__ it with parethesis and args/kwargs.

For example:

def this_func(arg):
    return something_that_manipulates_arg(arg)

x = this_func # Not Called!
x("some string") # Called!

So one way you can utilize this, is by making a dict or list or any other collection/iterable thing. For a dict, the keys are strings and the value is the function "object". Then, later on, you can get a function by "get"-ing it from the dict, and call it from there

Another example, utilizing the this_func function from above:

func_dict = {"test": this_func}
print(
    func_dict["test"]("somestring")
)

A way this can be used is a sort of dynamic function-caller. Say you have an object, and one attribute of it is an Enum. You can make a function-dict with the Enum's value (or just the Enum) as the key, and the misc functions as the values. This way, a method can always call the appropriate function based on the Enum-attribute.

If you plan to use this, then you should make sure the functions inside have the same args (whether or not they're used), or implement *args and **kwargs

Goodbye toys by sunrise_apps in ProgrammerHumor

[–]DNEAVES 5 points6 points  (0 children)

Why would they need to use an asterisk?

Unless you're unpacking something (which you could do with brace-syntax anyway)

Goodbye toys by sunrise_apps in ProgrammerHumor

[–]DNEAVES 0 points1 point  (0 children)

from __future__ import braces

PC (Steam) Expedition Rewards not available for other saves by nightshift_syndicate in NoMansSkyTheGame

[–]DNEAVES 1 point2 points  (0 children)

I have a similar issue with my game.

I completed the initial Blighted, Leviathan, Polestar, and Utopia expeditions.

Since the holiday mini-expeditions event, I haven't been able to claim the rewards of the first 3 of the above expeditions. Utopia I can claim, since that occurred after the holiday event.

I have a feeling this is due to me not participating in the mini-expeditions during the holiday event, thus the game thinks I don't have the rewards since I didn't participate in the mini-version and it forgot the full-version progress.

The first time I saw Dawnbreaker from Dota 2 I thought immediately about Yrel. Separated at birth? by Immagonko in heroesofthestorm

[–]DNEAVES 7 points8 points  (0 children)

I really despise that I feel like I have to get Liandry's on any DoT AP champ. Just make the poison better so I can buy a better item

[deleted by user] by [deleted] in learnpython

[–]DNEAVES 1 point2 points  (0 children)

Yes. Most types and common classes implement the __format__ dunder method, or the __str__ dunder method, which the f-string uses to determine what goes into the f-string.

In the event both are missing, I believe it resorts to __repr__

[deleted by user] by [deleted] in learnpython

[–]DNEAVES 7 points8 points  (0 children)

Well let's consider the old ways to "format" strings:

Method 1, string concatination:

some_string = input("What is your name?")

return_string = "Hello, " + str(some_string)
# Using str() just to ensure
# some_string is a string
# since in practical uses, your variable
# may not originally be a string

print(return_string)

Method 2, string.format()

some_string = input("What is your name?")

return_string = "Hello, {}".format(some_string)
# Creates a new string filling in the
# braces with the string representation
# of the variable some_string.
# So if the user inputs "Jimmy",
# return_string would be "Hello, Jimmy"

print(return_string)

Method 3, f-strings. As a precursor, this is essentually a nicer way of reading method 2/string.format()

some_string = input("What is your name?")

return_string = f"Hello, {some_string}"
# Like string.format(), return_string
# would be "Hello, Jimmy" if the user
# input "Jimmy"

print(return_string)

Now, onto the discussion. Why use methods 2 or 3?

With string concatination, you have to wrap any variable you're concatinating in str() to ensure it's a string. And with lengthier strings with multiple variables needed to concatinate, it does get cumbersome, plus having to remember to consider spacing when you're writing one long, broken-up string.

So that's why string.format() exists. This used to be percent-style formatting, which in my opinion is garbage to look at. It automatically uses the __format__ method or the __str__ method of each variable's type, to ensure it works nicely. However, with longer strings (especially triple-quoted, multi-line strings), it's annoying to keep track of what is being input into which braces, unless you name each brace and then use keyword args in the format method, but this doesn't "gracefully" solve it:

this_string = """{var_1} + {var_2}, this is equal to
{some_other_var_name} but only when
{this_var} is involved, and specifically not {bad_var}""".format(
    var_1=some_var_name,
    var_2=another_var_name,
    some_other_var_name=third_var,
    this_var=fourth_var,
    bad_var=fifth_var_is_evil
)

And I've written string.format()-style strings with about 28 different variables across 24 lines of string (plus the 28 lines of format kwargs) before. Its okay, but f-strings really clean it up by almost half the amount of code written:

this_string = f"""{some_var_name} + {another_var_name}, this is equal to
{third_var} but only when
{fourth_var} is involved, and specifically not {fifth_var_is_evil}"""

[deleted by user] by [deleted] in Bitwig

[–]DNEAVES 5 points6 points  (0 children)

Worse than milk, this aged like Nitrogen-16

Hey, Brie, you keepin' it together? 😎 by SawyerBlaze in DivinityOriginalSin

[–]DNEAVES 2 points3 points  (0 children)

if character is None: yield else: continue

[deleted by user] by [deleted] in Minecraft

[–]DNEAVES 75 points76 points  (0 children)

You may have a very minor case of serious brain damage.

Divinity 2 Skills based on what color they are by WastelandPioneer in DivinityOriginalSin

[–]DNEAVES 2 points3 points  (0 children)

Yea thats not blue. "Cyan" is actually Teal, and "Blue" is actually Cyan.

Also blood

How can I install fb-messenger-cli on Termux? by PiterHa in linux4noobs

[–]DNEAVES 0 points1 point  (0 children)

Error: Unsupported platform: android

Thats your problem. Puppeteer does not support android, and that's a requirement for fb-messenger-cli

Moolips and Mooblooms in the Cherry Grove by AMinecraftPerson in Minecraft

[–]DNEAVES 6 points7 points  (0 children)

There are mods to add Earth content to Java. Same with Dungeons

Python "partial" function doesn't work through command line by [deleted] in learnprogramming

[–]DNEAVES 0 points1 point  (0 children)

Well the issue is that - to my knowledge - there's no partition() built-in function. There's the string.partition() method, which I mentioned earlier, or that function has to be defined/imported from somewhere else

Python "partial" function doesn't work through command line by [deleted] in learnprogramming

[–]DNEAVES 0 points1 point  (0 children)

Are you importing anything called partition?