<p>I have some Python code that creates a Calendar object based on parsed VEvent objects from and iCalendar file.</p>

<p>The calendar object just has a method that adds events as they get parsed.</p>

<p>Now I want to create a factory function that creates a calendar from a file object, path, or URL.</p>

<p>I've been using the <a href="http://codespeak.net/icalendar/" rel="nofollow noreferrer">iCalendar python module</a>, which implements a factory function as a class method directly on the Class that it returns an instance of:</p>

<pre><code>cal = icalendar.Calendar.from_string(data)
</code></pre>

<p>From what little I know about Java, this is a common pattern in Java code, though I seem to find more references to a factory method being on a different class than the class you actually want to instantiate instances from.</p>

<p>The question is, is this also considered Pythonic ? Or is it considered more pythonic to just create a module-level method as the factory function ?</p>

It's pythonic not to think about esoteric difference in some pattern you read somewhere and now want to use everywhere, like the factory pattern.
Most of the time you would think of a @staticmethod as a solution it's probably better to use a module function, except when you stuff multiple classes in one module and each has a different implementation of the same interface, then it's better to use a @staticmethod
Ultimately weather you create your instances by a @staticmethod or by module function makes little difference.
I'd probably use the initializer ( __init__ ) of a class because one of the more accepted "patterns" in python is that the factory for a class is the class initialization.