On 12/10/18 17:12, Rob Gaddi wrote:
On 10/11/2018 11:29 PM, Kaan Taze wrote:
Hi everyone,

Since this is my first post to mail-list I'm kind of hesitant to ask this
question here but as many of you spend years working with Python maybe some
of you can guide me.

What I trouble with is not a logical error that exist on a program I wrote. It's the Python itself. Well, I'm 22 years old CS student -from Turkey- and what they showed us at university was C Language and Java but I mainly use
C in school projects etc. So it's been few months that I started to use
Python for my personal side-projects. There are lots of resources to learn
language. I do what I need to do with Python too but I was kinda shocked
when I solve Python questions at Hackerrank. Even with list comprehensions
you can implement in very smart way to get things done and easy.
Iterations, string operations. The codes I see on the Internet using basics
in a very clever way which I couldn't come up with the same solution if I
tried to for some time. I do understand this ways but coming from ANSI C
makes it hard to see this flexibility. I probably do things in a both
inefficient and hard way in my projects.

How do I get used to this? Is this just another "practice, practice,
practice" situation? Anything you can recommend?


All the best.

Kaan.


A) Yes, it's practice practice practice.

B) Don't get hung up on finding the clever solution.  Comprehensions and generators and lots of other things are great under some circumstances for making the code clearer and easier to read, but they too can become the hammer that makes everything look like a nail.  The most important thing is that your code is logical, clean, and easy to understand.  If it doesn't take full advantage of the language features, or if the performance isn't optimized to within an inch of its life, well so be it.

I completely agree. I too have come from a background in C, and still do most of my day job in C or assembler. It took a while before I was writing idiomatic Python, never mind efficient Python (arguably I still don't, but as Rob says, who cares?). Don't worry about it; at some point you will discover that the "obvious" Python you are writing looks a lot like the code you are looking at now and thinking "that's really clever, I'll never be able to to that."

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to