Skip to content

Commit

Permalink
Merge pull request #8 from Zozi96/develop
Browse files Browse the repository at this point in the history
chore: Update Linq class __repr__ method to include iterable elements
  • Loading branch information
Zozi96 authored Aug 7, 2024
2 parents 3d57ae3 + d4ab2f4 commit f445939
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ pip install linq-tool

## Usage Examples

You might create a Linq instance and iterate throughout the object

```python
linq = Linq([1, 2, 3])
for item in linq:
print(item) # 1
```

The object is an iterable, if you need to use it as list, you need to invoke the `to_list` method

### Select

```python
Expand Down
14 changes: 14 additions & 0 deletions linq/linq.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,17 @@ def __iter__(self) -> Iterator[T]:
3
"""
return iter(self.iterable)

def __repr__(self) -> str:
"""
Returns a string representation of the Linq object.
Returns:
str: A string representation of the Linq object.
Example:
>>> linq = Linq([1, 2, 3])
>>> repr(linq)
'Linq([1, 2, 3])'
"""
return f"Linq({list(self.iterable)})"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
long_description_content_type='text/markdown',
author='Zozimo Fernandez',
author_email='zozi.fer96@gmail.com',
url='https://github.com/tu_usuario/linq-tool',
url='https://github.com/Zozi96/linq-tool',
packages=find_packages(),
classifiers=[
'Programming Language :: Python :: 3',
Expand Down

0 comments on commit f445939

Please sign in to comment.