what is this 'f' string prefix?
i posted the source code for that function i wrote, over in Completed Scripts/Snippets.
Output:lt1/forums /home/forums 5> cat gcsi.py
import inspect
class GetCallStackItem:
def __init__(self):
self.full_stack = inspect.stack()
for stacklevel, item in enumerate(self.full_stack):
attributes = self.get_method_attributes(item)
print(f'\nstacklevel: {stacklevel}')
for attrname, value in attributes:
if attrname == 'lineno':
print(f'line Number: {value}')
def get_method_attributes(self, method):
temp = dir(type('whatever', (object,), {}))
return [item for item in inspect.getmembers(method) if item[0] not in temp]
if __name__ == '__main__':
gcsi = GetCallStackItem()
lt1/forums /home/forums 6> py3 gcsi.py
File "gcsi.py", line 8
print(f'\nstacklevel: {stacklevel}')
^
SyntaxError: invalid syntax
lt1/forums /home/forums 7>
i posted the source code for that function i wrote, over in Completed Scripts/Snippets.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.