Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

pdpinch

  • 2 years ago

Are list comprehensions in Python worth the effort? They seem like fun brainteasers, but once I write the code down it looks illegible to me -- even it works. It reminds me of some of the unmaintainable code I wrote in Perl years ago.

  • This Question is Closed
  1. Screech
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    That's why the "comment" statement was invented. Just because the code works doesn't mean your job is done. Arcane coding should also include some explanatory comments to help out the next programmer to come along (which might be yourself in 6 months).

  2. Shadowys
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Aye, you can use comments to explain it. List comprehensions save a whole lot of space and speed, ideal for some very complex programming.

  3. andrew.m.higgs
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Perl code, unmaintainable?? :-)

  4. Screech
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I never found Perl unmaintainable. In fact, after a bit of effort, it became easy to read and I always had to remind myself that others were not coming in with the same background. Thus, its still a good habit to comment and document techniques which might be tricky or just out of the ordinary.

  5. andrew.m.higgs
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Yeah. Like regular expressions....:-)

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.