[Tutor] RE: what i miss is a C style for loop & the python way

kevin parks kp87@lycos.com
Tue Oct 22 10:31:12 2002


Since i have started working with python, i find it hard to imagine missing anything from C!

Use what Python has for a few months and then tells us if you still miss some  feature of C or an aspect of C syntax. I bet you a bowl of kimchee stew you won't look back at nothing! Don't go through contortions to make Python syntax like what you are used to, rather make a few adjustments to Python's quirks and you will be writing real Python code, much more quickly. Remember, this isn't Perl. 

See Tim Peter's "The Python Way"

   1. Beautiful is better than ugly.
   2. Explicit is better than implicit.
   3. Simple is better than complex.
   4. Complex is better than complicated.
   5. Flat is better than nested.
   6. Sparse is better than dense.
   7. Readability counts.
   8. Special cases aren't special enough to break the rules.
   9. Although practicality beats purity.
  10. Errors should never pass silently.
  11. Unless explicitly silenced.
  12. In the face of ambiguity, refuse the temptation to guess.
  13. There should be one-- and preferably only one --obvious way to do it.
  14. Although that way may not be obvious at first unless you're Dutch.
  15. Now is better than never.
  16. Although never is often better than *right* now.
  17. If the implementation is hard to explain, it's a bad idea.
  18. If the implementation is easy to explain, it may be a good idea.
  19. Namespaces are one honking great idea -- let's do more of those!


I would like to nominate number 20 for newbies like myself.

20. built-in is better than homebrewed (why reinvent the wheel!?)

(see the sort method as an example of something that is constantly snubbed despite the fact that anything you try to band-aid together is likely to be slower anyway)

If you miss anything about C, i suspect it is because you haven't been using Python long enough.


cheers,

kevin (hardly the one to be giving advice, but what the heck!)



PS. (gernerators and list comprehensions sort of weaken # 13 a bit, but it still remains in spirit, true. Besides, you going to argue with Tim? I sure as lambda ain't!)




____________________________________________________________
Get 250 full-color business cards FREE right now!
http://businesscards.lycos.com