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 9016041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:53:45+00:00 2026-06-16T03:53:45+00:00

I have seen in opensource projects by big companies on github that they do

  • 0

I have seen in opensource projects by big companies on github that they do the simple programs in as small steps as possible.

They try to minimize the lines of code by using advanced methods, which make even the simple function calls appear complex.

How can I understand these things. It is not about advanced concepts, but doing simple things in efficient way, and that makes the code look hard to understand.

As an example this is the code of crawlerSpider from scrapy

def identity(x):
    return x

class Rule(object):

    def __init__(self, link_extractor, callback=None, cb_kwargs=None, follow=None, process_links=None, process_request=identity):
        self.link_extractor = link_extractor
        self.callback = callback
        self.cb_kwargs = cb_kwargs or {}
        self.process_links = process_links
        self.process_request = process_request
        if follow is None:
            self.follow = False if callback else True
        else:
            self.follow = follow

This is where they used the rule

rules = ()
for link in links:
                r = Request(url=link.url, callback=self._response_downloaded)
                r.meta.update(rule=n, link_text=link.text)
                yield rule.process_request(r)

Now I am not able to understand what is the use of identity function there its doing nothing

and process_request = identity so it means

rule.process_request(r) = identity(r) whcih returns r so basically that line equals to

yield r. why can’t he write that simple line instead of identity.

There are many things like this, which I am not able to comprehend.

Is there any book which explains writing programs that way. I don’t like books where they start with data types go chapter by chapter and in the end I still don’t see even a single program like we have on github.

  • 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-16T03:53:46+00:00Added an answer on June 16, 2026 at 3:53 am

    The identity function is a sort of technicality, that lets you put your data through a process that expects a transformation when you really don’t want one.

    For instance, if you have a function that expects an array and another function to map over the array, but you don’t want the mapping (but everything else the function does), then you pass it the identity function.

    This pattern is very common in languages with good support for higher order abstractions, especially functional languages. It’s not limited to Python.

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

Sidebar

Related Questions

I have seen some people in SO commenting that Singleton Pattern is an anti-pattern.
I have seen behaviour in Perforce that I am unable to explain. I took
I have seen this question and its answers and they clear up some of
I have seen apps that have pop-ups (if you click Open Source License on
I have seen several Java web application projects adding some JSP or servlet to
I have seen in the past that before MS takes a dash at something,
I have seen at least one site in the past that had analytics on
I've recently seen a couple of open source projects that actually do this; return
Have seen some similar questions: What is the difference between a JavaBean and a
I have seen many posting this issue in SO. I have gone through those

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.