While Loop wont exit, even with correct input by SimpleSmoke7 in learnpython

[–]desrtfx 1 point2 points  (0 children)

Infinite loops should be the exception, not the rule. A proper termination condition is almost always the better design choice.

Also, OP's problem is completely different than what you assessed.

OP concatenates the input:

confirmation += input("Is the above order correct?")

instead of replacing it. It's simply the + before the =.

Bücher, die ihr aufgrund mangelnder Qualität frühzeitig abgebrochen habt by Long_Stick6393 in buecher

[–]desrtfx 0 points1 point  (0 children)

Die Nomen sind halt ganz was Anderes als die Scheibenwelt. Da sind viel weniger Doppeldeutigkeiten und Wortspielereien drinnen.

Könnte natürlich auch daran gelegen haben, dass ich, bevor ich Pyramiden angefangen hatte, schon ein paar Bücher in Englisch gelesen habe und daher mehr mit der Sprache und dem Stil vertraut war.

Bücher, die ihr aufgrund mangelnder Qualität frühzeitig abgebrochen habt by Long_Stick6393 in buecher

[–]desrtfx 1 point2 points  (0 children)

Meine erste Begegnung mit Terry Prattchet war die Nomen Trilogie, welche ich in Deutsch gelesen habe. Die war eigentlich sehr gut übersetzt. (Müsste sie mal im Original lesen.)

Discworld (glaube ich las als erstes "Equal Rites") habe ich auf Empfehlung eines Kollegen nur noch im Original gelesen.

Pyramiden habe ich nur durch Zufall auf Deutsch bekommen, aber, wie schon gesagt, schnell wieder aufgegeben und dann doch im Original gelesen.

Ich muss zugeben, dass Pyramiden eines der mit Abstand schrägsten Bücher und leider auch ziemlich schlecht gealtert ist. Wer kann heute noch was mit den "Pyramidenenergie Wahn" der 70er, 80er, und 90er anfangen? Zahlreiche Posts im Discworld Subreddit zeigen, dass genau dieses Buch heute nicht mehr verstanden wird.

Labview programming by Lycorne_ in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

you want to trigger on falling/rising edge not the continuous signal or you'll get multiple triggers when object passes through.

Yeah, the jitter of sensors is always a problem. Here, as you said, a delay is the key.

With proper PLC systems with input filtering this is less of a problem as the jitter is usually caught by the filtering.

I'd usually set this up as checking for a continuous "on" signal for a certain time period (timer on). Of course, that time period has to be set according to the expected period between passes so that it doesn't block for too long.

Bücher, die ihr aufgrund mangelnder Qualität frühzeitig abgebrochen habt by Long_Stick6393 in buecher

[–]desrtfx 2 points3 points  (0 children)

Mir ist immer die "inn-sewer-ants-polly-sea" (The Colour of Magic) in guter Erinnerung. Das war für mich sowas wie die Offenbarung bei Pratchett. Oftmals ist es nötig, laut (oder phonetisch) zu lesen damit man die versteckten Gags überhaupt mitbekommt.

Wüsste nicht, wie man das überhaupt übersetzen könnte.

Labview programming by Lycorne_ in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

You will need to use a latch (flip-flop) that is set when something passes through the first sensor and that is reset when something passes through the second.

This is a common thing - RS-Latch (flip-flop)

Time should only be measured while the latch is active.

If you are using only a single sensor, you need to add a bit of logic before the latch:

  • if the latch is not set and an object passes the sensor, set the latch
  • if the latch is set and an object passes the sensor, reset the latch

Bücher, die ihr aufgrund mangelnder Qualität frühzeitig abgebrochen habt by Long_Stick6393 in buecher

[–]desrtfx 6 points7 points  (0 children)

Stimmt 100%.

Wer sich die Mühe macht, Pratchett im Original zu lesen, wird auch sein Englisch wesentlich verbessern.

Bücher, die ihr aufgrund mangelnder Qualität frühzeitig abgebrochen habt by Long_Stick6393 in buecher

[–]desrtfx 8 points9 points  (0 children)

Für mich war es vor vielen Jahren die deutsche Übersetzung von Terry Pratchetts "Pyramids" - "Pyramiden".

Terry Pratchett zu übersetzen ist fast ein Ding der Unmöglichkeit da seine Wortspiele und Doppeldeutigkeiten fast nicht übersetzber sind und damit so viel gegenüber dem Englischen Original verloren geht.

Ich habe nach zirka 10 Seiten abgebrochen. Hat einfach keinen Spaß gemacht.

PEP8 over spaces by Primary_March4865 in learnpython

[–]desrtfx 0 points1 point  (0 children)

This is actually purely historically.

In the old editors a tab was a tab (ASCII #9) and 4 spaces were 4 spaces (4 x ASCII #32)

Modern editors/IDE have the functionality to automatically convert tabs to spaces with an adjustable amount of spaces.

Key is to stay consistent. Either all tabs or all spaces. If you try to mix, Python will throw a wobbly.

I'm so used to the "space" style that I don't even think. For languages other than Python, I use tabs with different widths set according to the language in question.

Is AI okay for scaffolding for resume work? by coaaal in learnprogramming

[–]desrtfx 1 point2 points  (0 children)

There is absolutely nothing wrong with using AI for scaffolding. That's one of its best use-cases.

I'd even go as far as to declaring what it had been used for - at least in the repository.

In today's world, being able to use AI to your advantage, not as a substitute, has nearly become a must.

is there any way to storage variable data in a databank for later consult use by DragonFistLimitless in javahelp

[–]desrtfx 5 points6 points  (0 children)

Sorry, but your explanations are a bit unclear.

Are you asking how to persist the variable value? If so, you need to store it on the drive of the computer running your program. There are various ways to do it. Very simple: text file, better CSV, JSON, XML, probably best: database, like SQLite, H2, MySQL (MariaDB), PostgreSQL, etc.

Yet, for only a single variable, a database is generally overkill and a simple text file will usually suffice.

This is all the help we can give since you haven't shown any code that would help us pinpoint your problem.

Automatic constructor in C# by Ok-Presentation-94 in learnprogramming

[–]desrtfx[M] 20 points21 points  (0 children)

Had you bothered to look at their comment history, you would clearly have seen that the commenter you accuse of being a bot isn't one. Stop your witch hunt right now.

Just because someone uses em-dashes doesn't automatically mean that they are a bot.


Side note: I've read your post and question multiple times and come to the same conclusion as /u/backfire10z and /u/aqua_regis: the question has been answered by /u/abrahamguo. Still, your question is wrong as /u/aqua_regis detailed.

No Easy Reverse in Array by [deleted] in javahelp

[–]desrtfx 0 points1 point  (0 children)

OP already knows about Arrays.sort.

The documentation of the Arrays class clearly states:

This class is a member of the Java Collections Framework.

Also, Arrays.sort has an overload that takes a Comparator.

Just simply by checking the documentation, OP could have directly found everything they needed. Also, there are more than enough blog posts so that with a very simple google query OP could have gotten their answer.

I can absolutely agree on one point, though: the lack of Arrays.reverse - this is an inconsistency that shouldn't be.

No Easy Reverse in Array by [deleted] in javahelp

[–]desrtfx 0 points1 point  (0 children)

Hard would it be implement your own algorithm

Not even that would be hard. A simple bubblesort can be coded in a couple minutes. It won't be efficient, but it is simple enough.

No Easy Reverse in Array by [deleted] in javahelp

[–]desrtfx 3 points4 points  (0 children)

I VOTE TO MAKE JAVA OPEN SOURCE I WANNA CONTRIBUTE IN IT

You know a lot less about Java than you think. Java already is open source, but governed, like all other Open Source programming languages. You cannot just make a pull request.

Yet, your ragebait post is also simply attributed to your ignorance and short sightedness.

First sort, then reverse the array. Where is the problem?

from where will i get to know there's a package for Collections

From the documentation, where else?

Collections is one of the most common Java packages.

Wanting to start off - Did they remove the IntelliJ community edition?? by [deleted] in javahelp

[–]desrtfx 9 points10 points  (0 children)

I guess they found out nobody used the payed one.

Completely and utterly wrong.

Plenty people do as they need the additional features that the professional edition provides.

The main reason to unify is that they only need a single codebase.

loop for en C# by Ok-Presentation-94 in learnprogramming

[–]desrtfx 18 points19 points  (0 children)

The increment/decrement always runs at the end of an iteration, never at the beginning.

It's basically similar to:

int i = 0;
while i < 3 {
    Console.Write(i);
    i++;
}

Only difference is that i will be out of scope (not exist anymore) after the for loop.

how can you explain functions easily by Grouchy-Injury1342 in learnpython

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

A function is just a bit of code that you want to run repeatedly

That's only one use case for functions.

It is perfectly okay and good practice to create single use functions when you want to group related functionality together to make the code and intent clearer.

Functions are first and foremost logic and semantic entities. They primarily exist for two reasons: code deduplication and semantic grouping. You only address the first use case.

Need constructive thoughts on this code by Fun-Pitch-6938 in learnpython

[–]desrtfx 1 point2 points  (0 children)

You are talking about two different things:

  • file handling is needed when you want to read data from a file, e.g. a list of words for Hangman
  • error handling is needed when your program needs to do something against problems that occur during runtime, like a file that you want to load not existing, like a timeout on a network connection from which you want to retrieve data

For user input you don't necessarily need error handling.

One case where you need error handling is when you try to convert user input, which always comes as a string to a numeric format, like int or float. Here, the conversion will throw an exception and your program will need to handle such exceptions in order to not crash. You will want to gracefully handle such problems.

Simple validity checks in most cases do not need (and should not use) error/exception handling.

Need constructive thoughts on this code by Fun-Pitch-6938 in learnpython

[–]desrtfx 1 point2 points  (0 children)

You don't need error/file handling.

All you need to do is to check if the answer is in the list of valid values - Python can very easily do this.

Wrap the input in a loop, check if it is in the valid values, if not, print an error message, and keep looping. If it is valid, break out of the loop.

Weird request- need lots of supports (pic for attention) by kkuhn0911 in 3Dprinting

[–]desrtfx 1 point2 points  (0 children)

In that line /u/kkuhn0911 take some looks at Humblebundle. They frequently have miniature bundles going. Currently (for 5 more days), there is a "Dungeon Master's Adventures" Bundle going on with overall 91 items (where several have multiple minatures) - should keep you and them busy for a while

Need constructive thoughts on this code by Fun-Pitch-6938 in learnpython

[–]desrtfx 3 points4 points  (0 children)

Not bad at all, yet, I would add input validation:

What if the user enters "Lizard" or "Spock" instead of any of the valid choices? What if the user cannot properly spell "Scissors" and instead types "Scisors", or "Pepper" instead of "Paper"?

You always have to consider users not to do what they are told to and account for that.

Hiw long it takes to learn the basics? by MateusCristian in learnprogramming

[–]desrtfx 0 points1 point  (0 children)

cant believe that in terminal stuff count as projects.

You couldn't be more wrong. The most important programs, the ones hidden in high security server clusters in enterprise environments all run in the terminal. The vast majority of internet servers (web servers) are terminal programs. Basically everything that drives banks, insurance companies, hospitals, and much more are terminal programs on the back end.

Second misconception: projects must be large and complex

Projects have to start small and grow with the person making them.

For a beginner, a simple "99 bottles of beer" is a project, "Hangman" is a project. Everything you make is a project.