Skip to content

Commit c5b39b3

Browse files
committed
Gave AI credit and remove my email address
1 parent 6168724 commit c5b39b3

3 files changed

Lines changed: 104 additions & 8 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
[⬅ Back to Table of Contents](../index.md)
2+
3+
# Includes and Namespaces
4+
5+
## The Easy Way (Recommended)
6+
7+
Just include the main header—this pulls in everything under the `Pythonic` (or `py`) namespace:
8+
9+
```cpp
10+
#include "pythonic/pythonic.hpp"
11+
12+
using namespace Pythonic;
13+
// or
14+
using namespace py;
15+
```
16+
17+
## The Manual Way
18+
19+
Or, pick exactly what you need:
20+
21+
```cpp
22+
#include "pythonicVars.hpp" // var, list, dict, set
23+
#include "pythonicPrint.hpp" // print(), pprint()
24+
#include "pythonicLoop.hpp" // range(), enumerate(), zip() + macros
25+
#include "pythonicFunction.hpp" // map, filter, comprehensions
26+
#include "pythonicFile.hpp" // File I/O
27+
#include "pythonicMath.hpp" // Math functions (trig, logarithms, etc.)
28+
29+
using namespace pythonic::vars;
30+
using namespace pythonic::print;
31+
using namespace pythonic::loop;
32+
using namespace pythonic::math;
33+
using namespace pythonic::file;
34+
using namespace pythonic::func;
35+
using namespace pythonic::graph;
36+
using namespace pythonic::fast;
37+
using namespace pythonic::overflow;
38+
using namespace pythonic::error;
39+
```
40+
41+
> **Caution:**
42+
> If you import namespaces globally, be careful with `std` and other namespaces—they might clash or cause ambiguity. We recommend using `std::` explicitly if you make the `pythonic` namespace global.
43+
44+
---
45+
46+
## About Namespaces
47+
48+
- `pythonic::vars` – Core `var` type, containers, type conversion
49+
- `pythonic::print` – Printing and formatting (`print()`, `pprint()`)
50+
- `pythonic::loop` – Iteration helpers (`range()`, `enumerate()`, `zip()`, `reversed()`)
51+
- `pythonic::func` – Functional programming (`map()`, `filter()`, comprehensions)
52+
- `pythonic::file` – File I/O
53+
- `pythonic::math` – Comprehensive math library (`trig`, `logarithms`, `random`, etc.)
54+
- `pythonic::graph` – Graph data structure and algorithms
55+
- `pythonic::error` – Exception hierarchy and error handling
56+
- `pythonic::fast` – Hot-loop optimizations
57+
- `pythonic::overflow` – Checked arithmetic helpers
58+
59+
You can use them all at once with:
60+
61+
```cpp
62+
using namespace Pythonic;
63+
// or
64+
using namespace py;
65+
```
66+
67+
---
68+
69+
> **Note:**
70+
> We highly recommend including the whole library at once, as many parts have dependencies on others (e.g., the math library depends on `var`). If you try to use the math library without including `pythonicVar.hpp` and the `var` namespace, your code may not work as expected.
71+
72+
---
73+
74+
## Next
75+
76+
- [Print](../Print/print.md)

docs/Print/print.md

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[⬅ Back to Table of Contents](../index.md)
2+
[⬅ Back to Include and namespaces](../Includes_and_namespaces/incl_name.md)
23

34
# Print and Pretty Print
45

@@ -14,15 +15,22 @@ The `print` and `pprint` helpers in Pythonic provide a convenient way to output
1415

1516
## `print`
1617

17-
The `print` function is used for standard output of `var` objects and other types. It supports multiple arguments, custom separators, and end characters.
18+
### Function Signatures and Parameters
1819

19-
### Features
20+
| Function | Description |
21+
| ------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- |
22+
| `print(args...)` | Prints any number of arguments (of any type), separated by a space, ending with a newline. For `var` types, uses the simple `str()` representation. |
23+
| `pprint(var v, size_t indent_step=2)` | Pretty-prints a `var` object with indentation. `indent_step` sets the number of spaces per indent level (default: 2). |
2024

21-
- Outputs `var` objects and other types using `str()` or `operator<<`.
22-
- Supports multiple arguments, separated by a customizable separator (default is a space).
23-
- Allows customization of the end character (default is a newline `\n`).
25+
**Parameters:**
2426

25-
### Example
27+
- `args...` (print): Any number of arguments of any type.
28+
- `v` (pprint): The `var` object to pretty-print.
29+
- `indent_step` (pprint): (Optional) Number of spaces for each indentation level. Default is 2.
30+
31+
> **Note:** The current implementation does not support custom separators or end characters for `print`. Output always ends with a newline, and arguments are separated by a single space.
32+
33+
### Usage Examples
2634

2735
```cpp
2836
#include "pythonicPrint.hpp"
@@ -44,13 +52,23 @@ int main() {
4452

4553
## `pprint`
4654

47-
The `pprint` function is designed for pretty-printing complex or nested structures. It uses `pretty_str()` to format the output with indentation and line breaks for better readability.
55+
### Function Signature
56+
57+
```cpp
58+
pprint(const var& v, size_t indent_step = 2);
59+
```
60+
61+
### Parameters
62+
63+
- `v`: The `var` object to pretty-print.
64+
- `indent_step`: (Optional) Number of spaces to use for each indentation level. Default is 2. Increase for wider indentation.
4865
4966
### Features
5067
5168
- Outputs nested structures in a human-readable format.
5269
- Automatically applies indentation and line breaks for clarity.
5370
- Ideal for debugging and inspecting large or deeply nested data.
71+
- Allows customizing indentation width via `indent_step`.
5472
5573
### Example
5674
@@ -146,4 +164,4 @@ While `print` and `pprint` are convenient for debugging and output, they may not
146164

147165
# Next Check
148166

149-
- [Var](../Var/var.md)
167+
- [Var](../Var/var.md)

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
Central table of contents for the project documentation.
66

77
Recommended reading order:
8+
9+
- [Include and namespaces](Includes_and_namespaces/incl_name.md) — Talkes about the namespaces and include files
810
- [Print](Print/print.md)`print` Python style printing
911
- [Variable](Var/var.md)`var` fundamentals, ownership, type model
1012
- [Types & DTypes](Var/dtypes.md)

0 commit comments

Comments
 (0)