![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Programmer
Join Date: Apr 2005
Posts: 73
Rep Power: 4
![]() |
Quote:
def reverse(x):
return x[::-1]
for elem in ([1,2,3], (1,2,3), "123"):
print reverse(elem)-T. |
|
|
|
|
|
|
#12 | |
|
Programmer
Join Date: Apr 2005
Posts: 73
Rep Power: 4
![]() |
Quote:
def blah(mystr):
while mystr:
print mystr
mystr = mystr[:-1]
def dosomething():
print "something"-T. |
|
|
|
|
|
|
#13 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#14 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
I find hydroxide's example ...
def reverse(x):
return x[::-1]
for elem in ([1,2,3], (1,2,3), "123"):
print reverse(elem)for elem in ([1,2,3], (1,2,3), "123"):
print elem[::-1]I have to agree with hydroxide's statement: Pythonicity is about elegance and clarity of structure and intent. Pythonic code is "pretty", as brief as it can be, but not at the expense of readability, and written using Python idioms.
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
#15 | |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 648
Rep Power: 4
![]() |
Quote:
![]() I also prefer "end", as long as it's not "end for" and "end if" like in some languages. All in all, I actually far prefer Ruby, but that's another topic entirely :p
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
|
#16 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 648
Rep Power: 4
![]() |
Arg! Edit button disappears!
I misread the post. Contrary to you opinion, I prefer Ruby's "end" to Python's forced indentation
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|