I am trying to get the string dynamically and use regex over it but i get the error:
coding partial snippet:
import re
def file_save():
f = th1.asksaveasfile(mode='w', defaultextension=".txt")
re.search(r"<[^>]*\bname='([^']*)", f).group(1)
f.close()
Error
re.search(r"<[^>]*\bname='([^']*)", f).group(1)
File "C:\Python34\lib\re.py", line 166, in search
return _compile(pattern, flags).search(string)
TypeError: expected string or buffer
Here,the input string has to be attained from a 'filename to be saved' which produces the text 'f' as:
<_io.TextIOWrapper name='C:/Python34/abcd.txt' mode='w' encoding='cp1252'>
the regex works perfect,but icannot get the string and get the ouput as:
C:/Python34/abcd.txt
Please help me to fix my problem.Answers will be appreciated!