https://github.com/teddyoweh/transvarpy
A new method of declaring and editing variables in python.
https://github.com/teddyoweh/transvarpy
algorithms algorithms-and-data-structures modules pointers pointers-and-arrays python
Last synced: 4 months ago
JSON representation
A new method of declaring and editing variables in python.
- Host: GitHub
- URL: https://github.com/teddyoweh/transvarpy
- Owner: teddyoweh
- License: mit
- Created: 2022-04-07T18:49:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-30T10:34:15.000Z (over 3 years ago)
- Last Synced: 2025-05-29T15:54:39.832Z (5 months ago)
- Topics: algorithms, algorithms-and-data-structures, modules, pointers, pointers-and-arrays, python
- Language: Python
- Homepage: https://pypi.org/project/transvarpy/
- Size: 142 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.TXT
Awesome Lists containing this project
README
# Pointers in Python
This module is a new method of assigning variables in python.The most popular languages that have pointers are C and C++, pointers allow a variable to be change by altering the memory address of the variable.
## C Pointers
```C
#includeint main(void) {
int num = 10;
//declaring and initializing the pointer
int *ptr = #printf("value of num: %d\n", num);
printf("value of num: (using pointer): %d\n", *ptr);//updating the value
*ptr = 20;printf("value of num: %d\n", num);
printf("value of num (using pointer): %d\n", *ptr);return 0;
}
```
# Overview
In python, there has been one standard way of declaring a variable and no way of editing the varibale name.
The ```transvar``` package/algorithm introduces a more efficient way of declaring variables and editing variable name, and gives methods which can be used for large scale programs & projects.```Python
name = 'teddy'
temp = '{}_'.format(name) # Adds _ at the end of the name variable ( teddy )
name = temp
```## Implementation
### import modules
```py
from transvarpy import transdict
from transvarpy import transfile
from transvarpy import transindv
```
### Basic Implementation
```py
newvar = transvar('name','teddy')
newvar.init(globals())
print(name)
```
#### name gets created as a variable with the value name as teddy
```sh
>>> teddy
```
### Dictionary Implementation
Rather than creating 10 different variables, create a dictionay object, insert the variable name as the key and the content as what you want the variable name to be equals to.```Python
mydict = {
'name':'teddy',
'major':'cs',
'language': 'English',
'laptop':'Mac',
'phone': 'Iphone',
'class':'calc 1',
'address':'est drive',
'age':'5',
'food':'burger',
'car':'ford'
}
for key,content in mydict.items():
transindv(key,content).init(globals())
```
## OR
```Python
mydict = {
'name':'teddy',
'major':'cs',
'language': 'English',
'laptop':'Mac',
'phone': 'Iphone',
'class':'calc 1',
'address':'est drive',
'age':'5',
'food':'burger',
'car':'ford'
}
transdict(mydict).init(globals())
```
10 different variables have been created ( name,major,language,laptop,phone,class,address,age,food and car.
and when you call the variable name, it prints what has been assigned to it.```Python
print(car)```
## Output
```sh
>>> ford```
### Files Implementation
##### Setup File example
#### SETUP.txt
```txt
name = severin
age = 10
class = grade10
date = avery```
```Python
transfile('SETUP.txt').init(globals())
print(class)
```
## Output
```sh
>>> grade10```
License
----MIT License
Copyright (c) 2021 Teddy Oweh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.Hire me: `teddyoweh`