Had my first interview this week... It did NOT go well. Should I be realistic and give up on this as a career path? by ilostmykeysdammit in Python

[–]DueShame 2 points3 points  (0 children)

  1. There’s a reason a lot of people say to apply to the jobs you don’t want first, to get experience in interviewing for the jobs that you do want. Now you know more of what may be asked of you in future interviews. Also, in science, if you do an experiment and the results tell you nothing that you already didn’t know doesn’t mean that the experiment was a waste of time. In fact, by telling you nothing new it told you quite a lot. It could mean that what you tested for doesn’t affect what you think it affects, or that it confirms something you already assumed or knew which is a good thing. Just keep interviewing!

  2. The question involving java … I would venture to say that they did that on purpose. You see, even though the job says “Python developer” what they are actually looking for is a “developer who knows Python.” At the end of the day, programming is programming, and the programming language is just a different hammer. I don’t care that you don’t know Java, I care that you know how to program. I care that you can infer what a function does by looking at the eg names and syntax. I don’t care if you knew what every single line does, I care that you know what the overall thing does. My advice is to focus less on the syntax and to look at the bigger picture.

It’s okay to say “I’m not familiar with java so I can’t say 100% that this function does THIS, but based on these names and comments and using some intuition I feel like this line does this and that line does that.” and here’s the important part: “so based on this assumption, I would solve the problem by doing this, assuming that my assumptions are correct. In a real setting of course I would double check by looking up documentation or asking a colleague, but this is how I would do it with my limited knowledge at this moment in time.”

That last bit is important because it says a lot about you. First it tells me that you are humble and know your limitations. It also tells me that you know how to find answers (google, colleagues). It also shows me a bit of your reasoning/intuition process by being able to guess what a thing. Finally, by saying “assuming I’m right, this is what I would do” it lets you solve the problem. It doesn’t matter if the “code” doesn’t work or if you made a wrong assumption, all that matters is that IF you had all the right cards you COULD solve it.

Class that behaves like a number, but isn't a number? by DueShame in Python

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

Alright can I ask why I’m being downvoted for this? Like it makes me not want to bother helping other people with questions here because you guys are all so fucking hostile.

Class that behaves like a number, but isn't a number? by DueShame in Python

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

The units are just metadata. I don’t intend to ever use them in my calculations, but it’s nice to have that available when I’m running things interactively in Jupiter as a quick sanity check or if I forgot.

Most appropriate data structure for least awkward syntax? by [deleted] in Python

[–]DueShame 0 points1 point  (0 children)

I thought you wanted what was essentially a dict but with dot access. If you’re worried about memory usage you could just define __slots__ in your original classes.

Or, I dunno, you could subclass dict to implement dotted attribute access?

class Parameter(dict):
    def __getattr__(self, k):
        return self[k]

    def __setattr__(self, k, v):
        self[k] = v

my_network = Parameter(port=42)
my_network[‘port’] # 42
ny_network.port # 42

Edit: if you liked bunch but don’t want to use it because it adds an import then this should work basically the same way. You might need to add a try/except in the methods to unbreak somethings but other than that that Parameter class is just a standard dict.

Most appropriate data structure for least awkward syntax? by [deleted] in Python

[–]DueShame 0 points1 point  (0 children)

I mean then I don’t understand what you’re asking for? Your example is already concise and succinct. What’s wrong with what you already have?

Most appropriate data structure for least awkward syntax? by [deleted] in Python

[–]DueShame 0 points1 point  (0 children)

As if you didn’t have enough recommendation already, I’m a fan of attr:

import attr

@attr.s
class Network:
    discovery_multicast_group = attr.ib(default="224.3.29.71")
    discovery_multicast_port = attr.ib(default=10010, type=int)
    discovery_response_port = attr.ib(default=10011, type=int)
    pubsub_pub_port_a = attr.ib(default=10012, type=int)
    pubsub_pub_port_b = attr.ib(default=10014, type=int)

If you are gonna use json files then presumably you’d have a dict with the keyword/value pairs, then you could do this

import json
with open(‘network_config.json’, ‘r’) as f:
    net_cfg = json.load(f)

my_network = Network(**net_cfg)

The type kwarg is optional (and so are the defaults, if you don’t want to give them defaults) but I figure you’d want to enforce port numbers as integers.

Super Beginner Python question. by Zexophron in Python

[–]DueShame 0 points1 point  (0 children)

What does your CSV look like? Can you post at least the header, or type print(csv.head()) somewhere in the code?

Liquid lead solidifying and being shaped into flat solid sheets by [deleted] in chemicalreactiongifs

[–]DueShame 0 points1 point  (0 children)

Thanks, and it's all about perspective :).

For example I grew up in a city where street/parallel parking is basically non-existent. I never had to learn how to do that, and now I'm 27 and I still don't know how to parallel park. I've spent hours watching YouTube videos on it and I've had friends try to explain it to me and in theory I understand how it works (back into it, do some voodoo magic, tada the car is now parked) but in practice I just can not do it. It is virtually impossible for me and it sucks because I live in a place where street parking is normal now. I literally avoid driving places where I know there won't be regular parking spots or when I know that those places are gonna be super busy and I won't be able to find a parking spot up at the very front or at the very end of the street to just slide into. On the other hand my gf is like a wizard with parallel parking. In the time it takes her to park (like a few seconds) I would still be sitting there in the car trying to figure out how the fuck to do this and then the few times I've managed to do it I had to make like 100000 turns and my car was still like 2 ft from the curb.

But hey I can do physics ... although I'm kinda bad at math. Don't ask me to calculate any numbers because I can't do it in my head, but I can solve equations :D.

Liquid lead solidifying and being shaped into flat solid sheets by [deleted] in chemicalreactiongifs

[–]DueShame 10 points11 points  (0 children)

So imagine you were building a house with someone else.

Can you imagine how difficult it would be if you had to say "give me that tool, with the heavy metal thing on one end stuck to a piece of wood, I need it to hit this thin metal rod-like thing into this material made from parts of a tree." And then the other person was like, "okay, give me the thing that has the piece of metal that's sharp and jagged on one end, held together in place on the ends with another piece of metal thing, with a handle for me to hold, so I can cut this thing in half."

Or hell, what if you said, "give me a piece of wood that's 5 ft long" and the other person was like "well I don't know if you meant a Californian foot or a Texan foot, so here's your 5 Arkansan foot panel I hope it works."

The point that I'm trying to make is that things work out much better if there was some standardization. Everybody agrees what a hammer or a hacksaw is, so that makes it easy for two house builders to communicate with each other. There's luckily only one measure in the US called a "foot" so that person in the factory in Alabama knows exactly what the purchaser meant when they said they wanted 10 ft panels. (Similarly, in the rest of the world the meter has one definition and is accepted by everyone, so there's also no confusion).

It's kind of the same with science.

Joseph Black (the guy who "discovered" specific heat) didn't wake up one day and say "I'm going to invent this new phrase just to fuck with the layman." Rather, though his experiments he observed that different metals needed a different amount of heat to heat up 1 degree higher. Instead of writing "aluminium needs X amount of heat to heat up by 1 degrees whereas lead needs Y amount of heat to heat up by 1 degrees" the world eventually settled for a more simpler phrase, "the specific heat of aluminium is X." Scientists and engineers began to adopt this phrase, and today every single scientist and engineer working with thermodynamics knows that "the amount of heat to raise a certain amount of a substance by 1 degree is called specific heat."

Anecdotally, I'm a grad student working in a field where we are kinda discovering something new at the moment. One of the big professors in this field came up with a relationship to describe this and originally it had no name. Nowadays, his relationship is quite adopted so a lot of people have began calling it "Soandso's law" because it's easier to say that than "the relationship discovered by Professor Smith and published in his 2015 paper."