Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10816
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'arguments': 0.05; 'python': 0.08; 'args,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:parameters': 0.09; 'subject:parsing': 0.09; 'wrote:': 0.15; '*args,': 0.16; '42,': 0.16; 'f(a,': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'subject:function': 0.16; '>>>': 0.16; 'def': 0.16; 'trying': 0.23; 'function': 0.26; '(and': 0.27; 'pass': 0.28; 'lee': 0.28; 'import': 0.29; 'from:addr:web.de': 0.30; 'it.': 0.33; 'to:addr:python-list': 0.34; 'header:X -Complaints-To:1': 0.34; 'calling': 0.34; 'some': 0.37; 'received:org': 0.38; 'subject:: ': 0.38; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: parsing function parameters |
| Date | Wed, 03 Aug 2011 18:51:27 +0200 |
| Organization | None |
| References | <SNT106-W25A79F03CB12FDF1A4230CB13A0@phx.gbl> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084b5bb.dip.t-dialin.net |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1853.1312390301.1164.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1312390301 news.xs4all.nl 23915 [2001:888:2000:d::a6]:45476 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:10816 |
Show key headers only | View raw
Lee Harr wrote:
> I am trying to get some information about a function
> before (and without) calling it.
If you allow for the function arguments to be evaluated it's easy (requires
Python 2.7):
>>> import inspect
>>> def get_args(*args, **kw):
... return args, kw
...
>>> argstr = "1, 2, z=42"
>>> def f(a, b, x=1, y=2, z=3):
... pass
...
>>> args, kw = eval("get_args(%s)" % argstr)
>>> inspect.getcallargs(f, *args, **kw)
{'a': 1, 'x': 1, 'b': 2, 'z': 42, 'y': 2}
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: parsing function parameters Peter Otten <__peter__@web.de> - 2011-08-03 18:51 +0200
csiph-web