By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,379 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

Re: code of a function

P: n/a

On May 29, 2008, at 9:38 AM, Gary Herron wrote:
Dark Wind wrote:
>Hi,

Is there any command in Python which gives the code for a function
like just typing the name of a function (say svd) in R returns its
code.

Thank you

Nope.
If you're using IPython, you can do svd?? .

Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Anand Patil wrote:
If you're using IPython, you can do svd?? .

http://www.scipy.org/doc/numpy_api_d...lg.linalg.html

hth,
Alan Isaac
Jun 27 '08 #2

P: n/a
On May 30, 8:54 am, Alan Isaac <ais...@american.eduwrote:
Anand Patil wrote:
If you're using IPython, you can do svd?? .

http://www.scipy.org/doc/numpy_api_d...lg.linalg.html

hth,
Alan Isaac
That wasn't a question :) In IPython, '<entity>?' is roughly
equivalent to 'help(<entity>)', whereas '<entity>??' displays the
code, if possible:

IPython 0.8.2 -- An enhanced Interactive Python.
? -Introduction and overview of IPython's features.
%quickref -Quick reference.
help -Python's own help system.
object? -Details about 'object'. ?object also works, ?? prints
more.

In [1]: from functools import wraps

In [2]: wraps??
Type: function
Base Class: <type 'function'>
String Form: <function wraps at 0x00CF31B0>
Namespace: Interactive
File: c:\python25\lib\functools.py
Definition: wraps(wrapped, assigned=('__module__', '__name__',
'__doc__'), updated=('__dict__',))
Source:
def wraps(wrapped,
assigned = WRAPPER_ASSIGNMENTS,
updated = WRAPPER_UPDATES):
"""Decorator factory to apply update_wrapper() to a wrapper
function

Returns a decorator that invokes update_wrapper() with the
decorated
function as the wrapper argument and the arguments to wraps()
as the
remaining arguments. Default arguments are as for
update_wrapper().
This is a convenience function to simplify applying partial()
to
update_wrapper().
"""
return partial(update_wrapper, wrapped=wrapped,
assigned=assigned, updated=updated)

Which is very handy, like most of IPython.
Jun 27 '08 #3

P: n/a
alex23 <wu*****@gmail.comwrites:
Which is very handy, like most of IPython.
+1 QOTW
--
Pete Forman -./\.- Disclaimer: This post is originated
WesternGeco -./\.- by myself and does not represent
pe*********@westerngeco.com -./\.- the opinion of Schlumberger or
http://petef.22web.net -./\.- WesternGeco.
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.