lkj 0.1.44__py3-none-any.whl → 0.1.45__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lkj-0.1.44.dist-info → lkj-0.1.45.dist-info}/METADATA +101 -1
- {lkj-0.1.44.dist-info → lkj-0.1.45.dist-info}/RECORD +5 -5
- {lkj-0.1.44.dist-info → lkj-0.1.45.dist-info}/LICENSE +0 -0
- {lkj-0.1.44.dist-info → lkj-0.1.45.dist-info}/WHEEL +0 -0
- {lkj-0.1.44.dist-info → lkj-0.1.45.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lkj
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.45
|
|
4
4
|
Summary: A dump of homeless useful utils
|
|
5
5
|
Home-page: https://github.com/thorwhalen/lkj
|
|
6
6
|
Author: Thor Whalen
|
|
@@ -167,3 +167,103 @@ import_object(dot_path: str)
|
|
|
167
167
|
>>> f is join
|
|
168
168
|
True
|
|
169
169
|
```
|
|
170
|
+
|
|
171
|
+
## Pretty Printing Lists
|
|
172
|
+
|
|
173
|
+
The `print_list` function provides flexible, human-friendly ways to display lists and collections. It supports multiple display styles and can be used in several ways.
|
|
174
|
+
|
|
175
|
+
### Basic Usage
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from lkj.strings import print_list
|
|
179
|
+
|
|
180
|
+
items = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig']
|
|
181
|
+
|
|
182
|
+
# Different display styles
|
|
183
|
+
print_list(items, style='wrapped') # Automatic line wrapping
|
|
184
|
+
print_list(items, style='columns') # Column format
|
|
185
|
+
print_list(items, style='numbered') # Numbered list
|
|
186
|
+
print_list(items, style='bullet') # Bullet points
|
|
187
|
+
print_list(items, style='compact') # All on one line
|
|
188
|
+
print_list(items, style='table') # Table format
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Direct Usage with Customization
|
|
192
|
+
|
|
193
|
+
```python
|
|
194
|
+
# Customize width, separators, and formatting
|
|
195
|
+
print_list(items, style='wrapped', max_width=40, sep=' | ')
|
|
196
|
+
print_list(items, style='columns', items_per_line=3)
|
|
197
|
+
print_list(items, style='numbered', line_prefix=' ')
|
|
198
|
+
print_list(items, style='bullet', show_count=False)
|
|
199
|
+
|
|
200
|
+
# Return string instead of printing
|
|
201
|
+
result = print_list(items, style='numbered', print_func=None)
|
|
202
|
+
print(result)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Partial Function Factory
|
|
206
|
+
|
|
207
|
+
When you don't specify the `items` parameter, `print_list` returns a partial function that you can reuse:
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
# Create specialized printers
|
|
211
|
+
numbered_printer = print_list(style='numbered', show_count=False)
|
|
212
|
+
bullet_printer = print_list(style='bullet', print_func=None)
|
|
213
|
+
compact_printer = print_list(style='compact', max_width=60)
|
|
214
|
+
|
|
215
|
+
# Reuse with different data
|
|
216
|
+
numbered_printer(['a', 'b', 'c']) # Prints: 1. a\n2. b\n3. c
|
|
217
|
+
result = bullet_printer(['x', 'y', 'z']) # Returns: '• x\n• y\n• z'
|
|
218
|
+
compact_printer(['item1', 'item2']) # Prints: item1, item2
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Convenience Methods
|
|
222
|
+
|
|
223
|
+
The `print_list` object provides convenient pre-configured methods:
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
# Quick access to common styles
|
|
227
|
+
print_list.compact(items) # Compact format, no count
|
|
228
|
+
print_list.wrapped(items) # Wrapped format, no count
|
|
229
|
+
print_list.columns(items) # Column format, no count
|
|
230
|
+
print_list.numbered(items) # Numbered format, no count
|
|
231
|
+
print_list.bullets(items) # Bullet format, no count
|
|
232
|
+
|
|
233
|
+
# Specialized methods
|
|
234
|
+
print_list.as_table(data) # Table with headers
|
|
235
|
+
print_list.summary(items) # Summary for long lists
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Advanced Examples
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
# Table with custom data
|
|
242
|
+
data = [['Name', 'Age', 'City'], ['Alice', 25, 'NYC'], ['Bob', 30, 'LA']]
|
|
243
|
+
print_list.as_table(data)
|
|
244
|
+
|
|
245
|
+
# Summary for long lists
|
|
246
|
+
long_list = list(range(100))
|
|
247
|
+
print_list.summary(long_list, max_items=6) # Shows: [0, 1, 2, ..., 97, 98, 99]
|
|
248
|
+
|
|
249
|
+
# Custom print function (e.g., for logging)
|
|
250
|
+
def my_logger(msg):
|
|
251
|
+
print(f"[LOG] {msg}")
|
|
252
|
+
|
|
253
|
+
print_list(items, style='bullet', print_func=my_logger)
|
|
254
|
+
|
|
255
|
+
# Combine partial with custom parameters
|
|
256
|
+
custom_compact = print_list(style='compact', sep=' | ')
|
|
257
|
+
custom_compact(items) # Prints: apple | banana | cherry | date | elderberry | fig
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### Key Features
|
|
261
|
+
|
|
262
|
+
- **Multiple Styles**: `wrapped`, `columns`, `numbered`, `bullet`, `compact`, `table`
|
|
263
|
+
- **Flexible Output**: Print directly or return strings with `print_func=None`
|
|
264
|
+
- **Partial Functions**: Create reusable printers with pre-configured settings
|
|
265
|
+
- **Customizable**: Control width, separators, line prefixes, and more
|
|
266
|
+
- **Type Safe**: Uses `Literal` types for style validation
|
|
267
|
+
- **Self-Contained**: No external dependencies beyond Python standard library
|
|
268
|
+
|
|
269
|
+
The `print_list` function is perfect for debugging, logging, user interfaces, and any situation where you need to display lists in a readable format.
|
|
@@ -8,8 +8,8 @@ lkj/iterables.py,sha256=9jeO36w-IGiZryge7JKgXZOGZAgehUvhwKV3nHPcZWk,2801
|
|
|
8
8
|
lkj/loggers.py,sha256=ImmBdacz89Lvb3dg_xI5jOct_44rSRv0hNI_CVehy60,13706
|
|
9
9
|
lkj/misc.py,sha256=IZf05tkl0cgiMgBwCMH5cLSC59fRXwnemPRo8G0OxQg,1436
|
|
10
10
|
lkj/strings.py,sha256=aib3KLFBuHl2WuDI2m7xC2JXM9E2-fk9CkXU7Pld6VU,41459
|
|
11
|
-
lkj-0.1.
|
|
12
|
-
lkj-0.1.
|
|
13
|
-
lkj-0.1.
|
|
14
|
-
lkj-0.1.
|
|
15
|
-
lkj-0.1.
|
|
11
|
+
lkj-0.1.45.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
12
|
+
lkj-0.1.45.dist-info/METADATA,sha256=J8VwBFxfxTERN8kVlzKROEz3kkz0FvILqflc6rFVxeI,8221
|
|
13
|
+
lkj-0.1.45.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
14
|
+
lkj-0.1.45.dist-info/top_level.txt,sha256=3DZOUwYmyurJFBXQCvCmEIVm8z2b42O5Sx3RDQyePfg,4
|
|
15
|
+
lkj-0.1.45.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|