![[Formales]]
![[bpython__732094472.png]]
> [!TLDR]
> - Bpython is an interactive Python interpreter that provides several features to enhance the coding experience, such as syntax highlighting, auto-completion, and in-line documentation.
> - Here are some key features and commands you might find useful when using bpython.
# Key Features of Bpython
> [!multi-column]
>
>> [!NOTE] Syntax Highlighting
>> Bpython highlights Python syntax, making it easier to read and write code.
>
>> [!NOTE] Auto-Completion
>> As you type, bpython suggests completions for variables, functions, and keywords.
> [!multi-column]
>
>> [!NOTE] In-line Documentation
>> When you type a function name followed by an opening parenthesis, bpython shows the function's docstring.
>
>> [!NOTE] Rewind Function
>> Allows you to undo the last line of code you executed.
> [!NOTE] Pastebin Integration
> You can send your code to a pastebin service directly from the interpreter.
# Basic Commands
## Starting Bpython
To start bpython, simply type bpython in your terminal
```bash
bpython
```
## Basic Operations
### Print a message
```python
print("Hello, World!")
```
### Define a function
```python
def greet(name):
return f"Hello, {name}!"
```
### Call a function
```python
greet("Alice")
```
# Usage
## Auto-Completion
As you type, bpython will suggest completions. For example, typing 'pri' will suggest 'print'.
## In-line Documentation
When you type a function name followed by an opening parenthesis, bpython shows the function's docstring:
```python
print(
# Shows the docstring for the print function
```
## Rewind Function
If you make a mistake, you can undo the last line of code by pressing Ctrl-R.
## Pastebin Integration
To send your code to a pastebin service, use the :pastebin command:
```python
:pastebin
```
## Exiting Bpython
To exit bpython, you can use the exit() function or press Ctrl-D.
# Example Session
```python
>>> def add(a, b):
... """Return the sum of a and b."""
... return a + b
...
>>> add(2, 3)
5
>>> :pastebin
# Sends the code to a pastebin service and returns the URL
```
Bpython is a powerful tool for interactive Python development, providing features that make coding more efficient and enjoyable.