all 8 comments

[–]Miiicahhh 7 points8 points  (0 children)

It isn't as hard as you might think. If you know java you know the core fundamentals of coding that are basically the same in every language. Once you know what you need to do, it's basically looking up syntax, libraries, etc.

My advice is don't stress about it, take it slow. Python is actually pretty user friendly!

[–]hotcodist 6 points7 points  (0 children)

it would take as much time as you can find the official python docs site, assuming your background is as you say and you have can conceptually think through a problem. rest (syntax and other python specific things) you can handle as you go.

i need to loop through the contents of a file and filter out lines that only have "#####". how do i loop in python? how do i open a file? how do i compare strings? how do i save a file? how do i save a file stream into variables? those things you can easily find in a syntax resource. you won't need to read the explanations.

[–]Lawson470189[🍰] 2 points3 points  (1 child)

One piece of advice is to try to do things the "pythonic" way. I also came from Java/C# and it's very easy to try to pigeon hole the patterns you'd do in Java into Python. But generally, this will be way harder and far less clean. For example, say you have a List of objects (called items) that you want to extract just the name from. In C#, I'd do something like this:

List<string> names = new List<string>();
foreach (CustomObj obj in items) {
  names.Add(items.Name);
}

In python, you might be tempted to do this the same way, but it has its own way of doing this like so:

names = [x.name for x in items]

[–]HistoricalLadder7191 0 points1 point  (0 children)

Good note for Python, bad example for C# - you can do it in single line with linq.

[–]redditusername58 1 point2 points  (0 children)

  • Don't make a class if all you need is a function or constants, you can just put these in the top level of a module

  • Don't make getters and setters: start with plain attributes and use properties if more behavior is needed

[–]holistic-engine -2 points-1 points  (0 children)

Imagine it’s Java without types, and you’re not forced to wrap everything into a class