![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Feb 2005
Posts: 434
Rep Power: 4
![]() |
Function without purpose?
Here is another function from the net that seems to be imcomplete as far as its purpose goes:
#global dict to store targets
targets={}
#the target class
class Target:
def __init__(self, name='', dependencies=[], fn=None):
self.name = name
self.dependencies = dependencies
self.fn = fn
self.done = False
self.success = False
def run(self):
if (not self.done):
self.success = self.fn(self)
self.done = True
return self.success
#the target decorator function
def target(name, dependencies=[]):
def decorator(f):
mytarget = Target(name, dependencies, f)
targets[name] = mytarget
return f
return decorator
#implementing the decorator
@target('my_target')
def MyFunction(target):
print "hello world! from", target.name
return True
targets['my_target'].run() # hello world! from my_target
__________________
I looked it up on the Intergnats! |
|
|
|
|
|
#2 |
|
Unverified User
Join Date: Aug 2006
Posts: 88
Rep Power: 0
![]() |
Are you making these up to test everyones python ability? :p
Good on you if you are If not its good to have some threads that are actually on programming. |
|
|
|
|
|
#3 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compiling Maverik 6.2 (from C) | megamind5005 | C | 16 | May 3rd, 2006 5:41 PM |
| libraries | matko | C | 1 | Jan 22nd, 2006 2:12 PM |
| Php Postgresql Class | Pizentios | Show Off Your Open Source Projects | 15 | Jun 28th, 2005 9:55 AM |
| Jackpot game | zorin | Visual Basic | 3 | Jun 10th, 2005 1:19 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |