Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 14th, 2006, 3:46 PM   #1
Dietrich
Professional Programmer
 
Dietrich's Avatar
 
Join Date: Feb 2005
Posts: 434
Rep Power: 4 Dietrich is on a distinguished road
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
There's got to be something missing? All that code for such a silly outcome. Help me, so I can stop scratching my head.
__________________
I looked it up on the Intergnats!
Dietrich is offline   Reply With Quote
Old Aug 14th, 2006, 4:00 PM   #2
Random Spirit
Unverified User
 
Join Date: Aug 2006
Posts: 88
Rep Power: 0 Random Spirit is on a distinguished road
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.
Random Spirit is offline   Reply With Quote
Old Aug 15th, 2006, 5:47 AM   #3
Arevos
Programming Guru
 
Arevos's Avatar
 
Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5 Arevos is on a distinguished road
Quote:
Originally Posted by Dietrich
There's got to be something missing? All that code for such a silly outcome. Help me, so I can stop scratching my head.
It looks to be the beginnings of an event-loop system, though as you point out, it's incomplete.
Arevos is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:36 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC