Last active
August 9, 2017 09:23
-
-
Save EncodeTheCode/7a6303d60fcad43c07f5d318d3825d1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class globall(): | |
# print(globals.a,globals.b,globals,c) ; 1,2,3 | |
s='description' | |
t='content.txt' | |
def string_search(t,s): # Searches the first occurence of the search term. | |
if s is None:s=globall.s | |
if t is None:t=globall.t | |
s=s or globall.s | |
t=t or globall.t | |
with open(t) as f: | |
for n,l in enumerate(f,1): | |
if s in l: | |
print('Discovered on line number',str(n)+'.') | |
break | |
def string_perform(t,s): | |
if s is None:s=globall.s | |
if t is None:t=globall.t | |
s=s or globall.s | |
t=t or globall.t | |
with open(t) as f: | |
for n,l in enumerate(f,1): | |
if s in l: | |
return n | |
string_search(0,0) # "Discovered on line number 7." | |
string_search(0,'249997999009') # "Discovered on line number 10." | |
string_perform(0,'249997999009') # Return: 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment