On 08/03/10 06:21, quoth loial:
> In a unix shell script I can do something like this to look in a
> directory and get the name of a file or files into a variable :
>
> MYFILE=`ls /home/mydir/JOHN*.xml`
>
>
> Can I do this in one line in python?
>
Sorry, but I just can't help myself.
Yeah, it
Ops I miss the "one line" request, so my previous answer was definitely OT.
glob seems to be your solution.
On Tue, Aug 3, 2010 at 12:44 PM, Rory Campbell-Lange
wrote:
> On 03/08/10, Alex Willmer (a...@moreati.org.uk) wrote:
>> On Aug 3, 11:21?am, loial wrote:
>> > In a unix shell script I can
On 03/08/10, Alex Willmer (a...@moreati.org.uk) wrote:
> On Aug 3, 11:21?am, loial wrote:
> > In a unix shell script I can do something like this to look in a
> > directory and get the name of a file or files into a variable :
> >
> > MYFILE=`ls /home/mydir/JOHN*.xml`
> >
> > Can I do this in one
On 3 Aug, 11:31, Alex Willmer wrote:
> On Aug 3, 11:21 am, loial wrote:
>
> > In a unix shell script I can do something like this to look in a
> > directory and get the name of a file or files into a variable :
>
> > MYFILE=`ls /home/mydir/JOHN*.xml`
>
> > Can I do this in one line in python?
>
>
I suggest you to take a look at walk function inside the os module
[1]; IIRC, on the list you would find a discussion on how to create a
wrapper for os.walk with support for filters or wildcards.
Regards.
[1] http://docs.python.org/library/os.html?highlight=os.walk#os.walk
On Tue, Aug 3, 2010 at
On Aug 3, 11:21 am, loial wrote:
> In a unix shell script I can do something like this to look in a
> directory and get the name of a file or files into a variable :
>
> MYFILE=`ls /home/mydir/JOHN*.xml`
>
> Can I do this in one line in python?
Depends if you count imports.
import glob
my_files
In a unix shell script I can do something like this to look in a
directory and get the name of a file or files into a variable :
MYFILE=`ls /home/mydir/JOHN*.xml`
Can I do this in one line in python?
--
http://mail.python.org/mailman/listinfo/python-list