ipython / ipython/ipython

Display help for literals

Open
#6,323 1 comment 0 reactions 0 assignees View on GitHub
core
Dominant language
Python
Stars
16.8k
Forks
4.5k
Avg merge
1d 2h
Merged PRs (30d)
6

Description

Not sure if this is the same as https://github.com/ipython/ipython/issues/1682, question mark help doesn't work for ints:

```
In [1]: 5?
File "", line 1
5?
^
SyntaxError: invalid syntax
```

unless you do it like this:

```
In [2]: 5
Out[2]: 5

In [3]: _?
Type: int
String form: 5
Docstring:
int(x=0) -> int or long
int(x, base=10) -> int or long

Convert a number or string to an integer, or return 0 if no arguments
are given. If x is floating point, the conversion truncates towards zero.
If x is outside the integer range, the function returns a long instead.

If x is not a number or if base is given, then x must be a string or
Unicode object representing an integer literal in the given base. The
literal can be preceded by '+' or '-' and be surrounded by whitespace.
The base defaults to 10. Valid bases are 0 and 2-36. Base 0 means to
interpret the base from the string as an integer literal.
>>> int('0b100', base=0)
4
```

I mostly notice this with things like sympy integers stored in lists, which are visually indistinguishable from normal ints:

```
In [4]: [1,2,3,4]
Out[4]: [1, 2, 3, 4]

In [6]: [Integer(1),Integer(2),Integer(3),Integer(4)]
Out[6]: [1, 2, 3, 4]

In [7]: _[0]?
File "", line 1
_[0]?
^
SyntaxError: invalid syntax

In [8]: _[0]
Out[8]: 1

In [9]: _?
Type: One
String form: 1
File: c:\python27\lib\site-packages\sympy\core\numbers.py
Docstring:
The number one.

One is a singleton, and can be accessed by ``S.One``.

Examples
...
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.