Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Weekends were made for programming. -- Karl Lehenbauer


devel / comp.lang.python / Get a function definition/implementation hint similar to the one shown in pycharm.

SubjectAuthor
* Get a function definition/implementation hint similar to the onehongy...@gmail.com
`* Re: Get a function definition/implementation hint similar to the oneCameron Simpson
 +- Re: Get a function definition/implementation hint similar to the onehongy...@gmail.com
 `* Re: Get a function definition/implementation hint similar to the onehongy...@gmail.com
  `- Re: Get a function definition/implementation hint similar to the oneChris Angelico

1
Get a function definition/implementation hint similar to the one shown in pycharm.

<a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15652&group=comp.lang.python#15652

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ac8:5916:: with SMTP id 22mr27831994qty.247.1634546597973;
Mon, 18 Oct 2021 01:43:17 -0700 (PDT)
X-Received: by 2002:a37:9307:: with SMTP id v7mr20757432qkd.371.1634546597811;
Mon, 18 Oct 2021 01:43:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 18 Oct 2021 01:43:17 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=172.104.173.61; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 172.104.173.61
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>
Subject: Get a function definition/implementation hint similar to the one
shown in pycharm.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Mon, 18 Oct 2021 08:43:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: hongy...@gmail.com - Mon, 18 Oct 2021 08:43 UTC

I've written the following python code snippet in pycharm:
```python
import numpy as np
from numpy import pi, sin

a = np.array([1], dtype=bool)
if np.in|vert(a) == ~a:
print('ok')
```
When putting the point/cursor in the above code snippet at the position denoted by `|`, I would like to see information similar to that provided by `pycharm`, as shown in the following screenshots:

https://user-images.githubusercontent.com/11155854/137619512-674e0eda-7564-4e76-af86-04a194ebeb8e.png
https://user-images.githubusercontent.com/11155854/137619524-a0b584a3-1627-4612-ab1f-05ec1af67d55.png

But I wonder if there are any other python packages/tools that can help me achieve this goal?

Regards,
HZ

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

<mailman.982.1634592126.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15654&group=comp.lang.python#15654

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: cs...@cskk.id.au (Cameron Simpson)
Newsgroups: comp.lang.python
Subject: Re: Get a function definition/implementation hint similar to the one
shown in pycharm.
Date: Tue, 19 Oct 2021 08:22:00 +1100
Lines: 41
Message-ID: <mailman.982.1634592126.4164.python-list@python.org>
References: <a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>
<YW3leOnT36jpB4Nk@cskk.homeip.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.uni-berlin.de xeXSTkWew7aUdeK49ta4JAL7K8OHzD0otr3GkLSwJlAQ==
Return-Path: <cameron@cskk.id.au>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.005
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'def': 0.04; 'pycharm':
0.04; '>from': 0.09; 'numpy': 0.09; 'sig': 0.09; 'cheers,': 0.11;
'import': 0.15; '"inspect"': 0.16; 'cameron': 0.16; 'extracting':
0.16; 'from:addr:cs': 0.16; 'from:addr:cskk.id.au': 0.16;
'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net':
0.16; 'pi,': 0.16; 'received:13.237': 0.16; 'received:13.237.201':
0.16; 'received:13.237.201.189': 0.16; 'received:cskk.id.au':
0.16; 'received:id.au': 0.16; 'received:l': 0.16;
'received:mail.cskk.id.au': 0.16; 'simpson': 0.16; 'things,':
0.16; 'wrote:': 0.16; 'python': 0.16; 'libraries': 0.19; 'to:addr
:python-list': 0.20; 'written': 0.22; 'code': 0.23; 'function':
0.27; '>>>': 0.28; 'printed': 0.28; 'header:User-Agent:1': 0.30;
'putting': 0.31; 'there': 0.33; 'header:In-Reply-To:1': 0.34;
'received:au': 0.35; 'following': 0.35; 'functions': 0.36; 'want':
0.40; 'reference': 0.60; 'skip:h 10': 0.61; 'above': 0.62;
'received:13': 0.64; 'similar': 0.65; 'url:png': 0.66;
'received:userid': 0.66; 'subject:Get': 0.69; 'subject:skip:i 10':
0.69; 'documented': 0.76; 'subject:one': 0.76; 'position': 0.81;
'broadly,': 0.84; 'subject: \n ': 0.84; 'subject:definition':
0.84; 'zhao': 0.84; 'sin': 0.91
Mail-Followup-To: python-list@python.org
Content-Disposition: inline
In-Reply-To: <a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>
User-Agent: Mutt/2.0.3 (2020-12-04)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <https://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>
X-Mailman-Original-Message-ID: <YW3leOnT36jpB4Nk@cskk.homeip.net>
X-Mailman-Original-References: <a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>
 by: Cameron Simpson - Mon, 18 Oct 2021 21:22 UTC

On 18Oct2021 01:43, Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>I've written the following python code snippet in pycharm:
>```python
>import numpy as np
>from numpy import pi, sin
>
>a = np.array([1], dtype=bool)
>if np.in|vert(a) == ~a:
> print('ok')
>```
>When putting the point/cursor in the above code snippet at the position denoted by `|`, I would like to see information similar to that provided by `pycharm`, as shown in the following screenshots:
>
>https://user-images.githubusercontent.com/11155854/137619512-674e0eda-7564-4e76-af86-04a194ebeb8e.png
>https://user-images.githubusercontent.com/11155854/137619524-a0b584a3-1627-4612-ab1f-05ec1af67d55.png
>
>But I wonder if there are any other python packages/tools that can help
>me achieve this goal?

Broadly, you want the "inspect" module, which is part of the stdlib,
documented here: https://docs.python.org/3/library/inspect.html

It has many functions for extracting information about things, and you
want the signature() function to get the parameters and type annotations
of a function.

def f(a):
...

sig = signature(f)

You also want the function docstring for the help text, which is
"f.__doc__" in the example above. This is what gets printed by help():

>>> import numpy as np
>>> help(np.invert)

It may be that PyCharm has additional information about some libraries
allowing it to include a reference to the only documentation.

Cheers,
Cameron Simpson <cs@cskk.id.au>

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

<6275eae6-0bc6-4243-9464-570c351eb020n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15655&group=comp.lang.python#15655

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ac8:4155:: with SMTP id e21mr33659175qtm.312.1634607431598;
Mon, 18 Oct 2021 18:37:11 -0700 (PDT)
X-Received: by 2002:a37:d48:: with SMTP id 69mr23707936qkn.457.1634607431409;
Mon, 18 Oct 2021 18:37:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 18 Oct 2021 18:37:11 -0700 (PDT)
In-Reply-To: <mailman.982.1634592126.4164.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=188.166.234.30; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 188.166.234.30
References: <YW3leOnT36jpB4Nk@cskk.homeip.net> <a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>
<mailman.982.1634592126.4164.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6275eae6-0bc6-4243-9464-570c351eb020n@googlegroups.com>
Subject: Re: Get a function definition/implementation hint similar to the one
shown in pycharm.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 19 Oct 2021 01:37:11 +0000
Content-Type: text/plain; charset="UTF-8"
 by: hongy...@gmail.com - Tue, 19 Oct 2021 01:37 UTC

On Tuesday, October 19, 2021 at 5:22:25 AM UTC+8, cameron...@gmail.com wrote:
> On 18Oct2021 01:43, Hongyi Zhao <hongy...@gmail.com> wrote:
> >I've written the following python code snippet in pycharm:
> >```python
> >import numpy as np
> >from numpy import pi, sin
> >
> >a = np.array([1], dtype=bool)
> >if np.in|vert(a) == ~a:
> > print('ok')
> >```
> >When putting the point/cursor in the above code snippet at the position denoted by `|`, I would like to see information similar to that provided by `pycharm`, as shown in the following screenshots:
> >
> >https://user-images.githubusercontent.com/11155854/137619512-674e0eda-7564-4e76-af86-04a194ebeb8e.png
> >https://user-images.githubusercontent.com/11155854/137619524-a0b584a3-1627-4612-ab1f-05ec1af67d55.png
> >
> >But I wonder if there are any other python packages/tools that can help
> >me achieve this goal?
> Broadly, you want the "inspect" module, which is part of the stdlib,
> documented here: https://docs.python.org/3/library/inspect.html
>
> It has many functions for extracting information about things, and you
> want the signature() function to get the parameters and type annotations
> of a function.
>
> def f(a):
> ...
>
> sig = signature(f)

The following ipython test failed:

In [1]: import numpy as np

In [2]: from inspect import signature

In [3]: signature(np.invert)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-3-f1808184276a> in <module>
----> 1 signature(np.invert)

~/.pyenv/versions/3.9.1/lib/python3.9/inspect.py in signature(obj, follow_wrapped)
3128 def signature(obj, *, follow_wrapped=True):
3129 """Get a signature object for the passed callable."""
-> 3130 return Signature.from_callable(obj, follow_wrapped=follow_wrapped)
3131
3132

~/.pyenv/versions/3.9.1/lib/python3.9/inspect.py in from_callable(cls, obj, follow_wrapped)
2877 def from_callable(cls, obj, *, follow_wrapped=True):
2878 """Constructs Signature for the given callable object."""
-> 2879 return _signature_from_callable(obj, sigcls=cls,
2880 follow_wrapper_chains=follow_wrapped)
2881

~/.pyenv/versions/3.9.1/lib/python3.9/inspect.py in _signature_from_callable(obj, follow_wrapper_chains, skip_bound_arg, sigcls)
2441 raise ValueError(msg)
2442
-> 2443 raise ValueError('callable {!r} is not supported by signature'.format(obj))
2444
2445

ValueError: callable <ufunc 'invert'> is not supported by signature


> You also want the function docstring for the help text, which is
> "f.__doc__" in the example above. This is what gets printed by help():
>
> >>> import numpy as np
> >>> help(np.invert)
>
> It may be that PyCharm has additional information about some libraries
> allowing it to include a reference to the only documentation.
>
> Cheers,
> Cameron Simpson <c...@cskk.id.au>

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

<efa910b2-5d63-4a9b-a282-41286c2abed0n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15657&group=comp.lang.python#15657

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a0c:f44f:: with SMTP id h15mr29567569qvm.21.1634620677462;
Mon, 18 Oct 2021 22:17:57 -0700 (PDT)
X-Received: by 2002:a37:9ec7:: with SMTP id h190mr26104782qke.105.1634620677314;
Mon, 18 Oct 2021 22:17:57 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Mon, 18 Oct 2021 22:17:57 -0700 (PDT)
In-Reply-To: <mailman.982.1634592126.4164.python-list@python.org>
Injection-Info: google-groups.googlegroups.com; posting-host=172.104.173.61; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 172.104.173.61
References: <YW3leOnT36jpB4Nk@cskk.homeip.net> <a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>
<mailman.982.1634592126.4164.python-list@python.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <efa910b2-5d63-4a9b-a282-41286c2abed0n@googlegroups.com>
Subject: Re: Get a function definition/implementation hint similar to the one
shown in pycharm.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 19 Oct 2021 05:17:57 +0000
Content-Type: text/plain; charset="UTF-8"
 by: hongy...@gmail.com - Tue, 19 Oct 2021 05:17 UTC

On Tuesday, October 19, 2021 at 5:22:25 AM UTC+8, cameron...@gmail.com wrote:
> On 18Oct2021 01:43, Hongyi Zhao <hongy...@gmail.com> wrote:
> >I've written the following python code snippet in pycharm:
> >```python
> >import numpy as np
> >from numpy import pi, sin
> >
> >a = np.array([1], dtype=bool)
> >if np.in|vert(a) == ~a:
> > print('ok')
> >```
> >When putting the point/cursor in the above code snippet at the position denoted by `|`, I would like to see information similar to that provided by `pycharm`, as shown in the following screenshots:
> >
> >https://user-images.githubusercontent.com/11155854/137619512-674e0eda-7564-4e76-af86-04a194ebeb8e.png
> >https://user-images.githubusercontent.com/11155854/137619524-a0b584a3-1627-4612-ab1f-05ec1af67d55.png
> >
> >But I wonder if there are any other python packages/tools that can help
> >me achieve this goal?
> Broadly, you want the "inspect" module, which is part of the stdlib,
> documented here: https://docs.python.org/3/library/inspect.html
>
> It has many functions for extracting information about things, and you
> want the signature() function to get the parameters and type annotations
> of a function.
>
> def f(a):
> ...
>
> sig = signature(f)
>
> You also want the function docstring for the help text, which is
> "f.__doc__" in the example above. This is what gets printed by help():
>
> >>> import numpy as np
> >>> help(np.invert)

But the following doesn't work:

In [4]: help(~)
File "<ipython-input-4-2a4ba1e3ecdb>", line 1
help(~)
^
SyntaxError: invalid syntax


> It may be that PyCharm has additional information about some libraries
> allowing it to include a reference to the only documentation.
>
> Cheers,
> Cameron Simpson <c...@cskk.id.au>

Re: Get a function definition/implementation hint similar to the one shown in pycharm.

<mailman.983.1634667814.4164.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=15659&group=comp.lang.python#15659

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!news2.arglkargh.de!news.karotte.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Get a function definition/implementation hint similar to the one
shown in pycharm.
Date: Wed, 20 Oct 2021 05:23:22 +1100
Lines: 54
Message-ID: <mailman.983.1634667814.4164.python-list@python.org>
References: <YW3leOnT36jpB4Nk@cskk.homeip.net>
<a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>
<mailman.982.1634592126.4164.python-list@python.org>
<efa910b2-5d63-4a9b-a282-41286c2abed0n@googlegroups.com>
<CAPTjJmqw=PQpW1gy1WLxkRLMd1dSQBCy02qZzdm3FvyF9wcr9g@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de 7WpeHzykBsHsV/YEDamXOg4Bkfqo9k500EokrrFq8EwA==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=Hw0xp+uh;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.036
X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'def': 0.04; 'string':
0.07; '>from': 0.09; 'numpy': 0.09; 'sig': 0.09; 'import': 0.15;
'syntax': 0.15; '"inspect"': 0.16; 'chrisa': 0.16; 'extracting':
0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16;
'pi,': 0.16; 'received:209.85.128.42': 0.16; 'received:mail-
wm1-f42.google.com': 0.16; 'syntaxerror:': 0.16; 'things,': 0.16;
'work:': 0.16; 'wrote:': 0.16; 'python': 0.16; 'october': 0.17;
"can't": 0.17; 'to:addr:python-list': 0.20; 'written': 0.22;
'code': 0.23; 'function': 0.27; '>>>': 0.28; 'printed': 0.28;
'putting': 0.31; "doesn't": 0.32; '"",': 0.32; 'to:name:python':
0.32; 'message-id:@mail.gmail.com': 0.32; 'but': 0.32; 'there':
0.33; 'header:In-Reply-To:1': 0.34; 'received:google.com': 0.34;
'invalid': 0.35; 'following': 0.35; 'from:addr:gmail.com': 0.35;
'functions': 0.36; 'received:209.85': 0.37; 'file': 0.38;
'received:209': 0.39; 'wed,': 0.39; 'want': 0.40; 'try': 0.40;
'skip:h 10': 0.61; 'above': 0.62; 'email addr:gmail.com': 0.63;
'pass': 0.64; 'similar': 0.65; 'url:png': 0.66; '20,': 0.67;
'perfectly': 0.69; 'subject:Get': 0.69; 'subject:skip:i 10': 0.69;
'2021': 0.71; 'documented': 0.76; 'subject:one': 0.76; 'position':
0.81; '4:45': 0.84; 'broadly,': 0.84; 'subject: \n ': 0.84;
'subject:definition': 0.84; 'zhao': 0.84; 'sin': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
bh=ritBWp9UebvTszIUiYaSPt/QvyunfNSLdrzXVyJkxJQ=;
b=Hw0xp+uhEPmBA+oayEl0gdJKJvmlnouN6mX+8TY/GZ4Q5UuqDubHEgJ/R/oG4JI8Zc
AZsLG4AzYilw6kklYX+03DHEbYAtBXMPU1lJNBjox5CO26ya67BhgAXPI9/AcYl43SLz
IZNVXCBbRkoPZuXm/c930hFp82vWCqgrCBb0cyh9gTwd/FJabWaf/pZlPFD4druCe4FD
Bu1vGe+WnFaL2kHnvNlRkED0oM0uNYO/ILgDeZO7chZgv5kUmf1WUVbg76Rw2wNupYGS
J8Oidz1iZ/xA/AzWlg0get0dvY2pfHPudHCSm5mtHmKYfIQE834BemC0mBOOTAdwimrR
iRJQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to;
bh=ritBWp9UebvTszIUiYaSPt/QvyunfNSLdrzXVyJkxJQ=;
b=3rWfT+dlmxPo7JWWHhYWjwrYmt+QEumLuuYo8C2VJ98tFLD4ZdOMMiAHRRS08guKB2
jzAWbobbT4U7u1zl2rZSQrhTAH1G38hWDCOBQJvCM+xmH/E43PCj9iyGTObIwE0rVOqq
jik7iqMcujhSeq47mw+9HrQlq/8RLP/X1D5/K5I+Ph04Ar7kboLeL0sk06qnCGDHXB2J
WhbvTpwuoS+GvxWYeyp1/e3PwPY02K+C2a2RjIfT6niP4WanWTqtysAfpaNzBvW0y+9y
4jyJKDKdCcAXrw1/9Wf0Z1P5HA0H8tdE5IaxR62aykMA+mW5TZMkp79DQVcfilZB7YXq
FQ8A==
X-Gm-Message-State: AOAM533jV0sjCqN3iLwZsq09uUckJu0YXQTZSVr4joaQfxCLJrZbno4e
arHB7jh876eJsARboW5EuIRO7sCfL1cywquUF0/F1vd02YY=
X-Google-Smtp-Source: ABdhPJwHiF7MtkcYntu+gnh8URjCrE49M7fgHOlG7RrpY+gm+i6FCNv8rxJX9CVoymBSwXQwPYLVCtBm42QD6YYBIJY=
X-Received: by 2002:adf:9b97:: with SMTP id d23mr44539631wrc.53.1634667813150;
Tue, 19 Oct 2021 11:23:33 -0700 (PDT)
In-Reply-To: <efa910b2-5d63-4a9b-a282-41286c2abed0n@googlegroups.com>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.34
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: <https://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>
X-Mailman-Original-Message-ID: <CAPTjJmqw=PQpW1gy1WLxkRLMd1dSQBCy02qZzdm3FvyF9wcr9g@mail.gmail.com>
X-Mailman-Original-References: <YW3leOnT36jpB4Nk@cskk.homeip.net>
<a2d000ac-5e43-463e-aaa3-01667238079an@googlegroups.com>
<mailman.982.1634592126.4164.python-list@python.org>
<efa910b2-5d63-4a9b-a282-41286c2abed0n@googlegroups.com>
 by: Chris Angelico - Tue, 19 Oct 2021 18:23 UTC

On Wed, Oct 20, 2021 at 4:45 AM hongy...@gmail.com
<hongyi.zhao@gmail.com> wrote:
>
> On Tuesday, October 19, 2021 at 5:22:25 AM UTC+8, cameron...@gmail.com wrote:
> > On 18Oct2021 01:43, Hongyi Zhao <hongy...@gmail.com> wrote:
> > >I've written the following python code snippet in pycharm:
> > >```python
> > >import numpy as np
> > >from numpy import pi, sin
> > >
> > >a = np.array([1], dtype=bool)
> > >if np.in|vert(a) == ~a:
> > > print('ok')
> > >```
> > >When putting the point/cursor in the above code snippet at the position denoted by `|`, I would like to see information similar to that provided by `pycharm`, as shown in the following screenshots:
> > >
> > >https://user-images.githubusercontent.com/11155854/137619512-674e0eda-7564-4e76-af86-04a194ebeb8e.png
> > >https://user-images.githubusercontent.com/11155854/137619524-a0b584a3-1627-4612-ab1f-05ec1af67d55.png
> > >
> > >But I wonder if there are any other python packages/tools that can help
> > >me achieve this goal?
> > Broadly, you want the "inspect" module, which is part of the stdlib,
> > documented here: https://docs.python.org/3/library/inspect.html
> >
> > It has many functions for extracting information about things, and you
> > want the signature() function to get the parameters and type annotations
> > of a function.
> >
> > def f(a):
> > ...
> >
> > sig = signature(f)
> >
> > You also want the function docstring for the help text, which is
> > "f.__doc__" in the example above. This is what gets printed by help():
> >
> > >>> import numpy as np
> > >>> help(np.invert)
>
> But the following doesn't work:
>
> In [4]: help(~)
> File "<ipython-input-4-2a4ba1e3ecdb>", line 1
> help(~)
> ^
> SyntaxError: invalid syntax
>

That's because help() is a perfectly ordinary callable, and you can't
pass an operator as a parameter. Try passing it a string instead:

help("~")

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor