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

  • Home
  • SEARCH
  • 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 538819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:04:17+00:00 2026-05-13T10:04:17+00:00

How does this import work, what file does it use? import _functools In python

  • 0

How does this import work, what file does it use?

import _functools

In python 2.5:

import _functools
print _functools.__file__

Gives:

Traceback (most recent call last):
  File "D:\zjm_code\mysite\zjmbooks\a.py", line 5, in <module>
    print _functools.__file__
AttributeError: 'module' object has no attribute '__file__'

How can I get the meaning of partial (from _functools import partial) if I can’t read C code?

  • 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-05-13T10:04:17+00:00Added an answer on May 13, 2026 at 10:04 am

    C-coded modules can be built-in (lacking __file__) or live in a .so or .pyd dynamic library (which their __file__ will indicate) — that’s an implementation detail that you should not care about.

    If you want to understand how a Python-callable, C-coded function works by studying code, learning to read C is generally best (far less hard than actually productively coding in C;-). However, often you’ll find (suggestive, non-authoritative) “sample Python implementations” of C-coded functionality, and you can study those.

    A particularly fruitful repository of Python-coded equivalents to Python standard library functionality that’s normally coded in C is the pypy project (which does Python implementations coded in Python) — its sources are browseable here and of course you can download and peruse them on your machine.

    In particular, this is pypy’s _functools.py implementation:

    """ Supplies the internal functions for functools.py in the standard library """
    
    class partial:
        """
        partial(func, *args, **keywords) - new function with partial application
        of the given arguments and keywords.
        """
        __slots__ = ['func', 'args', 'keywords']
    
        def __init__(self, func, *args, **keywords):
            if not callable(func):
                raise TypeError("the first argument must be callable")
            self.func = func
            self.args = args
            self.keywords = keywords
    
        def __call__(self, *fargs, **fkeywords):
            newkeywords = self.keywords.copy()
            newkeywords.update(fkeywords)
            return self.func(*(self.args + fargs), **newkeywords)
    

    Pretty trivial to read and understand, I hope!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following (broken) code: import functools class Foo(object): def __init__(self): def f(a,self,b): print
I have an xml file that contains in products. File's structure this: <?xml version=1.0
I've got some python code in a library that attempts to load a simple
A week or so ago someone on StackOverflow asked why their Python code for
I found this script attached to a thread in the fontforge-users mailing list .
EDIT: after reading this http://projects.scipy.org/numpy/ticket/1322 it seems that the NumPy version I am using
I've just read about @Resource annotation from this article ( http://www.infoq.com/articles/spring-2.5-part-1 ) and wish
this error is trown by the following TEST. If i test the DataLayer, the
SSIS does 2 things in relation to handling flat files which are particularly frustrating,
I have following btrace script. I would like to record entry and exit of

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.