Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #63590
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <mhysnm1964@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.015 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'explicit': 0.07; '*args,': 0.09; 'parameter': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; '**kwargs):': 0.16; '11:19': 0.16; 'args,': 0.16; 'command)': 0.16; 'command,': 0.16; 'dictionary.': 0.16; 'func': 0.16; 'kwargs': 0.16; 'outputs': 0.16; 'parameters,': 0.16; 'subject:dictionaries': 0.16; 'wrote:': 0.18; 'resolved': 0.19; 'cc:addr:python.org': 0.22; 'print': 0.22; 'example.': 0.24; 'sean': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'compared': 0.30; 'skip:@ 10': 0.30; 'that.': 0.31; 'class': 0.32; '-----': 0.33; 'call.': 0.33; 'actual': 0.34; 'received:google.com': 0.35; 'subject:data': 0.36; 'charset:us- ascii': 0.36; 'thanks': 0.36; 'possible': 0.36; 'searching': 0.37; 'message-id:@gmail.com': 0.38; 'thank': 0.38; 'outstanding': 0.38; 'issue': 0.38; 'pm,': 0.38; 'sure': 0.39; 'how': 0.40; 'simple': 0.61; 'you.': 0.62; 'header:Message-Id:1': 0.63; 'information': 0.63; 'notice:': 0.67; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'saw': 0.77; "'foo'": 0.84; 'medium.': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=I3N3itBMvgIoEKlqb/FGwLRrVtfqJJhRnCjqzjf7LL4=; b=ifdSivm7HdruDW4eofOAOaohIs2wV//5S0eJBphaa2/mdITRENEf+G+LkMptqLIlNC /08iri0sdH/8sxGHTaLvv5fVUVDSYWR7NmBJhmdFZC56kkaIyASKY9biE7kz+RRof0EZ k+RutKUqWbxZpQSXGHegg6ZL4g0hrULAneel0O/qq4GOS/pYAhyxuyaoaMdq4EQeFlgi svU/ZMOdujW9G74d2M75N9eJOdcPQaWuC/7fTzhRrmq5F+S+3PE+A53iNBJ9XADtkQyf ZYgQfBIzpyMC0d22eQt31zSQe/TcCLH25wk5PZwXw9oUlkO7mbk0G9n06/hjx89eENFc KzOA== |
| X-Received | by 10.66.41.106 with SMTP id e10mr2601978pal.109.1389262119460; Thu, 09 Jan 2014 02:08:39 -0800 (PST) |
| Content-Type | text/plain; charset=us-ascii |
| Mime-Version | 1.0 (Mac OS X Mail 6.6 \(1510\)) |
| Subject | Re: nested dictionaries and functions in data structures. |
| From | Sean Murphy <mhysnm1964@gmail.com> |
| In-Reply-To | <59989803.3050665.1389097176191.JavaMail.root@sequans.com> |
| Date | Thu, 9 Jan 2014 21:08:34 +1100 |
| Content-Transfer-Encoding | quoted-printable |
| References | <59989803.3050665.1389097176191.JavaMail.root@sequans.com> |
| To | Jean-Michel Pichavant <jeanmichel@sequans.com> |
| X-Mailer | Apple Mail (2.1510) |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5253.1389262128.18130.python-list@python.org> (permalink) |
| Lines | 49 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1389262128 news.xs4all.nl 2868 [2001:888:2000:d::a6]:36149 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:63590 |
Show key headers only | View raw
Thanks for that. I will have a play and see how I can apply your example.
On 07/01/2014, at 11:19 PM, Jean-Michel Pichavant <jeanmichel@sequans.com> wrote:
> ----- Original Message -----
>> Thanks for that. It resolved the issue and it was so simple compared
>> to everything else I saw on the net.
>>
>> Only outstanding thing I have to work out is how to execute functions
>> from a dictionary. I will continue searching on the net.
>>
>>
>> Sean
>
> This may help you (untested code)
>
> class Workers:
> @staticmethod
> def ospf(*args, **kwargs):
> print args, kwargs
> return 'Bar'
>
> @staticmethod
> def bhp(*args, **kwargs):
> return 'Foo'
>
> outputs = {'ospf' : {1 : {'param1' : 'foo', 'param2' : 'foo2'}}
>
> for command, value in outputs.items():
> for counter, kwargs in value:
> func = getattr(Workers, command) # get the function
> func(**kwargs) # the actual call
>
> It would be possible to do it without the *args, **kwargs magic. You can write ospf and bhp with the explicit parameters, however you must make sure you pass the correct number of parameter in the call.
>
> JM
>
>
> -- IMPORTANT NOTICE:
>
> The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: nested dictionaries and functions in data structures. Sean Murphy <mhysnm1964@gmail.com> - 2014-01-09 21:08 +1100
csiph-web