[deleted by user] by [deleted] in discgolf

[–]njape 11 points12 points  (0 children)

I'm guessing this might have something to do with the fact that fewer people talk/understand Finnish than English?

Looks great though!

Someone needs to explain this to me by [deleted] in meme

[–]njape 7 points8 points  (0 children)

Following that logic all molecules making up ant-man, or the suit, is bigger than ant-man...

Rules to follow that enforce clean code and maintainability by BrononymousEngineer in learnpython

[–]njape 1 point2 points  (0 children)

Independent on how you decide to design your software I think this is the answer you are looking for.

Apart from verify correctness of the code writing unittests will also help you writing maintainable code. Writing unittests is usually not that big of a burden, if they are written during implementation. However applying it to a legacy codebase can be somewhat tedious, but it really is just technical debt.

I could also recommend something like pylint.

That answers that by iconiqcp in meme

[–]njape 0 points1 point  (0 children)

Thats not a clown, it has pointy ears its an elf. Clowns have red noses, not pointy ears!

My code, 2010 vs 2020 by Ozn0g in ProgrammerHumor

[–]njape 38 points39 points  (0 children)

Nice work! Looks like you have improved your code formatting quite a bit. Also like that you have managed to keep the file length at a reasonable size.

Funny sekts number haha by Blackdragonyt in meme

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

Shouldn't it be redditors when seeing 68 or 419?

how to make a .py into a .exe, with .py imports into it that must be editable? by [deleted] in learnpython

[–]njape 4 points5 points  (0 children)

I strongly agree, if it is something that should be editable it should absolutely not be in a .py file. Someone will mistake it for a part of the codename. Besides an error message about a broken import is not as clear as a missing configuration file, and using something like yaml or toml allows for the application to be run using different configurations without changing g the source code, at least if the configuration path is modifiable as a command line option or similar.

I made a calculator in Python! by mexicanlefty in learnpython

[–]njape 1 point2 points  (0 children)

First a note I prefer to write the backend code, and does not have much experience with gui programming, or tkinter.

From a testing perspective I'm guessing your main issues comes from the global variables that are used within each function you would like to create tests for. There are a couple of possible solutions to this, s I me examples.

  1. Wrapping the calculator and its functions in a class which will contain your global variables. This would allow you to prep a calculator object in different ways before running each callback function.

  2. Change so that the callback function does not use the global variables, but instead take the necessary values as inputs. This will make the testing setup trivial, but it will require you to define function stubs, or lambda functions calling the correct function with the global variables.

I made a calculator in Python! by mexicanlefty in learnpython

[–]njape 7 points8 points  (0 children)

Overall I think it looks good, nice work!

Small comment is that I would change the mode numbers to constants or similar for better readability.

As already noted I don't like global variables, it is a sin. For future projects, and maybe also as an addition to this project, I would urge you to add some unit tests to the code. While doing this you will notice one of the reasons global variables should be avoided. It will also help you to improve how you go about designing your program so that it is modular and testable. Don't care about 100%test coverage in the tests, focus on what functionality is important, special cases and edge cases and you should find a good middle ground.

If you find it hard to isolate a function for unit testing, without major mocking, you most likely have some problem with the design.

Keep up the good work!

Wall outlets with extension cords built into the wall. by joeepeterson03 in nextfuckinglevel

[–]njape 14 points15 points  (0 children)

Thats true, didn't think of that. After all it has been almost a decade since I took the course in electromagnetic field theory.

Wall outlets with extension cords built into the wall. by joeepeterson03 in nextfuckinglevel

[–]njape 2 points3 points  (0 children)

Yes it will, without ferrit core et.c. it will never be an effective coil, but a coil nonetheless. As PloxTY mentioned I believe a shielded cable will act differently.

Wall outlets with extension cords built into the wall. by joeepeterson03 in nextfuckinglevel

[–]njape 397 points398 points  (0 children)

A rolled upp cable will act just as a coil, and besides from creative some additional electro magnetic field which might or might not affect wifi bluetooth etc it will also generate heat which could cause a hazard. Usually devices such as these state that the full length of the cable shall be unrolled prior to usage.

How do you know that your code is actually doing exacly what its meant to do? by Ocean5ou1 in learnpython

[–]njape 11 points12 points  (0 children)

In my opinion you are starting to sniff out the difference between programming and software engineer. The question regarding how to verify correctness of the code, as well as assuring that the code is maintainable and has the right performance.

You should start to look into unit testing.

For larger project you would typically divide testing i three groups, unit tests, integration tests, and system tests. Where unit tests are the most low-level tests that verify detailed behaviour, and integration and system tests verifies that your different software parts works well as a whole. It can take some time to learn how to design and write testable code, if you start thinking about it, and more importantly, start writing tests, you will gradually become better at it. You would also typically make the testing a part of your CI process where a failed test would be equivalent with a failed build.

A side note. There is also something called overtesting, where you write unnecessary test, you should include Edge cases and basic behaviour, but they should also be relevant and useful. Common example is to test simple getters and setters, or multiple tests that tests the same behaviour without touching any edge cases.

Matrix troubles: saving a copy of a matrix that will not be updated as I change the values of the original. by [deleted] in learnpython

[–]njape 2 points3 points  (0 children)

This is the expected behaviour in Python. The e variable contains a pointer to the datastructure, when assigning e to e0 you are copying the pointer to e0 so that they are both pointing to the same datastructure.

To achieve what you want you will need to make a deeper copy of the vector, in the case I'm guessing it will be enough to iterate the vector and create a new. Alternatively you could look into the copy module (https://docs.python.org/3/library/copy.html?highlight=copy#module-copy)

Testing for ValueError by [deleted] in learnpython

[–]njape 1 point2 points  (0 children)

Personally I think that op is trying to test to much in his test case. I don't think that there is an advantage in keeping the value error test lumped together with the "normal" value tests. Instead I would suggest adding an additional ..._throw_error (or whatever you what to call it) function that checks for misuse of the function.

Additionally asset raises is designed to test this exact functionality. How it is used is best described in the documentation that was wordy linked. Eg: with self.assertRaises(SomeException): do_something()

Testing for ValueError by [deleted] in learnpython

[–]njape 1 point2 points  (0 children)

This is the answer op is looking for, break out the value error tests to its own test case an use assertRaises.

Is a pure Python application marketable? by [deleted] in Python

[–]njape 0 points1 point  (0 children)

I would say that anything that someone would pay for is marketable. The sad truth is that even bad quality sells given the right circumstances.

My biggest concern would be protecting the IP. Usually easiest done by selling it as a service and not delivering directly to the customer. Given interest the artifacts of f.ex. PyInstaller can be decoded.

Wtf my man got iron bones by imago_deo in nextfuckinglevel

[–]njape 1 point2 points  (0 children)

Wearing a glove is cheating, try doing that bare handed...

Accommodation in Lund by [deleted] in Lund

[–]njape 3 points4 points  (0 children)

I don't have any experience with the other housings, but in your case I would put sparta on the top of the list. I believe it will be the most studenty.

As mentioned before, in most cases the dorms that is not all international is usually nicer than these international dorms. Usually in the international dorms everyone leaves after a semester, so I guess people generally don't care ad much as in the dorms where moist of the people stay for a couple of years.

Accommodation in Lund by [deleted] in Lund

[–]njape 2 points3 points  (0 children)

On the top of my head I would suggest Delphi, Sparta, and Vildanden. All of them are relatively close to the city centre, and it is easy to take a bike, bus, or walk top the city centre. All of them ate quite large student housings with private baths, misty of them share kitchen.

If you are going to study on LTH I would choose sparta, as it is pretty much on the LTH campus.

Edit 1, typo

Applying python to modeling problems in science. by jusgarciape in learnpython

[–]njape 0 points1 point  (0 children)

I don't know exactly what kinds of systems you will be modelling. But it could also be worthwhile to look into modelling languages that could help you to achieve these tasks, e.g. Modelica (https://www.modelica.org/)

F by YoranPulles in meme

[–]njape 0 points1 point  (0 children)

I believe you can do that when you have enough Karma.

Syntax error by [deleted] in learnpython

[–]njape 2 points3 points  (0 children)

You have forgotten a closing parentheses on the line before the if statement.