How to only get a list of the names of the non-directory files incurrent directory ('.')?

I

iMath

How to only get a list of the names of the non-directory files in current directory ('.')?
(Note excluding its subdirectories ).

I need the code : )
 
C

Chris Angelico

How to only get a list of the names of the non-directory files in current directory ('.')?
(Note excluding its subdirectories ).

I need the code : )

Start by getting a list of names of everything in the current directory.

Then filter that list by testing each one to see if it's a directory.

Tip: The second step can be done with os.path.isdir

Put some code together and try it. If you have trouble, post your
code, any exception traceback you get, and what you're having
difficulty with, and we'll go on from there.

Have fun!

ChrisA
 
I

iMath

在 2012å¹´11月6日星期二UTC+8下åˆ1æ—¶24分41秒,Chris Angelico写é“:
Start by getting a list of names of everything in the current directory.



Then filter that list by testing each one to see if it's a directory.



Tip: The second step can be done with os.path.isdir



Put some code together and try it. If you have trouble, post your

code, any exception traceback you get, and what you're having

difficulty with, and we'll go on from there.



Have fun!



ChrisA

how to get a list of names of everything in the current directory ?
 
I

iMath

在 2012å¹´11月6日星期二UTC+8下åˆ1æ—¶24分41秒,Chris Angelico写é“:
Start by getting a list of names of everything in the current directory.



Then filter that list by testing each one to see if it's a directory.



Tip: The second step can be done with os.path.isdir



Put some code together and try it. If you have trouble, post your

code, any exception traceback you get, and what you're having

difficulty with, and we'll go on from there.



Have fun!



ChrisA

how to get a list of names of everything in the current directory ?
 
P

Prasad, Ramit

E

emile

how to get a list of names of everything in the current directory ?

Start by working through the tutorial to get familiar with python at
http://docs.python.org/2/tutorial/

then for your specific question, review the content at
http://www.diveintopython.net/file_handling/os_module.html

Emile


BTW, googling for "python how to get a list of names of everything in
the current directory" yields some good information as well. Google is
your friend for this level of question. Not sure anymore beyond that...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top