473,320 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Passing keywords

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):
---------------
Jul 20 '08 #1
1 961
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>

Jul 20 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Nel | last post by:
Hi all, Before I re-invent the wheel here, has anyone willing to share a basic script to extract META keywords from a string. I have a string, let's say $pageText that contains the dynamic...
2
by: Cherry | last post by:
I have a trigger that won't compile: CREATE OR REPLACE TRIGGER TRG_CORRESPONDENCE_UPT AFTER UPDATE on TBLCORRESPONDENCE for each row BEGIN IF :OLD.Keywords <> :NEW.Keywords THEN
14
by: Jason Heyes | last post by:
I want to write a class that supports operations on keywords belonging to the C++ programming language. The following program repeatedly prompts the user for a keyword until 'explicit' is finally...
2
by: google | last post by:
I have a script which parses the BBC RSS feed once an hour, and drops any stories with certain keywords into a database. I would like to ban certain strings; at the moment the script will pick up...
9
by: Just Me | last post by:
PARAFORMAT2 is a structure that SendMessage will return stuff in. Is the "ref" correct or since only a pointer is being passed should it be by value? Suppose I was passing data rather then...
5
by: Digital.Rebel.18 | last post by:
I'm trying to figure out how to extract the keywords from an HTML document. The input string would typically look like: <meta name='keywords' content='word1, more stuff, etc'> Either single...
9
by: Nenad Loncarevic | last post by:
I am a geologist, and over the years I've accumulated quite a number of proffesional papers on the subject, in various publications. I would like to make a database that would help me find the...
5
by: mforema | last post by:
Hi Everyone, I want to search records by typing in multiple keywords. I currently have a search form. It has a combo box, text box, Search command button, and a subform. The combo box lists the...
5
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
How can I get the list of connection string's keywords available in sqlclient programmatically? I have found the list in here...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.