# Python Reference Variables `refvars`
This repository contains but one simple but extremely useful Python class, `Make_Reference` and `Reference_Instance`.
This holy grail of simple python hacks, `refvars` provides a convenient way to work with references to objects. It allows you to set and get the value of the reference using simple methods.
## Usage
To use the `refvars` class, simply import it into your Python script:
```python
from refvars import Make_Reference, Reference_Instance
```
Then use `Make_Reference` to create a reference to an object:
```python
# Create a reference
ref = Make_Reference[int](0).reference
```
> Note that `Make_Reference` will run a variety of runtime AND intellisense time checks to ensure that the reference is being used correctly.
Now, you can use the `Reference_Instance` to get and set the value of the reference:
```python
# To ensure that the initial value does actually change.
print(ref.get()) # 0
# If we want a function to modify the reference, we can pass the reference to the function.
def modify_reference(ref:"Reference_Instance[int]"):
ref.set(1)
modify_reference(ref)
# Now the getting is a bit different.
print(ref.get()) # 1
```
## Installation
To install the `refvars`, use pip:
```bash
pip install refvars
```
## Confirmed versions of Python
- [x] 3.11 - Works perfectly.
- [ ] 3.12 - Not tested.
## License
Covered under the GNU General Public License v2.0.
## V0.6 released on 12th/4/2024
Previous V0.2 didn't work.
- Could not import the module.
- The description did not appear on PyPi.
This version hopefully fixes that.
Raw data
{
"_id": null,
"home_page": null,
"name": "refvars",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, reference, variables, pointers, output, return, types, reference types, refvars",
"author": "matrikater (Joel C. Watson)",
"author_email": "matrikater@matriko.xyz",
"download_url": null,
"platform": null,
"description": "# Python Reference Variables `refvars`\n\nThis repository contains but one simple but extremely useful Python class, `Make_Reference` and `Reference_Instance`.\n\nThis holy grail of simple python hacks, `refvars` provides a convenient way to work with references to objects. It allows you to set and get the value of the reference using simple methods.\n\n## Usage\n\nTo use the `refvars` class, simply import it into your Python script:\n\n```python\nfrom refvars import Make_Reference, Reference_Instance\n```\n\nThen use `Make_Reference` to create a reference to an object:\n\n```python\n# Create a reference\nref = Make_Reference[int](0).reference\n```\n\n> Note that `Make_Reference` will run a variety of runtime AND intellisense time checks to ensure that the reference is being used correctly.\n\nNow, you can use the `Reference_Instance` to get and set the value of the reference:\n\n```python\n# To ensure that the initial value does actually change.\nprint(ref.get()) # 0\n\n# If we want a function to modify the reference, we can pass the reference to the function.\ndef modify_reference(ref:\"Reference_Instance[int]\"):\n ref.set(1)\n\nmodify_reference(ref)\n\n# Now the getting is a bit different.\nprint(ref.get()) # 1\n```\n\n## Installation\n\nTo install the `refvars`, use pip:\n\n```bash\npip install refvars\n```\n\n## Confirmed versions of Python\n\n- [x] 3.11 - Works perfectly.\n- [ ] 3.12 - Not tested.\n\n## License\n\nCovered under the GNU General Public License v2.0.\n\n## V0.6 released on 12th/4/2024\n\nPrevious V0.2 didn't work.\n - Could not import the module.\n - The description did not appear on PyPi.\nThis version hopefully fixes that.\n",
"bugtrack_url": null,
"license": null,
"summary": "Solving one of Python's biggest problems. Reference types (output variables) are not implemented.",
"version": "0.6",
"project_urls": null,
"split_keywords": [
"python",
" reference",
" variables",
" pointers",
" output",
" return",
" types",
" reference types",
" refvars"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d49165f6cb985945e4db520fa4bab1c72c8351a10093430c4af90cc56b28c4e2",
"md5": "91414e0034771cc3b517594643f9e6bd",
"sha256": "75ddaadc1d00ed6f26e16978145a7b3ee6854aee0e3ffa4f8741f7171b8ac12c"
},
"downloads": -1,
"filename": "refvars-0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "91414e0034771cc3b517594643f9e6bd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12449,
"upload_time": "2024-04-12T05:23:13",
"upload_time_iso_8601": "2024-04-12T05:23:13.810100Z",
"url": "https://files.pythonhosted.org/packages/d4/91/65f6cb985945e4db520fa4bab1c72c8351a10093430c4af90cc56b28c4e2/refvars-0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-12 05:23:13",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "refvars"
}