> notejam wrote:
> Thanks everyone for the help. I got a simple two line program to work
> from a text file.
> Can not figure out how to write more than one line in interpreter mode.
> Is that all interpreter is good for, testing one liners? I have it
> run the program everytime I hit return, an
Hello everybody!
I need make all files extension to lower by a given directory.
Here is my solution:
import os
def make_all_file_ext_lower(root):
for path, subdirs, files in os.walk(root):
for file in files:
(name, ext) = os.path.splitext(file)
fullname = name[
Fredrik Lundh wrote:
> > fullname = name[:len(name) - 1] + ext.lower()
> are you sure you want to strip off the last character in the actual
> filename? should "FOO.BAR" really be turned into "FO.bar" ?
> name[:len(name) - 1] can be written name[:-1], btw.
> > os.rename(os
Fredrik Lundh wrote:
> that's not how splitext works, though:
>
> >>> os.path.splitext("FOO.BAR")
> ('FOO', '.BAR')
>
> can you post an example of a filename that misbehaves on your machine?
>
>
To Fredrik Lundh and Tim Chase:
My task was read all tga file names and generate a config xml file,
t
Tim Chase wrote:
> Having a win32 program take case-sensitive filenames is a bit
> odd, given that the OS is case-agnostic...however, that doesn't
> preclude bad programming on the part of your tool-maker. Alas.
>
> Thus, to accomodate the lousy programming of your tool's maker, I
> proffer thi
Matthias Winterland wrote:
> Hi,
>
> I have a simple question. When I read in a string like:
> a='1,2,3,4,5 6 7,3,4', can I get the list l=[1,2,3,4,5,6,7,3,4] with a
> single split-call?
>
> Thx,
> Matthias
Maybe like this:
>>> a = "1,2,3,4,5,6,7,3,4"
>>> l = [int(n) for n in a.split(',')]
>>> l
Matthias Winterland wrote:
> Hi,
>
> I have a simple question. When I read in a string like:
> a='1,2,3,4,5 6 7,3,4', can I get the list l=[1,2,3,4,5,6,7,3,4] with a
> single split-call?
>
> Thx,
> Matthias
Sorry, I didn't notice there are spaces between 5 6 7 :{P
here is new code:
>>> a = "1,2,3
ced
"os.getcwd()" in above
line?
And I have another question, I've tried remove a copy of svn repository by
calling
shutil.rmtree(svn_repos_copy_dir)
I got error "Access denied!" Is that mean my script has no power to delete
it? Is there some way to
give the right to do
>
>
> The path of your script is given by __file__.
thanks MRAB, and sorry for such a trivial question :)
cheers!
tiefeng wu
--
http://mail.python.org/mailman/listinfo/python-list
w_values = sorted(values, reverse = True)
>>> new_items = [items[x] for x in [i for i in map(values.index,
new_values)]]
>>> print(new_values)
[7, 5, 2, 1]
>>> print(new_items)
['town', 'apple', 'car', 'phone']
>>>
cheers!
tiefeng wu
2009-04-22
--
http://mail.python.org/mailman/listinfo/python-list
>
> > Just being pedantic here :)
> >
> > [items[x] for x in [i for i in map(values.index, new_values)]]
> >
> > Is the same as
> >
> > [items[x] for x in map(values.index, new_values)]
>
> It's also the same as
>
>[items[x] for x in [values.index(i) for i in new_values]]
>
> Which reduces to
>
File "C:\usr\bin\python30\lib\smtplib.py", line 239, in __init__
(code, msg) = self.connect(host, port)
File "C:\usr\bin\python30\lib\smtplib.py", line 296, in connect
(code, msg) = self.getreply()
File "C:\usr\bin\python30\lib\smtplib.py", line
>
> I've tested with 3.0.1 on Windows XP and worked fine. Seems to be a problem
> in the SSL support, but that's all I could say.
>
> --
> Gabriel Genellina
>
thanks, I'll check SSL support on my system
Tiefeng Wu
2009-05-04
--
http://mail.python.org/mailman/listinfo/python-list
(m)
None
Pretty ugly! And I know for a valid c/cpp source file, it will be not
necessary to check and match '<' with '>' and " with ",
but I'm wondering to see more elegant way to do such thing.
tiefeng wu
2009-07-23
--
http://mail.python.org/mailman/listinfo/python-list
; p = re.compile('#a=*;b=*;c=*;')
> m = p.match(line)
> if m:
> print m.group(),
> --
> http://mail.python.org/mailman/listinfo/python-list
>
maybe like this:
>>> p = re.compile(r'#?\w+=(\w+);')
>>> l = re.findall(p, '#a=
MRAB wrote:
> I'd probably do:
>
>>>> p = re.compile(r'#\s*include\s+(?:<([^>]*)>|"([^"]*)")')
>>>> m = p.search('#include ')
>>>> m.group(1) or m.group(2)
> 'header.h'
>
yes, i
d I've
met the problem like in your example
The reason I choose regex because I barely know about "real parser",
for me it still in some "dark area" :)
But I'll find something to learn.
tiefeng wu
2009-07-23
--
http://mail.python.org/mailman/listinfo/python-list
things out
:)
I know some programs like doxygen do such things, but I can learn much
by doing this than simply write configuration files.
cheers!
tiefeng wu
2009-07-24
--
http://mail.python.org/mailman/listinfo/python-list
2009/7/29 Nobody :
>> The output should be something like
>> document.write("hello my name is 21c";)
>
> import re
> r = re.compile(r'"\s*\+\s*"')
> s = r'''document.write("h" +"e"+ "ll"+ "o"+ " m" +"y"+" n"+"ame"+
> " is "+"21c";)'''
> r.sub('', s)
>
Nobody's solution is good.
here is m
f the
> string; that is, not the individual components as I have it coded above, but
> the entire 3-character block?
> TIA,
> Victor
I'm not sure I totally understand your problem, try this:
aLine = re.sub(r'(?:)?]*>(?:)'.format(str(x)), '', aLine)
tiefeng wu
2009-08-03
--
http://mail.python.org/mailman/listinfo/python-list
20 matches
Mail list logo