Depending on the usage of the function, it might be more appropriate to turn it into a classmethod or staticmethod. Then it's association with the class is clear, but you don't violate any naming conventions.

e.g.:

class MyClass(object):
     def __init__(self,arg):
         self.arg = arg

     @classmethod
     def from_sum(cls,*args):
         return cls(sum(args))

inst = MyClass.from_sum(1,2,3,4)
print inst.arg  #10
Answer from mgilson on Stack Overflow
🌐
Profound Academy
profound.academy › python-mid › class-naming-conventions-bxS5gJ9tLnPvyZhd5giU
Class Naming Conventions • Intermediate Python
January 18, 2025 - The term PascalCase originated from the Pascal programming language, attributing to its case convention. CapWords is the term used in Python's official style guide (PEP 8), and it's essentially the same as PascalCase.
Top answer
1 of 2
11

Depending on the usage of the function, it might be more appropriate to turn it into a classmethod or staticmethod. Then it's association with the class is clear, but you don't violate any naming conventions.

e.g.:

class MyClass(object):
     def __init__(self,arg):
         self.arg = arg

     @classmethod
     def from_sum(cls,*args):
         return cls(sum(args))

inst = MyClass.from_sum(1,2,3,4)
print inst.arg  #10
2 of 2
1

Let's take a step back. Usually, you don't want to do this at all, so the naming convention is the least of your worries.

First, normally, you don't care what actual class or type something is. This is what duck typing is all about. You don't want a SpreadsheetColumn instance, you want something that you can use as a spreadsheet column. It may be an instance of SpreadsheetColumn, or of a subclass, or of some proxy class, or of some mock class for testing—whatever it is, you don't care, as long as it looks and works like a column.

Notice that, even in static languages like Java and C#, factory functions (or objects) usually don't create an instance of a specific class, they create an instance of any class that implements a specific interface. In Python, that's usually implicit. (And, when it's not, it's usually because you're using something like PEAK or Twisted, and you should follow their coding style for protocols or interfaces.)

So, your factory function should be called get_column, not get_SpreadsheetColumn.

When the function is more of an "alternate constructor" than a factory, then mgilson's answer is the way to go. See chain() and chain.from_iterable() in itertools from a good standard library example.

But notice that this isn't very common in the standard library, most of the popular modules on PyPI, etc. And there's a good reason. Usually, you can just use a single constructor with default-valued parameters, keyword parameters, or at worst *args and **kwargs. If this makes the API too confusing for human readers, or too ambiguous to code, that's when you need an alternate constructor. Otherwise, you don't.

Sometimes, you really do need a factory that creates objects of a concrete type, and that concrete type is a part of the interface that the caller needs to know about. As I mentioned above, this is pretty rare even in static languages, and it's even rarer in Python, but it does come up. And then, you really do need an answer to your original question.

In that case, I think I would name the function something ugly and unusual like get_MyClass or get_MyClass_instance. It ought to stick out immediately, because anyone reading my code will probably need to figure out why I'm explicitly getting a MyClass instead of a thing in order to understand the rest of my code.

🌐
Williams College
cs.williams.edu › ~jannen › teaching › f16 › cs135 › lectures › lecture.27.pdf pdf
Williams College Lecture 27 Brent Heeringa, Bill Jannen Names and Python Syntax
conventions, PEP 8 describes and names a set of common styles. The following naming styles are commonly ... • CapitalizedWords (or CapWords, or CamelCase – so named because of the bumpy look of its letters).
🌐
Astral
docs.astral.sh › ruff › rules › invalid-class-name
invalid-class-name (N801) | Ruff - Astral Docs
Note that there is a separate convention for builtin names: most builtin names are single words (or two words run together), with the CapWords convention used only for exception names and builtin constants.
🌐
Educative
educative.io › home › naming conventions
Naming Conventions
Note that there is a separate convention for builtin names: most builtin names are single words (or two words run together), with the CapWords convention used only for exception names and builtin constants.
🌐
Bovi-analytics
bovi-analytics.com › tutorials › general-naming-convention.html
Naming conventions – Bovi-Analytics
// Variables and functions let ... make; this.model = model; } ... Variables and functions should be in camelCase. Constants should be in uppercase with underscores (ALL_CAPS). Class names should follow the CapWords convention (PascalCase)....
Find elsewhere
🌐
Scottlarsen
scottlarsen.com › 2021 › 03 › 14 › Python-Naming-Conventions-(PEP-8).html
Scott Larsen - Python Naming Conventions (PEP 8)
Module (File) names, Function names, Method names and (Instance) Variables should all use snake_case (all lowercase letters, with underscores as necessary - when in doubt, use snake case). Class Names use the CapWords convention (no spaces, capitalize first letter of each word).
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-naming-conventions
Python Naming Conventions - GeeksforGeeks
July 23, 2025 - Classes in Python names should follow the CapWords (or CamelCase) convention.
🌐
GitHub
github.com › PyCQA › pep8-naming
GitHub - PyCQA/pep8-naming: Naming Convention checker for Python · GitHub
type variable names should use CapWords convention and an optional '_co' or '_contra' suffix (type variable names)
Author: PyCQA
🌐
Python
bugs.python.org › issue5530
Issue 5530: datetime class names should obey PEP 8 CapWords convention - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/49780
🌐
Pep8
pep8.org
PEP 8: The Style Guide for Python Code
Names of type variables introduced in PEP 484 should normally use CapWords preferring short names: T, AnyStr, Num. It is recommended to add suffixes _co or _contra to the variables used to declare covariant or contravariant behavior correspondingly. Examples · from typing import TypeVar VT_co = TypeVar('VT_co', covariant=True) KT_contra = TypeVar('KT_contra', contravariant=True) Because exceptions should be classes, the class naming convention applies here.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-capwords-method
Python string capwords() method - GeeksforGeeks
July 11, 2025 - The capwords() method capitalizes the first letter of each word and lowers the rest, resulting in proper formatting.
🌐
Python
python.org › dev › peps › pep-0008
PEP 8 -- Style Guide for Python Code | Python.org
March 3, 2022 - Note that there is a separate convention for builtin names: most builtin names are single words (or two words run together), with the CapWords convention used only for exception names and builtin constants.
🌐
GitHub
github.com › coala › coala › issues › 5626
class name docs should use CapWords convention · Issue #5626 · coala/coala
July 11, 2018 - class name docs should use CapWords convention#5626 · #5629 · Copy link · Assignees · Labels · difficulty/lowtype/codestyle · ankitxjoshi · opened · on Jul 11, 2018 · Issue body actions · Files to be fixed are Redundancy.py, Metadata.py, root.py, Formatting.py, Smell.py, Security.py, Spelling.py.
Author: coala