![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4
![]() |
Only in python!
Only in python could I do things like:
for word in "This is a sentence".split():
print wordor
numbs = range(10)
def kid(x):
if x < 8:
return x
for x in filter(mature, numbs):
print xor even
people = {"Bob":20, "Joe":25, "Anne":10}
for a, b in dict([(name, age) for name, age in people.items() if age > 15]).items():
print a, bI just feel like I am cheating. Yes, the features in python are fantastic, but I somehow get more satisfaction from implementing it myself. Am I the only one?
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! Last edited by Jessehk; Dec 16th, 2005 at 9:01 PM. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Dec 2005
Posts: 67
Rep Power: 0
![]() |
Yes and No......... I feel real satisfaction from writing an assembly language program too .... but I would still much rather create projects with C\C+ then that..... and I would much rather create projects with Python then C\C+ for the same reasons..... I still get satisfaction from it....either way,,
|
|
|
|
|
|
#3 |
|
Expert Programmer
|
Its not cheating, these are pythons features man :-)
These are the things that i love about python. But the higher the level of your programming the language, the more cool stuff like this are included. (IME)
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Sep 2005
Location: GA
Posts: 99
Rep Power: 4
![]() |
you are not cheating, you can do that too in ruby.
|
|
|
|
|
|
#5 |
|
Programmer
|
>>Master
Does that make it any less.. cheatlike? I don't think it's cheating, or lame; the built-in functions are included for a reason. The reason? To be used. ![]() This is cheating, in my opinion. |
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
for a, b in dict([(name, age) for name, age in people.items() if age > 15].items(): And you think these features are cool and make life too easy? Try reading webpages, writing/reading CSV files, dumping/loading objects from files, and using db files in C++ or C or even PHP or Perl. |
|
|
|
|
|
#7 | |
|
The Oblivious One
Join Date: May 2005
Location: Ontario, Canada
Posts: 644
Rep Power: 4
![]() |
Quote:
Ya, I caught the pointless conversion to a dict and then to a list of tuples. Unfortunately, the edit button dissapeared. There is also an error the second code snippet where I define a kid() function and then call mature() with filter(). The specific examples are really not the point of the thread.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS! |
|
|
|
|
|
|
#8 | |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Quote:
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
|
#9 |
|
Hobbyist Programmer
Join Date: Dec 2005
Posts: 118
Rep Power: 0
![]() |
It's hardly a case of 'only in Python' - more like 'only in high level languages'. The filter function you like so much is a functional programming feature which Lisp had fifty years ago. And with the right kind of libraries you can do a lot of those things in C++ or Java too.
Using a library isn't cheating if your goal is to write a program to do something which the library would make easier. It's only cheating if your goal is to learn how to write such code and understand how it works yourself. So long as you don't cheat yourself, I wouldn't worry. Or would you rather write everything in machine code? (Not even assembler, I'm talking about using hex code instead of mnemonics like ADD and MOV! :p) |
|
|
|
|
|
#10 | |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Quote:
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|