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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:55:11+00:00 2026-06-04T12:55:11+00:00

just a simple question. Some python functions I have seen are called like this,

  • 0

just a simple question.

Some python functions I have seen are called like this, for example pygame:

pygame.display.set_mode((255, 255), FULLSCREEN) This seems normal to me.

But when you want to use more than one argument, you must use |. For example:
pygame.display.set_mode((255, 255), FULLSCREEN | HWSURFACE | DOUBLEBUF)

When and why would you want this kind of calling? I have heard it is the bitwise OR operator, but it seems that is only for boolean values. How does this work?

  • 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-04T12:55:13+00:00Added an answer on June 4, 2026 at 12:55 pm

    They’re flags for different options. Each flag is just a number, specifically a power of 2. You use the bitwise operator | to flip the bits for all the flags you want. An example might help:

    >>> import re
    >>> re.VERBOSE
    64
    >>> re.IGNORECASE
    2
    >>> re.VERBOSE | re.IGNORECASE
    66
    

    so if re wants to know whether the IGNORECASE flag is set it can just check whether the second bit(for 2^1) is equal to 1. If so, we should ignore case. And if it wants to know whether to be VERBOSE, it checks the 7th bit(for 2^6). By oring 2 and 64 together, you have a number with the second and seventh bits flipped.

    >>> 66 & 2
    2
    >>> 66 & 64
    64
    >>> 66 & 8
    0
    

    We can see that 66 triggers flags for 2 and 64, but not 8.

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

Sidebar

Related Questions

This is just a simple question. Either way works. I prefer my first example,
This is just a simple question. I've been reading the source of something which
[see later answer for more] I think this is just a simple rails question,
Simple question. Just wondering if this can be done without me having to enforce
I came here to ask a simple, very beginner question regarding python. I just
Note:I don't mean some theoretical question which don't have any implementation just languages that
I have written a small Python application where I use PyGame for displaying some
Question for Python 2.6 I would like to create an simple web application which
Please forgive my simple question. I have just started to use Matplotlib and I
I have this code in Python that was quite simple to do with mechanize

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.