Skip to content

Commit a064e56

Browse files
#v1.2.0
\\ Fixed inappropriate ways of importing other packages and methods into this package without re-declaring them inside current package.
1 parent 0774d05 commit a064e56

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# randomisedString v1.1.1
1+
# randomisedString v1.2.0
22

33
```pip install randomisedString --upgrade```
44

randomisedString.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
__version__ = "1.1.1"
1+
__version__ = "1.2.0"
22

33

44
class Generator:
5-
from random import choice as __choice, randrange as __randrange
65
def __init__(self):
76
"""
87
Initialise the Generator and use the public functions to generate a randomised string.
98
"""
9+
from random import choice as __choice, randrange as __randrange
10+
self.__choice = __choice
11+
self.__randrange = __randrange
1012
self.LOWER_CASE_ASCIIS = list(range(97, 122 + 1))
1113
self.UPPER_CASE_ASCIIS = list(range(65, 90 + 1))
1214
self.NUMBER_ASCIIS = list(range(48, 57 + 1))
@@ -25,8 +27,8 @@ def AlphaNumeric(self, _min=10, _max=20)->str:
2527
if _maxLength == _minLength:
2628
_maxLength+=1
2729
string = ''
28-
for _ in range(Generator.__randrange(_minLength, _maxLength)):
29-
string += chr(Generator.__choice(self.ALPHANUMERIC_ASCIIS))
30+
for _ in range(self.__randrange(_minLength, _maxLength)):
31+
string += chr(self.__choice(self.ALPHANUMERIC_ASCIIS))
3032
return string
3133

3234

@@ -42,8 +44,8 @@ def OnlyNumeric(self, _min=10, _max=20)->str:
4244
if _maxLength == _minLength:
4345
_maxLength += 1
4446
string = ''
45-
for _ in range(Generator.__randrange(_minLength, _maxLength)):
46-
string += chr(Generator.__choice(self.LOWER_CASE_ASCIIS+self.UPPER_CASE_ASCIIS))
47+
for _ in range(self.__randrange(_minLength, _maxLength)):
48+
string += chr(self.__choice(self.LOWER_CASE_ASCIIS+self.UPPER_CASE_ASCIIS))
4749
return string
4850

4951

@@ -59,7 +61,7 @@ def OnlyAlpha(self, _min=10, _max=20)->str:
5961
if _maxLength == _minLength:
6062
_maxLength += 1
6163
string = ''
62-
for _ in range(Generator.__randrange(_minLength, _maxLength)):
63-
string += chr(Generator.__choice(self.LOWER_CASE_ASCIIS+self.UPPER_CASE_ASCIIS))
64+
for _ in range(self.__randrange(_minLength, _maxLength)):
65+
string += chr(self.__choice(self.LOWER_CASE_ASCIIS+self.UPPER_CASE_ASCIIS))
6466
return string
6567

0 commit comments

Comments
 (0)