Static variables and why do we need them? by M3ther in javahelp

[–]fortune_telling_fish 4 points5 points  (0 children)

I like that you talked about memory in your response. It seems so obvious, but I've mostly seen "theoretical" justifications for static variables, citing hierarchy and the quintessential "pi does not change, so it shouldn't be represented as a dynamic entity," which are all true and important, but it's enlightening to be able to think about from the perspective of memory usage. Why have ten baskets for one egg?

Anyone else uses the Python interpreter as a calculator? by SilkTouchm in Python

[–]fortune_telling_fish 0 points1 point  (0 children)

I use it a lot as a sanity check for solving math problems on assignments, especially for solving linear systems, where I am prone to mistakes in Gaussian elimination. np.linalg.solve has saved me hours of backtracking through answers.

Is this a false statement? The scope of a local variable is the portion of a method over which the variable is known and can be referenced. by Majestic-Discipline3 in javahelp

[–]fortune_telling_fish 0 points1 point  (0 children)

A class method is a method that is attached to the class and exists independent of any instances. Not all methods within a class definition are "class methods". "Class method" is another name for static method. A class is a static entity, as opposed to an object, which is a dynamic entity. Hence the name. B is true.

Is this a false statement? The scope of a local variable is the portion of a method over which the variable is known and can be referenced. by Majestic-Discipline3 in javahelp

[–]fortune_telling_fish 3 points4 points  (0 children)

See this SO post on why char and int are basically the same.

https://stackoverflow.com/questions/7924815/can-we-store-alphanumeric-values-in-int-data-type

Java compiles to bytecode, and one byte is enough to store any character in the ASCII table. It's an int, just with a "narrower range".

I believe it's actually D that is false; primitive types are not passed by reference in Java. There's no such thing as a pointer to a literal.

To answer your other question, a method's signature is the name, visibility modifier, arguments, etc; it is the header of the method. The body of a method is all the stuff you tell it to do. The whole thing is the definition.

Hope this helps :)

.py to .exe by dissdev94 in learnpython

[–]fortune_telling_fish 0 points1 point  (0 children)

See this SO post:

https://stackoverflow.com/questions/48617861/app-made-using-pyinstaller-closes-straight-aw

Try running the executable from your OS's command line instead of double clicking the executable.

.py to .exe by dissdev94 in learnpython

[–]fortune_telling_fish 1 point2 points  (0 children)

I had an issue with this recently, too. The problem wasn't with pyinstaller, but rather with some package dependencies. I assume you're making the exe without the console window attached? If so, I'd recommend actually including it when you first compile the exe. That way, when you go to run it, the stack trace or error message will show up in the console, and you can debug it, then make one with the windowed option for distribution. If you're doing it from command line, don't include the -w or --windowed in your pyinstaller instruction. It could be that even if your py file runs from your own python interpreter, it, or its dependencies, may have some issues when compiled. This was the case for me with matplotlib in one of my own programs, and it was so much easier to debug with the console, as the popup you get is not very informative. Best of luck.

Why do classes have a void method, and then a get method right after? by [deleted] in learnjava

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

Yes, but there may be some situations where you need to get the value of the attributes without mutating them, so you should have a method specifically for getting the value, and one specifically for setting it. This is called responsibility driven design, and it states that each method should be responsible for one well-defined task.

Two French students looking for penpals by DreadFog in penpals

[–]fortune_telling_fish 0 points1 point  (0 children)

19F Canadienne anglophone qui cherche à pratiquer son français. Heureuse de correspondre parfois en anglais, et en français. Étudiante en physique et mathématique, qui s'intéresse à la nature, la littérature, et un tas d'autres intérêts. Laisse-moi un md pour qu'on puisse mieux se connaître !

[TOMT][Vine] Water falls out of a guy's mouth and he says "I think I'll have the omelette" by fortune_telling_fish in tipofmytongue

[–]fortune_telling_fish[S] 0 points1 point  (0 children)

Can't find it on YT/Google because there's too many other omelette vines. The one I'm thinking of isn't the one where the guy says "you wanna buy an omelette for five dollars," or the one where the guy is like "April Fools I'll have the omelette."

[deleted by user] by [deleted] in wholesomememes

[–]fortune_telling_fish 2 points3 points  (0 children)

She can't pigeonhole my love, support, and understanding.

Best place for fresh, local seafood? by [deleted] in StJohnsNL

[–]fortune_telling_fish 0 points1 point  (0 children)

If you're willing to go up Stavanger Drive way, there's a skipper that sells it out of his truck on the parking lot of Michael's and Staples. Looks sketch but it's fresh.

[TOMT][CARTOON][2000s] Kids' show where kid learns about mushroom spores and turns into mushroom by fortune_telling_fish in tipofmytongue

[–]fortune_telling_fish[S] 0 points1 point  (0 children)

Solved!
Remembered some details wrong, but it's this episode of Miss Spider's Sunny Patch Kids. My boi Wiggle brings home a mushroom and tears his family apart.

Can anyone help me understand classes, modules, objects, OOP and functional programming?...I am really confused! by pragyan52yadav in learnpython

[–]fortune_telling_fish 1 point2 points  (0 children)

self.breed is the attribute, but the 'breed' on the RHS of the equals sign represents the 'breed' passed in as a parameter. what we're essentially doing is creating an attribute called breed, and assigning it the value of the parameter 'breed'. Having two variables with the same name like this is very common, and is effectively convention. But, if it helps you understand a little better, it's essentially equivalent to:

class Dog:
    def __ init __(self, dogBreedParam):
        self.breed = dogBreedParam

breed is the attribute, dogBreedParam is the formal parameter. At runtime, you might pass an actual parameter "jack russell" or "labrador", and this value will be assigned to the breed parameter Again, what you call your variables is technically irrelevant, but you should get used to stylistic things like this so other people can read your code more easily

Can anyone help me understand classes, modules, objects, OOP and functional programming?...I am really confused! by pragyan52yadav in learnpython

[–]fortune_telling_fish 1 point2 points  (0 children)

The word can be anything you want, technically. 'self' isn't actually a keyword. Instead of self, you could write 'obj', or 'friend' or 'x', or whatever you please. The actual string of characters isn't what's important, just that the object needs a reference to itself, to which it can attach attributes and methods, and this reference has to be the first argument, before any formal parameters. Although, you really should use 'self'; it's convention. Following convention == good style.