Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Passing keywords

Reply
Thread Tools

Passing keywords

 
 
Kless
Guest
Posts: n/a
 
      07-20-2008
I've a constructor with several values that must be used by any
functions:

---------------
class foo:

def __init__(self, foo1, foo2, foon):

self.__check(foo1=foo1, foo2=foo2, foon=foon)
self.__check2(foo1=foo1, foo2=foo2, foon=foon)

def __check(self, foo1, foo2, foon):
...

def __check2(self, foo1, foo2, foon):
...
---------------

How simplify all that?

I could use the next but I don't think...

---------------
def __check(self, **keywords):
---------------
 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      07-20-2008
Kless wrote:

> I could use the next but I don't think...
>
> ---------------
> def __check(self, **keywords):
> ---------------


don't think what?

if you keep using the same variables in all submethods you call from a
method inside the class, why not make them attributes?

otherwise, using the **-form when *calling* the methods might work. you
can use the **-form in the functions to ignore arguments that you're not
interested in.

self.__check(**kwargs)
self.__check2(**kwargs)

def __check(self, foo1, foo2, **extra):
# use foo1 and foo2 here; ignore the rest

etc.

</F>

 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables to SQL query keywords enthusiast General Computer Support 0 06-07-2010 01:01 PM
Firefox 0.9.3 Smart Keywords disable? Michael Volland Firefox 0 10-09-2004 06:25 PM
Firefox 0.9.3 Smart Keywords disable? Michael Volland Firefox 0 10-09-2004 06:01 PM
Creating Smart Keywords for Mozilla Firebird (using Quick Searches) Who Firefox 1 12-06-2003 01:37 AM
Creating Smart Keywords for Firebird Nick Firefox 0 08-06-2003 12:01 AM



Advertisments