4
Is there a function to return the source file name itself?
The intention would be to create a log file, which one of the data would have the name of the source that is generating that log. If you have an error, it’s easier to go directly to the source file for maintenance.
In this case, it is taking the absolute path plus the file name. Would you know another function to return only the file name? Thank you!
– Rodrigo Saito
@Rodrigosaito which case? I put two ways
– Jéf Bueno
In both cases, both show the absolute path plus the file name
– Rodrigo Saito
Python 2 or 3? In my think I was showing only the final name even. Now I’m not in front of the PC, so I have no way to test. Anyway you can always split by / and catch the last position of the result.
– Jéf Bueno
It would be in python 3. Good idea. I will make a function to receive the function, give the split, check the size of the vector and return the last position. Thank you very much.
– Rodrigo Saito
@Rodrigosaito I gave an even better suggestion in the answer. Btw, you can always mark an answer as correct in your questions. Just use the V on the left side of the response.
– Jéf Bueno
I am in no way belittling your reply and I thank you for that. I will actually complement your suggestion, as it will be used several times, which encapsulate all this in a function is better not to keep repeating code. Thank you
– Rodrigo Saito
@Rodrigosaito Sure, I know you’re not belittling her. I just left the tip to complement the answer.
– Jéf Bueno