Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:13:25+00:00 2026-06-13T06:13:25+00:00

i am quite new to python, but i have quite some experience in C#.

  • 0

i am quite new to python, but i have quite some experience in C#. One of the things i love there is the set of tools that you get with the Linq-Framework.
Therefore i was searching for some equivalent in Python, and as it seems there are a few attempts. Besides pynq, which i just did not get to work and seems to have died anyway, i found out that itertools has some options to get into that direction.
but i still have problems to get it to work.
what i want is a list of entries in a directory which are NOT directories.
yes, i am sure there are plenty other and propably better ways to do this, but i want to solve this problem with itertools, as a similar problem could appear somewhere else, too.

import os, itertools

listing = os.listdir(".")
filteredfiles = itertools.ifilterfalse(lambda dirContent: os.path.isdir(dirContent), listing)
for f in filteredfiles:
    print "found file: " + f

This gives me an output of the complete content of the directory.
If i replace ifilterfalse with ifilter, i get an empty list as an result.

i just can make a guess that it is just not working with a complex call to os.path.isdir(…), but i am not sure.

Can anyone give me an answer? Basically, as i said above, i just want some Linq-like possibility to filter Iterables. I dont like loops. They make me dizzy. 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:13:26+00:00Added an answer on June 13, 2026 at 6:13 am

    You need to create the full path name before checking:

    os.path.isdir(os.path.join(path, dirContent))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to computer programming and have some experience programming with python. I
Scenario: Quite new to DI and Ninject but would love to master it so
I am quite new to mongoid and rails. So I have some troubles to
I am quite new in python.I want to match string in some lines of
I'm still quite new to python with less than a year of experience, and
I'm creating a game, and am quite new to Python generally. I created a
I have a method in c++ that gets called from python and needs to
I have a Python script that we're using to parse CSV files with user-entered
I'm trying to validate a few python arguments. Until we get the new static
I'm new to Python (I have been programming in Java for multiple years now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.