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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:39:11+00:00 2026-05-22T00:39:11+00:00

In python (and some other languages) I have learned, that the name of a

  • 0

In python (and some other languages) I have learned, that the name of a class should be written in small letters except for the first letter of each word, which should be a capital letter. Example:

class FooBar:
    ...

A class should go in a file, named the same as the class. In this example it would be a file foobar.py. If I want to import the class foo somewhere I have to do this:

from foobar import FooBar

This convention confuses me a little. My intuition tells me, that if the filename indicates a class, it should be written with the first letter in capitals, too, like FooBar.py. This doesn’t look pretty in file names. Perhaps someone could tell me what is the standard convention for this?

I hope I made my question understandable. 🙂

  • 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-22T00:39:12+00:00Added an answer on May 22, 2026 at 12:39 am

    What you have presented is the standard convention.

    Package and Module Names

    Modules should have short, all-lowercase names. Underscores can
    be used in the module name if it improves readability. Python packages
    should also have short, all-lowercase names, although the use of underscores
    is discouraged.

    Since module names are mapped to file names, and some file systems are
    case insensitive and truncate long names, it is important that module
    names be chosen to be fairly short — this won’t be a problem on Unix,
    but it may be a problem when the code is transported to older Mac or
    Windows versions, or DOS.

    When an extension module written in C or C++ has an accompanying Python
    module that provides a higher level (e.g. more object oriented)
    interface, the C/C++ module has a leading underscore (e.g. _socket).

    Class Names

    Almost without exception, class names use the CapWords convention.
    Classes for internal use have a leading underscore in addition.

    (Python Style Guide)


    See e.g.

    from configparser import ConfigParser
    

    (which, incidentally, was ConfigParser in Python 2.x but changed to be lowercase in 3.x).

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

Sidebar

Related Questions

I have some Python code that works correctly when I use python.exe to run
First, let me say that I'm a complete beginner at Python. I've never learned
I often have to write code in other languages that interact with C structs.
I have a series of Python classes in a file. Some classes reference others.
I've done some Python but have just now starting to use Ruby I could
I have created some python code which creates an object in a loop, and
I've inherited some python code that contains a rather cryptic decorator. This decorator sets
What are some new and exciting programming languages? I have already looked at ruby
From the other languages I program in, I'm used to having ranges. In Python,
I created a small application that, when run, creates or updates some tables in

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.