Which is more pythonic, factory as a function in a module, or as a method on the class it creates?
<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">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>
