Metadata-Version: 2.2
Name: omarlib
Version: 1.0.0
Summary: Extended Python features: xor, pointers, references, nameof, private methods, and function overloading
Author-email: OmarYauh <omaryauh@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/SlackPen/omarlib
Project-URL: Documentation, https://github.com/SlackPen/omarlib#readme
Project-URL: Repository, https://github.com/SlackPen/omarlib
Project-URL: Issues, https://github.com/SlackPen/omarlib/issues
Keywords: xor,pointer,reference,nameof,private,overload,utilities,extensions,metaprogramming
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"

# omarlib

Extended Python features inspired by other programming languages.

## Installation

```bash
pip install omarlib
```

## Features

### 1. `xor(a, b)` - Logical XOR

```python
from omarlib import xor

xor(True, False)   # True
xor(True, True)    # False
xor(False, False)  # False
xor(1, 0)          # True (truthy/falsy)
```

### 2. `ptr(obj)` - Pointers

C-style pointers for Python objects.

```python
from omarlib import ptr

x = [1, 2, 3]
p = ptr(x)

print(p.value)     # [1, 2, 3] - dereference
print(p.addr)      # memory address (id)
print(~p)          # [1, 2, 3] - dereference with ~

# Pointer arithmetic with sequences
arr = [10, 20, 30, 40, 50]
p = ptr(arr)
print((p + 2).value)  # 30

# Null pointer
p.set_null()
print(p.is_null())    # True
print(bool(p))        # False
```

### 3. `ref(name)` - Real References

Create references that can modify the original variable.

```python
from omarlib import ref

x = 42
r = ref('x')
print(r.value)    # 42

r.value = 100
print(x)          # 100 - x was modified!

# Swap example
a, b = 1, 2
ref('a').value, ref('b').value = ref('b').value, ref('a').value
print(a, b)       # 2, 1
```

### 4. `nameof(var)` - Get Variable Name

```python
from omarlib import nameof

my_variable = 42
print(nameof(my_variable))  # 'my_variable'

user_name = "Omar"
print(nameof(user_name))    # 'user_name'
```

### 5. `nameof_all(*vars)` - Get Multiple Variable Names

```python
from omarlib import nameof_all

a = 1
b = 2
c = 3

names = nameof_all(a, b, c)
print(names)  # ['a', 'b', 'c']

# Useful for iteration
for name, value in zip(nameof_all(a, b, c), [a, b, c]):
    print(f"{name} = {value}")
```

### 6. `@private` - Real Private Methods

```python
from omarlib import private

class BankAccount:
    def __init__(self, balance):
        self._balance = balance

    @private
    def _calculate_interest(self):
        return self._balance * 0.05

    def apply_interest(self):
        # OK - called from inside the class
        interest = self._calculate_interest()
        self._balance += interest
        return interest

account = BankAccount(1000)
account.apply_interest()      # OK
account._calculate_interest() # PermissionError!
```

### 7. `@overload` - Function Overloading

```python
from omarlib import overload

@overload
def process(x: int):
    return x * 2

@process.register
def process(x: str):
    return x.upper()

@process.register
def process(x: int, y: int):
    return x + y

print(process(5))        # 10
print(process("hello"))  # HELLO
print(process(3, 4))     # 7
```

## Import Everything

```python
from omarlib import *

# Now you have: xor, ptr, ref, nameof, nameof_all, private, overload
```

## Requirements

- Python 3.8+
- No external dependencies

## License

MIT License - see LICENSE file.

## Author

OmarYauh

## Contributing

Contributions are welcome! Please open an issue or submit a pull request.
