I am trying the following:
re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
and I get a return of NoneType, and I have no idea why. I know that I
missing something here, but I really can't figure out why (I bet it's
something obvious). I also tried this RE on KODOS and it works fine
there, so I
Yoav wrote:
I am trying the following:
re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
and I get a return of NoneType, and I have no idea why. I know that I
missing something here, but I really can't figure out why (I bet it's
something obvious). I also tried this RE on KODOS and it works
Yoav enlightened us with:
I am trying the following:
re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
and I get a return of NoneType, and I have no idea why.
Because you don't match a carriage return \r.
I know that I missing something here, but I really can't figure out
why (I bet it's
Yoav wrote:
I am trying the following:
re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
and I get a return of NoneType, and I have no idea why. I know that I
missing something here, but I really can't figure out why
instead of struggling with weird REs, why not use Python's standard
filename
Thanks guys. Issue solved.
I am also going to give Microsoft a call about it. Any other issues you
want me to raise while I am talking to them?
Cheers.
Robert Kern wrote:
Yoav wrote:
I am trying the following:
re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
and I get a return of NoneType,
Don't think it will do much good. I need to get them from a file and
extract the last folder in the path. For example:
if I get c:\dos\util
I want to extract the string \util
Fredrik Lundh wrote:
Yoav wrote:
I am trying the following:
re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
and I
Yoav wrote:
Don't think it will do much good. I need to get them from a file and
extract the last folder in the path. For example:
if I get c:\dos\util
I want to extract the string \util
like frederik says (I use '/' as I am using Unix):
import os
os.path.split ('c:/foo/bar')
Yoav wrote:
Don't think it will do much good. I need to get them from a file and
extract the last folder in the path. For example:
if I get c:\dos\util
I want to extract the string \util
Then os.path.basename should be for you.
Reinhold
--
Hi,
Don't think it will do much good. I need to get them from a file and
extract the last folder in the path. For example:
if I get c:\dos\util
I want to extract the string \util
Still, os.path is your friend:
import os
filepath = r'C:\dos\util'
base, last = os.path.split(filepath)
Yoav wrote:
Don't think it will do much good. I need to get them from a file and
extract the last folder in the path. For example:
if I get c:\dos\util
I want to extract the string \util
You mean like this:
import os
os.path.sep + os.path.split(rc:\dos\util)[-1]
--
Robert Kern
[EMAIL
In article [EMAIL PROTECTED], Yoav [EMAIL PROTECTED] wrote:
Fredrik Lundh wrote:
Yoav wrote:
I am trying the following:
re.search(r'\\[^\\]+(?=(?$))', c:\ret_files)
instead of struggling with weird REs, why not use Python's standard
filename manipulation library instead?
Thank you all guys. It seems like the simpler the solution, the more I
am happy about it. Sorry, for the simple question, I am quite new to
this lang.
Cheers.
Robert Kern wrote:
Yoav wrote:
Don't think it will do much good. I need to get them from a file and
extract the last folder in the
12 matches
Mail list logo